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...@@ -1370,7 +1370,7 @@ static void resolve_c_import_decl(CodeGen *g, ImportTableEntry *parent_import, A
1370 return;1370 return;
1371 }1371 }
13721372
1373 find_libc_path(g);1373 find_libc_include_path(g);
13741374
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}
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) {
6111 // later we can handle this better by reporting an error via the normal mechanism6117 // 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}
61226125
6123static uint32_t hash_ptr(void *ptr) {6126static 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);
31TypeTableEntry *get_smallest_unsigned_int_type(CodeGen *g, uint64_t x);31TypeTableEntry *get_smallest_unsigned_int_type(CodeGen *g, uint64_t x);
32bool handle_is_ptr(TypeTableEntry *type_entry);32bool 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
35TypeTableEntry *get_underlying_type(TypeTableEntry *type_entry);36TypeTableEntry *get_underlying_type(TypeTableEntry *type_entry);
36bool type_has_bits(TypeTableEntry *type_entry);37bool 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}
36963696
3697void codegen_parseh(CodeGen *g, Buf *src_dirname, Buf *src_basename, Buf *source_code) {3697void 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);
37013701
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) {
127static void construct_linker_job_linux(LinkJob *lj) {127static void construct_linker_job_linux(LinkJob *lj) {
128 CodeGen *g = lj->codegen;128 CodeGen *g = lj->codegen;
129129
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));
132137
...@@ -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) {
253static void construct_linker_job_mingw(LinkJob *lj) {258static void construct_linker_job_mingw(LinkJob *lj) {
254 CodeGen *g = lj->codegen;259 CodeGen *g = lj->codegen;
255260
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 }
527536
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);
537540