authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2017-08-27 02:51:25-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2017-08-27 02:51:25-04:00
log91536813ec5d159ed4bea857621ed10a1216411a
treeb7bb3a00d615aa968f17ee7b7509be7ccf592736
parent01f88bf8c658ab6e74d8c3b030b55b17a5048502

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.

15 files changed, 75 insertions(+), 55 deletions(-)

ci/travis_osx_install+8-38
......@@ -6,44 +6,14 @@ brew install gcc@7
66brew outdated gcc@7 || brew upgrade gcc@7
77brew link --overwrite gcc@7
88
9which gcc
10which g++
11which gcc-7
12which g++-7
13
149SRC_DIR=$(pwd)
15PREFIX_DIR=$SRC_DIR/local
16export CC=/usr/local/Cellar/gcc/7.2.0/bin/gcc-7
17export CXX=/usr/local/Cellar/gcc/7.2.0/bin/g++-7
18
19wget http://prereleases.llvm.org/5.0.0/rc2/llvm-5.0.0rc2.src.tar.xz
20wget http://prereleases.llvm.org/5.0.0/rc2/cfe-5.0.0rc2.src.tar.xz
21wget http://prereleases.llvm.org/5.0.0/rc2/lld-5.0.0rc2.src.tar.xz
22
23ls -ahl /usr/local/opt
24
25cd $SRC_DIR
26tar xf llvm-5.0.0rc2.src.tar.xz
27cd llvm-5.0.0rc2.src
28mkdir build
29cd build
30cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$PREFIX_DIR -DCMAKE_PREFIX_PATH=$PREFIX_DIR
31make install
32
33cd $SRC_DIR
34tar xf lld-5.0.0rc2.src.tar.xz
35cd lld-5.0.0rc2.src
36mkdir build
37cd build
38cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$PREFIX_DIR -DCMAKE_PREFIX_PATH=$PREFIX_DIR
39make install
40
41cd $SRC_DIR
42tar xf cfe-5.0.0rc2.src.tar.xz
43cd cfe-5.0.0rc2.src
44mkdir build
45cd build
46cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$PREFIX_DIR -DCMAKE_PREFIX_PATH=$PREFIX_DIR
47make install
10PREFIX_DIR=$HOME/local/llvm5
11export CC=/usr/local/opt/gcc/bin/gcc-7
12export CXX=/usr/local/opt/gcc/bin/g++-7
13
14mkdir -p $HOME/local
15cd $HOME/local
16wget http://s3.amazonaws.com/superjoe/temp/llvm5.tar.xz
17tar xfp llvm5.tar.xz
4818
4919cd $SRC_DIR
ci/travis_osx_script+3-3
......@@ -2,9 +2,9 @@
22
33set -x
44
5PREFIX_DIR=$(pwd)/local
6export CC=/usr/local/Cellar/gcc/7.2.0/bin/gcc-7
7export CXX=/usr/local/Cellar/gcc/7.2.0/bin/g++-7
5PREFIX_DIR=$HOME/local/llvm5
6export CC=/usr/local/opt/gcc/bin/gcc-7
7export CXX=/usr/local/opt/gcc/bin/g++-7
88
99echo $PATH
1010mkdir build
src/codegen.cpp+1
......@@ -139,6 +139,7 @@ CodeGen *codegen_create(Buf *root_src_path, const ZigTarget *target, OutType out
139139 g->zig_target.os == ZigLLVM_IOS)
140140 {
141141 g->libc_link_lib = create_link_lib(buf_create_from_str("c"));
142 g->link_libs_list.append(g->libc_link_lib);
142143 }
143144
144145 return g;
src/link.cpp+23-13
......@@ -570,7 +570,7 @@ static void get_darwin_platform(LinkJob *lj, DarwinPlatform *platform) {
570570 } else if (g->mios_version_min) {
571571 platform->kind = IPhoneOS;
572572 } else {
573 zig_panic("unable to infer -macosx-version-min or -mios-version-min");
573 zig_panic("unable to infer -mmacosx-version-min or -mios-version-min");
574574 }
575575
576576 bool had_extra;
......@@ -703,20 +703,30 @@ static void construct_linker_job_macho(LinkJob *lj) {
703703 lj->args.append((const char *)buf_ptr(g->link_objects.at(i)));
704704 }
705705
706 for (size_t i = 0; i < g->link_libs_list.length; i += 1) {
707 LinkLib *link_lib = g->link_libs_list.at(i);
708 if (buf_eql_str(link_lib->name, "c")) {
709 continue;
710 }
711 Buf *arg = buf_sprintf("-l%s", buf_ptr(link_lib->name));
712 lj->args.append(buf_ptr(arg));
706 // compiler_rt on darwin is missing some stuff, so we still build it and rely on LinkOnce
707 if (g->out_type == OutTypeExe || g->out_type == OutTypeLib) {
708 Buf *compiler_rt_o_path = build_compiler_rt(g);
709 lj->args.append(buf_ptr(compiler_rt_o_path));
713710 }
714711
715 // on Darwin, libSystem has libc in it, but also you have to use it
716 // to make syscalls because the syscall numbers are not documented
717 // and change between versions.
718 // so we always link against libSystem
719 lj->args.append("-lSystem");
712 if (g->is_native_target) {
713 for (size_t lib_i = 0; lib_i < g->link_libs_list.length; lib_i += 1) {
714 LinkLib *link_lib = g->link_libs_list.at(lib_i);
715 if (buf_eql_str(link_lib->name, "c")) {
716 // on Darwin, libSystem has libc in it, but also you have to use it
717 // to make syscalls because the syscall numbers are not documented
718 // and change between versions.
719 // so we always link against libSystem
720 lj->args.append("-lSystem");
721 } else {
722 Buf *arg = buf_sprintf("-l%s", buf_ptr(link_lib->name));
723 lj->args.append(buf_ptr(arg));
724 }
725 }
726 } else {
727 lj->args.append("-undefined");
728 lj->args.append("dynamic_lookup");
729 }
720730
721731 if (platform.kind == MacOS) {
722732 if (darwin_version_lt(&platform, 10, 5)) {
std/special/compiler_rt/comparetf2.zig+25-1
......@@ -18,7 +18,13 @@ const significandMask = implicitBit - 1;
1818const exponentMask = absMask ^ significandMask;
1919const infRep = exponentMask;
2020
21const builtin = @import("builtin");
22const is_test = builtin.is_test;
23
2124export fn __letf2(a: f128, b: f128) -> c_int {
25 @setDebugSafety(this, is_test);
26 @setGlobalLinkage(__letf2, builtin.GlobalLinkage.LinkOnce);
27
2228 const aInt = @bitCast(rep_t, a);
2329 const bInt = @bitCast(rep_t, b);
2430
......@@ -58,7 +64,11 @@ export fn __letf2(a: f128, b: f128) -> c_int {
5864
5965// Alias for libgcc compatibility
6066// TODO https://github.com/zig-lang/zig/issues/420
61export fn __cmptf2(a: f128, b: f128) -> c_int { __letf2(a, b) }
67export fn __cmptf2(a: f128, b: f128) -> c_int {
68 @setGlobalLinkage(__cmptf2, builtin.GlobalLinkage.LinkOnce);
69 @setDebugSafety(this, is_test);
70 return __letf2(a, b);
71}
6272
6373// TODO https://github.com/zig-lang/zig/issues/305
6474// and then make the return types of some of these functions the enum instead of c_int
......@@ -68,6 +78,9 @@ const GE_GREATER = c_int(1);
6878const GE_UNORDERED = c_int(-1); // Note: different from LE_UNORDERED
6979
7080export fn __getf2(a: f128, b: f128) -> c_int {
81 @setGlobalLinkage(__getf2, builtin.GlobalLinkage.LinkOnce);
82 @setDebugSafety(this, is_test);
83
7184 const aInt = @bitCast(srep_t, a);
7285 const bInt = @bitCast(srep_t, b);
7386 const aAbs = @bitCast(rep_t, aInt) & absMask;
......@@ -95,6 +108,9 @@ export fn __getf2(a: f128, b: f128) -> c_int {
95108}
96109
97110export fn __unordtf2(a: f128, b: f128) -> c_int {
111 @setGlobalLinkage(__unordtf2, builtin.GlobalLinkage.LinkOnce);
112 @setDebugSafety(this, is_test);
113
98114 const aAbs = @bitCast(rep_t, a) & absMask;
99115 const bAbs = @bitCast(rep_t, b) & absMask;
100116 return c_int(aAbs > infRep or bAbs > infRep);
......@@ -103,17 +119,25 @@ export fn __unordtf2(a: f128, b: f128) -> c_int {
103119// The following are alternative names for the preceding routines.
104120
105121export fn __eqtf2(a: f128, b: f128) -> c_int {
122 @setGlobalLinkage(__eqtf2, builtin.GlobalLinkage.LinkOnce);
123 @setDebugSafety(this, is_test);
106124 return __letf2(a, b);
107125}
108126
109127export fn __lttf2(a: f128, b: f128) -> c_int {
128 @setGlobalLinkage(__lttf2, builtin.GlobalLinkage.LinkOnce);
129 @setDebugSafety(this, is_test);
110130 return __letf2(a, b);
111131}
112132
113133export fn __netf2(a: f128, b: f128) -> c_int {
134 @setGlobalLinkage(__netf2, builtin.GlobalLinkage.LinkOnce);
135 @setDebugSafety(this, is_test);
114136 return __letf2(a, b);
115137}
116138
117139export fn __gttf2(a: f128, b: f128) -> c_int {
140 @setGlobalLinkage(__gttf2, builtin.GlobalLinkage.LinkOnce);
141 @setDebugSafety(this, is_test);
118142 return __getf2(a, b);
119143}
std/special/compiler_rt/fixunsdfdi.zig+1
......@@ -1,6 +1,7 @@
11const fixuint = @import("fixuint.zig").fixuint;
22
33export fn __fixunsdfdi(a: f64) -> u64 {
4 @setGlobalLinkage(__fixunsdfdi, @import("builtin").GlobalLinkage.LinkOnce);
45 return fixuint(f64, u64, a);
56}
67
std/special/compiler_rt/fixunsdfsi.zig+1
......@@ -1,6 +1,7 @@
11const fixuint = @import("fixuint.zig").fixuint;
22
33export fn __fixunsdfsi(a: f64) -> u32 {
4 @setGlobalLinkage(__fixunsdfsi, @import("builtin").GlobalLinkage.LinkOnce);
45 return fixuint(f64, u32, a);
56}
67
std/special/compiler_rt/fixunsdfti.zig+1
......@@ -1,6 +1,7 @@
11const fixuint = @import("fixuint.zig").fixuint;
22
33export fn __fixunsdfti(a: f64) -> u128 {
4 @setGlobalLinkage(__fixunsdfti, @import("builtin").GlobalLinkage.LinkOnce);
45 return fixuint(f64, u128, a);
56}
67
std/special/compiler_rt/fixunssfdi.zig+1
......@@ -1,6 +1,7 @@
11const fixuint = @import("fixuint.zig").fixuint;
22
33export fn __fixunssfdi(a: f32) -> u64 {
4 @setGlobalLinkage(__fixunssfdi, @import("builtin").GlobalLinkage.LinkOnce);
45 return fixuint(f32, u64, a);
56}
67
std/special/compiler_rt/fixunssfsi.zig+1
......@@ -1,6 +1,7 @@
11const fixuint = @import("fixuint.zig").fixuint;
22
33export fn __fixunssfsi(a: f32) -> u32 {
4 @setGlobalLinkage(__fixunssfsi, @import("builtin").GlobalLinkage.LinkOnce);
45 return fixuint(f32, u32, a);
56}
67
std/special/compiler_rt/fixunssfti.zig+1
......@@ -1,6 +1,7 @@
11const fixuint = @import("fixuint.zig").fixuint;
22
33export fn __fixunssfti(a: f32) -> u128 {
4 @setGlobalLinkage(__fixunssfti, @import("builtin").GlobalLinkage.LinkOnce);
45 return fixuint(f32, u128, a);
56}
67
std/special/compiler_rt/fixunstfdi.zig+1
......@@ -1,6 +1,7 @@
11const fixuint = @import("fixuint.zig").fixuint;
22
33export fn __fixunstfdi(a: f128) -> u64 {
4 @setGlobalLinkage(__fixunstfdi, @import("builtin").GlobalLinkage.LinkOnce);
45 return fixuint(f128, u64, a);
56}
67
std/special/compiler_rt/fixunstfsi.zig+1
......@@ -1,6 +1,7 @@
11const fixuint = @import("fixuint.zig").fixuint;
22
33export fn __fixunstfsi(a: f128) -> u32 {
4 @setGlobalLinkage(__fixunstfsi, @import("builtin").GlobalLinkage.LinkOnce);
45 return fixuint(f128, u32, a);
56}
67
std/special/compiler_rt/fixunstfti.zig+1
......@@ -1,6 +1,7 @@
11const fixuint = @import("fixuint.zig").fixuint;
22
33export fn __fixunstfti(a: f128) -> u128 {
4 @setGlobalLinkage(__fixunstfti, @import("builtin").GlobalLinkage.LinkOnce);
45 return fixuint(f128, u128, a);
56}
67
std/special/compiler_rt/index.zig+6
......@@ -23,11 +23,13 @@ const __udivmoddi4 = @import("udivmoddi4.zig").__udivmoddi4;
2323
2424export fn __udivdi3(a: u64, b: u64) -> u64 {
2525 @setDebugSafety(this, is_test);
26 @setGlobalLinkage(__udivdi3, builtin.GlobalLinkage.LinkOnce);
2627 return __udivmoddi4(a, b, null);
2728}
2829
2930export fn __umoddi3(a: u64, b: u64) -> u64 {
3031 @setDebugSafety(this, is_test);
32 @setGlobalLinkage(__umoddi3, builtin.GlobalLinkage.LinkOnce);
3133
3234 var r: u64 = undefined;
3335 _ = __udivmoddi4(a, b, &r);
......@@ -63,6 +65,7 @@ export nakedcc fn __aeabi_uidivmod() {
6365 @setDebugSafety(this, false);
6466
6567 if (comptime isArmArch()) {
68 @setGlobalLinkage(__aeabi_uidivmod, builtin.GlobalLinkage.LinkOnce);
6669 asm volatile (
6770 \\ push { lr }
6871 \\ sub sp, sp, #4
......@@ -80,6 +83,7 @@ export nakedcc fn __aeabi_uidivmod() {
8083
8184export fn __udivmodsi4(a: u32, b: u32, rem: &u32) -> u32 {
8285 @setDebugSafety(this, is_test);
86 @setGlobalLinkage(__udivmodsi4, builtin.GlobalLinkage.LinkOnce);
8387
8488 const d = __udivsi3(a, b);
8589 *rem = u32(i32(a) -% (i32(d) * i32(b)));
......@@ -92,12 +96,14 @@ export fn __udivmodsi4(a: u32, b: u32, rem: &u32) -> u32 {
9296
9397export fn __aeabi_uidiv(n: u32, d: u32) -> u32 {
9498 @setDebugSafety(this, is_test);
99 @setGlobalLinkage(__aeabi_uidiv, builtin.GlobalLinkage.LinkOnce);
95100
96101 return __udivsi3(n, d);
97102}
98103
99104export fn __udivsi3(n: u32, d: u32) -> u32 {
100105 @setDebugSafety(this, is_test);
106 @setGlobalLinkage(__udivsi3, builtin.GlobalLinkage.LinkOnce);
101107
102108 const n_uword_bits: c_uint = u32.bit_count;
103109 // special cases