| author | |
| committer | |
| log | f580c7fa4330a0c181226060d2e778285fa38dc0 |
| tree | 5e50ba6c9097b62371cf57b913465ff6e8ebbce2 |
| parent | c6bf9c6942a8d348aeb02e6dff843ec382c3f0b9 |
4 files changed, 20 insertions(+), 13 deletions(-)
src/analyze.cpp+8-5| ... | @@ -1370,7 +1370,7 @@ static void resolve_c_import_decl(CodeGen *g, ImportTableEntry *parent_import, A | ... | @@ -1370,7 +1370,7 @@ static void resolve_c_import_decl(CodeGen *g, ImportTableEntry *parent_import, A |
| 1370 | return; | 1370 | return; |
| 1371 | } | 1371 | } |
| 1372 | 1372 | ||
| 1373 | find_libc_path(g); | 1373 | find_libc_include_path(g); |
| 1374 | 1374 | ||
| 1375 | ImportTableEntry *child_import = allocate<ImportTableEntry>(1); | 1375 | ImportTableEntry *child_import = allocate<ImportTableEntry>(1); |
| 1376 | child_import->fn_table.init(32); | 1376 | child_import->fn_table.init(32); |
| ... | @@ -6107,7 +6107,13 @@ bool handle_is_ptr(TypeTableEntry *type_entry) { | ... | @@ -6107,7 +6107,13 @@ bool handle_is_ptr(TypeTableEntry *type_entry) { |
| 6107 | zig_unreachable(); | 6107 | zig_unreachable(); |
| 6108 | } | 6108 | } |
| 6109 | 6109 | ||
| 6110 | void find_libc_path(CodeGen *g) { | 6110 | void find_libc_include_path(CodeGen *g) { |
| 6111 | if (!g->libc_include_dir || buf_len(g->libc_include_dir) == 0) { | ||
| 6112 | zig_panic("Unable to determine libc include path."); | ||
| 6113 | } | ||
| 6114 | } | ||
| 6115 | |||
| 6116 | void find_libc_lib_path(CodeGen *g) { | ||
| 6111 | // later we can handle this better by reporting an error via the normal mechanism | 6117 | // later we can handle this better by reporting an error via the normal mechanism |
| 6112 | if (!g->libc_lib_dir || buf_len(g->libc_lib_dir) == 0) { | 6118 | if (!g->libc_lib_dir || buf_len(g->libc_lib_dir) == 0) { |
| 6113 | zig_panic("Unable to determine libc lib path."); | 6119 | zig_panic("Unable to determine libc lib path."); |
| ... | @@ -6115,9 +6121,6 @@ void find_libc_path(CodeGen *g) { | ... | @@ -6115,9 +6121,6 @@ void find_libc_path(CodeGen *g) { |
| 6115 | if (!g->libc_static_lib_dir || buf_len(g->libc_static_lib_dir) == 0) { | 6121 | if (!g->libc_static_lib_dir || buf_len(g->libc_static_lib_dir) == 0) { |
| 6116 | zig_panic("Unable to determine libc static lib path."); | 6122 | zig_panic("Unable to determine libc static lib path."); |
| 6117 | } | 6123 | } |
| 6118 | if (!g->libc_include_dir || buf_len(g->libc_include_dir) == 0) { | ||
| 6119 | zig_panic("Unable to determine libc include path."); | ||
| 6120 | } | ||
| 6121 | } | 6124 | } |
| 6122 | 6125 | ||
| 6123 | static uint32_t hash_ptr(void *ptr) { | 6126 | static uint32_t hash_ptr(void *ptr) { |
src/analyze.hpp+2-1| ... | @@ -30,7 +30,8 @@ TypeTableEntry *get_partial_container_type(CodeGen *g, ImportTableEntry *import, | ... | @@ -30,7 +30,8 @@ TypeTableEntry *get_partial_container_type(CodeGen *g, ImportTableEntry *import, |
| 30 | ContainerKind kind, AstNode *decl_node, const char *name); | 30 | ContainerKind kind, AstNode *decl_node, const char *name); |
| 31 | TypeTableEntry *get_smallest_unsigned_int_type(CodeGen *g, uint64_t x); | 31 | TypeTableEntry *get_smallest_unsigned_int_type(CodeGen *g, uint64_t x); |
| 32 | bool handle_is_ptr(TypeTableEntry *type_entry); | 32 | bool handle_is_ptr(TypeTableEntry *type_entry); |
| 33 | void find_libc_path(CodeGen *g); | 33 | void find_libc_include_path(CodeGen *g); |
| 34 | void find_libc_lib_path(CodeGen *g); | ||
| 34 | 35 | ||
| 35 | TypeTableEntry *get_underlying_type(TypeTableEntry *type_entry); | 36 | TypeTableEntry *get_underlying_type(TypeTableEntry *type_entry); |
| 36 | bool type_has_bits(TypeTableEntry *type_entry); | 37 | bool type_has_bits(TypeTableEntry *type_entry); |
src/codegen.cpp+1-1| ... | @@ -3695,7 +3695,7 @@ static void init(CodeGen *g, Buf *source_path) { | ... | @@ -3695,7 +3695,7 @@ static void init(CodeGen *g, Buf *source_path) { |
| 3695 | } | 3695 | } |
| 3696 | 3696 | ||
| 3697 | void codegen_parseh(CodeGen *g, Buf *src_dirname, Buf *src_basename, Buf *source_code) { | 3697 | void codegen_parseh(CodeGen *g, Buf *src_dirname, Buf *src_basename, Buf *source_code) { |
| 3698 | find_libc_path(g); | 3698 | find_libc_include_path(g); |
| 3699 | Buf *full_path = buf_alloc(); | 3699 | Buf *full_path = buf_alloc(); |
| 3700 | os_path_join(src_dirname, src_basename, full_path); | 3700 | os_path_join(src_dirname, src_basename, full_path); |
| 3701 | 3701 |
src/link.cpp+9-6| ... | @@ -127,6 +127,11 @@ static const char *getLDMOption(const ZigTarget *t) { | ... | @@ -127,6 +127,11 @@ static const char *getLDMOption(const ZigTarget *t) { |
| 127 | static void construct_linker_job_linux(LinkJob *lj) { | 127 | static void construct_linker_job_linux(LinkJob *lj) { |
| 128 | CodeGen *g = lj->codegen; | 128 | CodeGen *g = lj->codegen; |
| 129 | 129 | ||
| 130 | if (lj->link_in_crt) { | ||
| 131 | find_libc_lib_path(g); | ||
| 132 | } | ||
| 133 | |||
| 134 | |||
| 130 | lj->args.append("-m"); | 135 | lj->args.append("-m"); |
| 131 | lj->args.append(getLDMOption(&g->zig_target)); | 136 | lj->args.append(getLDMOption(&g->zig_target)); |
| 132 | 137 | ||
| ... | @@ -253,6 +258,10 @@ static bool is_target_cyg_mingw(const ZigTarget *target) { | ... | @@ -253,6 +258,10 @@ static bool is_target_cyg_mingw(const ZigTarget *target) { |
| 253 | static void construct_linker_job_mingw(LinkJob *lj) { | 258 | static void construct_linker_job_mingw(LinkJob *lj) { |
| 254 | CodeGen *g = lj->codegen; | 259 | CodeGen *g = lj->codegen; |
| 255 | 260 | ||
| 261 | if (lj->link_in_crt) { | ||
| 262 | find_libc_lib_path(g); | ||
| 263 | } | ||
| 264 | |||
| 256 | if (g->zig_target.arch.arch == ZigLLVM_x86) { | 265 | if (g->zig_target.arch.arch == ZigLLVM_x86) { |
| 257 | lj->args.append("-m"); | 266 | lj->args.append("-m"); |
| 258 | lj->args.append("i386pe"); | 267 | lj->args.append("i386pe"); |
| ... | @@ -526,12 +535,6 @@ void codegen_link(CodeGen *g, const char *out_file) { | ... | @@ -526,12 +535,6 @@ void codegen_link(CodeGen *g, const char *out_file) { |
| 526 | } | 535 | } |
| 527 | 536 | ||
| 528 | lj.link_in_crt = (g->link_libc && g->out_type == OutTypeExe); | 537 | lj.link_in_crt = (g->link_libc && g->out_type == OutTypeExe); |
| 529 | if (lj.link_in_crt) { | ||
| 530 | find_libc_path(g); | ||
| 531 | } | ||
| 532 | |||
| 533 | |||
| 534 | |||
| 535 | // invoke `ld` | 538 | // invoke `ld` |
| 536 | ensure_we_have_linker_path(g); | 539 | ensure_we_have_linker_path(g); |
| 537 | 540 |