Conversation
|
Getting a rustc build failure on x86_64-linux 🤔 |
|
@emilazy is this the thing you warned me was coming a while ago?
Am I remembering right that our conclusion was that we could just not build compiler-builtins here?
|
|
Yes, the prophecy has come to pass. IIRC, Rust added per‐target flags for whether to use the C compiler built‐ins; we could presumably turn them off solely for the WASM targets (and solely when they’re not already the |
|
The problematic upstream PR and code path for reference: |
|
I wouldn't really say it's problematic - we (and upstream) were shipping broken machine code before (native platform in a WASM library). |
|
This should fix the build by disabling diff --git a/pkgs/development/compilers/rust/rustc.nix b/pkgs/development/compilers/rust/rustc.nix
index 463c0133015f..a64a1b861f1b 100644
--- a/pkgs/development/compilers/rust/rustc.nix
+++ b/pkgs/development/compilers/rust/rustc.nix
@@ -238,6 +238,11 @@ stdenv.mkDerivation (finalAttrs: {
# doesn't work) to build a linker.
"--disable-llvm-bitcode-linker"
]
+ ++ optionals (!fastCross && !stdenv.cc.isClang) [
+ # See https://github.com/rust-lang/rust/issues/132802
+ "--set=target.wasm32-unknown-unknown.optimized-compiler-builtins=false"
+ "--set=target.wasm32v1-none.optimized-compiler-builtins=false"
+ ]
++ optionals (stdenv.targetPlatform.isLinux && !(stdenv.targetPlatform.useLLVM or false)) [
"--enable-profiler" # build libprofiler_builtins
]Edit: builds fine on x86_64-linux for me with this applied Note that despite the value of |
|
That will keep using our wrapped Clang to build with the wrong |
|
Managed to get diff --git a/pkgs/development/compilers/rust/rustc.nix b/pkgs/development/compilers/rust/rustc.nix
index 463c0133015f..c708e5be377e 100644
--- a/pkgs/development/compilers/rust/rustc.nix
+++ b/pkgs/development/compilers/rust/rustc.nix
@@ -62,12 +62,6 @@ stdenv.mkDerivation (finalAttrs: {
passthru.isReleaseTarball = true;
};
- hardeningDisable = optionals stdenv.cc.isClang [
- # remove once https://github.com/NixOS/nixpkgs/issues/318674 is
- # addressed properly
- "zerocallusedregs"
- ];
-
__darwinAllowLocalNetworking = true;
# rustc complains about modified source files otherwise
@@ -238,6 +232,11 @@ stdenv.mkDerivation (finalAttrs: {
# doesn't work) to build a linker.
"--disable-llvm-bitcode-linker"
]
+ ++ optionals (!fastCross && stdenv.targetPlatform.config != "wasm32-unknown-none") [
+ # See https://github.com/rust-lang/rust/issues/132802
+ "--set=target.wasm32-unknown-unknown.optimized-compiler-builtins=false"
+ "--set=target.wasm32v1-none.optimized-compiler-builtins=false"
+ ]
++ optionals (stdenv.targetPlatform.isLinux && !(stdenv.targetPlatform.useLLVM or false)) [
"--enable-profiler" # build libprofiler_builtins
]and disabling tests for a few packages in staging (diffutils, gnugrep) on aarch64-darwin (macOS 26). One exception, on aarch64-darwin, |
|
Looks like a golden snapshot just needs updating there. Which also means someone is going to have to build this on |
|
Also built the same there for |
Figured it out, tests pass on aarch64-darwin & x86_64-darwin with: diff --git a/pkgs/build-support/rust/build-rust-crate/test/default.nix b/pkgs/build-support/rust/build-rust-crate/test/default.nix
index 50e045921387..d5c56858c6a4 100644
--- a/pkgs/build-support/rust/build-rust-crate/test/default.nix
+++ b/pkgs/build-support/rust/build-rust-crate/test/default.nix
@@ -772,10 +772,11 @@ rec {
]
++ lib.optionals stdenv.hostPlatform.isDarwin [
# On Darwin, the debug symbols are in a separate directory.
"./bin/test_binary1.dSYM/Contents/Info.plist"
"./bin/test_binary1.dSYM/Contents/Resources/DWARF/test_binary1"
+ "./bin/test_binary1.dSYM/Contents/Resources/Relocations/${stdenv.hostPlatform.rust.platform.arch}/test_binary1.yml"
];
};
crateBinNoPath1Outputs = assertOutputs {
name = "crateBinNoPath1";
|
|
@nekowinston thx, I've added you changes. So far I've managed to build fd on x86_64-linux (that's the only arch I have). |
|
I also tried Edit: just found #395734 (comment), maybe we just need the same for stage-1? |
|
Managed to get a working diff --git a/pkgs/development/compilers/rust/rustc.nix b/pkgs/development/compilers/rust/rustc.nix
index c708e5be377e..97f86780a4d4 100644
--- a/pkgs/development/compilers/rust/rustc.nix
+++ b/pkgs/development/compilers/rust/rustc.nix
@@ -278,16 +278,17 @@ stdenv.mkDerivation (finalAttrs: {
buildPhase =
if fastCross then
''
runHook preBuild
- mkdir -p build/${stdenv.hostPlatform.rust.rustcTargetSpec}/stage0-{std,rustc}/${stdenv.hostPlatform.rust.rustcTargetSpec}/release/
+ mkdir -p build/${stdenv.hostPlatform.rust.rustcTargetSpec}/stage{0,1}-{std,rustc}/${stdenv.hostPlatform.rust.rustcTargetSpec}/release/
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
+ ln -s ${rustc.unwrapped}/bin/rustc build/${stdenv.hostPlatform.rust.rustcTargetSpec}/stage1-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
+ touch build/${stdenv.hostPlatform.rust.rustcTargetSpec}/stage{0,1}-rustc/${stdenv.hostPlatform.rust.rustcTargetSpec}/release/.librustc-stamp
python ./x.py --keep-stage=0 --stage=1 build library
runHook postBuild
''
else
|
Co-authored-by: winston <hey@winston.sh>
|
@nekowinston applied, thx! Managed to build firefox on x86_64-linux. |
niklaskorz
left a comment
There was a problem hiding this comment.
LGTM, currently compiling zed-editor on aarch64-darwin and x86_64-linux for a final test.
| # doesn't work) to build a linker. | ||
| "--disable-llvm-bitcode-linker" | ||
| ] | ||
| ++ optionals (!fastCross && stdenv.targetPlatform.config != "wasm32-unknown-none") [ |
There was a problem hiding this comment.
I trust that the !fastCross is correct, though I haven't tested it.
There was a problem hiding this comment.
We disable wasm targets for fastCross (some lines further above)
|
Bisect says |
|
rust-lang/mdBook@841c68d looks like it should fix it. |
https://blog.rust-lang.org/2025/10/30/Rust-1.91.0/
build on x86_64-linux:
Things done
passthru.tests.nixpkgs-reviewon this PR. See nixpkgs-review usage../result/bin/.Add a 👍 reaction to pull requests you find important.