Commit 91536813ec
Changed files (15)
ci/travis_osx_install
@@ -6,44 +6,14 @@ brew install gcc@7
brew outdated gcc@7 || brew upgrade gcc@7
brew link --overwrite gcc@7
-which gcc
-which g++
-which gcc-7
-which g++-7
-
SRC_DIR=$(pwd)
-PREFIX_DIR=$SRC_DIR/local
-export CC=/usr/local/Cellar/gcc/7.2.0/bin/gcc-7
-export CXX=/usr/local/Cellar/gcc/7.2.0/bin/g++-7
-
-wget http://prereleases.llvm.org/5.0.0/rc2/llvm-5.0.0rc2.src.tar.xz
-wget http://prereleases.llvm.org/5.0.0/rc2/cfe-5.0.0rc2.src.tar.xz
-wget http://prereleases.llvm.org/5.0.0/rc2/lld-5.0.0rc2.src.tar.xz
-
-ls -ahl /usr/local/opt
-
-cd $SRC_DIR
-tar xf llvm-5.0.0rc2.src.tar.xz
-cd llvm-5.0.0rc2.src
-mkdir build
-cd build
-cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$PREFIX_DIR -DCMAKE_PREFIX_PATH=$PREFIX_DIR
-make install
-
-cd $SRC_DIR
-tar xf lld-5.0.0rc2.src.tar.xz
-cd lld-5.0.0rc2.src
-mkdir build
-cd build
-cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$PREFIX_DIR -DCMAKE_PREFIX_PATH=$PREFIX_DIR
-make install
-
-cd $SRC_DIR
-tar xf cfe-5.0.0rc2.src.tar.xz
-cd cfe-5.0.0rc2.src
-mkdir build
-cd build
-cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$PREFIX_DIR -DCMAKE_PREFIX_PATH=$PREFIX_DIR
-make install
+PREFIX_DIR=$HOME/local/llvm5
+export CC=/usr/local/opt/gcc/bin/gcc-7
+export CXX=/usr/local/opt/gcc/bin/g++-7
+
+mkdir -p $HOME/local
+cd $HOME/local
+wget http://s3.amazonaws.com/superjoe/temp/llvm5.tar.xz
+tar xfp llvm5.tar.xz
cd $SRC_DIR
ci/travis_osx_script
@@ -2,9 +2,9 @@
set -x
-PREFIX_DIR=$(pwd)/local
-export CC=/usr/local/Cellar/gcc/7.2.0/bin/gcc-7
-export CXX=/usr/local/Cellar/gcc/7.2.0/bin/g++-7
+PREFIX_DIR=$HOME/local/llvm5
+export CC=/usr/local/opt/gcc/bin/gcc-7
+export CXX=/usr/local/opt/gcc/bin/g++-7
echo $PATH
mkdir build
src/codegen.cpp
@@ -139,6 +139,7 @@ CodeGen *codegen_create(Buf *root_src_path, const ZigTarget *target, OutType out
g->zig_target.os == ZigLLVM_IOS)
{
g->libc_link_lib = create_link_lib(buf_create_from_str("c"));
+ g->link_libs_list.append(g->libc_link_lib);
}
return g;
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)) {
std/special/compiler_rt/comparetf2.zig
@@ -18,7 +18,13 @@ const significandMask = implicitBit - 1;
const exponentMask = absMask ^ significandMask;
const infRep = exponentMask;
+const builtin = @import("builtin");
+const is_test = builtin.is_test;
+
export fn __letf2(a: f128, b: f128) -> c_int {
+ @setDebugSafety(this, is_test);
+ @setGlobalLinkage(__letf2, builtin.GlobalLinkage.LinkOnce);
+
const aInt = @bitCast(rep_t, a);
const bInt = @bitCast(rep_t, b);
@@ -58,7 +64,11 @@ export fn __letf2(a: f128, b: f128) -> c_int {
// Alias for libgcc compatibility
// TODO https://github.com/zig-lang/zig/issues/420
-export fn __cmptf2(a: f128, b: f128) -> c_int { __letf2(a, b) }
+export fn __cmptf2(a: f128, b: f128) -> c_int {
+ @setGlobalLinkage(__cmptf2, builtin.GlobalLinkage.LinkOnce);
+ @setDebugSafety(this, is_test);
+ return __letf2(a, b);
+}
// TODO https://github.com/zig-lang/zig/issues/305
// 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);
const GE_UNORDERED = c_int(-1); // Note: different from LE_UNORDERED
export fn __getf2(a: f128, b: f128) -> c_int {
+ @setGlobalLinkage(__getf2, builtin.GlobalLinkage.LinkOnce);
+ @setDebugSafety(this, is_test);
+
const aInt = @bitCast(srep_t, a);
const bInt = @bitCast(srep_t, b);
const aAbs = @bitCast(rep_t, aInt) & absMask;
@@ -95,6 +108,9 @@ export fn __getf2(a: f128, b: f128) -> c_int {
}
export fn __unordtf2(a: f128, b: f128) -> c_int {
+ @setGlobalLinkage(__unordtf2, builtin.GlobalLinkage.LinkOnce);
+ @setDebugSafety(this, is_test);
+
const aAbs = @bitCast(rep_t, a) & absMask;
const bAbs = @bitCast(rep_t, b) & absMask;
return c_int(aAbs > infRep or bAbs > infRep);
@@ -103,17 +119,25 @@ export fn __unordtf2(a: f128, b: f128) -> c_int {
// The following are alternative names for the preceding routines.
export fn __eqtf2(a: f128, b: f128) -> c_int {
+ @setGlobalLinkage(__eqtf2, builtin.GlobalLinkage.LinkOnce);
+ @setDebugSafety(this, is_test);
return __letf2(a, b);
}
export fn __lttf2(a: f128, b: f128) -> c_int {
+ @setGlobalLinkage(__lttf2, builtin.GlobalLinkage.LinkOnce);
+ @setDebugSafety(this, is_test);
return __letf2(a, b);
}
export fn __netf2(a: f128, b: f128) -> c_int {
+ @setGlobalLinkage(__netf2, builtin.GlobalLinkage.LinkOnce);
+ @setDebugSafety(this, is_test);
return __letf2(a, b);
}
export fn __gttf2(a: f128, b: f128) -> c_int {
+ @setGlobalLinkage(__gttf2, builtin.GlobalLinkage.LinkOnce);
+ @setDebugSafety(this, is_test);
return __getf2(a, b);
}
std/special/compiler_rt/fixunsdfdi.zig
@@ -1,6 +1,7 @@
const fixuint = @import("fixuint.zig").fixuint;
export fn __fixunsdfdi(a: f64) -> u64 {
+ @setGlobalLinkage(__fixunsdfdi, @import("builtin").GlobalLinkage.LinkOnce);
return fixuint(f64, u64, a);
}
std/special/compiler_rt/fixunsdfsi.zig
@@ -1,6 +1,7 @@
const fixuint = @import("fixuint.zig").fixuint;
export fn __fixunsdfsi(a: f64) -> u32 {
+ @setGlobalLinkage(__fixunsdfsi, @import("builtin").GlobalLinkage.LinkOnce);
return fixuint(f64, u32, a);
}
std/special/compiler_rt/fixunsdfti.zig
@@ -1,6 +1,7 @@
const fixuint = @import("fixuint.zig").fixuint;
export fn __fixunsdfti(a: f64) -> u128 {
+ @setGlobalLinkage(__fixunsdfti, @import("builtin").GlobalLinkage.LinkOnce);
return fixuint(f64, u128, a);
}
std/special/compiler_rt/fixunssfdi.zig
@@ -1,6 +1,7 @@
const fixuint = @import("fixuint.zig").fixuint;
export fn __fixunssfdi(a: f32) -> u64 {
+ @setGlobalLinkage(__fixunssfdi, @import("builtin").GlobalLinkage.LinkOnce);
return fixuint(f32, u64, a);
}
std/special/compiler_rt/fixunssfsi.zig
@@ -1,6 +1,7 @@
const fixuint = @import("fixuint.zig").fixuint;
export fn __fixunssfsi(a: f32) -> u32 {
+ @setGlobalLinkage(__fixunssfsi, @import("builtin").GlobalLinkage.LinkOnce);
return fixuint(f32, u32, a);
}
std/special/compiler_rt/fixunssfti.zig
@@ -1,6 +1,7 @@
const fixuint = @import("fixuint.zig").fixuint;
export fn __fixunssfti(a: f32) -> u128 {
+ @setGlobalLinkage(__fixunssfti, @import("builtin").GlobalLinkage.LinkOnce);
return fixuint(f32, u128, a);
}
std/special/compiler_rt/fixunstfdi.zig
@@ -1,6 +1,7 @@
const fixuint = @import("fixuint.zig").fixuint;
export fn __fixunstfdi(a: f128) -> u64 {
+ @setGlobalLinkage(__fixunstfdi, @import("builtin").GlobalLinkage.LinkOnce);
return fixuint(f128, u64, a);
}
std/special/compiler_rt/fixunstfsi.zig
@@ -1,6 +1,7 @@
const fixuint = @import("fixuint.zig").fixuint;
export fn __fixunstfsi(a: f128) -> u32 {
+ @setGlobalLinkage(__fixunstfsi, @import("builtin").GlobalLinkage.LinkOnce);
return fixuint(f128, u32, a);
}
std/special/compiler_rt/fixunstfti.zig
@@ -1,6 +1,7 @@
const fixuint = @import("fixuint.zig").fixuint;
export fn __fixunstfti(a: f128) -> u128 {
+ @setGlobalLinkage(__fixunstfti, @import("builtin").GlobalLinkage.LinkOnce);
return fixuint(f128, u128, a);
}
std/special/compiler_rt/index.zig
@@ -23,11 +23,13 @@ const __udivmoddi4 = @import("udivmoddi4.zig").__udivmoddi4;
export fn __udivdi3(a: u64, b: u64) -> u64 {
@setDebugSafety(this, is_test);
+ @setGlobalLinkage(__udivdi3, builtin.GlobalLinkage.LinkOnce);
return __udivmoddi4(a, b, null);
}
export fn __umoddi3(a: u64, b: u64) -> u64 {
@setDebugSafety(this, is_test);
+ @setGlobalLinkage(__umoddi3, builtin.GlobalLinkage.LinkOnce);
var r: u64 = undefined;
_ = __udivmoddi4(a, b, &r);
@@ -63,6 +65,7 @@ export nakedcc fn __aeabi_uidivmod() {
@setDebugSafety(this, false);
if (comptime isArmArch()) {
+ @setGlobalLinkage(__aeabi_uidivmod, builtin.GlobalLinkage.LinkOnce);
asm volatile (
\\ push { lr }
\\ sub sp, sp, #4
@@ -80,6 +83,7 @@ export nakedcc fn __aeabi_uidivmod() {
export fn __udivmodsi4(a: u32, b: u32, rem: &u32) -> u32 {
@setDebugSafety(this, is_test);
+ @setGlobalLinkage(__udivmodsi4, builtin.GlobalLinkage.LinkOnce);
const d = __udivsi3(a, b);
*rem = u32(i32(a) -% (i32(d) * i32(b)));
@@ -92,12 +96,14 @@ export fn __udivmodsi4(a: u32, b: u32, rem: &u32) -> u32 {
export fn __aeabi_uidiv(n: u32, d: u32) -> u32 {
@setDebugSafety(this, is_test);
+ @setGlobalLinkage(__aeabi_uidiv, builtin.GlobalLinkage.LinkOnce);
return __udivsi3(n, d);
}
export fn __udivsi3(n: u32, d: u32) -> u32 {
@setDebugSafety(this, is_test);
+ @setGlobalLinkage(__udivsi3, builtin.GlobalLinkage.LinkOnce);
const n_uword_bits: c_uint = u32.bit_count;
// special cases