| author | |
| committer | |
| log | 831bb668955fa9d332f7beb1ea11f1c8028e5235 |
| tree | bab62d5c936214739e177dbac1d91603cdf2eac5 |
| parent | a983a0a59b348a885f24656a8646707554170574 |
4 files changed, 17 insertions(+), 3 deletions(-)
src-self-hosted/libc_installation.zig+1-1| ... | @@ -172,7 +172,7 @@ pub const LibCInstallation = struct.{ | ... | @@ -172,7 +172,7 @@ pub const LibCInstallation = struct.{ |
| 172 | try group.call(findNativeStaticLibDir, self, loop); | 172 | try group.call(findNativeStaticLibDir, self, loop); |
| 173 | try group.call(findNativeDynamicLinker, self, loop); | 173 | try group.call(findNativeDynamicLinker, self, loop); |
| 174 | }, | 174 | }, |
| 175 | builtin.Os.macosx => { | 175 | builtin.Os.macosx, builtin.Os.freebsd => { |
| 176 | self.include_dir = try std.mem.dupe(loop.allocator, u8, "/usr/include"); | 176 | self.include_dir = try std.mem.dupe(loop.allocator, u8, "/usr/include"); |
| 177 | }, | 177 | }, |
| 178 | else => @compileError("unimplemented: find libc for this OS"), | 178 | else => @compileError("unimplemented: find libc for this OS"), |
src-self-hosted/target.zig+8-1| ... | @@ -299,6 +299,13 @@ pub const Target = union(enum).{ | ... | @@ -299,6 +299,13 @@ pub const Target = union(enum).{ |
| 299 | pub fn getDynamicLinkerPath(self: Target) ?[]const u8 { | 299 | pub fn getDynamicLinkerPath(self: Target) ?[]const u8 { |
| 300 | const env = self.getEnviron(); | 300 | const env = self.getEnviron(); |
| 301 | const arch = self.getArch(); | 301 | const arch = self.getArch(); |
| 302 | const os = self.getOs(); | ||
| 303 | switch (os) { | ||
| 304 | builtin.Os.freebsd => { | ||
| 305 | return "/libexec/ld-elf.so.1"; | ||
| 306 | }, | ||
| 307 | else => {}, | ||
| 308 | } | ||
| 302 | switch (env) { | 309 | switch (env) { |
| 303 | builtin.Environ.android => { | 310 | builtin.Environ.android => { |
| 304 | if (self.is64bit()) { | 311 | if (self.is64bit()) { |
| ... | @@ -493,6 +500,7 @@ pub const Target = union(enum).{ | ... | @@ -493,6 +500,7 @@ pub const Target = union(enum).{ |
| 493 | 500 | ||
| 494 | builtin.Os.linux, | 501 | builtin.Os.linux, |
| 495 | builtin.Os.macosx, | 502 | builtin.Os.macosx, |
| 503 | builtin.Os.freebsd, | ||
| 496 | builtin.Os.openbsd, | 504 | builtin.Os.openbsd, |
| 497 | builtin.Os.zen, | 505 | builtin.Os.zen, |
| 498 | => switch (id) { | 506 | => switch (id) { |
| ... | @@ -527,7 +535,6 @@ pub const Target = union(enum).{ | ... | @@ -527,7 +535,6 @@ pub const Target = union(enum).{ |
| 527 | builtin.Os.ananas, | 535 | builtin.Os.ananas, |
| 528 | builtin.Os.cloudabi, | 536 | builtin.Os.cloudabi, |
| 529 | builtin.Os.dragonfly, | 537 | builtin.Os.dragonfly, |
| 530 | builtin.Os.freebsd, | ||
| 531 | builtin.Os.fuchsia, | 538 | builtin.Os.fuchsia, |
| 532 | builtin.Os.ios, | 539 | builtin.Os.ios, |
| 533 | builtin.Os.kfreebsd, | 540 | builtin.Os.kfreebsd, |
src/analyze.cpp+5-1| ... | @@ -4606,7 +4606,7 @@ void find_libc_include_path(CodeGen *g) { | ... | @@ -4606,7 +4606,7 @@ void find_libc_include_path(CodeGen *g) { |
| 4606 | } | 4606 | } |
| 4607 | } else if (g->zig_target.os == OsLinux) { | 4607 | } else if (g->zig_target.os == OsLinux) { |
| 4608 | g->libc_include_dir = get_linux_libc_include_path(); | 4608 | g->libc_include_dir = get_linux_libc_include_path(); |
| 4609 | } else if (g->zig_target.os == OsMacOSX) { | 4609 | } else if (g->zig_target.os == OsMacOSX || g->zig_target.os == OsFreeBSD) { |
| 4610 | g->libc_include_dir = buf_create_from_str("/usr/include"); | 4610 | g->libc_include_dir = buf_create_from_str("/usr/include"); |
| 4611 | } else { | 4611 | } else { |
| 4612 | // TODO find libc at runtime for other operating systems | 4612 | // TODO find libc at runtime for other operating systems |
| ... | @@ -4652,6 +4652,8 @@ void find_libc_lib_path(CodeGen *g) { | ... | @@ -4652,6 +4652,8 @@ void find_libc_lib_path(CodeGen *g) { |
| 4652 | 4652 | ||
| 4653 | } else if (g->zig_target.os == OsLinux) { | 4653 | } else if (g->zig_target.os == OsLinux) { |
| 4654 | g->libc_lib_dir = get_linux_libc_lib_path("crt1.o"); | 4654 | g->libc_lib_dir = get_linux_libc_lib_path("crt1.o"); |
| 4655 | } else if (g->zig_target.os == OsFreeBSD) { | ||
| 4656 | g->libc_lib_dir = buf_create_from_str("/usr/lib"); | ||
| 4655 | } else { | 4657 | } else { |
| 4656 | zig_panic("Unable to determine libc lib path."); | 4658 | zig_panic("Unable to determine libc lib path."); |
| 4657 | } | 4659 | } |
| ... | @@ -4664,6 +4666,8 @@ void find_libc_lib_path(CodeGen *g) { | ... | @@ -4664,6 +4666,8 @@ void find_libc_lib_path(CodeGen *g) { |
| 4664 | return; | 4666 | return; |
| 4665 | } else if (g->zig_target.os == OsLinux) { | 4667 | } else if (g->zig_target.os == OsLinux) { |
| 4666 | g->libc_static_lib_dir = get_linux_libc_lib_path("crtbegin.o"); | 4668 | g->libc_static_lib_dir = get_linux_libc_lib_path("crtbegin.o"); |
| 4669 | } else if (g->zig_target.os == OsFreeBSD) { | ||
| 4670 | g->libc_static_lib_dir = buf_create_from_str("/usr/lib"); | ||
| 4667 | } else { | 4671 | } else { |
| 4668 | zig_panic("Unable to determine libc static lib path."); | 4672 | zig_panic("Unable to determine libc static lib path."); |
| 4669 | } | 4673 | } |
src/link.cpp+3| ... | @@ -195,6 +195,9 @@ static Buf *try_dynamic_linker_path(const char *ld_name) { | ... | @@ -195,6 +195,9 @@ static Buf *try_dynamic_linker_path(const char *ld_name) { |
| 195 | } | 195 | } |
| 196 | 196 | ||
| 197 | static Buf *get_dynamic_linker_path(CodeGen *g) { | 197 | static Buf *get_dynamic_linker_path(CodeGen *g) { |
| 198 | if (g->zig_target.os == OsFreeBSD) { | ||
| 199 | return buf_create_from_str("/libexec/ld-elf.so.1"); | ||
| 200 | } | ||
| 198 | if (g->is_native_target && g->zig_target.arch.arch == ZigLLVM_x86_64) { | 201 | if (g->is_native_target && g->zig_target.arch.arch == ZigLLVM_x86_64) { |
| 199 | static const char *ld_names[] = { | 202 | static const char *ld_names[] = { |
| 200 | "ld-linux-x86-64.so.2", | 203 | "ld-linux-x86-64.so.2", |