From a225595708f91e118828f3322dddcf773a577976 Mon Sep 17 00:00:00 2001 From: Tristan Ross Date: Fri, 13 Dec 2024 15:45:09 -0800 Subject: [PATCH 1/2] lib.systems: introduce toolchain, cc, and bintools attributes --- lib/systems/default.nix | 26 ++++++++++++++++--- lib/systems/examples.nix | 16 ++++++------ pkgs/build-support/cc-wrapper/default.nix | 4 +-- pkgs/by-name/cy/cyrus_sasl/package.nix | 2 +- pkgs/by-name/el/elfutils/package.nix | 6 ++--- pkgs/by-name/ke/kexec-tools/package.nix | 2 +- pkgs/by-name/li/libseccomp/package.nix | 2 +- pkgs/by-name/so/sourceHighlight/package.nix | 4 +-- .../llvm/common/compiler-rt/default.nix | 2 +- .../compilers/llvm/common/default.nix | 16 ++++++------ .../compilers/llvm/common/libcxx/default.nix | 2 +- pkgs/development/compilers/rust/1_83.nix | 4 +-- pkgs/development/compilers/rust/rustc.nix | 4 +-- pkgs/development/libraries/kerberos/krb5.nix | 2 +- .../libraries/libunwind/default.nix | 2 +- pkgs/development/libraries/libva/default.nix | 2 +- .../development/libraries/openssl/default.nix | 2 +- .../development/libraries/quictls/default.nix | 2 +- .../libraries/silgraphite/graphite2.nix | 2 +- .../python-modules/jedi/default.nix | 6 ++++- .../python-modules/mako/default.nix | 2 +- pkgs/os-specific/linux/systemd/default.nix | 2 +- pkgs/os-specific/windows/default.nix | 2 +- pkgs/servers/x11/xorg/overrides.nix | 4 +-- pkgs/stdenv/cross/default.nix | 10 ++++--- pkgs/top-level/all-packages.nix | 24 +++++++++-------- pkgs/top-level/stage.nix | 9 ++++--- 27 files changed, 94 insertions(+), 67 deletions(-) diff --git a/lib/systems/default.nix b/lib/systems/default.nix index 00f7f3523aa48..38fbad3898a57 100644 --- a/lib/systems/default.nix +++ b/lib/systems/default.nix @@ -66,7 +66,11 @@ 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 (systemOrArgs ? useLLVM == false) "elaborate cannot contain the deprecated useLLVM attribute"; + assert lib.assertMsg (systemOrArgs ? useArocc == false) "elaborate cannot contain the deprecated useArocc attribute"; + assert lib.assertMsg (systemOrArgs ? useZig == false) "elaborate cannot contain the deprecated useZig attribute"; + let allArgs = systemToAttrs systemOrArgs; # Those two will always be derived from "config", if given, so they should NOT @@ -91,7 +95,21 @@ let && final.parsed.kernel == platform.parsed.kernel; 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; + + toolchain = + /**/ if final.isDarwin then "apple" + else if final.isFreeBSD || final.isOpenBSD then "llvm" + else "gnu"; + + cc = if final.toolchain == "apple" || final.toolchain == "llvm" then + "clang" + else "gcc"; + + bintools = if final.toolchain == "bintools" then + "llvm" + else if final.toolchain == "apple" then + "apple" + else "gnu"; libc = /**/ if final.isDarwin then "libSystem" @@ -118,8 +136,8 @@ let # 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" + /**/ if final.toolchain == "llvm" then "lld" + else if final.toolchain == "apple" 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. diff --git a/lib/systems/examples.nix b/lib/systems/examples.nix index 223de50f67dd6..257760dfa0352 100644 --- a/lib/systems/examples.nix +++ b/lib/systems/examples.nix @@ -79,7 +79,7 @@ rec { androidNdkVersion = "26"; libc = "bionic"; useAndroidPrebuilt = false; - useLLVM = true; + toolchain = "llvm"; }; pogoplug4 = { @@ -330,19 +330,19 @@ rec { config = "aarch64-w64-mingw32"; libc = "ucrt"; rust.rustcTarget = "aarch64-pc-windows-gnullvm"; - useLLVM = true; + toolchain = "llvm"; }; # BSDs aarch64-freebsd = { config = "aarch64-unknown-freebsd"; - useLLVM = true; + toolchain = "llvm"; }; x86_64-freebsd = { config = "x86_64-unknown-freebsd"; - useLLVM = true; + toolchain = "llvm"; }; x86_64-netbsd = { @@ -352,12 +352,12 @@ rec { # this is broken and never worked fully x86_64-netbsd-llvm = { config = "x86_64-unknown-netbsd"; - useLLVM = true; + toolchain = "llvm"; }; x86_64-openbsd = { config = "x86_64-unknown-openbsd"; - useLLVM = true; + toolchain = "llvm"; }; # @@ -366,13 +366,13 @@ rec { wasi32 = { config = "wasm32-unknown-wasi"; - useLLVM = true; + toolchain = "llvm"; }; wasm32-unknown-none = { config = "wasm32-unknown-none"; rust.rustcTarget = "wasm32-unknown-unknown"; - useLLVM = true; + toolchain = "llvm"; }; # Ghcjs diff --git a/pkgs/build-support/cc-wrapper/default.nix b/pkgs/build-support/cc-wrapper/default.nix index d9174df31a2a1..d69f6a13fbe93 100644 --- a/pkgs/build-support/cc-wrapper/default.nix +++ b/pkgs/build-support/cc-wrapper/default.nix @@ -121,7 +121,7 @@ let useGccForLibs = useCcForLibs && libcxx == null && !targetPlatform.isDarwin - && !(targetPlatform.useLLVM or false) + && !(targetPlatform.toolchain == "llvm") && !(targetPlatform.useAndroidPrebuilt or false) && !(targetPlatform.isiOS or false) && gccForLibs != null; @@ -514,7 +514,7 @@ stdenvNoCC.mkDerivation { + optionalString (isClang && targetPlatform.isLinux && !(targetPlatform.useAndroidPrebuilt or false) - && !(targetPlatform.useLLVM or false) + && !(targetPlatform.toolchain == "llvm") && gccForLibs != null) ('' echo "--gcc-toolchain=${gccForLibs}" >> $out/nix-support/cc-cflags diff --git a/pkgs/by-name/cy/cyrus_sasl/package.nix b/pkgs/by-name/cy/cyrus_sasl/package.nix index 68d019ca2619b..6036bc91c0afe 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.targetPlatform.toolchain == "llvm") [ "--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 f07ab5b6aebcb..aed1d2ea2b3dc 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.toolchain == "llvm") ./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.toolchain == "llvm") 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.toolchain == "llvm") "--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 5eef5475390ed..c7aa9d8e9fa4a 100644 --- a/pkgs/by-name/ke/kexec-tools/package.nix +++ b/pkgs/by-name/ke/kexec-tools/package.nix @@ -25,7 +25,7 @@ stdenv.mkDerivation rec { 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; + ] ++ lib.optional (stdenv.hostPlatform.toolchain == "llvm") ./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 9ff313c84a65e..b939508cecc41 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.toolchain == "llvm"); # Hack to ensure that patchelf --shrink-rpath get rids of a $TMPDIR reference. preFixup = "rm -rfv src"; diff --git a/pkgs/by-name/so/sourceHighlight/package.nix b/pkgs/by-name/so/sourceHighlight/package.nix index 16eaa9e42e6ab..613dd187822a3 100644 --- a/pkgs/by-name/so/sourceHighlight/package.nix +++ b/pkgs/by-name/so/sourceHighlight/package.nix @@ -62,7 +62,7 @@ stdenv.mkDerivation rec { nativeBuildInputs = [ updateAutotoolsGnuConfigScriptsHook ]; buildInputs = [ boost ] - ++ lib.optional (stdenv.targetPlatform.useLLVM or false) ( + ++ lib.optional (stdenv.targetPlatform.toolchain == "llvm") ( llvmPackages.compiler-rt.override { doFakeLibgcc = true; } @@ -92,7 +92,7 @@ stdenv.mkDerivation rec { maintainers = with maintainers; [ SuperSandro2000 ]; }; } -// lib.optionalAttrs (stdenv.targetPlatform.useLLVM or false) { +// lib.optionalAttrs (stdenv.targetPlatform.toolchain == "llvm") { # Force linking to "libgcc" so tests pass NIX_CFLAGS_COMPILE = "-lgcc"; } diff --git a/pkgs/development/compilers/llvm/common/compiler-rt/default.nix b/pkgs/development/compilers/llvm/common/compiler-rt/default.nix index 50c8a3c96834a..6a6a3d0792439 100644 --- a/pkgs/development/compilers/llvm/common/compiler-rt/default.nix +++ b/pkgs/development/compilers/llvm/common/compiler-rt/default.nix @@ -33,7 +33,7 @@ let - useLLVM = stdenv.hostPlatform.useLLVM or false; + useLLVM = stdenv.hostPlatform.toolchain == "llvm"; bareMetal = stdenv.hostPlatform.parsed.kernel.name == "none"; haveLibc = stdenv.cc.libc != null; # TODO: Make this account for GCC having libstdcxx, which will help diff --git a/pkgs/development/compilers/llvm/common/default.nix b/pkgs/development/compilers/llvm/common/default.nix index 102a43161e3d8..e4d7f5d9b8a76 100644 --- a/pkgs/development/compilers/llvm/common/default.nix +++ b/pkgs/development/compilers/llvm/common/default.nix @@ -617,7 +617,7 @@ let clang = if stdenv.targetPlatform.libc == null then tools.clangNoLibc - else if stdenv.targetPlatform.useLLVM or false then + else if stdenv.targetPlatform.toolchain == "llvm" then tools.clangUseLLVM else if (pkgs.targetPackages.stdenv or args.stdenv).cc.isGNU then tools.libstdcxxClang @@ -755,7 +755,7 @@ 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) '' + + lib.optionalString (!stdenv.targetPlatform.isWasm && stdenv.targetPlatform.toolchain == "llvm") '' echo "-lunwind" >> $out/nix-support/cc-ldflags '' + lib.optionalString stdenv.targetPlatform.isWasm '' @@ -777,7 +777,7 @@ let ++ lib.optional ( !stdenv.targetPlatform.isWasm && !stdenv.targetPlatform.isFreeBSD - && stdenv.targetPlatform.useLLVM or false + && stdenv.targetPlatform.toolchain == "llvm" ) "-lunwind" ++ lib.optional stdenv.targetPlatform.isWasm "-fno-exceptions"; nixSupport.cc-ldflags = lib.optionals ( @@ -810,7 +810,7 @@ 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) '' + + lib.optionalString (!stdenv.targetPlatform.isWasm && stdenv.targetPlatform.toolchain == "llvm") '' echo "-lunwind" >> $out/nix-support/cc-ldflags '' + lib.optionalString stdenv.targetPlatform.isWasm '' @@ -832,7 +832,7 @@ let ++ lib.optional ( !stdenv.targetPlatform.isWasm && !stdenv.targetPlatform.isFreeBSD - && stdenv.targetPlatform.useLLVM or false + && stdenv.targetPlatform.toolchain == "llvm" ) "-lunwind" ++ lib.optional stdenv.targetPlatform.isWasm "-fno-exceptions"; nixSupport.cc-ldflags = lib.optionals ( @@ -1057,7 +1057,7 @@ 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.toolchain == "llvm" then overrideCC args.stdenv buildLlvmTools.clangWithLibcAndBasicRtAndLibcxx else args.stdenv; @@ -1066,7 +1066,7 @@ let patches = compiler-rtPatches; inherit stdenv; } - // lib.optionalAttrs (stdenv.hostPlatform.useLLVM or false) { + // lib.optionalAttrs (stdenv.hostPlatform.toolchain == "llvm") { libxcrypt = (libxcrypt.override { inherit stdenv; }).overrideAttrs (old: { configureFlags = old.configureFlags ++ [ "--disable-symvers" ]; }); @@ -1075,7 +1075,7 @@ let compiler-rt-no-libc = callPackage ./compiler-rt { patches = compiler-rtPatches; - doFakeLibgcc = stdenv.hostPlatform.useLLVM or false; + doFakeLibgcc = stdenv.hostPlatform.toolchain == "llvm"; 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 c4ada0bf669be..111fb0f94b80d 100644 --- a/pkgs/development/compilers/llvm/common/libcxx/default.nix +++ b/pkgs/development/compilers/llvm/common/libcxx/default.nix @@ -31,7 +31,7 @@ let runtimes = [ "libcxx" ] ++ lib.optional (cxxabi == null) "libcxxabi"; # Note: useLLVM is likely false for Darwin but true under pkgsLLVM - useLLVM = stdenv.hostPlatform.useLLVM or false; + useLLVM = stdenv.hostPlatform.toolchain == "llvm"; src' = if monorepoSrc != null then runCommand "${pname}-src-${version}" { inherit (monorepoSrc) passthru; } ('' diff --git a/pkgs/development/compilers/rust/1_83.nix b/pkgs/development/compilers/rust/1_83.nix index 8232079a2adcd..d6c1e710d5565 100644 --- a/pkgs/development/compilers/rust/1_83.nix +++ b/pkgs/development/compilers/rust/1_83.nix @@ -36,7 +36,7 @@ let { enableSharedLibraries = true; } - // lib.optionalAttrs (stdenv.targetPlatform.useLLVM or false) { + // lib.optionalAttrs (stdenv.targetPlatform.toolchain == "llvm") { # Force LLVM to compile using clang + LLVM libs when targeting pkgsLLVM stdenv = pkgSet.stdenv.override { allowedRequisites = null; @@ -59,7 +59,7 @@ 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.toolchain == "llvm") then callPackage ( { pkgs, diff --git a/pkgs/development/compilers/rust/rustc.nix b/pkgs/development/compilers/rust/rustc.nix index af287fcc9079d..b9852289452a8 100644 --- a/pkgs/development/compilers/rust/rustc.nix +++ b/pkgs/development/compilers/rust/rustc.nix @@ -52,7 +52,7 @@ let concatStringsSep ; inherit (darwin.apple_sdk.frameworks) Security; - useLLVM = stdenv.targetPlatform.useLLVM or false; + useLLVM = stdenv.targetPlatform.toolchain == "llvm"; in stdenv.mkDerivation (finalAttrs: { pname = "${targetPackages.stdenv.cc.targetPrefix}rustc"; @@ -207,7 +207,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.targetPlatform.toolchain == "llvm")) [ "--enable-profiler" # build libprofiler_builtins ] ++ optionals stdenv.buildPlatform.isMusl [ diff --git a/pkgs/development/libraries/kerberos/krb5.nix b/pkgs/development/libraries/kerberos/krb5.nix index 7a4df60f0ae5b..24aad2a47041e 100644 --- a/pkgs/development/libraries/kerberos/krb5.nix +++ b/pkgs/development/libraries/kerberos/krb5.nix @@ -89,7 +89,7 @@ stdenv.mkDerivation rec { ++ lib.optionals ( stdenv.hostPlatform.isLinux && stdenv.hostPlatform.libc != "bionic" - && !(stdenv.hostPlatform.useLLVM or false) + && !(stdenv.hostPlatform.toolchain == "llvm") ) [ keyutils ] ++ lib.optionals withLdap [ openldap ] ++ lib.optionals withLibedit [ libedit ] diff --git a/pkgs/development/libraries/libunwind/default.nix b/pkgs/development/libraries/libunwind/default.nix index f0f7de192f448..9c8107313719f 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.targetPlatform.toolchain == "llvm") (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 9fd523a70610c..00ecc2ac1f525 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.targetPlatform.toolchain == "llvm") { NIX_CFLAGS_COMPILE = "-DHAVE_SECURE_GETENV"; }; diff --git a/pkgs/development/libraries/openssl/default.nix b/pkgs/development/libraries/openssl/default.nix index f0cf68f8b6aa6..fe033d1425b6c 100644 --- a/pkgs/development/libraries/openssl/default.nix +++ b/pkgs/development/libraries/openssl/default.nix @@ -98,7 +98,7 @@ let ++ lib.optional static "etc"; setOutputFlags = false; separateDebugInfo = - !stdenv.hostPlatform.isDarwin && !(stdenv.hostPlatform.useLLVM or false) && stdenv.cc.isGNU; + !stdenv.hostPlatform.isDarwin && !(stdenv.hostPlatform.toolchain == "llvm") && stdenv.cc.isGNU; nativeBuildInputs = lib.optional (!stdenv.hostPlatform.isWindows) makeBinaryWrapper diff --git a/pkgs/development/libraries/quictls/default.nix b/pkgs/development/libraries/quictls/default.nix index 63ddc6313d6a7..2984b25a495bd 100644 --- a/pkgs/development/libraries/quictls/default.nix +++ b/pkgs/development/libraries/quictls/default.nix @@ -64,7 +64,7 @@ stdenv.mkDerivation rec { separateDebugInfo = !stdenv.hostPlatform.isDarwin && - !(stdenv.hostPlatform.useLLVM or false) && + !(stdenv.hostPlatform.toolchain == "llvm") && stdenv.cc.isGNU; # TODO(@Ericson2314): Improve with mass rebuild diff --git a/pkgs/development/libraries/silgraphite/graphite2.nix b/pkgs/development/libraries/silgraphite/graphite2.nix index 7289820b60df1..b4055e7e3938f 100644 --- a/pkgs/development/libraries/silgraphite/graphite2.nix +++ b/pkgs/development/libraries/silgraphite/graphite2.nix @@ -32,7 +32,7 @@ stdenv.mkDerivation (finalAttrs: { ]; buildInputs = [ freetype ] - ++ lib.optional (stdenv.targetPlatform.useLLVM or false) ( + ++ lib.optional (stdenv.targetPlatform.toolchain == "llvm") ( llvmPackages.compiler-rt.override { doFakeLibgcc = true; } diff --git a/pkgs/development/python-modules/jedi/default.nix b/pkgs/development/python-modules/jedi/default.nix index 8e31fe41c7805..e9676a63a5d11 100644 --- a/pkgs/development/python-modules/jedi/default.nix +++ b/pkgs/development/python-modules/jedi/default.nix @@ -49,7 +49,11 @@ buildPythonPackage rec { # sensitive to platform, causes false negatives on darwin "test_import" ] - ++ lib.optionals (stdenv.targetPlatform.useLLVM or false) [ + ++ lib.optionals (stdenv.hostPlatform.isAarch64 && pythonOlder "3.9") [ + # AssertionError: assert 'foo' in ['setup'] + "test_init_extension_module" + ] + ++ lib.optionals (stdenv.targetPlatform.toolchain == "llvm") [ # 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 0735cf8f2c9e7..4f2bc95bfa3fc 100644 --- a/pkgs/development/python-modules/mako/default.nix +++ b/pkgs/development/python-modules/mako/default.nix @@ -61,7 +61,7 @@ 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.targetPlatform.toolchain == "llvm") "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 425775e9dd163..4ae9694a1bb27 100644 --- a/pkgs/os-specific/linux/systemd/default.nix +++ b/pkgs/os-specific/linux/systemd/default.nix @@ -375,7 +375,7 @@ stdenv.mkDerivation (finalAttrs: { ++ lib.optionals withPasswordQuality [ libpwquality ] ++ lib.optionals withQrencode [ qrencode ] ++ lib.optionals withLibarchive [ libarchive ] - ++ lib.optional (withBootloader && stdenv.targetPlatform.useLLVM or false) (llvmPackages.compiler-rt.override { + ++ lib.optional (withBootloader && stdenv.targetPlatform.toolchain == "llvm") (llvmPackages.compiler-rt.override { doFakeLibgcc = true; }) ; diff --git a/pkgs/os-specific/windows/default.nix b/pkgs/os-specific/windows/default.nix index 59806318a23ec..a7d376021dfe3 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.toolchain == "llvm" 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 69f8f2ac8801f..6620dd7c69342 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.toolchain == "llvm") "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.toolchain == "llvm") "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/stdenv/cross/default.nix b/pkgs/stdenv/cross/default.nix index 69ea14be5c83d..7fdfcdfcedb35 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/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 689500e01f747..2bafd50d0151c 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -61,7 +61,7 @@ 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 + (if stdenvNoCC.hostPlatform.isDarwin || stdenvNoCC.hostPlatform.toolchain == "llvm" then overrideCC stdenvNoCC buildPackages.llvmPackages.clangNoCompilerRt else gccCrossLibcStdenv) else mkStdenvNoLibs stdenv; @@ -69,7 +69,7 @@ with pkgs; stdenvNoLibc = if stdenvNoCC.hostPlatform != stdenvNoCC.buildPlatform then - (if stdenvNoCC.hostPlatform.isDarwin || stdenvNoCC.hostPlatform.useLLVM or false + (if stdenvNoCC.hostPlatform.isDarwin || stdenvNoCC.hostPlatform.toolchain == "llvm" then overrideCC stdenvNoCC buildPackages.llvmPackages.clangNoLibc else gccCrossLibcStdenv) else mkStdenvNoLibs stdenv; @@ -6077,7 +6077,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.toolchain == "llvm") ; }; bintools = binutilsNoLibc; @@ -7850,11 +7850,13 @@ with pkgs; # In other words, try to only use this in wrappers, and only use those # wrappers from the next stage. bintools-unwrapped = let - inherit (stdenv.targetPlatform) linker; - in if linker == "lld" then llvmPackages.bintools-unwrapped - else if linker == "cctools" then darwin.binutils-unwrapped - else if linker == "bfd" then binutils-unwrapped - else if linker == "gold" then binutils-unwrapped.override { enableGoldDefault = true; } + # We should remove the linker inherit and solely go off of bintools in the future. + # The linker should be specified inside package build systems (cmake, meson, etc). + inherit (stdenv.targetPlatform) linker bintools; + in if linker == "lld" || bintools == "llvm" then llvmPackages.bintools-unwrapped + else if linker == "cctools" || bintools == "apple" then darwin.binutils-unwrapped + else if linker == "bfd" || bintools == "gnu" then binutils-unwrapped + else if linker == "gold" then binutils-unwrapped.override { enableGoldDefault = true; } else null; bintoolsNoLibc = wrapBintoolsWith { bintools = bintools-unwrapped; @@ -9172,7 +9174,7 @@ 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.toolchain != "llvm") { # other possible values: win32 or posix model = "mcf"; # For win32 or posix set this to null @@ -9640,7 +9642,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.toolchain == "llvm" then overrideCC stdenv buildPackages.llvmPackages.tools.clangNoLibcxx else stdenv; }; @@ -12161,7 +12163,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.targetPlatform.toolchain == "llvm" then overrideCC stdenv buildPackages.llvmPackages.clangNoLibcxx else stdenv; }; diff --git a/pkgs/top-level/stage.nix b/pkgs/top-level/stage.nix index 1cedd8dd18458..e0c8304aaa554 100644 --- a/pkgs/top-level/stage.nix +++ b/pkgs/top-level/stage.nix @@ -202,8 +202,7 @@ let # This is currently not possible when compiling natively, # so we don't need to check hostPlatform != buildPlatform. crossSystem = stdenv.hostPlatform // { - useLLVM = true; - linker = "lld"; + toolchain = "llvm"; }; }; @@ -217,7 +216,8 @@ let # This is currently not possible when compiling natively, # so we don't need to check hostPlatform != buildPlatform. crossSystem = stdenv.hostPlatform // { - useArocc = true; + toolchain = "llvm"; + cc = "arocc"; linker = "lld"; }; }; @@ -232,7 +232,8 @@ let # This is currently not possible when compiling natively, # so we don't need to check hostPlatform != buildPlatform. crossSystem = stdenv.hostPlatform // { - useZig = true; + toolchain = "llvm"; + cc = "zig"; linker = "lld"; }; }; From 09a98859da4e24341d56b285afe4bd8aaf47c610 Mon Sep 17 00:00:00 2001 From: Tristan Ross Date: Fri, 27 Dec 2024 08:42:26 -0800 Subject: [PATCH 2/2] lib.systems: introduce libcxx, unwinderlib, and rtlib --- lib/systems/default.nix | 18 +++++++++++++++++- pkgs/build-support/cc-wrapper/default.nix | 4 ++-- pkgs/by-name/cy/cyrus_sasl/package.nix | 2 +- pkgs/by-name/el/elfutils/package.nix | 6 +++--- pkgs/by-name/ke/kexec-tools/package.nix | 18 +++++++++++------- pkgs/by-name/so/sourceHighlight/package.nix | 4 ++-- .../libraries/libunwind/default.nix | 2 +- pkgs/development/libraries/libva/default.nix | 2 +- pkgs/development/libraries/openssl/default.nix | 3 ++- pkgs/development/libraries/quictls/default.nix | 2 +- .../libraries/silgraphite/graphite2.nix | 2 +- .../python-modules/jedi/default.nix | 2 +- .../python-modules/mako/default.nix | 2 +- pkgs/os-specific/linux/systemd/default.nix | 2 +- pkgs/os-specific/windows/default.nix | 2 +- pkgs/servers/x11/xorg/overrides.nix | 4 ++-- pkgs/top-level/all-packages.nix | 6 +++--- pkgs/top-level/stage.nix | 9 ++++++--- 18 files changed, 57 insertions(+), 33 deletions(-) diff --git a/lib/systems/default.nix b/lib/systems/default.nix index 38fbad3898a57..a215583e48ec1 100644 --- a/lib/systems/default.nix +++ b/lib/systems/default.nix @@ -105,12 +105,17 @@ let "clang" else "gcc"; - bintools = if final.toolchain == "bintools" then + bintools = if final.toolchain == "llvm" then "llvm" else if final.toolchain == "apple" then "apple" else "gnu"; + libcxx = + /**/ if final.toolchain == "llvm" then "libcxx" + else if final.toolchain == "gnu" then "libstdcxx" + else null; + libc = /**/ if final.isDarwin then "libSystem" else if final.isMinGW then "msvcrt" @@ -129,6 +134,17 @@ let else if final.isNone then "newlib" # TODO(@Ericson2314) think more about other operating systems else "native/impure"; + + unwinderlib = + /**/ if final.toolchain == "llvm" then "libunwinder" + else if final.toolchain == "gnu" then "libgcc_s" + else null; + + rtlib = + /**/ if final.toolchain == "llvm" then "compiler-rt" + else if final.toolchain == "gnu" then "libgcc" + else null; + # 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 diff --git a/pkgs/build-support/cc-wrapper/default.nix b/pkgs/build-support/cc-wrapper/default.nix index d69f6a13fbe93..8cc19deda4c66 100644 --- a/pkgs/build-support/cc-wrapper/default.nix +++ b/pkgs/build-support/cc-wrapper/default.nix @@ -120,8 +120,8 @@ let useGccForLibs = useCcForLibs && libcxx == null + && targetPlatform.rtlib == "libgcc" && !targetPlatform.isDarwin - && !(targetPlatform.toolchain == "llvm") && !(targetPlatform.useAndroidPrebuilt or false) && !(targetPlatform.isiOS or false) && gccForLibs != null; @@ -514,7 +514,7 @@ stdenvNoCC.mkDerivation { + optionalString (isClang && targetPlatform.isLinux && !(targetPlatform.useAndroidPrebuilt or false) - && !(targetPlatform.toolchain == "llvm") + && targetPlatform.rtlib == "libgcc" && gccForLibs != null) ('' echo "--gcc-toolchain=${gccForLibs}" >> $out/nix-support/cc-cflags diff --git a/pkgs/by-name/cy/cyrus_sasl/package.nix b/pkgs/by-name/cy/cyrus_sasl/package.nix index 6036bc91c0afe..8ebece88d7cfe 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.toolchain == "llvm") [ + ++ lib.optionals (stdenv.cc.isClang && !stdenv.hostPlatform.isDarwin) [ "--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 aed1d2ea2b3dc..80ca5846271c7 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.toolchain == "llvm") ./cxx-header-collision.patch; + ++ lib.optional (stdenv.hostPlatform.libcxx == "libcxx") ./cxx-header-collision.patch; postPatch = '' @@ -94,7 +94,7 @@ stdenv.mkDerivation rec { bzip2 ] ++ lib.optional enableDebuginfod pkg-config - ++ lib.optional (stdenv.targetPlatform.toolchain == "llvm") autoreconfHook; + ++ lib.optional (stdenv.hostPlatform.libcxx == "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.toolchain == "llvm") "--disable-demangler" + ++ lib.optional (stdenv.hostPlatform.unwinderlib == "libunwind") "--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 c7aa9d8e9fa4a..5ecd41e9851ca 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.toolchain == "llvm") ./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/so/sourceHighlight/package.nix b/pkgs/by-name/so/sourceHighlight/package.nix index 613dd187822a3..774c7b7679676 100644 --- a/pkgs/by-name/so/sourceHighlight/package.nix +++ b/pkgs/by-name/so/sourceHighlight/package.nix @@ -62,7 +62,7 @@ stdenv.mkDerivation rec { nativeBuildInputs = [ updateAutotoolsGnuConfigScriptsHook ]; buildInputs = [ boost ] - ++ lib.optional (stdenv.targetPlatform.toolchain == "llvm") ( + ++ lib.optional (stdenv.hostPlatform.rtlib == "compiler-rt") ( llvmPackages.compiler-rt.override { doFakeLibgcc = true; } @@ -92,7 +92,7 @@ stdenv.mkDerivation rec { maintainers = with maintainers; [ SuperSandro2000 ]; }; } -// lib.optionalAttrs (stdenv.targetPlatform.toolchain == "llvm") { +// lib.optionalAttrs (stdenv.targetPlatform.rtlib == "libunwind") { # Force linking to "libgcc" so tests pass NIX_CFLAGS_COMPILE = "-lgcc"; } diff --git a/pkgs/development/libraries/libunwind/default.nix b/pkgs/development/libraries/libunwind/default.nix index 9c8107313719f..687297a1121bc 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.toolchain == "llvm") (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 00ecc2ac1f525..667c03e8a5aed 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.toolchain == "llvm") { + // 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 fe033d1425b6c..f6022fb2258a4 100644 --- a/pkgs/development/libraries/openssl/default.nix +++ b/pkgs/development/libraries/openssl/default.nix @@ -98,7 +98,8 @@ let ++ lib.optional static "etc"; setOutputFlags = false; separateDebugInfo = - !stdenv.hostPlatform.isDarwin && !(stdenv.hostPlatform.toolchain == "llvm") && stdenv.cc.isGNU; + # Using "cc.isClang" causes infinite recursion. + !stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.cc != "clang" && stdenv.cc.isGNU; nativeBuildInputs = lib.optional (!stdenv.hostPlatform.isWindows) makeBinaryWrapper diff --git a/pkgs/development/libraries/quictls/default.nix b/pkgs/development/libraries/quictls/default.nix index 2984b25a495bd..55044aabc1b01 100644 --- a/pkgs/development/libraries/quictls/default.nix +++ b/pkgs/development/libraries/quictls/default.nix @@ -64,7 +64,7 @@ stdenv.mkDerivation rec { separateDebugInfo = !stdenv.hostPlatform.isDarwin && - !(stdenv.hostPlatform.toolchain == "llvm") && + !stdenv.cc.isClang && stdenv.cc.isGNU; # TODO(@Ericson2314): Improve with mass rebuild diff --git a/pkgs/development/libraries/silgraphite/graphite2.nix b/pkgs/development/libraries/silgraphite/graphite2.nix index b4055e7e3938f..00f1a16941c29 100644 --- a/pkgs/development/libraries/silgraphite/graphite2.nix +++ b/pkgs/development/libraries/silgraphite/graphite2.nix @@ -32,7 +32,7 @@ stdenv.mkDerivation (finalAttrs: { ]; buildInputs = [ freetype ] - ++ lib.optional (stdenv.targetPlatform.toolchain == "llvm") ( + ++ lib.optional (stdenv.hostPlatform.rtlib == "compiler-rt") ( llvmPackages.compiler-rt.override { doFakeLibgcc = true; } diff --git a/pkgs/development/python-modules/jedi/default.nix b/pkgs/development/python-modules/jedi/default.nix index e9676a63a5d11..49792d7577426 100644 --- a/pkgs/development/python-modules/jedi/default.nix +++ b/pkgs/development/python-modules/jedi/default.nix @@ -53,7 +53,7 @@ buildPythonPackage rec { # AssertionError: assert 'foo' in ['setup'] "test_init_extension_module" ] - ++ lib.optionals (stdenv.targetPlatform.toolchain == "llvm") [ + ++ lib.optionals (stdenv.cc.isClang && !stdenv.hostPlatform.isDarwin) [ # 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 4f2bc95bfa3fc..d8eea81246b9b 100644 --- a/pkgs/development/python-modules/mako/default.nix +++ b/pkgs/development/python-modules/mako/default.nix @@ -61,7 +61,7 @@ buildPythonPackage rec { "test_bytestring_passthru" ] # https://github.com/sqlalchemy/mako/issues/408 - ++ lib.optional (stdenv.targetPlatform.toolchain == "llvm") "test_future_import"; + ++ lib.optional (stdenv.cc.isClang && !stdenv.hostPlatform.isDarwin) "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 4ae9694a1bb27..ad09788f4af4a 100644 --- a/pkgs/os-specific/linux/systemd/default.nix +++ b/pkgs/os-specific/linux/systemd/default.nix @@ -375,7 +375,7 @@ stdenv.mkDerivation (finalAttrs: { ++ lib.optionals withPasswordQuality [ libpwquality ] ++ lib.optionals withQrencode [ qrencode ] ++ lib.optionals withLibarchive [ libarchive ] - ++ lib.optional (withBootloader && stdenv.targetPlatform.toolchain == "llvm") (llvmPackages.compiler-rt.override { + ++ lib.optional (withBootloader && stdenv.hostPlatform.rtlib == "compiler-rt") (llvmPackages.compiler-rt.override { doFakeLibgcc = true; }) ; diff --git a/pkgs/os-specific/windows/default.nix b/pkgs/os-specific/windows/default.nix index a7d376021dfe3..42ab0c9d75c8f 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.toolchain == "llvm" then + if stdenv.cc.isClang 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 6620dd7c69342..e865d1e733fd5 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.toolchain == "llvm") "ac_cv_path_RAWCPP=cpp"; + ++ lib.optional (stdenv.cc.isClang && !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.toolchain == "llvm") "ac_cv_path_RAWCPP=cpp"; + ++ lib.optional (stdenv.cc.isClang && !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/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 2bafd50d0151c..c9ab7bce9b38b 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -61,7 +61,7 @@ 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.toolchain == "llvm" + (if stdenvNoCC.hostPlatform.cc == "clang" then overrideCC stdenvNoCC buildPackages.llvmPackages.clangNoCompilerRt else gccCrossLibcStdenv) else mkStdenvNoLibs stdenv; @@ -69,7 +69,7 @@ with pkgs; stdenvNoLibc = if stdenvNoCC.hostPlatform != stdenvNoCC.buildPlatform then - (if stdenvNoCC.hostPlatform.isDarwin || stdenvNoCC.hostPlatform.toolchain == "llvm" + (if stdenvNoCC.hostPlatform.cc == "clang" then overrideCC stdenvNoCC buildPackages.llvmPackages.clangNoLibc else gccCrossLibcStdenv) else mkStdenvNoLibs stdenv; @@ -12163,7 +12163,7 @@ with pkgs; busybox = callPackage ../os-specific/linux/busybox { # Fixes libunwind from being dynamically linked to a static binary. - stdenv = if stdenv.targetPlatform.toolchain == "llvm" 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 e0c8304aaa554..b73886e192192 100644 --- a/pkgs/top-level/stage.nix +++ b/pkgs/top-level/stage.nix @@ -118,6 +118,9 @@ let inherit (self.pkgsBuildHost.xorg) lndir; }; + cleanToolchain = platform: builtins.removeAttrs platform + [ "toolchain" "cc" "bintools" "linker" "libc" "libcxx" "unwinderlib" "rtlib" ]; + stdenvBootstappingAndPlatforms = self: super: let withFallback = thisPkgs: (if adjacentPackages == null then self else thisPkgs) @@ -201,7 +204,7 @@ let # Bootstrap a cross stdenv using the LLVM toolchain. # This is currently not possible when compiling natively, # so we don't need to check hostPlatform != buildPlatform. - crossSystem = stdenv.hostPlatform // { + crossSystem = (cleanToolchain stdenv.hostPlatform) // { toolchain = "llvm"; }; }; @@ -215,7 +218,7 @@ let # Bootstrap a cross stdenv using the Aro C compiler. # This is currently not possible when compiling natively, # so we don't need to check hostPlatform != buildPlatform. - crossSystem = stdenv.hostPlatform // { + crossSystem = (cleanToolchain stdenv.hostPlatform) // { toolchain = "llvm"; cc = "arocc"; linker = "lld"; @@ -231,7 +234,7 @@ let # Bootstrap a cross stdenv using the Zig toolchain. # This is currently not possible when compiling natively, # so we don't need to check hostPlatform != buildPlatform. - crossSystem = stdenv.hostPlatform // { + crossSystem = (cleanToolchain stdenv.hostPlatform) // { toolchain = "llvm"; cc = "zig"; linker = "lld";