authorgravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2021-06-24 12:56:28+02:00
committergravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2021-06-24 14:45:45+02:00
logb55a3cefa49549e62dbd40f385cc0a5b4b6433b3
tree89b09ccde47abbb0d6dc925f537b6f2cbbdcd4b7
parentbc78b02c04143b7e1b32aceacdcf44130026a7a7

zld: extract path to libc in the linker proper


3 files changed, 3 insertions(+), 19 deletions(-)

src/Compilation.zig-15
......@@ -919,20 +919,6 @@ pub fn create(gpa: *Allocator, options: InitOptions) !*Compilation {
919919 }
920920 };
921921
922 const libc_stub_path: ?[]const u8 = if (options.target.isDarwin()) libc_stub: {
923 // TODO consider other platforms than Darwin which require linking against libc here.
924 const needs_libc_stub: bool = switch (options.output_mode) {
925 .Obj => false,
926 .Lib => if (options.link_mode) |mode| mode == .Dynamic else false,
927 .Exe => true,
928 };
929 if (needs_libc_stub) {
930 break :libc_stub try options.zig_lib_directory.join(arena, &[_][]const u8{
931 "libc", "darwin", "libSystem.B.tbd",
932 });
933 } else break :libc_stub null;
934 } else null;
935
936922 const must_dynamic_link = dl: {
937923 if (target_util.cannotDynamicLink(options.target))
938924 break :dl false;
......@@ -1302,7 +1288,6 @@ pub fn create(gpa: *Allocator, options: InitOptions) !*Compilation {
13021288 .use_lld = use_lld,
13031289 .use_llvm = use_llvm,
13041290 .system_linker_hack = darwin_options.system_linker_hack,
1305 .libc_stub_path = libc_stub_path,
13061291 .link_libc = link_libc,
13071292 .link_libcpp = link_libcpp,
13081293 .link_libunwind = link_libunwind,
src/link.zig-3
......@@ -62,9 +62,6 @@ pub const Options = struct {
6262 /// Darwin-only. If this is true, `use_llvm` is true, and `is_native_os` is true, this link code will
6363 /// use system linker `ld` instead of the LLD.
6464 system_linker_hack: bool,
65 /// Path to Zig-hosted libc stub file.
66 /// On Darwin, this is a path to libSystem.B.tbd stub file.
67 libc_stub_path: ?[]const u8,
6865 link_libc: bool,
6966 link_libcpp: bool,
7067 link_libunwind: bool,
src/link/MachO.zig+3-1
......@@ -848,7 +848,9 @@ fn linkWithLLD(self: *MachO, comp: *Compilation) !void {
848848 try zld.link(positionals.items, full_out_path, .{
849849 .libs = libs.items,
850850 .rpaths = rpaths.items,
851 .libc_stub_path = self.base.options.libc_stub_path.?,
851 .libc_stub_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{
852 "libc", "darwin", "libSystem.B.tbd",
853 }),
852854 });
853855
854856 break :outer;