diff --git a/pkgs/development/compilers/llvm/common/libc/default.nix b/pkgs/development/compilers/llvm/common/libc/default.nix index 6ccc7e44ff61..6e54fef55d9b 100644 --- a/pkgs/development/compilers/llvm/common/libc/default.nix +++ b/pkgs/development/compilers/llvm/common/libc/default.nix @@ -46,6 +46,7 @@ stdenv.mkDerivation (finalAttrs: { outputs = [ "out" ] ++ (lib.optional isFullBuild "dev"); postUnpack = lib.optionalString isFullBuild '' + chmod +w $sourceRoot/../$pname/utils/hdrgen patchShebangs $sourceRoot/../$pname/utils/hdrgen/main.py chmod +x $sourceRoot/../$pname/utils/hdrgen/main.py ''; @@ -65,10 +66,20 @@ stdenv.mkDerivation (finalAttrs: { libc = if (!isFullBuild) then stdenv.cc.libc else null; - cmakeFlags = [ - (lib.cmakeBool "LLVM_LIBC_FULL_BUILD" isFullBuild) - (lib.cmakeFeature "LLVM_ENABLE_RUNTIMES" "libc") - ]; + cmakeFlags = + [ + (lib.cmakeBool "LLVM_LIBC_FULL_BUILD" isFullBuild) + (lib.cmakeFeature "LLVM_ENABLE_RUNTIMES" "libc") + # Tests requires the host to have a libc. + (lib.cmakeBool "LLVM_INCLUDE_TESTS" (stdenv.cc.libc != null)) + ] + ++ lib.optional (isFullBuild && stdenv.cc.libc == null) [ + # CMake runs a check to see if the compiler works. + # This includes including headers which requires a libc. + # Skip these checks because a libc cannot be used when one doesn't exist. + (lib.cmakeBool "CMAKE_C_COMPILER_WORKS" true) + (lib.cmakeBool "CMAKE_CXX_COMPILER_WORKS" true) + ]; # For the update script: passthru = {