Skip to content

Conversation

@lblasc
Copy link
Contributor

@lblasc lblasc commented Oct 31, 2025

https://blog.rust-lang.org/2025/10/30/Rust-1.91.0/

build on x86_64-linux:

  • fd
  • firefox

Things done

  • Built on platform:
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • Tested, as applicable:
  • Ran nixpkgs-review on this PR. See nixpkgs-review usage.
  • Tested basic functionality of all binary files, usually in ./result/bin/.
  • Nixpkgs Release Notes
    • Package update: when the change is major or breaking.
  • NixOS Release Notes
    • Module addition: when adding a new NixOS module.
    • Module update: when the change is significant.
  • Fits CONTRIBUTING.md, pkgs/README.md, maintainers/README.md and other READMEs.

Add a 👍 reaction to pull requests you find important.

@nixpkgs-ci nixpkgs-ci bot added 10.rebuild-linux: 501+ This PR causes many rebuilds on Linux and should normally target the staging branches. 10.rebuild-darwin: 501+ This PR causes many rebuilds on Darwin and should normally target the staging branches. 10.rebuild-darwin: 5001+ This PR causes many rebuilds on Darwin and must target the staging branches. 10.rebuild-linux: 5001+ This PR causes many rebuilds on Linux and must target the staging branches. 6.topic: rust General-purpose programming language emphasizing performance, type safety, and concurrency. labels Oct 31, 2025
Copy link
Member

@alyssais alyssais left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Diff LGTM.

@nixpkgs-ci nixpkgs-ci bot added the 12.approvals: 1 This PR was reviewed and approved by one person. label Oct 31, 2025
@lblasc
Copy link
Contributor Author

lblasc commented Oct 31, 2025

Getting a rustc build failure on x86_64-linux 🤔

   Compiling clap_derive v4.5.18
   Compiling serde_derive v1.0.215
   Compiling bstr v1.10.0
   Compiling globset v0.4.15
   Compiling opener v0.8.2
   Compiling ignore v0.4.23
   Compiling clap v4.5.20
   Compiling clap_complete v4.5.37
   Compiling build_helper v0.1.0 (/build/rustc-1.91.0-src/src/build_helper)
    Finished `dev` profile [unoptimized] target(s) in 17.96s
WARNING: The `change-id` is missing in the `bootstrap.toml`. This means that you will not be able to track the major changes made to the bootstrap configura>
NOTE: to silence this warning, add `change-id = 146435` or `change-id = "ignore"` at the top of `bootstrap.toml`

thread 'main' (1745) panicked at src/bootstrap/src/core/sanity.rs:341:17:
Clang is required to build C code for Wasm targets, got `gcc` instead
this is because compiler-builtins is configured to build C source. Either ensure Clang is used, or adjust this configuration.
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Build completed unsuccessfully in 0:00:18
make: *** [Makefile:19: all] Error 1

@alyssais
Copy link
Member

alyssais commented Oct 31, 2025 via email

@emilazy
Copy link
Member

emilazy commented Oct 31, 2025

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 hostPlatform). This may have some compatibility hazard – AIUI they are only used by C code, but there was some use case like compiling SQLite to WASM to embed in a Rust application – but should be easy. The other alternatives I can see are to pull in an unwrapped Clang to build the built‐ins, or to give up on bundling WASM cross into our main Rust package.

@niklaskorz
Copy link
Contributor

@emilazy
Copy link
Member

emilazy commented Nov 1, 2025

I wouldn't really say it's problematic - we (and upstream) were shipping broken machine code before (native platform in a WASM library).

@niklaskorz
Copy link
Contributor

niklaskorz commented Nov 1, 2025

This should fix the build by disabling optimized-compiler-builtins for wasm targets:

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 false, this does not entirely disable optimized compiler builtins, it just limits them to Rust-only:

https://github.com/rust-lang/rust/blob/d85276b256a8ab18e03b6394b4f7a7b246176db7/src/bootstrap/src/core/config/mod.rs#L241-L252

@emilazy
Copy link
Member

emilazy commented Nov 1, 2025

That will keep using our wrapped Clang to build with the wrong --target=… on Clang platforms, which is not ideal. I’d suggest dropping the Clang conditional, or perhaps refining to stdenv.targetPlatform.config != "wasm32-unknown-none" or something. We should also be able to drop the hardeningDisable as a result.

@nekowinston
Copy link
Member

nekowinston commented Nov 2, 2025

Managed to get nix-build -A rustc -A cargo -A tests.buildRustCrate.tests -A fd to build on x86_64-linux and aarch64-darwin with

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, tests.buildRustCrate.tests.crateBinWithPath errors with:

ERROR: Difference in expected output files in /nix/store/nvbn51xrf0zbndx9f79rd7n68qs8am8n-rust_nixtestcrate-0.1.0
=== Got:
  ./bin/test_binary1
  ./bin/test_binary1.dSYM/Contents/Info.plist
  ./bin/test_binary1.dSYM/Contents/Resources/DWARF/test_binary1
  ./bin/test_binary1.dSYM/Contents/Resources/Relocations/aarch64/test_binary1.yml
