-
-
Notifications
You must be signed in to change notification settings - Fork 14.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
rust: make pkgsCross.wasi32.rustPlatform.buildRustPackage work #323161
base: master
Are you sure you want to change the base?
Conversation
I've re-verified that this is the best solution I can come up with. I've added comments on the parts that aren't entirely starightforward. @Kranzes, if you only removed your reviewer status because this was still a draft, can I ask you to have a look at some point? |
Thank you for the review. (The reason I wasn't particularly keen on touching wasilibc is that the following takes ages to build. The floorp failure also happens on master, so that's unrelated.) Result of 1 package blacklisted:
3 packages failed to build:
32 packages built:
|
cf1e88c
to
90b9b0c
Compare
I tried building pkgsCross.wasi32.qrtool, but it failed to build wasm32-unknown-wasi-rustc-1.78.0.
|
@alyssais Could you tell me exactly what you're trying to build? The following work for me (should be the same thing):
(qrtool will fail in installPhase because of #289517 / #308283. Try rq instead if the above does get past the failure you saw in rustc.) [Edit:] Did you try that on master / some other PR? Because that's nearly the same error as in the opening post for this PR. |
Looks like I might have mixed up which branch I was building — sorry! |
663fd2b
to
0b14612
Compare
…recognizable by rust rustc infers the linker flavor from the name of the linker, but refuses to recognize "cc" as anything. The reasons for this are not well documented, but are hinted at in a comment: https://github.com/rust-lang/rust/blob/18deb53874ac4701ba10ebc016cb8cde7a049b82/compiler/rustc_codegen_ssa/src/back/link.rs#L1392-L1397 In short, "cc" could be (or at least historically could have been) anything, and there's no way to know what flags to pass to it. This is a problem because nixpkgs insists to on overriding CARG_TARGET_…_LINKER to gcc or clang always, but rustc defaults to expecting ldd directly (not wrapped in a compiler) for some targets (e.g. wasi). Since rustc did not detec this override changing the flaver, linking has so far been broken for these targets. Adjusting rustc itself is not absolutely necessary, but a matter of sanity.
…erivation does not supply one
Here I'd thought I could finally make progress because found a decent workaround for the mess in the rust build environment setup (namely: do actually use linkers that are either named And already, three new messes have appeared.
I think I'll let this rest. |
Description of changes
This PR makes it possible to e.g. build and run rust packages like
nix shell .#pkgsCross.wasi32.charasay -c charasay.wasm say moo
(assuming you havewasm32-wasi
in your emulated systems).Without this PR, building the cross rustc fails with
I think this is neat, but it admittedly isn't super useful, as a lot of packages fail to compile due to failing C dependencies or some common dependencies assuming that all wasm is for the web. I've tested the 469 rust packages in by-name, and only 60¹ compile. Even those that do compile might fail at runtime, e.g. due to std::thread not being supported and panicking when attempting to create a thread (like alejandra).
I'm only aware of two mildly useful things that work, namely rq and qrtool. But I think it's nice to have this working.
¹ aarch64-esr-decoder, aba, action-validator, adrs, bunbun, cargo-autoinherit, cargo-bloat, cargo-bump, cargo-shear, cargo-swift, catppuccin-whiskers, catppuccinifier-cli, cdwe, circom, clippy-sarif, cmd-wrapped, commitmsgfmt, diesel-cli-ext, dipc, elf-info, emacs-lsp-booster, esbuild-config, french-numbers, galerio, git-upstream, hadolint-sarif, hvm, hyperlink, icnsify, ifrextractor-rs, keedump, kickstart, ldproxy, little_boxes, ludtwig, lutgen, majima, mcumgr-client, mdsh, ndstrim, obsidian-export, okolors, parallel-disk-usage, pdfrip, polylux2pdfpc, preserves-tools, prettypst, protoc-gen-rust-grpc, qrtool, rq, rs-tftpd, rusti-cal, rusty-diceware, sarif-fmt, shellcheck-sarif, tera-cli, thud, toml-cli, typstfmt, unison-fsmonitor, wit-bindgen
Things done
nix.conf
? (See Nix manual)sandbox = relaxed
sandbox = true
nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD"
. Note: all changes have to be committed, also see nixpkgs-review usage./result/bin/
)Add a 👍 reaction to pull requests you find important.