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...@@ -6,44 +6,14 @@ brew install gcc@7
6brew outdated gcc@7 || brew upgrade gcc@76brew outdated gcc@7 || brew upgrade gcc@7
7brew link --overwrite gcc@77brew link --overwrite gcc@7
88
9which gcc
10which g++
11which gcc-7
12which g++-7
13
14SRC_DIR=$(pwd)9SRC_DIR=$(pwd)
15PREFIX_DIR=$SRC_DIR/local10PREFIX_DIR=$HOME/local/llvm5
16export CC=/usr/local/Cellar/gcc/7.2.0/bin/gcc-711export CC=/usr/local/opt/gcc/bin/gcc-7
17export CXX=/usr/local/Cellar/gcc/7.2.0/bin/g++-712export CXX=/usr/local/opt/gcc/bin/g++-7
1813
19wget http://prereleases.llvm.org/5.0.0/rc2/llvm-5.0.0rc2.src.tar.xz 14mkdir -p $HOME/local
20wget http://prereleases.llvm.org/5.0.0/rc2/cfe-5.0.0rc2.src.tar.xz15cd $HOME/local
21wget http://prereleases.llvm.org/5.0.0/rc2/lld-5.0.0rc2.src.tar.xz16wget http://s3.amazonaws.com/superjoe/temp/llvm5.tar.xz
2217tar xfp llvm5.tar.xz
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
4818
49cd $SRC_DIR19cd $SRC_DIR
ci/travis_osx_script+3-3
...@@ -2,9 +2,9 @@...@@ -2,9 +2,9 @@
22
3set -x3set -x
44
5PREFIX_DIR=$(pwd)/local5PREFIX_DIR=$HOME/local/llvm5
6export CC=/usr/local/Cellar/gcc/7.2.0/bin/gcc-76export CC=/usr/local/opt/gcc/bin/gcc-7
7export CXX=/usr/local/Cellar/gcc/7.2.0/bin/g++-77export CXX=/usr/local/opt/gcc/bin/g++-7
88
9echo $PATH9echo $PATH
10mkdir build10mkdir build
src/codegen.cpp+1
...@@ -139,6 +139,7 @@ CodeGen *codegen_create(Buf *root_src_path, const ZigTarget *target, OutType out...@@ -139,6 +139,7 @@ CodeGen *codegen_create(Buf *root_src_path, const ZigTarget *target, OutType out
139 g->zig_target.os == ZigLLVM_IOS)139 g->zig_target.os == ZigLLVM_IOS)
140 {140 {
141 g->libc_link_lib = create_link_lib(buf_create_from_str("c"));141 g->libc_link_lib = create_link_lib(buf_create_from_str("c"));
142 g->link_libs_list.append(g->libc_link_lib);
142 }143 }
143144
144 return g;145 return g;
src/link.cpp+23-13
...@@ -570,7 +570,7 @@ static void get_darwin_platform(LinkJob *lj, DarwinPlatform *platform) {...@@ -570,7 +570,7 @@ static void get_darwin_platform(LinkJob *lj, DarwinPlatform *platform) {
570 } else if (g->mios_version_min) {570 } else if (g->mios_version_min) {
571 platform->kind = IPhoneOS;571 platform->kind = IPhoneOS;
572 } else {572 } 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");
574 }574 }
575575
576 bool had_extra;576 bool had_extra;
...@@ -703,20 +703,30 @@ static void construct_linker_job_macho(LinkJob *lj) {...@@ -703,20 +703,30 @@ static void construct_linker_job_macho(LinkJob *lj) {
703 lj->args.append((const char *)buf_ptr(g->link_objects.at(i)));703 lj->args.append((const char *)buf_ptr(g->link_objects.at(i)));
704 }704 }
705705
706 for (size_t i = 0; i < g->link_libs_list.length; i += 1) {706 // compiler_rt on darwin is missing some stuff, so we still build it and rely on LinkOnce
707 LinkLib *link_lib = g->link_libs_list.at(i);707 if (g->out_type == OutTypeExe || g->out_type == OutTypeLib) {
708 if (buf_eql_str(link_lib->name, "c")) {708 Buf *compiler_rt_o_path = build_compiler_rt(g);
709 continue;709 lj->args.append(buf_ptr(compiler_rt_o_path));
710 }
711 Buf *arg = buf_sprintf("-l%s", buf_ptr(link_lib->name));
712 lj->args.append(buf_ptr(arg));
713 }710 }
714711
715 // on Darwin, libSystem has libc in it, but also you have to use it712 if (g->is_native_target) {
716 // to make syscalls because the syscall numbers are not documented713 for (size_t lib_i = 0; lib_i < g->link_libs_list.length; lib_i += 1) {
717 // and change between versions.714 LinkLib *link_lib = g->link_libs_list.at(lib_i);
718 // so we always link against libSystem715 if (buf_eql_str(link_lib->name, "c")) {
719 lj->args.append("-lSystem");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
721 if (platform.kind == MacOS) {731 if (platform.kind == MacOS) {
722 if (darwin_version_lt(&platform, 10, 5)) {732 if (darwin_version_lt(&platform, 10, 5)) {
std/special/compiler_rt/comparetf2.zig+25-1
...@@ -18,7 +18,13 @@ const significandMask = implicitBit - 1;...@@ -18,7 +18,13 @@ const significandMask = implicitBit - 1;
18const exponentMask = absMask ^ significandMask;18const exponentMask = absMask ^ significandMask;
19const infRep = exponentMask;19const infRep = exponentMask;
2020
21const builtin = @import("builtin");
22const is_test = builtin.is_test;
23
21export fn __letf2(a: f128, b: f128) -> c_int {24export fn __letf2(a: f128, b: f128) -> c_int {
25 @setDebugSafety(this, is_test);
26 @setGlobalLinkage(__letf2, builtin.GlobalLinkage.LinkOnce);
27
22 const aInt = @bitCast(rep_t, a);28 const aInt = @bitCast(rep_t, a);
23 const bInt = @bitCast(rep_t, b);29 const bInt = @bitCast(rep_t, b);
2430
...@@ -58,7 +64,11 @@ export fn __letf2(a: f128, b: f128) -> c_int {...@@ -58,7 +64,11 @@ export fn __letf2(a: f128, b: f128) -> c_int {
5864
59// Alias for libgcc compatibility65// Alias for libgcc compatibility
60// TODO https://github.com/zig-lang/zig/issues/42066// 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
63// TODO https://github.com/zig-lang/zig/issues/30573// TODO https://github.com/zig-lang/zig/issues/305
64// and then make the return types of some of these functions the enum instead of c_int74// 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);...@@ -68,6 +78,9 @@ const GE_GREATER = c_int(1);
68const GE_UNORDERED = c_int(-1); // Note: different from LE_UNORDERED78const GE_UNORDERED = c_int(-1); // Note: different from LE_UNORDERED
6979
70export fn __getf2(a: f128, b: f128) -> c_int {80export fn __getf2(a: f128, b: f128) -> c_int {
81 @setGlobalLinkage(__getf2, builtin.GlobalLinkage.LinkOnce);
82 @setDebugSafety(this, is_test);
83
71 const aInt = @bitCast(srep_t, a);84 const aInt = @bitCast(srep_t, a);
72 const bInt = @bitCast(srep_t, b);85 const bInt = @bitCast(srep_t, b);
73 const aAbs = @bitCast(rep_t, aInt) & absMask;86 const aAbs = @bitCast(rep_t, aInt) & absMask;
...@@ -95,6 +108,9 @@ export fn __getf2(a: f128, b: f128) -> c_int {...@@ -95,6 +108,9 @@ export fn __getf2(a: f128, b: f128) -> c_int {
95}108}
96109
97export fn __unordtf2(a: f128, b: f128) -> c_int {110export fn __unordtf2(a: f128, b: f128) -> c_int {
111 @setGlobalLinkage(__unordtf2, builtin.GlobalLinkage.LinkOnce);
112 @setDebugSafety(this, is_test);
113
98 const aAbs = @bitCast(rep_t, a) & absMask;114 const aAbs = @bitCast(rep_t, a) & absMask;
99 const bAbs = @bitCast(rep_t, b) & absMask;115 const bAbs = @bitCast(rep_t, b) & absMask;
100 return c_int(aAbs > infRep or bAbs > infRep);116 return c_int(aAbs > infRep or bAbs > infRep);
...@@ -103,17 +119,25 @@ export fn __unordtf2(a: f128, b: f128) -> c_int {...@@ -103,17 +119,25 @@ export fn __unordtf2(a: f128, b: f128) -> c_int {
103// The following are alternative names for the preceding routines.119// The following are alternative names for the preceding routines.
104120
105export fn __eqtf2(a: f128, b: f128) -> c_int {121export fn __eqtf2(a: f128, b: f128) -> c_int {
122 @setGlobalLinkage(__eqtf2, builtin.GlobalLinkage.LinkOnce);
123 @setDebugSafety(this, is_test);
106 return __letf2(a, b);124 return __letf2(a, b);
107}125}
108126
109export fn __lttf2(a: f128, b: f128) -> c_int {127export fn __lttf2(a: f128, b: f128) -> c_int {
128 @setGlobalLinkage(__lttf2, builtin.GlobalLinkage.LinkOnce);
129 @setDebugSafety(this, is_test);
110 return __letf2(a, b);130 return __letf2(a, b);
111}131}
112132
113export fn __netf2(a: f128, b: f128) -> c_int {133export fn __netf2(a: f128, b: f128) -> c_int {
134 @setGlobalLinkage(__netf2, builtin.GlobalLinkage.LinkOnce);
135 @setDebugSafety(this, is_test);
114 return __letf2(a, b);136 return __letf2(a, b);
115}137}
116138
117export fn __gttf2(a: f128, b: f128) -> c_int {139export fn __gttf2(a: f128, b: f128) -> c_int {
140 @setGlobalLinkage(__gttf2, builtin.GlobalLinkage.LinkOnce);
141 @setDebugSafety(this, is_test);
118 return __getf2(a, b);142 return __getf2(a, b);
119}143}
std/special/compiler_rt/fixunsdfdi.zig+1
...@@ -1,6 +1,7 @@...@@ -1,6 +1,7 @@
1const fixuint = @import("fixuint.zig").fixuint;1const fixuint = @import("fixuint.zig").fixuint;
22
3export fn __fixunsdfdi(a: f64) -> u64 {3export fn __fixunsdfdi(a: f64) -> u64 {
4 @setGlobalLinkage(__fixunsdfdi, @import("builtin").GlobalLinkage.LinkOnce);
4 return fixuint(f64, u64, a);5 return fixuint(f64, u64, a);
5}6}
67
std/special/compiler_rt/fixunsdfsi.zig+1
...@@ -1,6 +1,7 @@...@@ -1,6 +1,7 @@
1const fixuint = @import("fixuint.zig").fixuint;1const fixuint = @import("fixuint.zig").fixuint;
22
3export fn __fixunsdfsi(a: f64) -> u32 {3export fn __fixunsdfsi(a: f64) -> u32 {
4 @setGlobalLinkage(__fixunsdfsi, @import("builtin").GlobalLinkage.LinkOnce);
4 return fixuint(f64, u32, a);5 return fixuint(f64, u32, a);
5}6}
67
std/special/compiler_rt/fixunsdfti.zig+1
...@@ -1,6 +1,7 @@...@@ -1,6 +1,7 @@
1const fixuint = @import("fixuint.zig").fixuint;1const fixuint = @import("fixuint.zig").fixuint;
22
3export fn __fixunsdfti(a: f64) -> u128 {3export fn __fixunsdfti(a: f64) -> u128 {
4 @setGlobalLinkage(__fixunsdfti, @import("builtin").GlobalLinkage.LinkOnce);
4 return fixuint(f64, u128, a);5 return fixuint(f64, u128, a);
5}6}
67
std/special/compiler_rt/fixunssfdi.zig+1
...@@ -1,6 +1,7 @@...@@ -1,6 +1,7 @@
1const fixuint = @import("fixuint.zig").fixuint;1const fixuint = @import("fixuint.zig").fixuint;
22
3export fn __fixunssfdi(a: f32) -> u64 {3export fn __fixunssfdi(a: f32) -> u64 {
4 @setGlobalLinkage(__fixunssfdi, @import("builtin").GlobalLinkage.LinkOnce);
4 return fixuint(f32, u64, a);5 return fixuint(f32, u64, a);
5}6}
67
std/special/compiler_rt/fixunssfsi.zig+1
...@@ -1,6 +1,7 @@...@@ -1,6 +1,7 @@
1const fixuint = @import("fixuint.zig").fixuint;1const fixuint = @import("fixuint.zig").fixuint;
22
3export fn __fixunssfsi(a: f32) -> u32 {3export fn __fixunssfsi(a: f32) -> u32 {
4 @setGlobalLinkage(__fixunssfsi, @import("builtin").GlobalLinkage.LinkOnce);
4 return fixuint(f32, u32, a);5 return fixuint(f32, u32, a);
5}6}
67
std/special/compiler_rt/fixunssfti.zig+1
...@@ -1,6 +1,7 @@...@@ -1,6 +1,7 @@
1const fixuint = @import("fixuint.zig").fixuint;1const fixuint = @import("fixuint.zig").fixuint;
22
3export fn __fixunssfti(a: f32) -> u128 {3export fn __fixunssfti(a: f32) -> u128 {
4 @setGlobalLinkage(__fixunssfti, @import("builtin").GlobalLinkage.LinkOnce);
4 return fixuint(f32, u128, a);5 return fixuint(f32, u128, a);
5}6}
67
std/special/compiler_rt/fixunstfdi.zig+1
...@@ -1,6 +1,7 @@...@@ -1,6 +1,7 @@
1const fixuint = @import("fixuint.zig").fixuint;1const fixuint = @import("fixuint.zig").fixuint;
22
3export fn __fixunstfdi(a: f128) -> u64 {3export fn __fixunstfdi(a: f128) -> u64 {
4 @setGlobalLinkage(__fixunstfdi, @import("builtin").GlobalLinkage.LinkOnce);
4 return fixuint(f128, u64, a);5 return fixuint(f128, u64, a);
5}6}
67
std/special/compiler_rt/fixunstfsi.zig+1
...@@ -1,6 +1,7 @@...@@ -1,6 +1,7 @@
1const fixuint = @import("fixuint.zig").fixuint;1const fixuint = @import("fixuint.zig").fixuint;
22
3export fn __fixunstfsi(a: f128) -> u32 {3export fn __fixunstfsi(a: f128) -> u32 {
4 @setGlobalLinkage(__fixunstfsi, @import("builtin").GlobalLinkage.LinkOnce);
4 return fixuint(f128, u32, a);5 return fixuint(f128, u32, a);
5}6}
67
std/special/compiler_rt/fixunstfti.zig+1
...@@ -1,6 +1,7 @@...@@ -1,6 +1,7 @@
1const fixuint = @import("fixuint.zig").fixuint;1const fixuint = @import("fixuint.zig").fixuint;
22
3export fn __fixunstfti(a: f128) -> u128 {3export fn __fixunstfti(a: f128) -> u128 {
4 @setGlobalLinkage(__fixunstfti, @import("builtin").GlobalLinkage.LinkOnce);
4 return fixuint(f128, u128, a);5 return fixuint(f128, u128, a);
5}6}
67
std/special/compiler_rt/index.zig+6
...@@ -23,11 +23,13 @@ const __udivmoddi4 = @import("udivmoddi4.zig").__udivmoddi4;...@@ -23,11 +23,13 @@ const __udivmoddi4 = @import("udivmoddi4.zig").__udivmoddi4;
2323
24export fn __udivdi3(a: u64, b: u64) -> u64 {24export fn __udivdi3(a: u64, b: u64) -> u64 {
25 @setDebugSafety(this, is_test);25 @setDebugSafety(this, is_test);
26 @setGlobalLinkage(__udivdi3, builtin.GlobalLinkage.LinkOnce);
26 return __udivmoddi4(a, b, null);27 return __udivmoddi4(a, b, null);
27}28}
2829
29export fn __umoddi3(a: u64, b: u64) -> u64 {30export fn __umoddi3(a: u64, b: u64) -> u64 {
30 @setDebugSafety(this, is_test);31 @setDebugSafety(this, is_test);
32 @setGlobalLinkage(__umoddi3, builtin.GlobalLinkage.LinkOnce);
3133
32 var r: u64 = undefined;34 var r: u64 = undefined;
33 _ = __udivmoddi4(a, b, &r);35 _ = __udivmoddi4(a, b, &r);
...@@ -63,6 +65,7 @@ export nakedcc fn __aeabi_uidivmod() {...@@ -63,6 +65,7 @@ export nakedcc fn __aeabi_uidivmod() {
63 @setDebugSafety(this, false);65 @setDebugSafety(this, false);
6466
65 if (comptime isArmArch()) {67 if (comptime isArmArch()) {
68 @setGlobalLinkage(__aeabi_uidivmod, builtin.GlobalLinkage.LinkOnce);
66 asm volatile (69 asm volatile (
67 \\ push { lr }70 \\ push { lr }
68 \\ sub sp, sp, #471 \\ sub sp, sp, #4
...@@ -80,6 +83,7 @@ export nakedcc fn __aeabi_uidivmod() {...@@ -80,6 +83,7 @@ export nakedcc fn __aeabi_uidivmod() {
8083
81export fn __udivmodsi4(a: u32, b: u32, rem: &u32) -> u32 {84export fn __udivmodsi4(a: u32, b: u32, rem: &u32) -> u32 {
82 @setDebugSafety(this, is_test);85 @setDebugSafety(this, is_test);
86 @setGlobalLinkage(__udivmodsi4, builtin.GlobalLinkage.LinkOnce);
8387
84 const d = __udivsi3(a, b);88 const d = __udivsi3(a, b);
85 *rem = u32(i32(a) -% (i32(d) * i32(b)));89 *rem = u32(i32(a) -% (i32(d) * i32(b)));
...@@ -92,12 +96,14 @@ export fn __udivmodsi4(a: u32, b: u32, rem: &u32) -> u32 {...@@ -92,12 +96,14 @@ export fn __udivmodsi4(a: u32, b: u32, rem: &u32) -> u32 {
9296
93export fn __aeabi_uidiv(n: u32, d: u32) -> u32 {97export fn __aeabi_uidiv(n: u32, d: u32) -> u32 {
94 @setDebugSafety(this, is_test);98 @setDebugSafety(this, is_test);
99 @setGlobalLinkage(__aeabi_uidiv, builtin.GlobalLinkage.LinkOnce);
95100
96 return __udivsi3(n, d);101 return __udivsi3(n, d);
97}102}
98103
99export fn __udivsi3(n: u32, d: u32) -> u32 {104export fn __udivsi3(n: u32, d: u32) -> u32 {
100 @setDebugSafety(this, is_test);105 @setDebugSafety(this, is_test);
106 @setGlobalLinkage(__udivsi3, builtin.GlobalLinkage.LinkOnce);
101107
102 const n_uword_bits: c_uint = u32.bit_count;108 const n_uword_bits: c_uint = u32.bit_count;
103 // special cases109 // special cases