authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2016-02-15 16:52:37-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2016-02-15 16:52:37-07:00
logf580c7fa4330a0c181226060d2e778285fa38dc0
tree5e50ba6c9097b62371cf57b913465ff6e8ebbce2
parentc6bf9c6942a8d348aeb02e6dff843ec382c3f0b9

handle libc include path and libc lib path differently


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
13701370 return;
13711371 }
13721372
1373 find_libc_path(g);
1373 find_libc_include_path(g);
13741374
13751375 ImportTableEntry *child_import = allocate<ImportTableEntry>(1);
13761376 child_import->fn_table.init(32);
......@@ -6107,7 +6107,13 @@ bool handle_is_ptr(TypeTableEntry *type_entry) {
61076107 zig_unreachable();
61086108}
61096109
6110void find_libc_path(CodeGen *g) {
6110void 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
6116void find_libc_lib_path(CodeGen *g) {
61116117 // later we can handle this better by reporting an error via the normal mechanism
61126118 if (!g->libc_lib_dir || buf_len(g->libc_lib_dir) == 0) {
61136119 zig_panic("Unable to determine libc lib path.");
......@@ -6115,9 +6121,6 @@ void find_libc_path(CodeGen *g) {
61156121 if (!g->libc_static_lib_dir || buf_len(g->libc_static_lib_dir) == 0) {
61166122 zig_panic("Unable to determine libc static lib path.");
61176123 }
6118 if (!g->libc_include_dir || buf_len(g->libc_include_dir) == 0) {
6119 zig_panic("Unable to determine libc include path.");
6120 }
61216124}
61226125
61236126static uint32_t hash_ptr(void *ptr) {
src/analyze.hpp+2-1
......@@ -30,7 +30,8 @@ TypeTableEntry *get_partial_container_type(CodeGen *g, ImportTableEntry *import,
3030 ContainerKind kind, AstNode *decl_node, const char *name);
3131TypeTableEntry *get_smallest_unsigned_int_type(CodeGen *g, uint64_t x);
3232bool handle_is_ptr(TypeTableEntry *type_entry);
33void find_libc_path(CodeGen *g);
33void find_libc_include_path(CodeGen *g);
34void find_libc_lib_path(CodeGen *g);
3435
3536TypeTableEntry *get_underlying_type(TypeTableEntry *type_entry);
3637bool type_has_bits(TypeTableEntry *type_entry);
src/codegen.cpp+1-1
......@@ -3695,7 +3695,7 @@ static void init(CodeGen *g, Buf *source_path) {
36953695}
36963696
36973697void codegen_parseh(CodeGen *g, Buf *src_dirname, Buf *src_basename, Buf *source_code) {
3698 find_libc_path(g);
3698 find_libc_include_path(g);
36993699 Buf *full_path = buf_alloc();
37003700 os_path_join(src_dirname, src_basename, full_path);
37013701
src/link.cpp+9-6
......@@ -127,6 +127,11 @@ static const char *getLDMOption(const ZigTarget *t) {
127127static void construct_linker_job_linux(LinkJob *lj) {
128128 CodeGen *g = lj->codegen;
129129
130 if (lj->link_in_crt) {
131 find_libc_lib_path(g);
132 }
133
134
130135 lj->args.append("-m");
131136 lj->args.append(getLDMOption(&g->zig_target));
132137
......@@ -253,6 +258,10 @@ static bool is_target_cyg_mingw(const ZigTarget *target) {
253258static void construct_linker_job_mingw(LinkJob *lj) {
254259 CodeGen *g = lj->codegen;
255260
261 if (lj->link_in_crt) {
262 find_libc_lib_path(g);
263 }
264
256265 if (g->zig_target.arch.arch == ZigLLVM_x86) {
257266 lj->args.append("-m");
258267 lj->args.append("i386pe");
......@@ -526,12 +535,6 @@ void codegen_link(CodeGen *g, const char *out_file) {
526535 }
527536
528537 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
535538 // invoke `ld`
536539 ensure_we_have_linker_path(g);
537540