aboutsummaryrefslogtreecommitdiff
path: root/src/Compilation.zig
diff options
context:
space:
mode:
authorJakub Konka <kubkon@jakubkonka.com>2021-06-20 10:14:18 +0200
committerJakub Konka <kubkon@jakubkonka.com>2021-06-24 14:45:45 +0200
commit09b46198ff8d64c9884a0cf13788855b4d4bbe2d (patch)
treeda0ac067ec33e1cb5e3a1bdcd3438c1cb6514621 /src/Compilation.zig
parenta600d4188025ae6ffc3fc5d6fa7572ef34438215 (diff)
downloadzig-09b46198ff8d64c9884a0cf13788855b4d4bbe2d.tar.gz
zig-09b46198ff8d64c9884a0cf13788855b4d4bbe2d.zip
zld: move logic unpacking path to libc stub to Compilation
Diffstat (limited to 'src/Compilation.zig')
-rw-r--r--src/Compilation.zig15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/Compilation.zig b/src/Compilation.zig
index ea878056ae..c9b6162bd9 100644
--- a/src/Compilation.zig
+++ b/src/Compilation.zig
@@ -919,6 +919,20 @@ pub fn create(gpa: *Allocator, options: InitOptions) !*Compilation {
}
};
+ const libc_stub_path: ?[]const u8 = if (options.target.isDarwin()) libc_stub: {
+ // TODO consider other platforms than Darwin which require linking against libc here.
+ const needs_libc_stub: bool = switch (options.output_mode) {
+ .Obj => false,
+ .Lib => if (options.link_mode) |mode| mode == .Dynamic else false,
+ .Exe => true,
+ };
+ if (needs_libc_stub) {
+ break :libc_stub try options.zig_lib_directory.join(arena, &[_][]const u8{
+ "libc", "darwin", "libSystem.B.tbd",
+ });
+ } else break :libc_stub null;
+ } else null;
+
const must_dynamic_link = dl: {
if (target_util.cannotDynamicLink(options.target))
break :dl false;
@@ -1288,6 +1302,7 @@ pub fn create(gpa: *Allocator, options: InitOptions) !*Compilation {
.use_lld = use_lld,
.use_llvm = use_llvm,
.system_linker_hack = darwin_options.system_linker_hack,
+ .libc_stub_path = libc_stub_path,
.link_libc = link_libc,
.link_libcpp = link_libcpp,
.link_libunwind = link_libunwind,