diff --git a/pkgs/development/compilers/llvm/16/compiler-rt/default.nix b/pkgs/development/compilers/llvm/16/compiler-rt/default.nix index e2b8d470f890..aa248c0e60eb 100644 --- a/pkgs/development/compilers/llvm/16/compiler-rt/default.nix +++ b/pkgs/development/compilers/llvm/16/compiler-rt/default.nix @@ -9,6 +9,7 @@ let useLLVM = stdenv.hostPlatform.useLLVM or false; bareMetal = stdenv.hostPlatform.parsed.kernel.name == "none"; haveLibc = stdenv.cc.libc != null; + isDarwinStatic = stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isStatic; inherit (stdenv.hostPlatform) isMusl isGnu; baseName = "compiler-rt"; @@ -41,7 +42,7 @@ stdenv.mkDerivation { "-DCMAKE_ASM_COMPILER_TARGET=${stdenv.hostPlatform.config}" ] ++ lib.optionals (haveLibc && stdenv.hostPlatform.libc == "glibc") [ "-DSANITIZER_COMMON_CFLAGS=-I${libxcrypt}/include" - ] ++ lib.optionals (useLLVM || bareMetal || isMusl) [ + ] ++ lib.optionals (useLLVM || bareMetal || isMusl || isDarwinStatic) [ "-DCOMPILER_RT_BUILD_SANITIZERS=OFF" "-DCOMPILER_RT_BUILD_XRAY=OFF" "-DCOMPILER_RT_BUILD_LIBFUZZER=OFF" @@ -49,9 +50,10 @@ stdenv.mkDerivation { "-DCOMPILER_RT_BUILD_ORC=OFF" # may be possible to build with musl if necessary ] ++ lib.optionals (useLLVM || bareMetal) [ "-DCOMPILER_RT_BUILD_PROFILE=OFF" + ] ++ lib.optionals ((useLLVM && !haveLibc) || bareMetal || isDarwinStatic ) [ + "-DCMAKE_CXX_COMPILER_WORKS=ON" ] ++ lib.optionals ((useLLVM && !haveLibc) || bareMetal) [ "-DCMAKE_C_COMPILER_WORKS=ON" - "-DCMAKE_CXX_COMPILER_WORKS=ON" "-DCOMPILER_RT_BAREMETAL_BUILD=ON" "-DCMAKE_SIZEOF_VOID_P=${toString (stdenv.hostPlatform.parsed.cpu.bits / 8)}" ] ++ lib.optionals (useLLVM && !haveLibc) [ @@ -63,6 +65,7 @@ stdenv.mkDerivation { ] ++ lib.optionals (bareMetal) [ "-DCOMPILER_RT_OS_DIR=baremetal" ] ++ lib.optionals (stdenv.hostPlatform.isDarwin) [ + "-DCMAKE_LIPO=${lib.getBin stdenv.cc.bintools.bintools}/bin/${stdenv.cc.targetPrefix}lipo" "-DDARWIN_macosx_OVERRIDE_SDK_VERSION=ON" "-DDARWIN_osx_ARCHS=${stdenv.hostPlatform.darwinArch}" "-DDARWIN_osx_BUILTIN_ARCHS=${stdenv.hostPlatform.darwinArch}" diff --git a/pkgs/development/compilers/llvm/16/default.nix b/pkgs/development/compilers/llvm/16/default.nix index 1e200b17b0b2..0c0ff44e155f 100644 --- a/pkgs/development/compilers/llvm/16/default.nix +++ b/pkgs/development/compilers/llvm/16/default.nix @@ -316,7 +316,7 @@ in let compiler-rt-libc = callPackage ./compiler-rt { inherit llvm_meta; - stdenv = if stdenv.hostPlatform.useLLVM or false + stdenv = if stdenv.hostPlatform.useLLVM or false || (stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isStatic) then overrideCC stdenv buildLlvmTools.clangNoCompilerRtWithLibc else stdenv; }; @@ -329,7 +329,7 @@ in let }; # N.B. condition is safe because without useLLVM both are the same. - compiler-rt = if stdenv.hostPlatform.isAndroid + compiler-rt = if stdenv.hostPlatform.isAndroid || stdenv.hostPlatform.isDarwin then libraries.compiler-rt-libc else libraries.compiler-rt-no-libc;