=== Expected:
  ./bin/test_binary1
  ./bin/test_binary1.dSYM/Contents/Info.plist
  ./bin/test_binary1.dSYM/Contents/Resources/DWARF/test_binary1
=== Diff:
  @@ -1,3 +1,4 @@
   ./bin/test_binary1
   ./bin/test_binary1.dSYM/Contents/Info.plist
   ./bin/test_binary1.dSYM/Contents/Resources/DWARF/test_binary1
  +./bin/test_binary1.dSYM/Contents/Resources/Relocations/aarch64/test_binary1.yml

@emilazy
Copy link
Member

emilazy commented Nov 2, 2025

Looks like a golden snapshot just needs updating there. Which also means someone is going to have to build this on x86_64-darwin 😔

@nekowinston
Copy link
Member

nekowinston commented Nov 3, 2025

Also built the same -A rustc -A cargo -A tests.buildRustCrate.tests -A fd on x86_64-darwin (with the patch above applied), and seeing:

ERROR: Difference in expected output files in /nix/store/v1dspk4zvx2nzv0gpvz5hz2d62fzwhf6-rust_nixtestcrate-0.1.0
=== Got:
  ./bin/test_binary1
  ./bin/test_binary1.dSYM/Contents/Info.plist
  ./bin/test_binary1.dSYM/Contents/Resources/DWARF/test_binary1
  ./bin/test_binary1.dSYM/Contents/Resources/Relocations/x86_64/test_binary1.yml
=== Expected:
  ./bin/test_binary1
  ./bin/test_binary1.dSYM/Contents/Info.plist
  ./bin/test_binary1.dSYM/Contents/Resources/DWARF/test_binary1
=== Diff:
  @@ -1,3 +1,4 @@
   ./bin/test_binary1
   ./bin/test_binary1.dSYM/Contents/Info.plist
   ./bin/test_binary1.dSYM/Contents/Resources/DWARF/test_binary1
  +./bin/test_binary1.dSYM/Contents/Resources/Relocations/x86_64/test_binary1.yml
---

there for tests.buildRustCrate.tests.crateBinWithPath.
Do we need the file contents or just the directory structure?

@nekowinston
Copy link
Member

Do we need the file contents or just the directory structure?

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";

@lblasc
Copy link
Contributor Author

lblasc commented Nov 3, 2025

@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).

@nekowinston
Copy link
Member

nekowinston commented Nov 3, 2025

I also tried pkgsCross.aarch64-multiplatform.fd after asking what other packages we should try on Matrix, running into trouble with aarch64-unknown-linux-gnu-rustc-1.91.0:

    Finished `dev` profile [unoptimized] target(s) in 23.25s
WARNING: The `change-id` is missing in the `bootstrap.toml`. This means that you will not be able to track the major changes made to the bootstrap configurations.
NOTE: to silence this warning, add `change-id = 146435` or `change-id = "ignore"` at the top of `bootstrap.toml`
WARNING: Using a potentially old librustc. This may not behave well.
WARNING: Use `--keep-stage-std` if you want to rebuild the compiler when it changes
ERROR: Unable to find the stamp file /build/rustc-1.91.0-src/build/x86_64-unknown-linux-gnu/stage1-rustc/x86_64-unknown-linux-gnu/release/.librustc-stamp, did you try to keep a nonexistent build stage?

full logs

Edit: just found #395734 (comment), maybe we just need the same for stage-1?

@DimitarNestorov DimitarNestorov removed their request for review November 3, 2025 16:10
@nekowinston
Copy link
Member

Managed to get a working pkgsCross.aarch64-multiplatform.fd to work with:

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

@lblasc
Copy link
Contributor Author

lblasc commented Nov 4, 2025

@nekowinston applied, thx! Managed to build firefox on x86_64-linux.

@nixpkgs-ci nixpkgs-ci bot added 12.approvals: 2 This PR was reviewed and approved by two persons. and removed 12.approvals: 1 This PR was reviewed and approved by one person. labels Nov 4, 2025
Copy link
Contributor

@niklaskorz niklaskorz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, currently compiling zed-editor on aarch64-darwin and x86_64-linux for a final test.

@nixpkgs-ci nixpkgs-ci bot added 12.approvals: 3+ This PR was reviewed and approved by three or more persons. and removed 12.approvals: 2 This PR was reviewed and approved by two persons. labels Nov 4, 2025
Copy link
Member

@winterqt winterqt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks all!

