From 91536813ec5d159ed4bea857621ed10a1216411a Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Sun, 27 Aug 2017 02:51:25 -0400 Subject: macos updates * try some macos travis stuff * put c in the link libs for macos since we always link with libSystem * for non-native targets on macos, allow runtime symbol resolution - it's causing an infinite loop in LLD. * for macos, always build compiler_rt and turn on LinkOnce because compiler_rt on darwin is missing some stuff. --- src/link.cpp | 36 +++++++++++++++++++++++------------- 1 file changed, 23 insertions(+), 13 deletions(-) (limited to 'src/link.cpp') diff --git a/src/link.cpp b/src/link.cpp index b22b78c4f9..b51fa6e4ca 100644 --- a/src/link.cpp +++ b/src/link.cpp @@ -570,7 +570,7 @@ static void get_darwin_platform(LinkJob *lj, DarwinPlatform *platform) { } else if (g->mios_version_min) { platform->kind = IPhoneOS; } else { - zig_panic("unable to infer -macosx-version-min or -mios-version-min"); + zig_panic("unable to infer -mmacosx-version-min or -mios-version-min"); } bool had_extra; @@ -703,20 +703,30 @@ static void construct_linker_job_macho(LinkJob *lj) { lj->args.append((const char *)buf_ptr(g->link_objects.at(i))); } - for (size_t i = 0; i < g->link_libs_list.length; i += 1) { - LinkLib *link_lib = g->link_libs_list.at(i); - if (buf_eql_str(link_lib->name, "c")) { - continue; - } - Buf *arg = buf_sprintf("-l%s", buf_ptr(link_lib->name)); - lj->args.append(buf_ptr(arg)); + // compiler_rt on darwin is missing some stuff, so we still build it and rely on LinkOnce + if (g->out_type == OutTypeExe || g->out_type == OutTypeLib) { + Buf *compiler_rt_o_path = build_compiler_rt(g); + lj->args.append(buf_ptr(compiler_rt_o_path)); } - // on Darwin, libSystem has libc in it, but also you have to use it - // to make syscalls because the syscall numbers are not documented - // and change between versions. - // so we always link against libSystem - lj->args.append("-lSystem"); + if (g->is_native_target) { + for (size_t lib_i = 0; lib_i < g->link_libs_list.length; lib_i += 1) { + LinkLib *link_lib = g->link_libs_list.at(lib_i); + if (buf_eql_str(link_lib->name, "c")) { + // on Darwin, libSystem has libc in it, but also you have to use it + // to make syscalls because the syscall numbers are not documented + // and change between versions. + // so we always link against libSystem + lj->args.append("-lSystem"); + } else { + Buf *arg = buf_sprintf("-l%s", buf_ptr(link_lib->name)); + lj->args.append(buf_ptr(arg)); + } + } + } else { + lj->args.append("-undefined"); + lj->args.append("dynamic_lookup"); + } if (platform.kind == MacOS) { if (darwin_version_lt(&platform, 10, 5)) { -- cgit v1.2.3