diff --git a/lib/systems/default.nix b/lib/systems/default.nix index ec0106a13dacf6..1600b37cdf325c 100644 --- a/lib/systems/default.nix +++ b/lib/systems/default.nix @@ -66,16 +66,60 @@ let # `parsed` is inferred from args, both because there are two options with one # clearly preferred, and to prevent cycles. A simpler fixed point where the RHS # always just used `final.*` would fail on both counts. - elaborate = systemOrArgs: let + elaborate = systemOrArgs: + assert lib.assertMsg (!(lib.oldestSupportedReleaseIsAtLeast 2511 && systemOrArgs ? useZig)) "The useZig attribute has been deprecated in favor of the toolchain attributes."; + let allArgs = systemToAttrs systemOrArgs; # Those two will always be derived from "config", if given, so they should NOT # be overridden further down with "// args". - args = builtins.removeAttrs allArgs [ "parsed" "system" ]; + args = lib.pipe (builtins.removeAttrs allArgs [ "parsed" "system" ]) [ + (lib.warnIf (lib.oldestSupportedReleaseIsAtLeast 2511 && systemOrArgs ? useLLVM) "The useLLVM attribute has been deprecated in favor of the toolchain attributes.") + (lib.warnIf (lib.oldestSupportedReleaseIsAtLeast 2511 && systemOrArgs ? useArocc) "The useArocc attribute has been deprecated in favor of the toolchain attributes.") + (lib.warnIf (lib.oldestSupportedReleaseIsAtLeast 2511 && systemOrArgs ? useZig) "The useZig attribute has been deprecated in favor of the toolchain attributes.") + ]; # TODO: deprecate args.rustc in favour of args.rust after 23.05 is EOL. rust = args.rust or args.rustc or {}; + toolchain = { + cc = if final.useLLVM || final.isDarwin then "clang" + else if final.useArocc then "arocc" + else if final.useZig then "zig" + else "gcc"; + + bintools = if final.useLLVM || final.useArocc || final.useZig || final.isDarwin then + "llvm" + else "gnu"; + + cxxlib = + /**/ if final.useLLVM || final.useArocc || final.useZig || final.isDarwin then "libcxx" + else "libstdcxx"; + + unwinderlib = + /**/ if final.useLLVM || final.useArocc || final.useZig then "libunwind" + else if final.isDarwin then "libunwind-system" + else "libgcc_s"; + + rtlib = + /**/ if final.useLLVM || final.useArocc || final.useZig || final.isDarwin then "compiler-rt" + else "libgcc"; + + # Choose what linker we wish to use by default. Someday we might also + # choose the C compiler, runtime library, C++ standard library, etc. in + # this way, nice and orthogonally, and deprecate `useLLVM`. But due to + # the monolithic GCC build we cannot actually make those choices + # independently, so we are just doing `linker` and keeping `useLLVM` for + # now. + linker = + /**/ if final.useLLVM then "lld" + else if final.isDarwin then "cctools" + # "bfd" and "gold" both come from GNU binutils. The existence of Gold + # is why we use the more obscure "bfd" and not "binutils" for this + # choice. + else "bfd"; + }; + final = { # Prefer to parse `config` as it is strictly more informative. parsed = parse.mkSystemFromString (args.config or allArgs.system); @@ -92,6 +136,8 @@ let isCompatible = _: throw "2022-05-23: isCompatible has been removed in favor of canExecute, refer to the 22.11 changelog for details"; # Derived meta-data useLLVM = final.isFreeBSD || final.isOpenBSD; + useArocc = false; + useZig = false; libc = /**/ if final.isDarwin then "libSystem" @@ -112,19 +158,7 @@ let else if final.isNone then "newlib" # TODO(@Ericson2314) think more about other operating systems else "native/impure"; - # Choose what linker we wish to use by default. Someday we might also - # choose the C compiler, runtime library, C++ standard library, etc. in - # this way, nice and orthogonally, and deprecate `useLLVM`. But due to - # the monolithic GCC build we cannot actually make those choices - # independently, so we are just doing `linker` and keeping `useLLVM` for - # now. - linker = - /**/ if final.useLLVM or false then "lld" - else if final.isDarwin then "cctools" - # "bfd" and "gold" both come from GNU binutils. The existence of Gold - # is why we use the more obscure "bfd" and not "binutils" for this - # choice. - else "bfd"; + # The standard lib directory name that non-nixpkgs binaries distributed # for this platform normally assume. libDir = if final.isLinux then @@ -318,7 +352,7 @@ let }) // mapAttrs (n: v: v final.parsed) inspect.predicates // mapAttrs (n: v: v final.gcc.arch or "default") architectures.predicates - // args // { + // toolchain // args // { rust = rust // { # Once args.rustc.platform.target-family is deprecated and # removed, there will no longer be any need to modify any @@ -430,6 +464,7 @@ let else throw message) true (final.parsed.abi.assertions or []); + assert (lib.listToAttrs (lib.map (key: lib.nameValuePair key final.${key}) (lib.attrNames toolchain))) == toolchain; final; in diff --git a/pkgs/build-support/cc-wrapper/default.nix b/pkgs/build-support/cc-wrapper/default.nix index 134fe37827994f..1a0a2a7faf083e 100644 --- a/pkgs/build-support/cc-wrapper/default.nix +++ b/pkgs/build-support/cc-wrapper/default.nix @@ -120,8 +120,7 @@ let useGccForLibs = useCcForLibs && libcxx == null - && !targetPlatform.isDarwin - && !(targetPlatform.useLLVM or false) + && targetPlatform.rtlib == "libgcc" && !(targetPlatform.useAndroidPrebuilt or false) && !(targetPlatform.isiOS or false) && gccForLibs != null; @@ -520,7 +519,7 @@ stdenvNoCC.mkDerivation { + optionalString (isClang && targetPlatform.isLinux && !(targetPlatform.useAndroidPrebuilt or false) - && !(targetPlatform.useLLVM or false) + && targetPlatform.rtlib == "libgcc" && gccForLibs != null) ('' echo "--gcc-toolchain=${gccForLibs}" >> $out/nix-support/cc-cflags diff --git a/pkgs/by-name/al/alsa-lib/package.nix b/pkgs/by-name/al/alsa-lib/package.nix index f21d216a63bb12..ee6dea039f7cfc 100644 --- a/pkgs/by-name/al/alsa-lib/package.nix +++ b/pkgs/by-name/al/alsa-lib/package.nix @@ -25,7 +25,7 @@ stdenv.mkDerivation (finalAttrs: { # order to support apps with 32bit sound running on x86_64 architecture. ./alsa-plugin-conf-multilib.patch ] - ++ lib.optional (stdenv.hostPlatform.useLLVM or false) + ++ lib.optional (stdenv.hostPlatform.linker == "lld") # Fixes version script under LLVM, should be fixed in the next update. # Check if "pkgsLLVM.alsa-lib" builds on next version bump and remove this # if it succeeds. diff --git a/pkgs/by-name/cl/cling/package.nix b/pkgs/by-name/cl/cling/package.nix index 63b4a681745c02..08d63e284e7ee9 100644 --- a/pkgs/by-name/cl/cling/package.nix +++ b/pkgs/by-name/cl/cling/package.nix @@ -27,7 +27,7 @@ # Build with libc++ (LLVM) rather than stdlibc++ (GCC). # This is experimental and not all features work. - useLLVMLibcxx ? clangStdenv.hostPlatform.isDarwin, + useLLVMLibcxx ? clangStdenv.hostPlatform.cxxlib == "libcxx", }: let diff --git a/pkgs/by-name/cy/cyrus_sasl/package.nix b/pkgs/by-name/cy/cyrus_sasl/package.nix index 68d019ca2619bf..72bcc6bab3f70b 100644 --- a/pkgs/by-name/cy/cyrus_sasl/package.nix +++ b/pkgs/by-name/cy/cyrus_sasl/package.nix @@ -74,7 +74,7 @@ stdenv.mkDerivation rec { "--enable-shared" ] ++ lib.optional enableLdap "--with-ldap=${openldap.dev}" - ++ lib.optionals (stdenv.targetPlatform.useLLVM or false) [ + ++ lib.optionals (stdenv.hostPlatform.cc == "clang" && stdenv.hostPlatform.libc == "glibc") [ "--disable-sample" "CFLAGS=-DTIME_WITH_SYS_TIME" ]; diff --git a/pkgs/by-name/el/elfutils/package.nix b/pkgs/by-name/el/elfutils/package.nix index f07ab5b6aebcbe..9c52c5df9c1da4 100644 --- a/pkgs/by-name/el/elfutils/package.nix +++ b/pkgs/by-name/el/elfutils/package.nix @@ -63,7 +63,7 @@ stdenv.mkDerivation rec { ++ lib.optionals stdenv.hostPlatform.isMusl [ ./musl-error_h.patch ] # Prevent headers and binaries from colliding which results in an error. # https://sourceware.org/pipermail/elfutils-devel/2024q3/007281.html - ++ lib.optional (stdenv.targetPlatform.useLLVM or false) ./cxx-header-collision.patch; + ++ lib.optional (stdenv.targetPlatform.cxxlib == "libcxx") ./cxx-header-collision.patch; postPatch = '' @@ -94,7 +94,7 @@ stdenv.mkDerivation rec { bzip2 ] ++ lib.optional enableDebuginfod pkg-config - ++ lib.optional (stdenv.targetPlatform.useLLVM or false) autoreconfHook; + ++ lib.optional (stdenv.targetPlatform.cxxlib == "libcxx") autoreconfHook; buildInputs = [ zlib @@ -128,7 +128,7 @@ stdenv.mkDerivation rec { # Versioned symbols are nice to have, but we can do without. (lib.enableFeature (!stdenv.hostPlatform.isMicroBlaze) "symbol-versioning") ] - ++ lib.optional (stdenv.targetPlatform.useLLVM or false) "--disable-demangler" + ++ lib.optional (stdenv.targetPlatform.cxxlib == "libcxx") "--disable-demangler" ++ lib.optionals stdenv.cc.isClang [ "CFLAGS=-Wno-unused-private-field" "CXXFLAGS=-Wno-unused-private-field" diff --git a/pkgs/by-name/ke/kexec-tools/package.nix b/pkgs/by-name/ke/kexec-tools/package.nix index 5eef5475390ed1..5ecd41e9851ca7 100644 --- a/pkgs/by-name/ke/kexec-tools/package.nix +++ b/pkgs/by-name/ke/kexec-tools/package.nix @@ -19,13 +19,17 @@ stdenv.mkDerivation rec { sha256 = "sha256-Z7GsUDqt5FpU2wvHkiiogwo11dT4PO6TLP8+eoGkqew="; }; - patches = [ - # Use ELFv2 ABI on ppc64be - (fetchpatch { - url = "https://raw.githubusercontent.com/void-linux/void-packages/6c1192cbf166698932030c2e3de71db1885a572d/srcpkgs/kexec-tools/patches/ppc64-elfv2.patch"; - sha256 = "19wzfwb0azm932v0vhywv4221818qmlmvdfwpvvpfyw4hjsc2s1l"; - }) - ] ++ lib.optional (stdenv.hostPlatform.useLLVM or false) ./fix-purgatory-llvm-libunwind.patch; + patches = + [ + # Use ELFv2 ABI on ppc64be + (fetchpatch { + url = "https://raw.githubusercontent.com/void-linux/void-packages/6c1192cbf166698932030c2e3de71db1885a572d/srcpkgs/kexec-tools/patches/ppc64-elfv2.patch"; + sha256 = "19wzfwb0azm932v0vhywv4221818qmlmvdfwpvvpfyw4hjsc2s1l"; + }) + ] + ++ lib.optional ( + stdenv.hostPlatform.unwinderlib == "libunwind" + ) ./fix-purgatory-llvm-libunwind.patch; hardeningDisable = [ "format" diff --git a/pkgs/by-name/li/libseccomp/package.nix b/pkgs/by-name/li/libseccomp/package.nix index 9ff313c84a65e7..a7523456fb67ca 100644 --- a/pkgs/by-name/li/libseccomp/package.nix +++ b/pkgs/by-name/li/libseccomp/package.nix @@ -37,7 +37,7 @@ stdenv.mkDerivation rec { util-linuxMinimal which ]; - doCheck = !(stdenv.targetPlatform.useLLVM or false); + doCheck = stdenv.targetPlatform.cc != "clang"; # Hack to ensure that patchelf --shrink-rpath get rids of a $TMPDIR reference. preFixup = "rm -rfv src"; diff --git a/pkgs/by-name/ru/rutabaga_gfx/package.nix b/pkgs/by-name/ru/rutabaga_gfx/package.nix index 7de2e8bb476bb6..c7b3a309774403 100644 --- a/pkgs/by-name/ru/rutabaga_gfx/package.nix +++ b/pkgs/by-name/ru/rutabaga_gfx/package.nix @@ -45,7 +45,7 @@ stdenv.mkDerivation (finalAttrs: { ./link-cxx.patch ]; - env = lib.optionalAttrs stdenv.hostPlatform.useLLVM { + env = lib.optionalAttrs (stdenv.hostPlatform.cxxlib == "libcxx" && !stdenv.hostPlatform.isDarwin) { USE_CLANG = true; }; diff --git a/pkgs/by-name/so/sourceHighlight/package.nix b/pkgs/by-name/so/sourceHighlight/package.nix index 16eaa9e42e6ab7..43809fdc548337 100644 --- a/pkgs/by-name/so/sourceHighlight/package.nix +++ b/pkgs/by-name/so/sourceHighlight/package.nix @@ -62,11 +62,9 @@ stdenv.mkDerivation rec { nativeBuildInputs = [ updateAutotoolsGnuConfigScriptsHook ]; buildInputs = [ boost ] - ++ lib.optional (stdenv.targetPlatform.useLLVM or false) ( - llvmPackages.compiler-rt.override { - doFakeLibgcc = true; - } - ); + ++ lib.optional ( + stdenv.hostPlatform.rtlib == "compiler-rt" && !stdenv.hostPlatform.isDarwin + ) llvmPackages.compiler-rt; configureFlags = [ "--with-boost=${boost.out}" @@ -92,7 +90,9 @@ stdenv.mkDerivation rec { maintainers = with maintainers; [ SuperSandro2000 ]; }; } -// lib.optionalAttrs (stdenv.targetPlatform.useLLVM or false) { - # Force linking to "libgcc" so tests pass - NIX_CFLAGS_COMPILE = "-lgcc"; -} +// + lib.optionalAttrs (stdenv.targetPlatform.rtlib == "compiler-rt" && !stdenv.hostPlatform.isDarwin) + { + # Force linking to "libgcc" so tests pass + NIX_CFLAGS_COMPILE = "-lgcc"; + } diff --git a/pkgs/development/compilers/llvm/common/clang/default.nix b/pkgs/development/compilers/llvm/common/clang/default.nix index 7afa284c25a2d7..b353cf85fe0beb 100644 --- a/pkgs/development/compilers/llvm/common/clang/default.nix +++ b/pkgs/development/compilers/llvm/common/clang/default.nix @@ -198,7 +198,7 @@ let ninjaFlags = [ "docs-clang-man" ]; })) // (lib.optionalAttrs (lib.versionAtLeast release_version "15") { - env = lib.optionalAttrs (stdenv.buildPlatform != stdenv.hostPlatform && !stdenv.hostPlatform.useLLVM) { + env = lib.optionalAttrs (stdenv.buildPlatform != stdenv.hostPlatform && stdenv.hostPlatform.cc != "clang") { # The following warning is triggered with (at least) gcc >= # 12, but appears to occur only for cross compiles. NIX_CFLAGS_COMPILE = "-Wno-maybe-uninitialized"; diff --git a/pkgs/development/compilers/llvm/common/compiler-rt/default.nix b/pkgs/development/compilers/llvm/common/compiler-rt/default.nix index f72af0f0855677..ddd689e5ab2171 100644 --- a/pkgs/development/compilers/llvm/common/compiler-rt/default.nix +++ b/pkgs/development/compilers/llvm/common/compiler-rt/default.nix @@ -33,7 +33,6 @@ let - useLLVM = stdenv.hostPlatform.useLLVM or false; bareMetal = stdenv.hostPlatform.parsed.kernel.name == "none"; haveLibc = stdenv.cc.libc != null; # TODO: Make this account for GCC having libstdcxx, which will help @@ -92,22 +91,22 @@ 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 && haveLibc && stdenv.cc.libcxx == libcxx) [ + ] ++ lib.optionals (stdenv.hostPlatform.cxxlib == "libcxx" && haveLibc && stdenv.cc.libcxx == libcxx && !stdenv.hostPlatform.isDarwin) [ "-DSANITIZER_CXX_ABI=libcxxabi" "-DSANITIZER_CXX_ABI_LIBNAME=libcxxabi" "-DCOMPILER_RT_USE_BUILTINS_LIBRARY=ON" ] ++ lib.optionals ((!haveLibc || bareMetal || isMusl || isAarch64) && (lib.versions.major release_version == "13")) [ "-DCOMPILER_RT_BUILD_LIBFUZZER=OFF" - ] ++ lib.optionals (useLLVM && haveLibc) [ + ] ++ lib.optionals (stdenv.hostPlatform.rtlib == "compiler-rt" && haveLibc && !stdenv.hostPlatform.isDarwin) [ "-DCOMPILER_RT_BUILD_SANITIZERS=ON" ] ++ lib.optionals (noSanitizers) [ "-DCOMPILER_RT_BUILD_SANITIZERS=OFF" - ] ++ lib.optionals ((useLLVM && !haveLibcxx) || !haveLibc || bareMetal || isMusl || isDarwinStatic) [ + ] ++ lib.optionals ((stdenv.hostPlatform.rtlib == "compiler-rt" && !haveLibcxx) || !haveLibc || bareMetal || isMusl || isDarwinStatic) [ "-DCOMPILER_RT_BUILD_XRAY=OFF" "-DCOMPILER_RT_BUILD_LIBFUZZER=OFF" "-DCOMPILER_RT_BUILD_MEMPROF=OFF" "-DCOMPILER_RT_BUILD_ORC=OFF" # may be possible to build with musl if necessary - ] ++ lib.optionals (useLLVM && haveLibc) [ + ] ++ lib.optionals (stdenv.hostPlatform.rtlib == "compiler-rt" && haveLibc && !stdenv.hostPlatform.isDarwin) [ "-DCOMPILER_RT_BUILD_PROFILE=ON" ] ++ lib.optionals (!haveLibc || bareMetal) [ "-DCOMPILER_RT_BUILD_PROFILE=OFF" @@ -119,7 +118,7 @@ stdenv.mkDerivation { "-DCMAKE_SIZEOF_VOID_P=${toString (stdenv.hostPlatform.parsed.cpu.bits / 8)}" ] ++ lib.optionals (!haveLibc) [ "-DCMAKE_C_FLAGS=-nodefaultlibs" - ] ++ lib.optionals (useLLVM) [ + ] ++ lib.optionals (stdenv.hostPlatform.rtlib == "compiler-rt" && !stdenv.hostPlatform.isDarwin) [ "-DCOMPILER_RT_BUILD_BUILTINS=ON" #https://stackoverflow.com/questions/53633705/cmake-the-c-compiler-is-not-able-to-compile-a-simple-test-program "-DCMAKE_TRY_COMPILE_TARGET_TYPE=STATIC_LIBRARY" @@ -191,7 +190,7 @@ stdenv.mkDerivation { # Hack around weird upsream RPATH bug postInstall = lib.optionalString (stdenv.hostPlatform.isDarwin) '' ln -s "$out/lib"/*/* "$out/lib" - '' + lib.optionalString (useLLVM && stdenv.hostPlatform.isLinux) '' + '' + lib.optionalString (stdenv.hostPlatform.rtlib == "compiler-rt" && stdenv.hostPlatform.isLinux) '' ln -s $out/lib/*/clang_rt.crtbegin-*.o $out/lib/crtbegin.o ln -s $out/lib/*/clang_rt.crtend-*.o $out/lib/crtend.o # Note the history of crt{begin,end}S in previous versions of llvm in nixpkg: diff --git a/pkgs/development/compilers/llvm/common/default.nix b/pkgs/development/compilers/llvm/common/default.nix index 5a108a4442ff4a..2601d4984b9e46 100644 --- a/pkgs/development/compilers/llvm/common/default.nix +++ b/pkgs/development/compilers/llvm/common/default.nix @@ -640,7 +640,13 @@ let clang = if stdenv.targetPlatform.libc == null then tools.clangNoLibc - else if stdenv.targetPlatform.useLLVM or false then + else if + stdenv.targetPlatform.cc == "clang" + && stdenv.targetPlatform.cxxlib == "libcxx" + && stdenv.targetPlatform.bintools == "llvm" + && stdenv.targetPlatform.rtlib == "compiler-rt" + && !stdenv.targetPlatform.isDarwin + then tools.clangUseLLVM else if (pkgs.targetPackages.stdenv or args.stdenv).cc.isGNU then tools.libstdcxxClang @@ -800,9 +806,12 @@ let echo "--unwindlib=libunwind" >> $out/nix-support/cc-cflags echo "-L${targetLlvmLibraries.libunwind}/lib" >> $out/nix-support/cc-ldflags '' - + lib.optionalString (!stdenv.targetPlatform.isWasm && stdenv.targetPlatform.useLLVM or false) '' - echo "-lunwind" >> $out/nix-support/cc-ldflags - '' + + + lib.optionalString + (!stdenv.targetPlatform.isWasm && stdenv.targetPlatform.unwinderlib == "libunwind") + '' + echo "-lunwind" >> $out/nix-support/cc-ldflags + '' + lib.optionalString stdenv.targetPlatform.isWasm '' echo "-fno-exceptions" >> $out/nix-support/cc-cflags '' @@ -822,7 +831,7 @@ let ++ lib.optional ( !stdenv.targetPlatform.isWasm && !stdenv.targetPlatform.isFreeBSD - && stdenv.targetPlatform.useLLVM or false + && stdenv.targetPlatform.unwinderlib == "libunwind" ) "-lunwind" ++ lib.optional stdenv.targetPlatform.isWasm "-fno-exceptions"; nixSupport.cc-ldflags = lib.optionals ( @@ -855,9 +864,12 @@ let echo "--unwindlib=libunwind" >> $out/nix-support/cc-cflags echo "-L${targetLlvmLibraries.libunwind}/lib" >> $out/nix-support/cc-ldflags '' - + lib.optionalString (!stdenv.targetPlatform.isWasm && stdenv.targetPlatform.useLLVM or false) '' - echo "-lunwind" >> $out/nix-support/cc-ldflags - '' + + + lib.optionalString + (!stdenv.targetPlatform.isWasm && stdenv.targetPlatform.unwinderlib == "libunwind") + '' + echo "-lunwind" >> $out/nix-support/cc-ldflags + '' + lib.optionalString stdenv.targetPlatform.isWasm '' echo "-fno-exceptions" >> $out/nix-support/cc-cflags '' @@ -877,7 +889,7 @@ let ++ lib.optional ( !stdenv.targetPlatform.isWasm && !stdenv.targetPlatform.isFreeBSD - && stdenv.targetPlatform.useLLVM or false + && stdenv.targetPlatform.unwinderlib == "libunwind" ) "-lunwind" ++ lib.optional stdenv.targetPlatform.isWasm "-fno-exceptions"; nixSupport.cc-ldflags = lib.optionals ( @@ -1103,7 +1115,9 @@ let # Darwin needs to use a bootstrap stdenv to avoid an infinite recursion when cross-compiling. if args.stdenv.hostPlatform.isDarwin then overrideCC darwin.bootstrapStdenv buildLlvmTools.clangWithLibcAndBasicRtAndLibcxx - else if args.stdenv.hostPlatform.useLLVM or false then + else if + args.stdenv.hostPlatform.rtlib == "compiler-rt" && args.stdenv.hostPlatform.cxxlib == "libcxx" + then overrideCC args.stdenv buildLlvmTools.clangWithLibcAndBasicRtAndLibcxx else args.stdenv; @@ -1111,8 +1125,9 @@ let { patches = compiler-rtPatches; inherit stdenv; + doFakeLibgcc = stdenv.hostPlatform.rtlib == "compiler-rt" && !stdenv.hostPlatform.isDarwin; } - // lib.optionalAttrs (stdenv.hostPlatform.useLLVM or false) { + // lib.optionalAttrs (stdenv.hostPlatform.rtlib == "compiler-rt") { libxcrypt = (libxcrypt.override { inherit stdenv; }).overrideAttrs (old: { configureFlags = old.configureFlags ++ [ "--disable-symvers" ]; }); @@ -1121,7 +1136,7 @@ let compiler-rt-no-libc = callPackage ./compiler-rt { patches = compiler-rtPatches; - doFakeLibgcc = stdenv.hostPlatform.useLLVM or false; + doFakeLibgcc = stdenv.hostPlatform.rtlib == "compiler-rt" && !stdenv.hostPlatform.isDarwin; stdenv = # Darwin needs to use a bootstrap stdenv to avoid an infinite recursion when cross-compiling. if stdenv.hostPlatform.isDarwin then diff --git a/pkgs/development/compilers/llvm/common/libcxx/default.nix b/pkgs/development/compilers/llvm/common/libcxx/default.nix index c4ada0bf669be8..6e955e03bbd2b0 100644 --- a/pkgs/development/compilers/llvm/common/libcxx/default.nix +++ b/pkgs/development/compilers/llvm/common/libcxx/default.nix @@ -30,9 +30,6 @@ let cxxabiName = "lib${if cxxabi == null then "cxxabi" else cxxabi.libName}"; runtimes = [ "libcxx" ] ++ lib.optional (cxxabi == null) "libcxxabi"; - # Note: useLLVM is likely false for Darwin but true under pkgsLLVM - useLLVM = stdenv.hostPlatform.useLLVM or false; - src' = if monorepoSrc != null then runCommand "${pname}-src-${version}" { inherit (monorepoSrc) passthru; } ('' mkdir -p "$out/llvm" @@ -54,7 +51,7 @@ let cxxabiCMakeFlags = lib.optionals (lib.versionAtLeast release_version "18") [ "-DLIBCXXABI_USE_LLVM_UNWINDER=OFF" - ] ++ lib.optionals (useLLVM && !stdenv.hostPlatform.isWasm) (if lib.versionAtLeast release_version "18" then [ + ] ++ lib.optionals (stdenv.hostPlatform.unwinderlib == "libunwind" && !stdenv.hostPlatform.isWasm) (if lib.versionAtLeast release_version "18" then [ "-DLIBCXXABI_ADDITIONAL_LIBRARIES=unwind" "-DLIBCXXABI_USE_COMPILER_RT=ON" ] else [ @@ -80,15 +77,15 @@ let "-DLIBCXX_CXX_ABI_INCLUDE_PATHS=${lib.getDev cxxabi}/include" ] ++ lib.optionals (stdenv.hostPlatform.isMusl || stdenv.hostPlatform.isWasi) [ "-DLIBCXX_HAS_MUSL_LIBC=1" - ] ++ lib.optionals (lib.versionAtLeast release_version "18" && !useLLVM && stdenv.hostPlatform.libc == "glibc" && !stdenv.hostPlatform.isStatic) [ + ] ++ lib.optionals (lib.versionAtLeast release_version "18" && stdenv.hostPlatform.unwinderlib == "libgcc_s" && stdenv.hostPlatform.libc == "glibc" && !stdenv.hostPlatform.isStatic) [ "-DLIBCXX_ADDITIONAL_LIBRARIES=gcc_s" ] ++ lib.optionals (lib.versionAtLeast release_version "18" && stdenv.hostPlatform.isFreeBSD) [ # Name and documentation claim this is for libc++abi, but its man effect is adding `-lunwind` # to the libc++.so linker script. We want FreeBSD's so-called libgcc instead of libunwind. "-DLIBCXXABI_USE_LLVM_UNWINDER=OFF" - ] ++ lib.optionals useLLVM [ + ] ++ lib.optionals (stdenv.hostPlatform.rtlib == "compiler-rt" && !stdenv.hostPlatform.isDarwin) [ "-DLIBCXX_USE_COMPILER_RT=ON" - ] ++ lib.optionals (useLLVM && !stdenv.hostPlatform.isFreeBSD && lib.versionAtLeast release_version "16") [ + ] ++ lib.optionals (stdenv.hostPlatform.unwinderlib == "libunwind" && !stdenv.hostPlatform.isFreeBSD && lib.versionAtLeast release_version "16") [ "-DLIBCXX_ADDITIONAL_LIBRARIES=unwind" ] ++ lib.optionals stdenv.hostPlatform.isWasm [ "-DLIBCXX_ENABLE_THREADS=OFF" @@ -135,7 +132,7 @@ stdenv.mkDerivation (rec { ++ lib.optional (cxxabi != null) lndir; buildInputs = [ cxxabi ] - ++ lib.optionals (useLLVM && !stdenv.hostPlatform.isWasm && !stdenv.hostPlatform.isFreeBSD) [ libunwind ]; + ++ lib.optionals (stdenv.hostPlatform.unwinderlib == "libunwind" && !stdenv.hostPlatform.isWasm && !stdenv.hostPlatform.isFreeBSD) [ libunwind ]; # libc++.so is a linker script which expands to multiple libraries, # libc++.so.1 and libc++abi.so or the external cxxabi. ld-wrapper doesn't diff --git a/pkgs/development/compilers/rust/1_84.nix b/pkgs/development/compilers/rust/1_84.nix index 6b98d8817bccd3..5da8f7fb88141c 100644 --- a/pkgs/development/compilers/rust/1_84.nix +++ b/pkgs/development/compilers/rust/1_84.nix @@ -36,13 +36,27 @@ let { enableSharedLibraries = true; } - // lib.optionalAttrs (stdenv.targetPlatform.useLLVM or false) { - # Force LLVM to compile using clang + LLVM libs when targeting pkgsLLVM - stdenv = pkgSet.stdenv.override { - allowedRequisites = null; - cc = pkgSet.pkgsBuildHost.llvmPackages_19.clangUseLLVM; - }; - } + // + lib.optionalAttrs + ( + stdenv.targetPlatform.cc == "clang" + && stdenv.targetPlatform.cxxlib == "libcxx" + && stdenv.targetPlatform.rtlib == "compiler-rt" + && stdenv.targetPlatform.unwinderlib == "libunwind" + && !( + stdenv.buildPlatform.cc == "clang" + && stdenv.buildPlatform.cxxlib == "libcxx" + && stdenv.buildPlatform.rtlib == "compiler-rt" + && stdenv.buildPlatform.unwinderlib == "libunwind" + ) + ) + { + # Force LLVM to compile using clang + LLVM libs when targeting pkgsLLVM + stdenv = pkgSet.stdenv.override { + allowedRequisites = null; + cc = pkgSet.pkgsBuildHost.llvmPackages_19.clangUseLLVM; + }; + } ); in import ./default.nix @@ -59,7 +73,20 @@ import ./default.nix # Expose llvmPackages used for rustc from rustc via passthru for LTO in Firefox llvmPackages = - if (stdenv.targetPlatform.useLLVM or false) then + if + ( + stdenv.targetPlatform.cc == "clang" + && stdenv.targetPlatform.cxxlib == "libcxx" + && stdenv.targetPlatform.rtlib == "compiler-rt" + && stdenv.targetPlatform.unwinderlib == "libunwind" + && !( + stdenv.buildPlatform.cc == "clang" + && stdenv.buildPlatform.cxxlib == "libcxx" + && stdenv.buildPlatform.rtlib == "compiler-rt" + && stdenv.buildPlatform.unwinderlib == "libunwind" + ) + ) + then callPackage ( { pkgs, @@ -89,6 +116,7 @@ import ./default.nix allowedRequisites = null; cc = pkgsBuildHost.llvmPackages_19.clangNoLibcxx; hostPlatform = stdenv.hostPlatform // { + # TODO: replace once "useLLVM" is fully dropped useLLVM = !stdenv.hostPlatform.isDarwin; }; }; diff --git a/pkgs/development/compilers/rust/rustc.nix b/pkgs/development/compilers/rust/rustc.nix index d7a1ee625f9ce1..34a287680d07d5 100644 --- a/pkgs/development/compilers/rust/rustc.nix +++ b/pkgs/development/compilers/rust/rustc.nix @@ -52,7 +52,6 @@ let concatStringsSep ; inherit (darwin.apple_sdk.frameworks) Security; - useLLVM = stdenv.targetPlatform.useLLVM or false; in stdenv.mkDerivation (finalAttrs: { pname = "${targetPackages.stdenv.cc.targetPrefix}rustc"; @@ -97,11 +96,21 @@ stdenv.mkDerivation (finalAttrs: { # This doesn't apply to cross-building for FreeBSD because the host # uses libstdc++, but the target (used for building std) uses libc++ optional ( - stdenv.hostPlatform.isLinux && !withBundledLLVM && !stdenv.targetPlatform.isFreeBSD && !useLLVM + stdenv.hostPlatform.isLinux + && !withBundledLLVM + && !stdenv.targetPlatform.isFreeBSD + && !stdenv.targetPlatform.isDarwin + && stdenv.targetPlatform.cxxlib == "libstdcxx" ) "--push-state --as-needed -lstdc++ --pop-state" ++ optional - (stdenv.hostPlatform.isLinux && !withBundledLLVM && !stdenv.targetPlatform.isFreeBSD && useLLVM) + ( + stdenv.hostPlatform.isLinux + && !withBundledLLVM + && !stdenv.targetPlatform.isFreeBSD + && !stdenv.targetPlatform.isDarwin + && stdenv.targetPlatform.cxxlib == "libcxx" + ) "--push-state --as-needed -L${llvmPackages.libcxx}/lib -lc++ -lc++abi -lLLVM-${lib.versions.major llvmPackages.llvm.version} --pop-state" ++ optional (stdenv.hostPlatform.isDarwin && !withBundledLLVM) "-lc++ -lc++abi" ++ optional stdenv.hostPlatform.isFreeBSD "-rpath ${llvmPackages.libunwind}/lib" @@ -207,7 +216,7 @@ stdenv.mkDerivation (finalAttrs: { # doesn't work) to build a linker. "--disable-llvm-bitcode-linker" ] - ++ optionals (stdenv.targetPlatform.isLinux && !(stdenv.targetPlatform.useLLVM or false)) [ + ++ optionals (stdenv.targetPlatform.isLinux && stdenv.hostPlatform.rtlib != "compiler-rt") [ "--enable-profiler" # build libprofiler_builtins ] ++ optionals stdenv.buildPlatform.isMusl [ @@ -226,11 +235,15 @@ stdenv.mkDerivation (finalAttrs: { # https://github.com/rust-lang/rust/issues/92173 "--set rust.jemalloc" ] - ++ optionals (useLLVM && !stdenv.targetPlatform.isFreeBSD) [ - # https://github.com/NixOS/nixpkgs/issues/311930 - "--llvm-libunwind=${if withBundledLLVM then "in-tree" else "system"}" - "--enable-use-libcxx" - ]; + ++ + optional (stdenv.targetPlatform.unwinderlib == "libunwind" && !stdenv.targetPlatform.isFreeBSD) + # https://github.com/NixOS/nixpkgs/issues/311930 + "--llvm-libunwind=${if withBundledLLVM then "in-tree" else "system"}" + ++ optional ( + stdenv.targetPlatform.cxxlib == "libcxx" + && !stdenv.targetPlatform.isFreeBSD + && !stdenv.targetPlatform.isDarwin + ) "--enable-use-libcxx"; # if we already have a rust compiler for build just compile the target std # library and reuse compiler @@ -353,15 +366,22 @@ stdenv.mkDerivation (finalAttrs: { zlib ] ++ optional (!withBundledLLVM) llvmShared.lib - ++ optional (useLLVM && !withBundledLLVM && !stdenv.targetPlatform.isFreeBSD) [ - llvmPackages.libunwind - # Hack which is used upstream https://github.com/gentoo/gentoo/blob/master/dev-lang/rust/rust-1.78.0.ebuild#L284 - (runCommandLocal "libunwind-libgcc" { } '' - mkdir -p $out/lib - ln -s ${llvmPackages.libunwind}/lib/libunwind.so $out/lib/libgcc_s.so - ln -s ${llvmPackages.libunwind}/lib/libunwind.so $out/lib/libgcc_s.so.1 - '') - ]; + ++ + optionals + ( + stdenv.targetPlatform.unwinderlib == "libunwind" + && !withBundledLLVM + && !stdenv.targetPlatform.isFreeBSD + ) + [ + llvmPackages.libunwind + # Hack which is used upstream https://github.com/gentoo/gentoo/blob/master/dev-lang/rust/rust-1.78.0.ebuild#L284 + (runCommandLocal "libunwind-libgcc" { } '' + mkdir -p $out/lib + ln -s ${llvmPackages.libunwind}/lib/libunwind.so $out/lib/libgcc_s.so + ln -s ${llvmPackages.libunwind}/lib/libunwind.so $out/lib/libgcc_s.so.1 + '') + ]; outputs = [ "out" @@ -421,10 +441,5 @@ stdenv.mkDerivation (finalAttrs: { # If rustc can't target a platform, we also can't build rustc for # that platform. badPlatforms = rustc.badTargetPlatforms; - # Builds, but can't actually compile anything - # https://github.com/NixOS/nixpkgs/issues/311930 - # https://github.com/rust-lang/rust/issues/55120 - # https://github.com/rust-lang/rust/issues/82521 - broken = stdenv.hostPlatform.useLLVM; }; }) diff --git a/pkgs/development/libraries/kerberos/krb5.nix b/pkgs/development/libraries/kerberos/krb5.nix index 7a4df60f0ae5b1..ca6421345e0fe2 100644 --- a/pkgs/development/libraries/kerberos/krb5.nix +++ b/pkgs/development/libraries/kerberos/krb5.nix @@ -86,11 +86,7 @@ stdenv.mkDerivation rec { buildInputs = [ openssl ] - ++ lib.optionals ( - stdenv.hostPlatform.isLinux - && stdenv.hostPlatform.libc != "bionic" - && !(stdenv.hostPlatform.useLLVM or false) - ) [ keyutils ] + ++ lib.optionals (stdenv.hostPlatform.isLinux && stdenv.hostPlatform.libc != "bionic") [ keyutils ] ++ lib.optionals withLdap [ openldap ] ++ lib.optionals withLibedit [ libedit ] ++ lib.optionals withVerto [ libverto ]; diff --git a/pkgs/development/libraries/libunwind/default.nix b/pkgs/development/libraries/libunwind/default.nix index f0f7de192f4487..687297a1121bcd 100644 --- a/pkgs/development/libraries/libunwind/default.nix +++ b/pkgs/development/libraries/libunwind/default.nix @@ -20,7 +20,7 @@ stdenv.mkDerivation (finalAttrs: { hash = "sha256-rCFBHs6rCSnp5FEwbUR5veNNTqSQpFblAv8ebSPX0qE="; }; - patches = lib.optional (stdenv.targetPlatform.useLLVM or false) (fetchpatch { + patches = lib.optional (stdenv.cc.isClang && !stdenv.hostPlatform.isDarwin) (fetchpatch { url = "https://github.com/libunwind/libunwind/pull/770/commits/a69d0f14c9e6c46e82ba6e02fcdedb2eb63b7f7f.patch"; hash = "sha256-9oBZimCXonNN++jJs3emp9w+q1aj3eNzvSKPgh92itA="; }); diff --git a/pkgs/development/libraries/libva/default.nix b/pkgs/development/libraries/libva/default.nix index 9fd523a70610c0..667c03e8a5aed3 100644 --- a/pkgs/development/libraries/libva/default.nix +++ b/pkgs/development/libraries/libva/default.nix @@ -69,7 +69,7 @@ stdenv.mkDerivation (finalAttrs: { { NIX_LDFLAGS = "--undefined-version"; } - // lib.optionalAttrs (stdenv.targetPlatform.useLLVM or false) { + // lib.optionalAttrs (stdenv.cc.isClang && !stdenv.hostPlatform.isDarwin) { NIX_CFLAGS_COMPILE = "-DHAVE_SECURE_GETENV"; }; diff --git a/pkgs/development/libraries/openssl/default.nix b/pkgs/development/libraries/openssl/default.nix index f0cf68f8b6aa67..8703b682617710 100644 --- a/pkgs/development/libraries/openssl/default.nix +++ b/pkgs/development/libraries/openssl/default.nix @@ -97,8 +97,7 @@ let # output minimal. ++ lib.optional static "etc"; setOutputFlags = false; - separateDebugInfo = - !stdenv.hostPlatform.isDarwin && !(stdenv.hostPlatform.useLLVM or false) && stdenv.cc.isGNU; + separateDebugInfo = !stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.cc == "gcc"; nativeBuildInputs = lib.optional (!stdenv.hostPlatform.isWindows) makeBinaryWrapper diff --git a/pkgs/development/libraries/quictls/default.nix b/pkgs/development/libraries/quictls/default.nix index 63ddc6313d6a7d..62b931d2e5fa42 100644 --- a/pkgs/development/libraries/quictls/default.nix +++ b/pkgs/development/libraries/quictls/default.nix @@ -64,8 +64,7 @@ stdenv.mkDerivation rec { separateDebugInfo = !stdenv.hostPlatform.isDarwin && - !(stdenv.hostPlatform.useLLVM or false) && - stdenv.cc.isGNU; + stdenv.hostPlatform.cc == "gcc"; # TODO(@Ericson2314): Improve with mass rebuild configurePlatforms = [ ]; diff --git a/pkgs/development/libraries/silgraphite/graphite2.nix b/pkgs/development/libraries/silgraphite/graphite2.nix index 7289820b60df1f..3275cb6d40cfd2 100644 --- a/pkgs/development/libraries/silgraphite/graphite2.nix +++ b/pkgs/development/libraries/silgraphite/graphite2.nix @@ -30,13 +30,9 @@ stdenv.mkDerivation (finalAttrs: { pkg-config cmake ]; - buildInputs = - [ freetype ] - ++ lib.optional (stdenv.targetPlatform.useLLVM or false) ( - llvmPackages.compiler-rt.override { - doFakeLibgcc = true; - } - ); + buildInputs = [ + freetype + ]; patches = lib.optionals stdenv.hostPlatform.isDarwin [ ./macosx.patch ]; postPatch = '' diff --git a/pkgs/development/python-modules/cffi/default.nix b/pkgs/development/python-modules/cffi/default.nix index bbdd6bf08cfc2a..91e31a9fefd0aa 100644 --- a/pkgs/development/python-modules/cffi/default.nix +++ b/pkgs/development/python-modules/cffi/default.nix @@ -69,7 +69,10 @@ else # The tests use -Werror but with python3.6 clang detects some unreachable code. env.NIX_CFLAGS_COMPILE = lib.optionalString stdenv.cc.isClang "-Wno-unused-command-line-argument -Wno-unreachable-code -Wno-c++11-narrowing"; - doCheck = !(stdenv.hostPlatform.isMusl || stdenv.hostPlatform.useLLVM or false); + doCheck = + !( + stdenv.hostPlatform.isMusl || (stdenv.hostPlatform.cc == "clang" && !stdenv.hostPlatform.isDarwin) + ); nativeCheckInputs = [ pytestCheckHook ]; diff --git a/pkgs/development/python-modules/jedi/default.nix b/pkgs/development/python-modules/jedi/default.nix index 8e31fe41c78056..24f4b36d57dd09 100644 --- a/pkgs/development/python-modules/jedi/default.nix +++ b/pkgs/development/python-modules/jedi/default.nix @@ -49,7 +49,7 @@ buildPythonPackage rec { # sensitive to platform, causes false negatives on darwin "test_import" ] - ++ lib.optionals (stdenv.targetPlatform.useLLVM or false) [ + ++ lib.optionals (stdenv.hostPlatform.cc == "clang" && stdenv.hostPlatform.libc == "glibc") [ # InvalidPythonEnvironment: The python binary is potentially unsafe. "test_create_environment_executable" # AssertionError: assert ['', '.1000000000000001'] == ['', '.1'] diff --git a/pkgs/development/python-modules/mako/default.nix b/pkgs/development/python-modules/mako/default.nix index caeda4a13dd3df..60f440f7204df4 100644 --- a/pkgs/development/python-modules/mako/default.nix +++ b/pkgs/development/python-modules/mako/default.nix @@ -62,7 +62,9 @@ buildPythonPackage rec { "test_bytestring_passthru" ] # https://github.com/sqlalchemy/mako/issues/408 - ++ lib.optional (stdenv.targetPlatform.useLLVM or false) "test_future_import"; + ++ lib.optional ( + stdenv.hostPlatform.cc == "clang" && stdenv.hostPlatform.libc == "glibc" + ) "test_future_import"; meta = with lib; { description = "Super-fast templating language"; diff --git a/pkgs/os-specific/linux/systemd/default.nix b/pkgs/os-specific/linux/systemd/default.nix index 11492bd163e343..ff2a313acb81e6 100644 --- a/pkgs/os-specific/linux/systemd/default.nix +++ b/pkgs/os-specific/linux/systemd/default.nix @@ -419,12 +419,7 @@ stdenv.mkDerivation (finalAttrs: { ++ lib.optional withUkify (python3Packages.python.withPackages (ps: with ps; [ pefile ])) ++ lib.optionals withPasswordQuality [ libpwquality ] ++ lib.optionals withQrencode [ qrencode ] - ++ lib.optionals withLibarchive [ libarchive ] - ++ lib.optional (withBootloader && stdenv.targetPlatform.useLLVM or false) ( - llvmPackages.compiler-rt.override { - doFakeLibgcc = true; - } - ); + ++ lib.optionals withLibarchive [ libarchive ]; mesonBuildType = "release"; diff --git a/pkgs/os-specific/windows/default.nix b/pkgs/os-specific/windows/default.nix index 59806318a23ec5..5921d78ff30ac3 100644 --- a/pkgs/os-specific/windows/default.nix +++ b/pkgs/os-specific/windows/default.nix @@ -26,7 +26,7 @@ lib.makeScope newScope ( # FIXME untested with llvmPackages_16 was using llvmPackages_8 crossThreadsStdenv = overrideCC stdenvNoLibc ( - if stdenv.hostPlatform.useLLVM or false then + if stdenv.hostPlatform.cc == "clang" then buildPackages.llvmPackages.clangNoLibcxx else buildPackages.gccWithoutTargetLibc.override (old: { diff --git a/pkgs/servers/x11/xorg/overrides.nix b/pkgs/servers/x11/xorg/overrides.nix index 54d8bfedf011ea..6e1f0d914d27e1 100644 --- a/pkgs/servers/x11/xorg/overrides.nix +++ b/pkgs/servers/x11/xorg/overrides.nix @@ -159,7 +159,7 @@ self: super: ]; configureFlags = attrs.configureFlags or [] ++ malloc0ReturnsNullCrossFlag - ++ lib.optional (stdenv.targetPlatform.useLLVM or false) "ac_cv_path_RAWCPP=cpp"; + ++ lib.optional (stdenv.targetPlatform.cc == "clang" && !stdenv.hostPlatform.isDarwin) "ac_cv_path_RAWCPP=cpp"; depsBuildBuild = [ buildPackages.stdenv.cc ] ++ lib.optionals stdenv.hostPlatform.isStatic [ @@ -269,7 +269,7 @@ self: super: ''; configureFlags = attrs.configureFlags or [] ++ malloc0ReturnsNullCrossFlag - ++ lib.optional (stdenv.targetPlatform.useLLVM or false) "ac_cv_path_RAWCPP=cpp"; + ++ lib.optional (stdenv.targetPlatform.cc == "clang" && !stdenv.hostPlatform.isDarwin) "ac_cv_path_RAWCPP=cpp"; propagatedBuildInputs = attrs.propagatedBuildInputs or [] ++ [ xorg.libSM ]; depsBuildBuild = [ buildPackages.stdenv.cc ]; CPP = if stdenv.hostPlatform.isDarwin then "clang -E -" else "${stdenv.cc.targetPrefix}cc -E -"; diff --git a/pkgs/servers/x11/xorg/xwayland.nix b/pkgs/servers/x11/xorg/xwayland.nix index 7375fa817d1ccf..3fb18281a6f606 100644 --- a/pkgs/servers/x11/xorg/xwayland.nix +++ b/pkgs/servers/x11/xorg/xwayland.nix @@ -24,7 +24,7 @@ libdrm, libtirpc, # Disable withLibunwind as LLVM's libunwind will conflict and does not support the right symbols. - withLibunwind ? !(stdenv.hostPlatform.useLLVM or false), + withLibunwind ? stdenv.hostPlatform.unwinderlib == "libgcc_s", libunwind, libxcb, libxkbfile, diff --git a/pkgs/stdenv/cross/default.nix b/pkgs/stdenv/cross/default.nix index 69ea14be5c83d0..7fdfcdfcedb351 100644 --- a/pkgs/stdenv/cross/default.nix +++ b/pkgs/stdenv/cross/default.nix @@ -118,14 +118,16 @@ lib.init bootStages throw "no C compiler provided for this platform" else if crossSystem.isDarwin then buildPackages.llvmPackages.libcxxClang - else if crossSystem.useLLVM or false then + else if crossSystem.cc == "clang" then buildPackages.llvmPackages.clang - else if crossSystem.useZig or false then + else if crossSystem.cc == "zig" then buildPackages.zig.cc - else if crossSystem.useArocc or false then + else if crossSystem.cc == "arocc" then buildPackages.arocc + else if crossSystem.cc == "gcc" then + buildPackages.gcc else - buildPackages.gcc; + throw "no C compiler provided for this platform"; }; in diff --git a/pkgs/tools/package-management/nix/2_26/dependencies.nix b/pkgs/tools/package-management/nix/2_26/dependencies.nix index 73739e2edcc5b6..ad195c03873a39 100644 --- a/pkgs/tools/package-management/nix/2_26/dependencies.nix +++ b/pkgs/tools/package-management/nix/2_26/dependencies.nix @@ -115,7 +115,7 @@ let // lib.optionalAttrs ( stdenv.isLinux && !(stdenv.hostPlatform.isStatic && stdenv.system == "aarch64-linux") - && !(stdenv.hostPlatform.useLLVM or false) + && stdenv.hostPlatform.linker != "lld" ) { LDFLAGS = "-fuse-ld=gold"; }; }; diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index d19bd26af8798f..e599fd58b27237 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -61,15 +61,15 @@ with pkgs; # thing to to create an earlier thing (leading to infinite recursion) and # we also would still respect the stage arguments choices for these # things. - (if stdenvNoCC.hostPlatform.isDarwin || stdenvNoCC.hostPlatform.useLLVM or false - then overrideCC stdenvNoCC buildPackages.llvmPackages.clangNoCompilerRt + (if stdenvNoCC.hostPlatform.cc == "clang" + then assert stdenvNoCC.hostPlatform.rtlib == "compiler-rt"; overrideCC stdenvNoCC buildPackages.llvmPackages.clangNoCompilerRt else gccCrossLibcStdenv) else mkStdenvNoLibs stdenv; stdenvNoLibc = if stdenvNoCC.hostPlatform != stdenvNoCC.buildPlatform then - (if stdenvNoCC.hostPlatform.isDarwin || stdenvNoCC.hostPlatform.useLLVM or false + (if stdenvNoCC.hostPlatform.cc == "clang" then overrideCC stdenvNoCC buildPackages.llvmPackages.clangNoLibc else gccCrossLibcStdenv) else mkStdenvNoLibs stdenv; @@ -5869,7 +5869,7 @@ with pkgs; # temporarily disabled due to breakage; # see https://github.com/NixOS/nixpkgs/pull/243249 && !stdenv.targetPlatform.isWindows - && !(stdenv.targetPlatform.useLLVM or false) + && !(stdenv.targetPlatform.cc == "clang" && stdenv.targetPlatform.cxxlib == "libcxx") ; }; bintools = binutilsNoLibc; @@ -8957,7 +8957,13 @@ with pkgs; else libcCrossChooser stdenv.targetPlatform.libc; threadsCross = - lib.optionalAttrs (stdenv.targetPlatform.isMinGW && !(stdenv.targetPlatform.useLLVM or false)) { + lib.optionalAttrs ( + stdenv.targetPlatform.isMinGW + && !(stdenv.targetPlatform.cc == "clang" + && stdenv.targetPlatform.cxxlib == "libcxx" + && stdenv.targetPlatform.rtlib == "compiler-rt" + && stdenv.targetPlatform.unwinderlib == "libunwind") + ) { # other possible values: win32 or posix model = "mcf"; # For win32 or posix set this to null @@ -9423,7 +9429,7 @@ with pkgs; libcomps = callPackage ../tools/package-management/libcomps { python = python3; }; libcxxrt = callPackage ../development/libraries/libcxxrt { - stdenv = if stdenv.hostPlatform.useLLVM or false + stdenv = if stdenv.hostPlatform.cxxlib == "libcxx" && stdenv.hostPlatform.cxxlib != "libcxx" then overrideCC stdenv buildPackages.llvmPackages.tools.clangNoLibcxx else stdenv; }; @@ -11914,7 +11920,7 @@ with pkgs; busybox = callPackage ../os-specific/linux/busybox { # Fixes libunwind from being dynamically linked to a static binary. - stdenv = if (stdenv.targetPlatform.useLLVM or false) then + stdenv = if stdenv.cc.isClang && stdenv.hostPlatform.unwinderlib == "libunwind" then overrideCC stdenv buildPackages.llvmPackages.clangNoLibcxx else stdenv; }; diff --git a/pkgs/top-level/stage.nix b/pkgs/top-level/stage.nix index 64bc2308f6da77..0b578aa239261e 100644 --- a/pkgs/top-level/stage.nix +++ b/pkgs/top-level/stage.nix @@ -207,6 +207,11 @@ let # so we don't need to check hostPlatform != buildPlatform. crossSystem = stdenv.hostPlatform // { useLLVM = true; + cc = "clang"; + bintools = "llvm"; + cxxlib = "libcxx"; + unwinderlib = "libunwind"; + rtlib = "compiler-rt"; linker = "lld"; }; }; @@ -235,6 +240,11 @@ let # so we don't need to check hostPlatform != buildPlatform. crossSystem = stdenv.hostPlatform // { useArocc = true; + cc = "arocc"; + bintools = "llvm"; + cxxlib = "libcxx"; + unwinderlib = "libunwind"; + rtlib = "compiler-rt"; linker = "lld"; }; }; @@ -250,6 +260,11 @@ let # so we don't need to check hostPlatform != buildPlatform. crossSystem = stdenv.hostPlatform // { useZig = true; + cc = "zig"; + bintools = "llvm"; + cxxlib = "libcxx"; + unwinderlib = "libunwind"; + rtlib = "compiler-rt"; linker = "lld"; }; };