33let
44
55 useLLVM = stdenv . hostPlatform . useLLVM or false ;
6+ isDarwin = stdenv . hostPlatform . isDarwin ;
67 bareMetal = stdenv . hostPlatform . parsed . kernel . name == "none" ;
78 haveLibc = stdenv . cc . libc != null ;
89 inherit ( stdenv . hostPlatform ) isMusl ;
@@ -15,7 +16,6 @@ stdenv.mkDerivation {
1516 src = fetch "compiler-rt" "0x1j8ngf1zj63wlnns9vlibafq48qcm72p4jpaxkmkb4qw0grwfy" ;
1617
1718 nativeBuildInputs = [ cmake python3 llvm . dev ] ;
18- buildInputs = lib . optional stdenv . hostPlatform . isDarwin libcxxabi ;
1919
2020 NIX_CFLAGS_COMPILE = [
2121 "-DSCUDO_DEFAULT_OPTIONS=DeleteSizeMismatch=0:DeallocationTypeMismatch=0"
@@ -25,19 +25,19 @@ stdenv.mkDerivation {
2525 "-DCOMPILER_RT_DEFAULT_TARGET_ONLY=ON"
2626 "-DCMAKE_C_COMPILER_TARGET=${ stdenv . hostPlatform . config } "
2727 "-DCMAKE_ASM_COMPILER_TARGET=${ stdenv . hostPlatform . config } "
28- ] ++ lib . optionals ( useLLVM || bareMetal || isMusl ) [
28+ ] ++ lib . optionals ( useLLVM || isDarwin || bareMetal || isMusl ) [
2929 "-DCOMPILER_RT_BUILD_SANITIZERS=OFF"
3030 "-DCOMPILER_RT_BUILD_XRAY=OFF"
3131 "-DCOMPILER_RT_BUILD_LIBFUZZER=OFF"
3232 "-DCOMPILER_RT_BUILD_PROFILE=OFF"
33- ] ++ lib . optionals ( ( useLLVM || bareMetal ) && ! haveLibc ) [
33+ ] ++ lib . optionals ( ( useLLVM || isDarwin || bareMetal ) && ! haveLibc ) [
3434 "-DCMAKE_C_COMPILER_WORKS=ON"
3535 "-DCMAKE_CXX_COMPILER_WORKS=ON"
3636 "-DCOMPILER_RT_BAREMETAL_BUILD=ON"
3737 "-DCMAKE_SIZEOF_VOID_P=${ toString ( stdenv . hostPlatform . parsed . cpu . bits / 8 ) } "
38- ] ++ lib . optionals ( useLLVM && ! haveLibc ) [
38+ ] ++ lib . optionals ( ( useLLVM || isDarwin ) && ! haveLibc ) [
3939 "-DCMAKE_C_FLAGS=-nodefaultlibs"
40- ] ++ lib . optionals ( useLLVM ) [
40+ ] ++ lib . optionals ( useLLVM || isDarwin ) [
4141 "-DCOMPILER_RT_BUILD_BUILTINS=ON"
4242 #https://stackoverflow.com/questions/53633705/cmake-the-c-compiler-is-not-able-to-compile-a-simple-test-program
4343 "-DCMAKE_TRY_COMPILE_TARGET_TYPE=STATIC_LIBRARY"
@@ -61,6 +61,11 @@ stdenv.mkDerivation {
6161 ] # ++ lib.optional stdenv.hostPlatform.isMusl ./sanitizers-nongnu.patch
6262 ++ lib . optional stdenv . hostPlatform . isAarch32 ./armv7l.patch ;
6363
64+
65+ preConfigure = lib . optionalString isDarwin ''
66+ cmakeFlagsArray+=("-DCMAKE_LIPO=$(command -v ${ stdenv . cc . targetPrefix } lipo)")
67+ '' ;
68+
6469 # TSAN requires XPC on Darwin, which we have no public/free source files for. We can depend on the Apple frameworks
6570 # to get it, but they're unfree. Since LLVM is rather central to the stdenv, we patch out TSAN support so that Hydra
6671 # can build this. If we didn't do it, basically the entire nixpkgs on Darwin would have an unfree dependency and we'd
@@ -71,7 +76,7 @@ stdenv.mkDerivation {
7176 --replace 'set(X86 i386)' 'set(X86 i386 i486 i586 i686)'
7277 '' + lib . optionalString stdenv . isDarwin ''
7378 substituteInPlace cmake/builtin-config-ix.cmake \
74- --replace 'set(ARM64 arm64 arm64e )' 'set(ARM64 )'
79+ --replace 'foreach(arch '' ${ARM64} )' 'foreach(arch )'
7580 substituteInPlace cmake/config-ix.cmake \
7681 --replace 'set(COMPILER_RT_HAS_TSAN TRUE)' 'set(COMPILER_RT_HAS_TSAN FALSE)'
7782 '' + lib . optionalString ( useLLVM ) ''
0 commit comments