llvmPackages_20.libc-full: fix building (#385706)

authored by Tristan Ross and committed by GitHub 4d4a2f8b 8ad49a1d

+44 -18
+1 -1
lib/systems/default.nix
··· 200 200 # don't support dynamic linking, but don't get the `staticMarker`. 201 201 # `pkgsStatic` sets `isStatic=true`, so `pkgsStatic.hostPlatform` always 202 202 # has the `staticMarker`. 203 - isStatic = final.isWasi || final.isRedox; 203 + isStatic = final.isWasi || final.isRedox || final.isLLVMLibc; 204 204 205 205 # Just a guess, based on `system` 206 206 inherit
+14 -10
pkgs/development/compilers/llvm/common/default.nix
··· 14 14 overrideCC, 15 15 wrapCCWith, 16 16 wrapBintoolsWith, 17 + buildPackages, 17 18 buildLlvmTools, # tools, but from the previous stage, for cross 18 19 targetLlvmLibraries, # libraries, but from the next stage, for cross 19 20 targetLlvm, ··· 423 424 libcxx = null; 424 425 bintools = bintoolsNoLibc'; 425 426 extraPackages = [ ]; 426 - extraBuildCommands = 427 - lib.optionalString (lib.versions.major metadata.release_version == "13") '' 428 - echo "-nostartfiles" >> $out/nix-support/cc-cflags 429 - '' 430 - + mkExtraBuildCommands0 cc; 427 + # "-nostartfiles" used to be needed for pkgsLLVM, causes problems so don't include it. 428 + extraBuildCommands = mkExtraBuildCommands0 cc; 431 429 } 432 430 // lib.optionalAttrs (lib.versionAtLeast metadata.release_version "14") { 433 - nixSupport.cc-cflags = 434 - [ "-nostartfiles" ] 435 - ++ lib.optional ( 436 - lib.versionAtLeast metadata.release_version "15" && stdenv.targetPlatform.isWasm 437 - ) "-fno-exceptions"; 431 + # "-nostartfiles" used to be needed for pkgsLLVM, causes problems so don't include it. 432 + nixSupport.cc-cflags = lib.optional ( 433 + lib.versionAtLeast metadata.release_version "15" && stdenv.targetPlatform.isWasm 434 + ) "-fno-exceptions"; 438 435 } 439 436 ); 440 437 ··· 576 573 # Use clang due to "gnu::naked" not working on aarch64. 577 574 # Issue: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77882 578 575 stdenv = overrideCC stdenv buildLlvmTools.clangNoLibcNoRt; 576 + cmake = 577 + if stdenv.targetPlatform.libc == "llvm" then buildPackages.cmakeMinimal else buildPackages.cmake; 578 + python3 = 579 + if stdenv.targetPlatform.libc == "llvm" then 580 + buildPackages.python3Minimal 581 + else 582 + buildPackages.python3; 579 583 }; 580 584 581 585 libc = if stdenv.targetPlatform.libc == "llvm" then libraries.libc-full else libraries.libc-overlay;
+29 -7
pkgs/development/compilers/llvm/common/libc/default.nix
··· 23 23 cp -r ${monorepoSrc}/cmake "$out" 24 24 cp -r ${monorepoSrc}/runtimes "$out" 25 25 cp -r ${monorepoSrc}/llvm "$out" 26 + cp -r ${monorepoSrc}/compiler-rt "$out" 26 27 cp -r ${monorepoSrc}/${pname} "$out" 27 28 ''); 28 29 in ··· 46 47 outputs = [ "out" ] ++ (lib.optional isFullBuild "dev"); 47 48 48 49 postUnpack = lib.optionalString isFullBuild '' 50 + chmod +w $sourceRoot/../$pname/utils/hdrgen 49 51 patchShebangs $sourceRoot/../$pname/utils/hdrgen/main.py 50 52 chmod +x $sourceRoot/../$pname/utils/hdrgen/main.py 51 53 ''; ··· 59 61 cd ../runtimes 60 62 ''; 61 63 62 - postInstall = lib.optionalString (!isFullBuild) '' 63 - substituteAll ${./libc-shim.tpl} $out/lib/libc.so 64 - ''; 64 + postInstall = 65 + lib.optionalString (!isFullBuild) '' 66 + substituteAll ${./libc-shim.tpl} $out/lib/libc.so 67 + '' 68 + # LLVM libc doesn't recognize static vs dynamic yet. 69 + # Treat LLVM libc as a static libc, requires this symlink until upstream fixes it. 70 + + lib.optionalString (isFullBuild && stdenv.hostPlatform.isLinux) '' 71 + ln $out/lib/crt1.o $out/lib/Scrt1.o 72 + ''; 65 73 66 74 libc = if (!isFullBuild) then stdenv.cc.libc else null; 67 75 68 - cmakeFlags = [ 69 - (lib.cmakeBool "LLVM_LIBC_FULL_BUILD" isFullBuild) 70 - (lib.cmakeFeature "LLVM_ENABLE_RUNTIMES" "libc") 71 - ]; 76 + cmakeFlags = 77 + [ 78 + (lib.cmakeBool "LLVM_LIBC_FULL_BUILD" isFullBuild) 79 + (lib.cmakeFeature "LLVM_ENABLE_RUNTIMES" "libc;compiler-rt") 80 + # Tests requires the host to have a libc. 81 + (lib.cmakeBool "LLVM_INCLUDE_TESTS" (stdenv.cc.libc != null)) 82 + (lib.cmakeBool "LLVM_LIBC_INCLUDE_SCUDO" true) 83 + (lib.cmakeBool "COMPILER_RT_BUILD_SCUDO_STANDALONE_WITH_LLVM_LIBC" true) 84 + (lib.cmakeBool "COMPILER_RT_BUILD_GWP_ASAN" false) 85 + (lib.cmakeBool "COMPILER_RT_SCUDO_STANDALONE_BUILD_SHARED" false) 86 + ] 87 + ++ lib.optional (isFullBuild && stdenv.cc.libc == null) [ 88 + # CMake runs a check to see if the compiler works. 89 + # This includes including headers which requires a libc. 90 + # Skip these checks because a libc cannot be used when one doesn't exist. 91 + (lib.cmakeBool "CMAKE_C_COMPILER_WORKS" true) 92 + (lib.cmakeBool "CMAKE_CXX_COMPILER_WORKS" true) 93 + ]; 72 94 73 95 # For the update script: 74 96 passthru = {