authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-09-22 17:41:15-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-09-22 17:41:15-04:00
loga239c7439f4743960bd11be66ae05962eebfa279
tree5d96f76e19adf9766f58d27f5f11e215d62f9826
parent31b72da84a14cb3652b3b770ac64e367d021529b
signaturelock-open Commit is signed but in an unrecognized format.

more helpful error message when failing to parse glibc abi.txt


2 files changed, 19 insertions(+), 4 deletions(-)

src/glibc.cpp+18-3
...@@ -93,8 +93,10 @@ Error glibc_load_metadata(ZigGLibCAbi **out_result, Buf *zig_lib_dir, bool verbo...@@ -93,8 +93,10 @@ Error glibc_load_metadata(ZigGLibCAbi **out_result, Buf *zig_lib_dir, bool verbo
93 {93 {
94 SplitIterator it = memSplit(buf_to_slice(abi_txt_contents), str("\n"));94 SplitIterator it = memSplit(buf_to_slice(abi_txt_contents), str("\n"));
95 ZigGLibCVerList *ver_list_base = nullptr;95 ZigGLibCVerList *ver_list_base = nullptr;
96 int line_num = 0;
96 for (;;) {97 for (;;) {
97 if (ver_list_base == nullptr) {98 if (ver_list_base == nullptr) {
99 line_num += 1;
98 Optional<Slice<uint8_t>> opt_line = SplitIterator_next_separate(&it);100 Optional<Slice<uint8_t>> opt_line = SplitIterator_next_separate(&it);
99 if (!opt_line.is_some) break;101 if (!opt_line.is_some) break;
100102
...@@ -122,7 +124,19 @@ Error glibc_load_metadata(ZigGLibCAbi **out_result, Buf *zig_lib_dir, bool verbo...@@ -122,7 +124,19 @@ Error glibc_load_metadata(ZigGLibCAbi **out_result, Buf *zig_lib_dir, bool verbo
122 target->os = OsLinux;124 target->os = OsLinux;
123125
124 err = target_parse_abi(&target->abi, (char*)opt_abi.value.ptr, opt_abi.value.len);126 err = target_parse_abi(&target->abi, (char*)opt_abi.value.ptr, opt_abi.value.len);
125 assert(err == ErrorNone);127 if (err != ErrorNone) {
128 fprintf(stderr, "Error parsing %s:%d: %s\n", buf_ptr(glibc_abi->abi_txt_path),
129 line_num, err_str(err));
130 fprintf(stderr, "arch: '%.*s', os: '%.*s', abi: '%.*s'\n",
131 (int)opt_arch.value.len, (const char*)opt_arch.value.ptr,
132 (int)opt_os.value.len, (const char*)opt_os.value.ptr,
133 (int)opt_abi.value.len, (const char*)opt_abi.value.ptr);
134 fprintf(stderr, "parsed from target: '%.*s'\n",
135 (int)opt_target.value.len, (const char*)opt_target.value.ptr);
136 fprintf(stderr, "parsed from line:\n%.*s\n", (int)opt_line.value.len, opt_line.value.ptr);
137 fprintf(stderr, "Zig installation appears to be corrupted.\n");
138 exit(1);
139 }
126140
127 glibc_abi->version_table.put(target, ver_list_base);141 glibc_abi->version_table.put(target, ver_list_base);
128 }142 }
...@@ -130,6 +144,7 @@ Error glibc_load_metadata(ZigGLibCAbi **out_result, Buf *zig_lib_dir, bool verbo...@@ -130,6 +144,7 @@ Error glibc_load_metadata(ZigGLibCAbi **out_result, Buf *zig_lib_dir, bool verbo
130 }144 }
131 for (size_t fn_i = 0; fn_i < glibc_abi->all_functions.length; fn_i += 1) {145 for (size_t fn_i = 0; fn_i < glibc_abi->all_functions.length; fn_i += 1) {
132 ZigGLibCVerList *ver_list = &ver_list_base[fn_i];146 ZigGLibCVerList *ver_list = &ver_list_base[fn_i];
147 line_num += 1;
133 Optional<Slice<uint8_t>> opt_line = SplitIterator_next_separate(&it);148 Optional<Slice<uint8_t>> opt_line = SplitIterator_next_separate(&it);
134 assert(opt_line.is_some);149 assert(opt_line.is_some);
135150
...@@ -266,7 +281,7 @@ Error glibc_build_dummies_and_maps(CodeGen *g, const ZigGLibCAbi *glibc_abi, con...@@ -266,7 +281,7 @@ Error glibc_build_dummies_and_maps(CodeGen *g, const ZigGLibCAbi *glibc_abi, con
266 // - If there are no versions, don't emit it281 // - If there are no versions, don't emit it
267 // - Take the greatest one <= than the target one282 // - Take the greatest one <= than the target one
268 // - If none of them is <= than the283 // - If none of them is <= than the
269 // specified one don't pick any default version 284 // specified one don't pick any default version
270 if (ver_list->len == 0) continue;285 if (ver_list->len == 0) continue;
271 uint8_t chosen_def_ver_index = 255;286 uint8_t chosen_def_ver_index = 255;
272 for (uint8_t ver_i = 0; ver_i < ver_list->len; ver_i += 1) {287 for (uint8_t ver_i = 0; ver_i < ver_list->len; ver_i += 1) {
...@@ -322,7 +337,7 @@ Error glibc_build_dummies_and_maps(CodeGen *g, const ZigGLibCAbi *glibc_abi, con...@@ -322,7 +337,7 @@ Error glibc_build_dummies_and_maps(CodeGen *g, const ZigGLibCAbi *glibc_abi, con
322 codegen_set_lib_version(child_gen, lib->sover, 0, 0);337 codegen_set_lib_version(child_gen, lib->sover, 0, 0);
323 child_gen->is_dynamic = true;338 child_gen->is_dynamic = true;
324 child_gen->is_dummy_so = true;339 child_gen->is_dummy_so = true;
325 child_gen->version_script_path = map_file_path; 340 child_gen->version_script_path = map_file_path;
326 child_gen->enable_cache = false;341 child_gen->enable_cache = false;
327 child_gen->output_dir = dummy_dir;342 child_gen->output_dir = dummy_dir;
328 codegen_build_and_link(child_gen);343 codegen_build_and_link(child_gen);
src/os.cpp+1-1
...@@ -116,7 +116,7 @@ static void os_spawn_process_posix(ZigList<const char *> &args, Termination *ter...@@ -116,7 +116,7 @@ static void os_spawn_process_posix(ZigList<const char *> &args, Termination *ter
116 pid_t pid;116 pid_t pid;
117 int rc = posix_spawnp(&pid, args.at(0), nullptr, nullptr, const_cast<char *const*>(argv), environ);117 int rc = posix_spawnp(&pid, args.at(0), nullptr, nullptr, const_cast<char *const*>(argv), environ);
118 if (rc != 0) {118 if (rc != 0) {
119 zig_panic("posix_spawn failed: %s", strerror(rc));119 zig_panic("unable to spawn %s: %s", args.at(0), strerror(rc));
120 }120 }
121121
122 int status;122 int status;