about summary refs log tree commit diff
path: root/pkgs/development/compilers/llvm/13
diff options
context:
space:
mode:
authorAlyssa Ross <hi@alyssa.is>2023-04-26 12:53:36 +0000
committerAlyssa Ross <hi@alyssa.is>2023-04-28 10:01:22 +0000
commit3e0cb1ab7d27ee531915948c751c612c850e77a5 (patch)
tree2f1fb820d0c2267ef7d2d94acc8ebb1df5f569ae /pkgs/development/compilers/llvm/13
parent6f72e87e60c1fd284c77c86aac2c033251b58a8c (diff)
compiler-rt: use -ffreestanding when no libc
This fixes building for x86_64-windows with no libc (for UEFI).
Otherwise, it would try to include a malloc header.
Diffstat (limited to 'pkgs/development/compilers/llvm/13')
-rw-r--r--pkgs/development/compilers/llvm/13/compiler-rt/default.nix6
1 files changed, 4 insertions, 2 deletions
diff --git a/pkgs/development/compilers/llvm/13/compiler-rt/default.nix b/pkgs/development/compilers/llvm/13/compiler-rt/default.nix
index 8f79770029209..faa123312bd76 100644
--- a/pkgs/development/compilers/llvm/13/compiler-rt/default.nix
+++ b/pkgs/development/compilers/llvm/13/compiler-rt/default.nix
@@ -46,8 +46,6 @@ stdenv.mkDerivation {
     "-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) [
-    "-DCMAKE_C_FLAGS=-nodefaultlibs"
   ] ++ lib.optionals (useLLVM) [
     "-DCOMPILER_RT_BUILD_BUILTINS=ON"
     #https://stackoverflow.com/questions/53633705/cmake-the-c-compiler-is-not-able-to-compile-a-simple-test-program
@@ -100,6 +98,10 @@ stdenv.mkDerivation {
       --replace "#include <assert.h>" ""
   '';
 
+  preConfigure = lib.optionalString (useLLVM && !haveLibc) ''
+    cmakeFlagsArray+=(-DCMAKE_C_FLAGS="-nodefaultlibs -ffreestanding")
+  '';
+
   # Hack around weird upsream RPATH bug
   postInstall = lib.optionalString (stdenv.hostPlatform.isDarwin || stdenv.hostPlatform.isWasm) ''
     ln -s "$out/lib"/*/* "$out/lib"