From e9ca6038eb5f4398fc57feb4084b7df4afaa6d7d Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Thu, 16 Nov 2023 19:07:23 +0100 Subject: rustc,cargo: 1.73.0 -> 1.74.0 The BOOTSTRAP_ARGS patch is no longer necessary since 863d2fddd79 ("Pass `-jN` from Make to `BOOTSTRAP_ARGS`"). We now have to set sysconfdir, because since 350ead87205 ("add sanity checks for user write access on `x install`"), the build system will check it can write there, even though nothing actually gets installed there. (Previously it defaulted to /etc.) --- pkgs/development/compilers/rust/1_73.nix | 60 ------------------------------- pkgs/development/compilers/rust/1_74.nix | 60 +++++++++++++++++++++++++++++++ pkgs/development/compilers/rust/rustc.nix | 9 +---- 3 files changed, 61 insertions(+), 68 deletions(-) delete mode 100644 pkgs/development/compilers/rust/1_73.nix create mode 100644 pkgs/development/compilers/rust/1_74.nix (limited to 'pkgs/development/compilers') diff --git a/pkgs/development/compilers/rust/1_73.nix b/pkgs/development/compilers/rust/1_73.nix deleted file mode 100644 index 37e75e0a7a4f..000000000000 --- a/pkgs/development/compilers/rust/1_73.nix +++ /dev/null @@ -1,60 +0,0 @@ -# New rust versions should first go to staging. -# Things to check after updating: -# 1. Rustc should produce rust binaries on x86_64-linux, aarch64-linux and x86_64-darwin: -# i.e. nix-shell -p fd or @GrahamcOfBorg build fd on github -# This testing can be also done by other volunteers as part of the pull -# request review, in case platforms cannot be covered. -# 2. The LLVM version used for building should match with rust upstream. -# Check the version number in the src/llvm-project git submodule in: -# https://github.com/rust-lang/rust/blob//.gitmodules -# 3. Firefox and Thunderbird should still build on x86_64-linux. - -{ stdenv, lib -, buildPackages -, targetPackages -, newScope, callPackage -, CoreFoundation, Security, SystemConfiguration -, pkgsBuildTarget, pkgsBuildBuild, pkgsBuildHost -, makeRustPlatform -, llvmPackages_16, llvm_16 -} @ args: - -import ./default.nix { - rustcVersion = "1.73.0"; - rustcSha256 = "sha256-ltYubR8tId96yKyzuYgkEfnnxwNhc/fy7enh8faxuzo="; - - llvmSharedForBuild = pkgsBuildBuild.llvmPackages_16.libllvm.override { enableSharedLibraries = true; }; - llvmSharedForHost = pkgsBuildHost.llvmPackages_16.libllvm.override { enableSharedLibraries = true; }; - llvmSharedForTarget = pkgsBuildTarget.llvmPackages_16.libllvm.override { enableSharedLibraries = true; }; - - # For use at runtime - llvmShared = llvm_16.override { enableSharedLibraries = true; }; - - # Expose llvmPackages used for rustc from rustc via passthru for LTO in Firefox - llvmPackages = llvmPackages_16; - - # Note: the version MUST be one version prior to the version we're - # building - bootstrapVersion = "1.72.1"; - - # fetch hashes by running `print-hashes.sh ${bootstrapVersion}` - bootstrapHashes = { - i686-unknown-linux-gnu = "a2a849a701dfd6643aaaa27e1ed5ac56aea00f7dee26c00d81c520808efd8911"; - x86_64-unknown-linux-gnu = "4fbd8df2000cf73c632d67a219a7fc153537ceffa2e6474491e3db71fdd5a410"; - x86_64-unknown-linux-musl = "94eddc044868a944a887d0b0375e393cb3acc6ebc034e3eac2ef2890ec7c0eac"; - arm-unknown-linux-gnueabihf = "a4d90538882181722d3e7cb8d7f021770e29e6b6d28375452e31a98049600110"; - armv7-unknown-linux-gnueabihf = "4c8e6b3c705a84d17894d3a1cfe744fb6083dd57c61868e67aac8b8512640ecb"; - aarch64-unknown-linux-gnu = "190d0473cbe619f163d33a6c4e2ef982abdd4178f73abc3194631cd2d5c8ed8b"; - aarch64-unknown-linux-musl = "c83778d1a95f6604bc3610a9070e8a8435c60a8bca5117aad71ffab36dea020f"; - x86_64-apple-darwin = "d01e7e9a7482f88a51b4fd888f06234274b49f51b5476c2d14fd46fd6e99ba9e"; - aarch64-apple-darwin = "42b0aaf269b6d9c60db13a64a920336d6064ab11d0c7043c9deeb9d4f67b3983"; - powerpc64le-unknown-linux-gnu = "9310df247efc072f2ca27354a875c4989cf3c29c9e545255a7472895d830163c"; - riscv64gc-unknown-linux-gnu = "1e08cd3ecd29d5bf247e3f7f4bc97318b439f0443dd9c99c36edcfa717d55101"; - }; - - selectRustPackage = pkgs: pkgs.rust_1_73; - - rustcPatches = [ ]; -} - -(builtins.removeAttrs args [ "pkgsBuildTarget" "pkgsBuildHost" "llvmPackages_16" "llvm_16"]) diff --git a/pkgs/development/compilers/rust/1_74.nix b/pkgs/development/compilers/rust/1_74.nix new file mode 100644 index 000000000000..72169a7b4d3f --- /dev/null +++ b/pkgs/development/compilers/rust/1_74.nix @@ -0,0 +1,60 @@ +# New rust versions should first go to staging. +# Things to check after updating: +# 1. Rustc should produce rust binaries on x86_64-linux, aarch64-linux and x86_64-darwin: +# i.e. nix-shell -p fd or @GrahamcOfBorg build fd on github +# This testing can be also done by other volunteers as part of the pull +# request review, in case platforms cannot be covered. +# 2. The LLVM version used for building should match with rust upstream. +# Check the version number in the src/llvm-project git submodule in: +# https://github.com/rust-lang/rust/blob//.gitmodules +# 3. Firefox and Thunderbird should still build on x86_64-linux. + +{ stdenv, lib +, buildPackages +, targetPackages +, newScope, callPackage +, CoreFoundation, Security, SystemConfiguration +, pkgsBuildTarget, pkgsBuildBuild, pkgsBuildHost +, makeRustPlatform +, llvmPackages_16, llvm_16 +} @ args: + +import ./default.nix { + rustcVersion = "1.74.0"; + rustcSha256 = "sha256-iCtYS8Mhxdz+d82qafJ3kGuTYlXveAj81cdJKSXPEEk="; + + llvmSharedForBuild = pkgsBuildBuild.llvmPackages_16.libllvm.override { enableSharedLibraries = true; }; + llvmSharedForHost = pkgsBuildHost.llvmPackages_16.libllvm.override { enableSharedLibraries = true; }; + llvmSharedForTarget = pkgsBuildTarget.llvmPackages_16.libllvm.override { enableSharedLibraries = true; }; + + # For use at runtime + llvmShared = llvm_16.override { enableSharedLibraries = true; }; + + # Expose llvmPackages used for rustc from rustc via passthru for LTO in Firefox + llvmPackages = llvmPackages_16; + + # Note: the version MUST be one version prior to the version we're + # building + bootstrapVersion = "1.73.0"; + + # fetch hashes by running `print-hashes.sh ${bootstrapVersion}` + bootstrapHashes = { + i686-unknown-linux-gnu = "6a088acbbda734d27e8b431499f1d746de7781673b88fead3aeae072be1d1a5a"; + x86_64-unknown-linux-gnu = "aa4cf0b7e66a9f5b7c623d4b340bb1ac2864a5f2c2b981f39f796245dc84f2cb"; + x86_64-unknown-linux-musl = "c888457d106ccd40288ca8db1cb966b23d719c9a128daca701ecc574c53773d4"; + arm-unknown-linux-gnueabihf = "9c29bb42786aedbb16ea71564eb06068a8b01cca6c6b8857f0c37f91dfba7134"; + armv7-unknown-linux-gnueabihf = "092b32b82c602c18279d76d9a96763e85030aa62cda64c1bc73fc1f6355bb99c"; + aarch64-unknown-linux-gnu = "e54d7d886ba413ae573151f668e76ea537f9a44406d3d29598269a4a536d12f6"; + aarch64-unknown-linux-musl = "f4e9ff895aa55558777585ad4debe2ccf3c0298cb5d65db67814f62428de4a5b"; + x86_64-apple-darwin = "ece9646bb153d4bc0f7f1443989de0cbcd8989a7d0bf3b7fb9956e1223954f0c"; + aarch64-apple-darwin = "9c96e4c57328fb438ee2d87aa75970ce89b4426b49780ccb3c16af0d7c617cc6"; + powerpc64le-unknown-linux-gnu = "8fa215ee3e274fb64364e7084613bc570369488fa22cf5bc8e0fe6dc810fe2b9"; + riscv64gc-unknown-linux-gnu = "381379a2381835428b2e7a396b3046581517356b7cc851e39e385aebd5700623"; + }; + + selectRustPackage = pkgs: pkgs.rust_1_74; + + rustcPatches = [ ]; +} + +(builtins.removeAttrs args [ "pkgsBuildTarget" "pkgsBuildHost" "llvmPackages_16" "llvm_16"]) diff --git a/pkgs/development/compilers/rust/rustc.nix b/pkgs/development/compilers/rust/rustc.nix index 1758abb6bea5..3a32dfc0c1e8 100644 --- a/pkgs/development/compilers/rust/rustc.nix +++ b/pkgs/development/compilers/rust/rustc.nix @@ -81,6 +81,7 @@ in stdenv.mkDerivation (finalAttrs: { ccForTarget = ccPrefixForStdenv pkgsBuildTarget.targetPackages.stdenv; cxxForTarget = cxxPrefixForStdenv pkgsBuildTarget.targetPackages.stdenv; in [ + "--sysconfdir=${placeholder "out"}/etc" "--release-channel=stable" "--set=build.rustc=${rustc}/bin/rustc" "--set=build.cargo=${cargo}/bin/cargo" @@ -178,14 +179,6 @@ in stdenv.mkDerivation (finalAttrs: { runHook postInstall '' else null; - # The bootstrap.py will generated a Makefile that then executes the build. - # The BOOTSTRAP_ARGS used by this Makefile must include all flags to pass - # to the bootstrap builder. - postConfigure = '' - substituteInPlace Makefile \ - --replace 'BOOTSTRAP_ARGS :=' 'BOOTSTRAP_ARGS := --jobs $(NIX_BUILD_CORES)' - ''; - # the rust build system complains that nix alters the checksums dontFixLibtool = true; -- cgit 1.4.1 From f81ea4a5e6ee213addcb05a2fde901131f1aca5c Mon Sep 17 00:00:00 2001 From: Nick Cao Date: Mon, 27 Nov 2023 21:11:01 -0500 Subject: glslang: fix build on riscv --- pkgs/development/compilers/glslang/default.nix | 3 +++ 1 file changed, 3 insertions(+) (limited to 'pkgs/development/compilers') diff --git a/pkgs/development/compilers/glslang/default.nix b/pkgs/development/compilers/glslang/default.nix index ff55201ebd03..0f75d09098be 100644 --- a/pkgs/development/compilers/glslang/default.nix +++ b/pkgs/development/compilers/glslang/default.nix @@ -26,6 +26,9 @@ stdenv.mkDerivation rec { nativeBuildInputs = [ cmake python3 bison jq ]; + # Workaround missing atomic ops with gcc <13 + env.LDFLAGS = lib.optionalString stdenv.hostPlatform.isRiscV "-latomic"; + postPatch = '' cp --no-preserve=mode -r "${spirv-tools.src}" External/spirv-tools ln -s "${spirv-headers.src}" External/spirv-tools/external/spirv-headers -- cgit 1.4.1 From 8b51cdd3bea18e806e3ed63add8e19292dfc84ec Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Wed, 18 Oct 2023 11:02:45 +0000 Subject: rustc: add a compiler wrapper MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We keep running into situations where we can't get the right combination of rustc flags through build systems into rustc. RUSTFLAGS is the only variable supported across build systems, but if RUSTFLAGS is set, Cargo will ignore all other ways of specifying rustc flags, including the target-specific ones, which we need to make dynamic musl builds work. (This is why pkgsCross.musl64.crosvm is currently broken — it works if you unset separateDebugInfo, which causes RUSTFLAGS not to be set.) So, we need to do the same thing we do for C and C++ compilers, and add a compiler wrapper so we can inject the flags we need, regardless of the build system. Currently the wrapper only supports a single mechanism for injecting flags — the NIX_RUSTFLAGS environment variable. As time goes on, we'll probably want to add additional features, like target-specific environment variables. --- doc/languages-frameworks/rust.section.md | 3 +-- pkgs/build-support/rust/rustc-wrapper/default.nix | 29 ++++++++++++++++++++++ .../rust/rustc-wrapper/rustc-wrapper.sh | 11 ++++++++ pkgs/development/compilers/rust/1_74.nix | 1 + pkgs/development/compilers/rust/binary.nix | 6 +++-- pkgs/development/compilers/rust/cargo.nix | 2 +- pkgs/development/compilers/rust/default.nix | 4 ++- pkgs/development/compilers/rust/rustc.nix | 12 ++++----- pkgs/top-level/all-packages.nix | 7 ++++-- 9 files changed, 61 insertions(+), 14 deletions(-) create mode 100644 pkgs/build-support/rust/rustc-wrapper/default.nix create mode 100644 pkgs/build-support/rust/rustc-wrapper/rustc-wrapper.sh (limited to 'pkgs/development/compilers') diff --git a/doc/languages-frameworks/rust.section.md b/doc/languages-frameworks/rust.section.md index d18b048b911b..9be381c0bfe2 100644 --- a/doc/languages-frameworks/rust.section.md +++ b/doc/languages-frameworks/rust.section.md @@ -963,7 +963,7 @@ repository: lib.updateManyAttrsByPath [{ path = [ "packages" "stable" ]; update = old: old.overrideScope(final: prev: { - rustc = prev.rustc.overrideAttrs (_: { + rustc-unwrapped = prev.rustc-unwrapped.overrideAttrs (_: { src = lib.cleanSource /git/scratch/rust; # do *not* put passthru.isReleaseTarball=true here }); @@ -1003,4 +1003,3 @@ nix-build $NIXPKGS -A package-broken-by-rust-changes The `git submodule update --init` and `cargo vendor` commands above require network access, so they can't be performed from within the `rustc` derivation, unfortunately. - diff --git a/pkgs/build-support/rust/rustc-wrapper/default.nix b/pkgs/build-support/rust/rustc-wrapper/default.nix new file mode 100644 index 000000000000..06cfcbb5457f --- /dev/null +++ b/pkgs/build-support/rust/rustc-wrapper/default.nix @@ -0,0 +1,29 @@ +{ lib, runCommand, rustc-unwrapped }: + +runCommand "${rustc-unwrapped.pname}-wrapper-${rustc-unwrapped.version}" { + preferLocalBuild = true; + strictDeps = true; + inherit (rustc-unwrapped) outputs; + + env = { + prog = "${rustc-unwrapped}/bin/rustc"; + }; + + passthru = { + inherit (rustc-unwrapped) pname version src llvm llvmPackages; + unwrapped = rustc-unwrapped; + }; + + meta = rustc-unwrapped.meta // { + description = "${rustc-unwrapped.meta.description} (wrapper script)"; + priority = 10; + }; +} '' + mkdir -p $out/bin + ln -s ${rustc-unwrapped}/bin/* $out/bin + rm $out/bin/rustc + substituteAll ${./rustc-wrapper.sh} $out/bin/rustc + chmod +x $out/bin/rustc + ${lib.concatMapStrings (output: "ln -s ${rustc-unwrapped.${output}} \$${output}\n") + (lib.remove "out" rustc-unwrapped.outputs)} +'' diff --git a/pkgs/build-support/rust/rustc-wrapper/rustc-wrapper.sh b/pkgs/build-support/rust/rustc-wrapper/rustc-wrapper.sh new file mode 100644 index 000000000000..866a6912e090 --- /dev/null +++ b/pkgs/build-support/rust/rustc-wrapper/rustc-wrapper.sh @@ -0,0 +1,11 @@ +#!@shell@ + +# Optionally print debug info. +if (( "${NIX_DEBUG:-0}" >= 1 )); then + echo "original flags to @prog@:" >&2 + printf " %q\n" "$@" >&2 + echo "extra flags after to @prog@:" >&2 + printf " %q\n" $NIX_RUSTFLAGS >&2 +fi + +exec @prog@ "$@" $NIX_RUSTFLAGS diff --git a/pkgs/development/compilers/rust/1_74.nix b/pkgs/development/compilers/rust/1_74.nix index 72169a7b4d3f..f8749a8b65c2 100644 --- a/pkgs/development/compilers/rust/1_74.nix +++ b/pkgs/development/compilers/rust/1_74.nix @@ -16,6 +16,7 @@ , CoreFoundation, Security, SystemConfiguration , pkgsBuildTarget, pkgsBuildBuild, pkgsBuildHost , makeRustPlatform +, wrapRustc , llvmPackages_16, llvm_16 } @ args: diff --git a/pkgs/development/compilers/rust/binary.nix b/pkgs/development/compilers/rust/binary.nix index bf03077f4aa8..efef07aba4c6 100644 --- a/pkgs/development/compilers/rust/binary.nix +++ b/pkgs/development/compilers/rust/binary.nix @@ -1,4 +1,4 @@ -{ lib, stdenv, makeWrapper, bash, curl, darwin, zlib +{ lib, stdenv, makeWrapper, wrapRustc, bash, curl, darwin, zlib , autoPatchelfHook, gcc , version , src @@ -19,7 +19,7 @@ let in rec { - rustc = stdenv.mkDerivation { + rustc-unwrapped = stdenv.mkDerivation { pname = "rustc-${versionType}"; inherit version; @@ -61,6 +61,8 @@ rec { setupHooks = ./setup-hook.sh; }; + rustc = wrapRustc rustc-unwrapped; + cargo = stdenv.mkDerivation { pname = "cargo-${versionType}"; diff --git a/pkgs/development/compilers/rust/cargo.nix b/pkgs/development/compilers/rust/cargo.nix index 8eb628aa536b..1bc1777acd47 100644 --- a/pkgs/development/compilers/rust/cargo.nix +++ b/pkgs/development/compilers/rust/cargo.nix @@ -11,7 +11,7 @@ rustPlatform.buildRustPackage.override { cargo-auditable = cargo-auditable.bootstrap; } ({ pname = "cargo"; - inherit (rustc) version src; + inherit (rustc.unwrapped) version src; # the rust source tarball already has all the dependencies vendored, no need to fetch them again cargoVendorDir = "vendor"; diff --git a/pkgs/development/compilers/rust/default.nix b/pkgs/development/compilers/rust/default.nix index efd7042c230c..b70b7ccf6264 100644 --- a/pkgs/development/compilers/rust/default.nix +++ b/pkgs/development/compilers/rust/default.nix @@ -18,6 +18,7 @@ , CoreFoundation, Security, SystemConfiguration , pkgsBuildBuild , makeRustPlatform +, wrapRustc }: let @@ -64,7 +65,7 @@ in buildRustPackages = (selectRustPackage buildPackages).packages.stable; # Analogous to stdenv rustPlatform = makeRustPlatform self.buildRustPackages; - rustc = self.callPackage ./rustc.nix ({ + rustc-unwrapped = self.callPackage ./rustc.nix ({ version = rustcVersion; sha256 = rustcSha256; inherit enableRustcDev; @@ -75,6 +76,7 @@ in # Use boot package set to break cycle inherit (bootstrapRustPackages) cargo rustc rustfmt; }); + rustc = wrapRustc self.rustc-unwrapped; rustfmt = self.callPackage ./rustfmt.nix { inherit Security; inherit (self.buildRustPackages) rustc; diff --git a/pkgs/development/compilers/rust/rustc.nix b/pkgs/development/compilers/rust/rustc.nix index 3a32dfc0c1e8..cb74ec11127f 100644 --- a/pkgs/development/compilers/rust/rustc.nix +++ b/pkgs/development/compilers/rust/rustc.nix @@ -154,9 +154,9 @@ in stdenv.mkDerivation (finalAttrs: { runHook preBuild mkdir -p build/${stdenv.hostPlatform.rust.rustcTargetSpec}/stage0-{std,rustc}/${stdenv.hostPlatform.rust.rustcTargetSpec}/release/ - ln -s ${rustc}/lib/rustlib/${stdenv.hostPlatform.rust.rustcTargetSpec}/libstd-*.so build/${stdenv.hostPlatform.rust.rustcTargetSpec}/stage0-std/${stdenv.hostPlatform.rust.rustcTargetSpec}/release/libstd.so - ln -s ${rustc}/lib/rustlib/${stdenv.hostPlatform.rust.rustcTargetSpec}/librustc_driver-*.so build/${stdenv.hostPlatform.rust.rustcTargetSpec}/stage0-rustc/${stdenv.hostPlatform.rust.rustcTargetSpec}/release/librustc.so - ln -s ${rustc}/bin/rustc build/${stdenv.hostPlatform.rust.rustcTargetSpec}/stage0-rustc/${stdenv.hostPlatform.rust.rustcTargetSpec}/release/rustc-main + ln -s ${rustc.unwrapped}/lib/rustlib/${stdenv.hostPlatform.rust.rustcTargetSpec}/libstd-*.so build/${stdenv.hostPlatform.rust.rustcTargetSpec}/stage0-std/${stdenv.hostPlatform.rust.rustcTargetSpec}/release/libstd.so + ln -s ${rustc.unwrapped}/lib/rustlib/${stdenv.hostPlatform.rust.rustcTargetSpec}/librustc_driver-*.so build/${stdenv.hostPlatform.rust.rustcTargetSpec}/stage0-rustc/${stdenv.hostPlatform.rust.rustcTargetSpec}/release/librustc.so + ln -s ${rustc.unwrapped}/bin/rustc build/${stdenv.hostPlatform.rust.rustcTargetSpec}/stage0-rustc/${stdenv.hostPlatform.rust.rustcTargetSpec}/release/rustc-main touch build/${stdenv.hostPlatform.rust.rustcTargetSpec}/stage0-std/${stdenv.hostPlatform.rust.rustcTargetSpec}/release/.libstd.stamp touch build/${stdenv.hostPlatform.rust.rustcTargetSpec}/stage0-rustc/${stdenv.hostPlatform.rust.rustcTargetSpec}/release/.librustc.stamp python ./x.py --keep-stage=0 --stage=1 build library/std @@ -169,9 +169,9 @@ in stdenv.mkDerivation (finalAttrs: { python ./x.py --keep-stage=0 --stage=1 install library/std mkdir -v $out/bin $doc $man - makeWrapper ${rustc}/bin/rustc $out/bin/rustc --add-flags "--sysroot $out" - makeWrapper ${rustc}/bin/rustdoc $out/bin/rustdoc --add-flags "--sysroot $out" - ln -s ${rustc}/lib/rustlib/{manifest-rust-std-,}${stdenv.hostPlatform.rust.rustcTargetSpec} $out/lib/rustlib/ + makeWrapper ${rustc.unwrapped}/bin/rustc $out/bin/rustc --add-flags "--sysroot $out" + makeWrapper ${rustc.unwrapped}/bin/rustdoc $out/bin/rustdoc --add-flags "--sysroot $out" + ln -s ${rustc.unwrapped}/lib/rustlib/{manifest-rust-std-,}${stdenv.hostPlatform.rust.rustcTargetSpec} $out/lib/rustlib/ echo rust-std-${stdenv.hostPlatform.rust.rustcTargetSpec} >> $out/lib/rustlib/components lndir ${rustc.doc} $doc lndir ${rustc.man} $man diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index b7992c9751b6..4fd7fa13e4ac 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -16897,6 +16897,9 @@ with pkgs; inherit (darwin) apple_sdk; }; + wrapRustcWith = { rustc-unwrapped, ... } @ args: callPackage ../build-support/rust/rustc-wrapper args; + wrapRustc = rustc-unwrapped: wrapRustcWith { inherit rustc-unwrapped; }; + rust_1_74 = callPackage ../development/compilers/rust/1_74.nix { inherit (darwin.apple_sdk.frameworks) CoreFoundation Security SystemConfiguration; llvm_16 = llvmPackages_16.libllvm; @@ -16915,7 +16918,7 @@ with pkgs; inherit (rustPackages) cargo cargo-auditable cargo-auditable-cargo-wrapper clippy rustc rustPlatform; # https://github.com/NixOS/nixpkgs/issues/89426 - rustc-wasm32 = (rustc.override { + rustc-wasm32 = wrapRustc ((rustc.unwrapped.override { stdenv = stdenv.override { targetPlatform = lib.systems.elaborate { # lib.systems.elaborate won't recognize "unknown" as the last component. @@ -16925,7 +16928,7 @@ with pkgs; }; }).overrideAttrs (old: { configureFlags = old.configureFlags ++ ["--set=build.docs=false"]; - }); + })); makeRustPlatform = callPackage ../development/compilers/rust/make-rust-platform.nix { }; -- cgit 1.4.1 From 8929ba838fa34da64f1490a4f47209d20c9346be Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Thu, 16 Nov 2023 12:19:36 +0100 Subject: rustc: use the wrapper for fastCross sysroot This avoids having two layers of wrapper for cross rustc. --- pkgs/build-support/rust/rustc-wrapper/default.nix | 3 ++- pkgs/build-support/rust/rustc-wrapper/rustc-wrapper.sh | 9 +++++++-- pkgs/development/compilers/rust/1_74.nix | 2 +- pkgs/development/compilers/rust/default.nix | 7 +++++-- pkgs/development/compilers/rust/rustc.nix | 2 +- 5 files changed, 16 insertions(+), 7 deletions(-) (limited to 'pkgs/development/compilers') diff --git a/pkgs/build-support/rust/rustc-wrapper/default.nix b/pkgs/build-support/rust/rustc-wrapper/default.nix index 06cfcbb5457f..d6034c08af47 100644 --- a/pkgs/build-support/rust/rustc-wrapper/default.nix +++ b/pkgs/build-support/rust/rustc-wrapper/default.nix @@ -1,4 +1,4 @@ -{ lib, runCommand, rustc-unwrapped }: +{ lib, runCommand, rustc-unwrapped, sysroot ? null }: runCommand "${rustc-unwrapped.pname}-wrapper-${rustc-unwrapped.version}" { preferLocalBuild = true; @@ -7,6 +7,7 @@ runCommand "${rustc-unwrapped.pname}-wrapper-${rustc-unwrapped.version}" { env = { prog = "${rustc-unwrapped}/bin/rustc"; + sysroot = lib.optionalString (sysroot != null) "--sysroot ${sysroot}"; }; passthru = { diff --git a/pkgs/build-support/rust/rustc-wrapper/rustc-wrapper.sh b/pkgs/build-support/rust/rustc-wrapper/rustc-wrapper.sh index 866a6912e090..a62e35b8736f 100644 --- a/pkgs/build-support/rust/rustc-wrapper/rustc-wrapper.sh +++ b/pkgs/build-support/rust/rustc-wrapper/rustc-wrapper.sh @@ -1,11 +1,16 @@ #!@shell@ +extraBefore=(@sysroot@) +extraAfter=($NIX_RUSTFLAGS) + # Optionally print debug info. if (( "${NIX_DEBUG:-0}" >= 1 )); then + echo "extra flags before to @prog@:" >&2 + printf " %q\n" "${extraBefore[@]}" >&2 echo "original flags to @prog@:" >&2 printf " %q\n" "$@" >&2 echo "extra flags after to @prog@:" >&2 - printf " %q\n" $NIX_RUSTFLAGS >&2 + printf " %q\n" "${extraAfter[@]}" >&2 fi -exec @prog@ "$@" $NIX_RUSTFLAGS +exec @prog@ "${extraBefore[@]}" "$@" "${extraAfter[@]}" diff --git a/pkgs/development/compilers/rust/1_74.nix b/pkgs/development/compilers/rust/1_74.nix index f8749a8b65c2..163c64c249b7 100644 --- a/pkgs/development/compilers/rust/1_74.nix +++ b/pkgs/development/compilers/rust/1_74.nix @@ -16,7 +16,7 @@ , CoreFoundation, Security, SystemConfiguration , pkgsBuildTarget, pkgsBuildBuild, pkgsBuildHost , makeRustPlatform -, wrapRustc +, wrapRustcWith , llvmPackages_16, llvm_16 } @ args: diff --git a/pkgs/development/compilers/rust/default.nix b/pkgs/development/compilers/rust/default.nix index b70b7ccf6264..d56b6fb9e08e 100644 --- a/pkgs/development/compilers/rust/default.nix +++ b/pkgs/development/compilers/rust/default.nix @@ -18,7 +18,7 @@ , CoreFoundation, Security, SystemConfiguration , pkgsBuildBuild , makeRustPlatform -, wrapRustc +, wrapRustcWith }: let @@ -76,7 +76,10 @@ in # Use boot package set to break cycle inherit (bootstrapRustPackages) cargo rustc rustfmt; }); - rustc = wrapRustc self.rustc-unwrapped; + rustc = wrapRustcWith { + inherit (self) rustc-unwrapped; + sysroot = if fastCross then self.rustc-unwrapped else null; + }; rustfmt = self.callPackage ./rustfmt.nix { inherit Security; inherit (self.buildRustPackages) rustc; diff --git a/pkgs/development/compilers/rust/rustc.nix b/pkgs/development/compilers/rust/rustc.nix index cb74ec11127f..7e365f52ef30 100644 --- a/pkgs/development/compilers/rust/rustc.nix +++ b/pkgs/development/compilers/rust/rustc.nix @@ -169,7 +169,7 @@ in stdenv.mkDerivation (finalAttrs: { python ./x.py --keep-stage=0 --stage=1 install library/std mkdir -v $out/bin $doc $man - makeWrapper ${rustc.unwrapped}/bin/rustc $out/bin/rustc --add-flags "--sysroot $out" + ln -s ${rustc.unwrapped}/bin/rustc $out/bin makeWrapper ${rustc.unwrapped}/bin/rustdoc $out/bin/rustdoc --add-flags "--sysroot $out" ln -s ${rustc.unwrapped}/lib/rustlib/{manifest-rust-std-,}${stdenv.hostPlatform.rust.rustcTargetSpec} $out/lib/rustlib/ echo rust-std-${stdenv.hostPlatform.rust.rustcTargetSpec} >> $out/lib/rustlib/components -- cgit 1.4.1 From 68aaaec7d2844cf16706b71b80d433f1b426e733 Mon Sep 17 00:00:00 2001 From: Sergei Trofimovich Date: Tue, 21 Nov 2023 10:17:52 +0000 Subject: gcc12, gcc13: fix typos in comments around __FILE__ patch MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Noticed by Robert Schütz. --- .../compilers/gcc/patches/12/mangle-NIX_STORE-in-__FILE__.patch | 4 ++-- .../compilers/gcc/patches/13/mangle-NIX_STORE-in-__FILE__.patch | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'pkgs/development/compilers') diff --git a/pkgs/development/compilers/gcc/patches/12/mangle-NIX_STORE-in-__FILE__.patch b/pkgs/development/compilers/gcc/patches/12/mangle-NIX_STORE-in-__FILE__.patch index d938d67a2d06..4e6c392ce76e 100644 --- a/pkgs/development/compilers/gcc/patches/12/mangle-NIX_STORE-in-__FILE__.patch +++ b/pkgs/development/compilers/gcc/patches/12/mangle-NIX_STORE-in-__FILE__.patch @@ -17,10 +17,10 @@ Ideally we would like to use `-fmacro-prefix-map=` feature of `gcc` as: -fmacro-prefix-map=/nix/store/$hash1-nlohmann-json-ver=/nix/store/eeee.eee-nlohmann-json-ver -fmacro-prefix-map=/nix/... -In practice it quickly exhausts argument lengtth limit due to `gcc` +In practice it quickly exhausts argument length limit due to `gcc` deficiency: https://gcc.gnu.org/PR111527 -Until it;s fixed let's hardcode header mangling if $NIX_STORE variable +Until it's fixed let's hardcode header mangling if $NIX_STORE variable is present in the environment. Tested as: diff --git a/pkgs/development/compilers/gcc/patches/13/mangle-NIX_STORE-in-__FILE__.patch b/pkgs/development/compilers/gcc/patches/13/mangle-NIX_STORE-in-__FILE__.patch index 57ae2111f020..ea0673219eb1 100644 --- a/pkgs/development/compilers/gcc/patches/13/mangle-NIX_STORE-in-__FILE__.patch +++ b/pkgs/development/compilers/gcc/patches/13/mangle-NIX_STORE-in-__FILE__.patch @@ -17,10 +17,10 @@ Ideally we would like to use `-fmacro-prefix-map=` feature of `gcc` as: -fmacro-prefix-map=/nix/store/$hash1-nlohmann-json-ver=/nix/store/eeee.eee-nlohmann-json-ver -fmacro-prefix-map=/nix/... -In practice it quickly exhausts argument lengtth limit due to `gcc` +In practice it quickly exhausts argument length limit due to `gcc` deficiency: https://gcc.gnu.org/PR111527 -Until it;s fixed let's hardcode header mangling if $NIX_STORE variable +Until it's fixed let's hardcode header mangling if $NIX_STORE variable is present in the environment. Tested as: -- cgit 1.4.1