mirror of
https://github.com/ziglang/zig.git
synced 2026-02-12 20:37:54 +00:00
handle libc include path and libc lib path differently
This commit is contained in:
parent
c6bf9c6942
commit
f580c7fa43
@ -1370,7 +1370,7 @@ static void resolve_c_import_decl(CodeGen *g, ImportTableEntry *parent_import, A
|
||||
return;
|
||||
}
|
||||
|
||||
find_libc_path(g);
|
||||
find_libc_include_path(g);
|
||||
|
||||
ImportTableEntry *child_import = allocate<ImportTableEntry>(1);
|
||||
child_import->fn_table.init(32);
|
||||
@ -6107,7 +6107,13 @@ bool handle_is_ptr(TypeTableEntry *type_entry) {
|
||||
zig_unreachable();
|
||||
}
|
||||
|
||||
void find_libc_path(CodeGen *g) {
|
||||
void find_libc_include_path(CodeGen *g) {
|
||||
if (!g->libc_include_dir || buf_len(g->libc_include_dir) == 0) {
|
||||
zig_panic("Unable to determine libc include path.");
|
||||
}
|
||||
}
|
||||
|
||||
void find_libc_lib_path(CodeGen *g) {
|
||||
// later we can handle this better by reporting an error via the normal mechanism
|
||||
if (!g->libc_lib_dir || buf_len(g->libc_lib_dir) == 0) {
|
||||
zig_panic("Unable to determine libc lib path.");
|
||||
@ -6115,9 +6121,6 @@ void find_libc_path(CodeGen *g) {
|
||||
if (!g->libc_static_lib_dir || buf_len(g->libc_static_lib_dir) == 0) {
|
||||
zig_panic("Unable to determine libc static lib path.");
|
||||
}
|
||||
if (!g->libc_include_dir || buf_len(g->libc_include_dir) == 0) {
|
||||
zig_panic("Unable to determine libc include path.");
|
||||
}
|
||||
}
|
||||
|
||||
static uint32_t hash_ptr(void *ptr) {
|
||||
|
||||
@ -30,7 +30,8 @@ TypeTableEntry *get_partial_container_type(CodeGen *g, ImportTableEntry *import,
|
||||
ContainerKind kind, AstNode *decl_node, const char *name);
|
||||
TypeTableEntry *get_smallest_unsigned_int_type(CodeGen *g, uint64_t x);
|
||||
bool handle_is_ptr(TypeTableEntry *type_entry);
|
||||
void find_libc_path(CodeGen *g);
|
||||
void find_libc_include_path(CodeGen *g);
|
||||
void find_libc_lib_path(CodeGen *g);
|
||||
|
||||
TypeTableEntry *get_underlying_type(TypeTableEntry *type_entry);
|
||||
bool type_has_bits(TypeTableEntry *type_entry);
|
||||
|
||||
@ -3695,7 +3695,7 @@ static void init(CodeGen *g, Buf *source_path) {
|
||||
}
|
||||
|
||||
void codegen_parseh(CodeGen *g, Buf *src_dirname, Buf *src_basename, Buf *source_code) {
|
||||
find_libc_path(g);
|
||||
find_libc_include_path(g);
|
||||
Buf *full_path = buf_alloc();
|
||||
os_path_join(src_dirname, src_basename, full_path);
|
||||
|
||||
|
||||
15
src/link.cpp
15
src/link.cpp
@ -127,6 +127,11 @@ static const char *getLDMOption(const ZigTarget *t) {
|
||||
static void construct_linker_job_linux(LinkJob *lj) {
|
||||
CodeGen *g = lj->codegen;
|
||||
|
||||
if (lj->link_in_crt) {
|
||||
find_libc_lib_path(g);
|
||||
}
|
||||
|
||||
|
||||
lj->args.append("-m");
|
||||
lj->args.append(getLDMOption(&g->zig_target));
|
||||
|
||||
@ -253,6 +258,10 @@ static bool is_target_cyg_mingw(const ZigTarget *target) {
|
||||
static void construct_linker_job_mingw(LinkJob *lj) {
|
||||
CodeGen *g = lj->codegen;
|
||||
|
||||
if (lj->link_in_crt) {
|
||||
find_libc_lib_path(g);
|
||||
}
|
||||
|
||||
if (g->zig_target.arch.arch == ZigLLVM_x86) {
|
||||
lj->args.append("-m");
|
||||
lj->args.append("i386pe");
|
||||
@ -526,12 +535,6 @@ void codegen_link(CodeGen *g, const char *out_file) {
|
||||
}
|
||||
|
||||
lj.link_in_crt = (g->link_libc && g->out_type == OutTypeExe);
|
||||
if (lj.link_in_crt) {
|
||||
find_libc_path(g);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// invoke `ld`
|
||||
ensure_we_have_linker_path(g);
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user