# doesn't work) to build a linker.
"--disable-llvm-bitcode-linker"
]
++ optionals (!fastCross && stdenv.targetPlatform.config != "wasm32-unknown-none") [
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I trust that the !fastCross is correct, though I haven't tested it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We disable wasm targets for fastCross (some lines further above)

@winterqt winterqt added this pull request to the merge queue Nov 4, 2025
@nixpkgs-ci nixpkgs-ci bot added the 12.approved-by: package-maintainer This PR was reviewed and approved by a maintainer listed in any of the changed packages. label Nov 4, 2025
Merged via the queue into NixOS:staging with commit 826c4e6 Nov 4, 2025
37 of 39 checks passed
@trofi
Copy link
Contributor

trofi commented Nov 5, 2025

Bisect says mdbook (nix build depend) broke in staging as:

$ nix build --no-link -f. mdbook -L
...
mdbook> test test::failing_tests ... FAILED
...
mdbook> failures:
mdbook>
mdbook> ---- test::failing_tests stdout ----
mdbook>
mdbook> thread 'test::failing_tests' (5314) panicked at tests/testsuite/book_test.rs:363:17:
mdbook>
mdbook> ---- expected: tests/testsuite/test.rs:29:28
mdbook> ++++ actual:   stderr
mdbook>    1    1 | [TIMESTAMP] [INFO] (mdbook::book): Testing chapter 'Failing Tests': "failing.md"
mdbook>    2    2 | [TIMESTAMP] [ERROR] (mdbook::book): rustdoc returned an error:
mdbook>    3    3 |
mdbook>    4    4 | --- stdout
mdbook>    5    5 |
mdbook>    6    6 | ...
mdbook>    7    7 | test failing.md - Failing_Tests (line 3) ... FAILED
mdbook>    8      - ...
mdbook>    9      - thread 'main' panicked at failing.md:3:1:
mdbook>         8 +
mdbook>         9 + failures:
mdbook>        10 +
mdbook>        11 + ---- failing.md - Failing_Tests (line 3) stdout ----
mdbook>        12 + Test executable failed ([EXIT_STATUS]: 101).
mdbook>        13 +
mdbook>        14 + stderr:
mdbook>        15 +
mdbook>        16 + thread 'main' (5728) panicked at failing.md:3:1:
mdbook>   10   17 | fail
mdbook>   11      - ...
mdbook>        18 + note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
mdbook>        19 +
mdbook>        20 +
mdbook>        21 +
mdbook>        22 + failures:
mdbook>        23 +     failing.md - Failing_Tests (line 3)
mdbook>        24 +
mdbook>        25 + test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.13s
mdbook>        26 +
mdbook>        27 +
mdbook>        28 + --- stderr
mdbook>        29 +
mdbook>   12   30 | [TIMESTAMP] [INFO] (mdbook::book): Testing chapter 'Failing Include': "failing_include.md"
mdbook>   13   31 | [TIMESTAMP] [ERROR] (mdbook::book): rustdoc returned an error:
mdbook>   14   32 |
mdbook>   15   33 | --- stdout
mdbook>   16      - ...
mdbook>        34 +
mdbook>        35 + running 1 test
mdbook>   17   36 | test failing_include.md - Failing_Include (line 3) ... FAILED
mdbook>   18      - ...
mdbook>   19      - thread 'main' panicked at failing_include.md:3:1:
mdbook>        37 +
mdbook>        38 + failures:
mdbook>        39 +
mdbook>        40 + ---- failing_include.md - Failing_Include (line 3) stdout ----
mdbook>        41 + Test executable failed ([EXIT_STATUS]: 101).
mdbook>        42 +
mdbook>        43 + stderr:
mdbook>        44 +
mdbook>        45 + thread 'main' (5954) panicked at failing_include.md:3:1:
mdbook>   20   46 | failing!
mdbook>   21      - ...
mdbook>        47 + note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
mdbook>        48 +
mdbook>        49 +
mdbook>        50 +
mdbook>        51 + failures:
mdbook>        52 +     failing_include.md - Failing_Include (line 3)
mdbook>        53 +
mdbook>        54 + test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.14s
mdbook>        55 +
mdbook>        56 +
mdbook>        57 + --- stderr
mdbook>        58 +
mdbook>   22   59 | [TIMESTAMP] [ERROR] (mdbook::utils): Error: One or more tests failed
mdbook>
mdbook> Update with SNAPSHOTS=overwrite
mdbook>
mdbook> note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
mdbook>
mdbook>
mdbook> failures:
mdbook>     test::failing_tests
mdbook>
mdbook> test result: FAILED. 71 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; finished in 18.50s

@alyssais
Copy link
Member

alyssais commented Nov 6, 2025

rust-lang/mdBook@841c68d looks like it should fix it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

6.topic: rust General-purpose programming language emphasizing performance, type safety, and concurrency. 10.rebuild-darwin: 501+ This PR causes many rebuilds on Darwin and should normally target the staging branches. 10.rebuild-darwin: 5001+ This PR causes many rebuilds on Darwin and must target the staging branches. 10.rebuild-linux: 501+ This PR causes many rebuilds on Linux and should normally target the staging branches. 10.rebuild-linux: 5001+ This PR causes many rebuilds on Linux and must target the staging branches. 12.approvals: 3+ This PR was reviewed and approved by three or more persons. 12.approved-by: package-maintainer This PR was reviewed and approved by a maintainer listed in any of the changed packages.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants