| author | |
| committer | |
| log | 91536813ec5d159ed4bea857621ed10a1216411a |
| tree | b7bb3a00d615aa968f17ee7b7509be7ccf592736 |
| parent | 01f88bf8c658ab6e74d8c3b030b55b17a5048502 |
* 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 | 6 | brew outdated gcc@7 || brew upgrade gcc@7 |
| 7 | 7 | brew link --overwrite gcc@7 |
| 8 | 8 | |
| 9 | which gcc | |
| 10 | which g++ | |
| 11 | which gcc-7 | |
| 12 | which g++-7 | |
| 13 | ||
| 14 | 9 | SRC_DIR=$(pwd) |
| 15 | PREFIX_DIR=$SRC_DIR/local | |
| 16 | export CC=/usr/local/Cellar/gcc/7.2.0/bin/gcc-7 | |
| 17 | export CXX=/usr/local/Cellar/gcc/7.2.0/bin/g++-7 | |
| 18 | ||
| 19 | wget http://prereleases.llvm.org/5.0.0/rc2/llvm-5.0.0rc2.src.tar.xz | |
| 20 | wget http://prereleases.llvm.org/5.0.0/rc2/cfe-5.0.0rc2.src.tar.xz | |
| 21 | wget http://prereleases.llvm.org/5.0.0/rc2/lld-5.0.0rc2.src.tar.xz | |
| 22 | ||
| 23 | ls -ahl /usr/local/opt | |
| 24 | ||
| 25 | cd $SRC_DIR | |
| 26 | tar xf llvm-5.0.0rc2.src.tar.xz | |
| 27 | cd llvm-5.0.0rc2.src | |
| 28 | mkdir build | |
| 29 | cd build | |
| 30 | cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$PREFIX_DIR -DCMAKE_PREFIX_PATH=$PREFIX_DIR | |
| 31 | make install | |
| 32 | ||
| 33 | cd $SRC_DIR | |
| 34 | tar xf lld-5.0.0rc2.src.tar.xz | |
| 35 | cd lld-5.0.0rc2.src | |
| 36 | mkdir build | |
| 37 | cd build | |
| 38 | cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$PREFIX_DIR -DCMAKE_PREFIX_PATH=$PREFIX_DIR | |
| 39 | make install | |
| 40 | ||
| 41 | cd $SRC_DIR | |
| 42 | tar xf cfe-5.0.0rc2.src.tar.xz | |
| 43 | cd cfe-5.0.0rc2.src | |
| 44 | mkdir build | |
| 45 | cd build | |
| 46 | cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$PREFIX_DIR -DCMAKE_PREFIX_PATH=$PREFIX_DIR | |
| 47 | make install | |
| 10 | PREFIX_DIR=$HOME/local/llvm5 | |
| 11 | export CC=/usr/local/opt/gcc/bin/gcc-7 | |
| 12 | export CXX=/usr/local/opt/gcc/bin/g++-7 | |
| 13 | ||
| 14 | mkdir -p $HOME/local | |
| 15 | cd $HOME/local | |
| 16 | wget http://s3.amazonaws.com/superjoe/temp/llvm5.tar.xz | |
| 17 | tar xfp llvm5.tar.xz | |
| 48 | 18 | |
| 49 | 19 | cd $SRC_DIR |
ci/travis_osx_script+3-3| ... | ... | @@ -2,9 +2,9 @@ |
| 2 | 2 | |
| 3 | 3 | set -x |
| 4 | 4 | |
| 5 | PREFIX_DIR=$(pwd)/local | |
| 6 | export CC=/usr/local/Cellar/gcc/7.2.0/bin/gcc-7 | |
| 7 | export CXX=/usr/local/Cellar/gcc/7.2.0/bin/g++-7 | |
| 5 | PREFIX_DIR=$HOME/local/llvm5 | |
| 6 | export CC=/usr/local/opt/gcc/bin/gcc-7 | |
| 7 | export CXX=/usr/local/opt/gcc/bin/g++-7 | |
| 8 | 8 | |
| 9 | 9 | echo $PATH |
| 10 | 10 | mkdir build |
src/codegen.cpp+1| ... | ... | @@ -139,6 +139,7 @@ CodeGen *codegen_create(Buf *root_src_path, const ZigTarget *target, OutType out |
| 139 | 139 | g->zig_target.os == ZigLLVM_IOS) |
| 140 | 140 | { |
| 141 | 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 | } |
| 143 | 144 | |
| 144 | 145 | return g; |
src/link.cpp+23-13| ... | ... | @@ -570,7 +570,7 @@ static void get_darwin_platform(LinkJob *lj, DarwinPlatform *platform) { |
| 570 | 570 | } else if (g->mios_version_min) { |
| 571 | 571 | platform->kind = IPhoneOS; |
| 572 | 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 | } |
| 575 | 575 | |
| 576 | 576 | bool had_extra; |
| ... | ... | @@ -703,20 +703,30 @@ static void construct_linker_job_macho(LinkJob *lj) { |
| 703 | 703 | lj->args.append((const char *)buf_ptr(g->link_objects.at(i))); |
| 704 | 704 | } |
| 705 | 705 | |
| 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)); | |
| 713 | 710 | } |
| 714 | 711 | |
| 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 | } | |
| 720 | 730 | |
| 721 | 731 | if (platform.kind == MacOS) { |
| 722 | 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 | 18 | const exponentMask = absMask ^ significandMask; |
| 19 | 19 | const infRep = exponentMask; |
| 20 | 20 | |
| 21 | const builtin = @import("builtin"); | |
| 22 | const is_test = builtin.is_test; | |
| 23 | ||
| 21 | 24 | export fn __letf2(a: f128, b: f128) -> c_int { |
| 25 | @setDebugSafety(this, is_test); | |
| 26 | @setGlobalLinkage(__letf2, builtin.GlobalLinkage.LinkOnce); | |
| 27 | ||
| 22 | 28 | const aInt = @bitCast(rep_t, a); |
| 23 | 29 | const bInt = @bitCast(rep_t, b); |
| 24 | 30 | |
| ... | ... | @@ -58,7 +64,11 @@ export fn __letf2(a: f128, b: f128) -> c_int { |
| 58 | 64 | |
| 59 | 65 | // Alias for libgcc compatibility |
| 60 | 66 | // TODO https://github.com/zig-lang/zig/issues/420 |
| 61 | export fn __cmptf2(a: f128, b: f128) -> c_int { __letf2(a, b) } | |
| 67 | export 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 | } | |
| 62 | 72 | |
| 63 | 73 | // TODO https://github.com/zig-lang/zig/issues/305 |
| 64 | 74 | // 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 | 78 | const GE_UNORDERED = c_int(-1); // Note: different from LE_UNORDERED |
| 69 | 79 | |
| 70 | 80 | export fn __getf2(a: f128, b: f128) -> c_int { |
| 81 | @setGlobalLinkage(__getf2, builtin.GlobalLinkage.LinkOnce); | |
| 82 | @setDebugSafety(this, is_test); | |
| 83 | ||
| 71 | 84 | const aInt = @bitCast(srep_t, a); |
| 72 | 85 | const bInt = @bitCast(srep_t, b); |
| 73 | 86 | const aAbs = @bitCast(rep_t, aInt) & absMask; |
| ... | ... | @@ -95,6 +108,9 @@ export fn __getf2(a: f128, b: f128) -> c_int { |
| 95 | 108 | } |
| 96 | 109 | |
| 97 | 110 | export fn __unordtf2(a: f128, b: f128) -> c_int { |
| 111 | @setGlobalLinkage(__unordtf2, builtin.GlobalLinkage.LinkOnce); | |
| 112 | @setDebugSafety(this, is_test); | |
| 113 | ||
| 98 | 114 | const aAbs = @bitCast(rep_t, a) & absMask; |
| 99 | 115 | const bAbs = @bitCast(rep_t, b) & absMask; |
| 100 | 116 | return c_int(aAbs > infRep or bAbs > infRep); |
| ... | ... | @@ -103,17 +119,25 @@ export fn __unordtf2(a: f128, b: f128) -> c_int { |
| 103 | 119 | // The following are alternative names for the preceding routines. |
| 104 | 120 | |
| 105 | 121 | export fn __eqtf2(a: f128, b: f128) -> c_int { |
| 122 | @setGlobalLinkage(__eqtf2, builtin.GlobalLinkage.LinkOnce); | |
| 123 | @setDebugSafety(this, is_test); | |
| 106 | 124 | return __letf2(a, b); |
| 107 | 125 | } |
| 108 | 126 | |
| 109 | 127 | export fn __lttf2(a: f128, b: f128) -> c_int { |
| 128 | @setGlobalLinkage(__lttf2, builtin.GlobalLinkage.LinkOnce); | |
| 129 | @setDebugSafety(this, is_test); | |
| 110 | 130 | return __letf2(a, b); |
| 111 | 131 | } |
| 112 | 132 | |
| 113 | 133 | export fn __netf2(a: f128, b: f128) -> c_int { |
| 134 | @setGlobalLinkage(__netf2, builtin.GlobalLinkage.LinkOnce); | |
| 135 | @setDebugSafety(this, is_test); | |
| 114 | 136 | return __letf2(a, b); |
| 115 | 137 | } |
| 116 | 138 | |
| 117 | 139 | export fn __gttf2(a: f128, b: f128) -> c_int { |
| 140 | @setGlobalLinkage(__gttf2, builtin.GlobalLinkage.LinkOnce); | |
| 141 | @setDebugSafety(this, is_test); | |
| 118 | 142 | return __getf2(a, b); |
| 119 | 143 | } |
std/special/compiler_rt/fixunsdfdi.zig+1| ... | ... | @@ -1,6 +1,7 @@ |
| 1 | 1 | const fixuint = @import("fixuint.zig").fixuint; |
| 2 | 2 | |
| 3 | 3 | export fn __fixunsdfdi(a: f64) -> u64 { |
| 4 | @setGlobalLinkage(__fixunsdfdi, @import("builtin").GlobalLinkage.LinkOnce); | |
| 4 | 5 | return fixuint(f64, u64, a); |
| 5 | 6 | } |
| 6 | 7 |
std/special/compiler_rt/fixunsdfsi.zig+1| ... | ... | @@ -1,6 +1,7 @@ |
| 1 | 1 | const fixuint = @import("fixuint.zig").fixuint; |
| 2 | 2 | |
| 3 | 3 | export fn __fixunsdfsi(a: f64) -> u32 { |
| 4 | @setGlobalLinkage(__fixunsdfsi, @import("builtin").GlobalLinkage.LinkOnce); | |
| 4 | 5 | return fixuint(f64, u32, a); |
| 5 | 6 | } |
| 6 | 7 |
std/special/compiler_rt/fixunsdfti.zig+1| ... | ... | @@ -1,6 +1,7 @@ |
| 1 | 1 | const fixuint = @import("fixuint.zig").fixuint; |
| 2 | 2 | |
| 3 | 3 | export fn __fixunsdfti(a: f64) -> u128 { |
| 4 | @setGlobalLinkage(__fixunsdfti, @import("builtin").GlobalLinkage.LinkOnce); | |
| 4 | 5 | return fixuint(f64, u128, a); |
| 5 | 6 | } |
| 6 | 7 |
std/special/compiler_rt/fixunssfdi.zig+1| ... | ... | @@ -1,6 +1,7 @@ |
| 1 | 1 | const fixuint = @import("fixuint.zig").fixuint; |
| 2 | 2 | |
| 3 | 3 | export fn __fixunssfdi(a: f32) -> u64 { |
| 4 | @setGlobalLinkage(__fixunssfdi, @import("builtin").GlobalLinkage.LinkOnce); | |
| 4 | 5 | return fixuint(f32, u64, a); |
| 5 | 6 | } |
| 6 | 7 |
std/special/compiler_rt/fixunssfsi.zig+1| ... | ... | @@ -1,6 +1,7 @@ |
| 1 | 1 | const fixuint = @import("fixuint.zig").fixuint; |
| 2 | 2 | |
| 3 | 3 | export fn __fixunssfsi(a: f32) -> u32 { |
| 4 | @setGlobalLinkage(__fixunssfsi, @import("builtin").GlobalLinkage.LinkOnce); | |
| 4 | 5 | return fixuint(f32, u32, a); |
| 5 | 6 | } |
| 6 | 7 |
std/special/compiler_rt/fixunssfti.zig+1| ... | ... | @@ -1,6 +1,7 @@ |
| 1 | 1 | const fixuint = @import("fixuint.zig").fixuint; |
| 2 | 2 | |
| 3 | 3 | export fn __fixunssfti(a: f32) -> u128 { |
| 4 | @setGlobalLinkage(__fixunssfti, @import("builtin").GlobalLinkage.LinkOnce); | |
| 4 | 5 | return fixuint(f32, u128, a); |
| 5 | 6 | } |
| 6 | 7 |
std/special/compiler_rt/fixunstfdi.zig+1| ... | ... | @@ -1,6 +1,7 @@ |
| 1 | 1 | const fixuint = @import("fixuint.zig").fixuint; |
| 2 | 2 | |
| 3 | 3 | export fn __fixunstfdi(a: f128) -> u64 { |
| 4 | @setGlobalLinkage(__fixunstfdi, @import("builtin").GlobalLinkage.LinkOnce); | |
| 4 | 5 | return fixuint(f128, u64, a); |
| 5 | 6 | } |
| 6 | 7 |
std/special/compiler_rt/fixunstfsi.zig+1| ... | ... | @@ -1,6 +1,7 @@ |
| 1 | 1 | const fixuint = @import("fixuint.zig").fixuint; |
| 2 | 2 | |
| 3 | 3 | export fn __fixunstfsi(a: f128) -> u32 { |
| 4 | @setGlobalLinkage(__fixunstfsi, @import("builtin").GlobalLinkage.LinkOnce); | |
| 4 | 5 | return fixuint(f128, u32, a); |
| 5 | 6 | } |
| 6 | 7 |
std/special/compiler_rt/fixunstfti.zig+1| ... | ... | @@ -1,6 +1,7 @@ |
| 1 | 1 | const fixuint = @import("fixuint.zig").fixuint; |
| 2 | 2 | |
| 3 | 3 | export fn __fixunstfti(a: f128) -> u128 { |
| 4 | @setGlobalLinkage(__fixunstfti, @import("builtin").GlobalLinkage.LinkOnce); | |
| 4 | 5 | return fixuint(f128, u128, a); |
| 5 | 6 | } |
| 6 | 7 |
std/special/compiler_rt/index.zig+6| ... | ... | @@ -23,11 +23,13 @@ const __udivmoddi4 = @import("udivmoddi4.zig").__udivmoddi4; |
| 23 | 23 | |
| 24 | 24 | export fn __udivdi3(a: u64, b: u64) -> u64 { |
| 25 | 25 | @setDebugSafety(this, is_test); |
| 26 | @setGlobalLinkage(__udivdi3, builtin.GlobalLinkage.LinkOnce); | |
| 26 | 27 | return __udivmoddi4(a, b, null); |
| 27 | 28 | } |
| 28 | 29 | |
| 29 | 30 | export fn __umoddi3(a: u64, b: u64) -> u64 { |
| 30 | 31 | @setDebugSafety(this, is_test); |
| 32 | @setGlobalLinkage(__umoddi3, builtin.GlobalLinkage.LinkOnce); | |
| 31 | 33 | |
| 32 | 34 | var r: u64 = undefined; |
| 33 | 35 | _ = __udivmoddi4(a, b, &r); |
| ... | ... | @@ -63,6 +65,7 @@ export nakedcc fn __aeabi_uidivmod() { |
| 63 | 65 | @setDebugSafety(this, false); |
| 64 | 66 | |
| 65 | 67 | if (comptime isArmArch()) { |
| 68 | @setGlobalLinkage(__aeabi_uidivmod, builtin.GlobalLinkage.LinkOnce); | |
| 66 | 69 | asm volatile ( |
| 67 | 70 | \\ push { lr } |
| 68 | 71 | \\ sub sp, sp, #4 |
| ... | ... | @@ -80,6 +83,7 @@ export nakedcc fn __aeabi_uidivmod() { |
| 80 | 83 | |
| 81 | 84 | export fn __udivmodsi4(a: u32, b: u32, rem: &u32) -> u32 { |
| 82 | 85 | @setDebugSafety(this, is_test); |
| 86 | @setGlobalLinkage(__udivmodsi4, builtin.GlobalLinkage.LinkOnce); | |
| 83 | 87 | |
| 84 | 88 | const d = __udivsi3(a, b); |
| 85 | 89 | *rem = u32(i32(a) -% (i32(d) * i32(b))); |
| ... | ... | @@ -92,12 +96,14 @@ export fn __udivmodsi4(a: u32, b: u32, rem: &u32) -> u32 { |
| 92 | 96 | |
| 93 | 97 | export fn __aeabi_uidiv(n: u32, d: u32) -> u32 { |
| 94 | 98 | @setDebugSafety(this, is_test); |
| 99 | @setGlobalLinkage(__aeabi_uidiv, builtin.GlobalLinkage.LinkOnce); | |
| 95 | 100 | |
| 96 | 101 | return __udivsi3(n, d); |
| 97 | 102 | } |
| 98 | 103 | |
| 99 | 104 | export fn __udivsi3(n: u32, d: u32) -> u32 { |
| 100 | 105 | @setDebugSafety(this, is_test); |
| 106 | @setGlobalLinkage(__udivsi3, builtin.GlobalLinkage.LinkOnce); | |
| 101 | 107 | |
| 102 | 108 | const n_uword_bits: c_uint = u32.bit_count; |
| 103 | 109 | // special cases |