aboutsummaryrefslogtreecommitdiff
path: root/src/link.cpp
diff options
context:
space:
mode:
authorAndrew Kelley <superjoe30@gmail.com>2017-08-27 02:51:25 -0400
committerAndrew Kelley <superjoe30@gmail.com>2017-08-27 02:51:25 -0400
commit91536813ec5d159ed4bea857621ed10a1216411a (patch)
treeb7bb3a00d615aa968f17ee7b7509be7ccf592736 /src/link.cpp
parent01f88bf8c658ab6e74d8c3b030b55b17a5048502 (diff)
downloadzig-91536813ec5d159ed4bea857621ed10a1216411a.tar.gz
zig-91536813ec5d159ed4bea857621ed10a1216411a.zip
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.
Diffstat (limited to 'src/link.cpp')
-rw-r--r--src/link.cpp36
1 files changed, 23 insertions, 13 deletions
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)) {