-
Notifications
You must be signed in to change notification settings - Fork 13.3k
rust-lld on NixOS can't link the program if the target dir lives on a path with spaces in it #138513
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
Comments
Thank you for the report! It would be useful to bisect the regression to the exact commit using cargo-bisect-rustc to make it easier to figure out what happened and ping the relevant people. |
This issue doesn't reproduce for me locally, does it need more than a hello world? I don't think we can prioritize yet, let's do that once we have a bisection if it's a regression, and more information on what's needed to reproduce. |
nope, i assumed it was something to do with ffi (i remember this being a problem with a i'll try to bisect rustc to see exactly which commit this starts happening on |
$ cargo bisect-rustc --start=2024-12-12 --end=2025-03-13
checking the start range to find a passing nightly
installing nightly-2024-12-12
rust-std-nightly-x86_64-unknown-linux-gnu: 29.32 MB / 29.32 MB [===========================================================================] 100.00 % 1.21 MB/s testing...
RESULT: nightly-2024-12-12, ===> Compile error
uninstalling nightly-2024-12-12
ERROR: the start of the range (nightly-2024-12-12) must not reproduce the regression false alarm, not a regression. would appreciate some help figuring out why rust suddenly isn't able to compile in directories with spaces though. |
I don't see anything wrong with the printed linker command args, nothing has been split incorrectly at that stage. It's hard to tell what's causing the issue without a way to reproduce it. |
that was what i found the most strange—all paths are in double quotes, so there should be no problem about reproducing: i'm using nixos, from which i got my copy of rustup, which i used to get cargo, rustc, and the other rust programs. i could copy my configuration file, cargo directory, and project shell file to a virtual machine. if the issue reproduces, it means the issue probably lies somewhere within nixos, and i can make a minimum reproducible configuration file that reproduces the problem so it can be fixed. if it doesn't, it means my setup is somehow broken on my specific install in a strange way. i don't know what i would do in that case |
I see, how did you get your Rust on NixOS? There may be a patched script inserted that can't handle the spaces... I tried on my NixOS (via |
the CLI args were shortened. notice how none of them contain |
This shortening was probably a bad idea. |
just by adding
how do you provide flags to rustc when running |
you can pass flags to rustc with
RUSTFLAGS=--verbose, or use
hmm. do you remember which part you needed, was it also the .rcgu.o object files? i'm fine with showing a short version of those (like we do for the sysroot rlibs), i just don't want to fully glob expand them. |
haha i looked it up at the same time as you sent this comment anyway, here's the output: longish command-line output$ RUSTFLAGS=--verbose cargo build
Compiling testing v0.1.0 (/tmp/test dir/testing)
error: linking with `cc` failed: exit status: 1
|
= note: LC_ALL="C" PATH="/Users/lily/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/bin:/Users/lily/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/bin/self-contained:/Users/lily/.cargo/bin:/Users/lily/.local/bin:/run/wrappers/bin:/Users/lily/.nix-profile/bin:/nix/profile/bin:/Users/lily/.local/state/nix/profile/bin:/etc/profiles/per-user/lily/bin:/nix/var/nix/profiles/default/bin:/run/current-system/sw/bin" VSLANG="1033" "cc" "-m64" "/tmp/rustcnRBXWa/symbols.o" "/tmp/test dir/testing/target/debug/deps/testing-d710013f68c27dbb.1bfyoq6rlzd3j6rlzixd6uskq.rcgu.o" "/tmp/test dir/testing/target/debug/deps/testing-d710013f68c27dbb.8g1cx5khh1sbf5bkfi8dem3ng.rcgu.o" "/tmp/test dir/testing/target/debug/deps/testing-d710013f68c27dbb.9ovjrihh4cz1ccqq6va1kyplk.rcgu.o" "/tmp/test dir/testing/target/debug/deps/testing-d710013f68c27dbb.btx0i6707le7wjb6vblydmhri.rcgu.o" "/tmp/test dir/testing/target/debug/deps/testing-d710013f68c27dbb.c5pedz95lu4ynzmy14tvxncrq.rcgu.o" "/tmp/test dir/testing/target/debug/deps/testing-d710013f68c27dbb.clas9xqc2eedytiy6rg88kkr9.rcgu.o" "/tmp/test dir/testing/target/debug/deps/testing-d710013f68c27dbb.41nm33s6nku8i3qh7g76xp28m.rcgu.o" "-Wl,--as-needed" "-Wl,-Bstatic" "/Users/lily/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-168b2af3cdbd9a8b.rlib" "/Users/lily/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libpanic_unwind-50ee00a6fa5c5e39.rlib" "/Users/lily/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libobject-e23f881d85955200.rlib" "/Users/lily/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libmemchr-a49c48c72917b7fd.rlib" "/Users/lily/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libaddr2line-3ca1e42d18edf654.rlib" "/Users/lily/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libgimli-a781adec4bf6a44b.rlib" "/Users/lily/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_demangle-2968ce6079bb1f71.rlib" "/Users/lily/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd_detect-5e63c5d4a51bde95.rlib" "/Users/lily/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libhashbrown-054c4e8a42992d63.rlib" "/Users/lily/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_std_workspace_alloc-7b1b7572bf2bef56.rlib" "/Users/lily/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libminiz_oxide-b1741068faf841b8.rlib" "/Users/lily/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libadler2-f0b81b684679327b.rlib" "/Users/lily/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libunwind-b6c8d2f9686f2666.rlib" "/Users/lily/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcfg_if-c93a46af375896b2.rlib" "/Users/lily/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liblibc-7a21846f18ba2952.rlib" "/Users/lily/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liballoc-96fab14884229a11.rlib" "/Users/lily/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_std_workspace_core-186a023b8864be69.rlib" "/Users/lily/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcore-74a8d2c13eeedc93.rlib" "/Users/lily/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcompiler_builtins-b294c1429f78dd04.rlib" "-Wl,-Bdynamic" "-lgcc_s" "-lutil" "-lrt" "-lpthread" "-lm" "-ldl" "-lc" "-L" "/tmp/rustcnRBXWa/raw-dylibs" "-B/Users/lily/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/bin/gcc-ld" "-fuse-ld=lld" "-Wl,-znostart-stop-gc" "-Wl,--eh-frame-hdr" "-Wl,-z,noexecstack" "-L" "/Users/lily/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-o" "/tmp/test dir/testing/target/debug/deps/testing-d710013f68c27dbb" "-Wl,--gc-sections" "-pie" "-Wl,-z,relro,-z,now" "-nodefaultlibs"
= note: rust-lld: error: cannot open dir/testing/target/debug/deps/testing-d710013f68c27dbb: No such file or directory
rust-lld: error: cannot open /tmp/test: No such file or directory
rust-lld: error: cannot open dir/testing/target/debug/deps/testing-d710013f68c27dbb.1bfyoq6rlzd3j6rlzixd6uskq.rcgu.o: No such file or directory
rust-lld: error: cannot open /tmp/test: No such file or directory
rust-lld: error: cannot open dir/testing/target/debug/deps/testing-d710013f68c27dbb.8g1cx5khh1sbf5bkfi8dem3ng.rcgu.o: No such file or directory
rust-lld: error: cannot open /tmp/test: No such file or directory
rust-lld: error: cannot open dir/testing/target/debug/deps/testing-d710013f68c27dbb.9ovjrihh4cz1ccqq6va1kyplk.rcgu.o: No such file or directory
rust-lld: error: cannot open /tmp/test: No such file or directory
rust-lld: error: cannot open dir/testing/target/debug/deps/testing-d710013f68c27dbb.btx0i6707le7wjb6vblydmhri.rcgu.o: No such file or directory
rust-lld: error: cannot open /tmp/test: No such file or directory
rust-lld: error: cannot open dir/testing/target/debug/deps/testing-d710013f68c27dbb.c5pedz95lu4ynzmy14tvxncrq.rcgu.o: No such file or directory
rust-lld: error: cannot open /tmp/test: No such file or directory
rust-lld: error: cannot open dir/testing/target/debug/deps/testing-d710013f68c27dbb.clas9xqc2eedytiy6rg88kkr9.rcgu.o: No such file or directory
rust-lld: error: cannot open /tmp/test: No such file or directory
rust-lld: error: cannot open dir/testing/target/debug/deps/testing-d710013f68c27dbb.41nm33s6nku8i3qh7g76xp28m.rcgu.o: No such file or directory
collect2: error: ld returned 1 exit status
error: could not compile `testing` (bin "testing") due to 1 previous error it just seems the same as the last output but with all of the object files listed explicitly |
I didn't know exactly what I needed, I wanted to get the full versions of command lines (including escaping and similar things) and compare them between the good and the bad versions of the compiler. |
yeah that all looks correct, the .o files are quoted correctly. what linker are you using? i see |
yep, it's a shell script: /Users/lily/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/bin/gcc-ld/ld.lld: Bourne-Again shell script, ASCII text executable the script itself is: #!/usr/bin/env bash
set -eu -o pipefail +o posix
shopt -s nullglob
export PROG="/Users/lily/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/bin/gcc-ld-unwrapped/ld.lld"
"/nix/store/dyn2kdxcnhcjz13nqpdrpcgd3qj7996b-rustup-1.27.1/nix-support/ld-wrapper.sh" $@ |
yeah there's your problem, |
(i'm really curious to find out who knows enough bash to know that you should use |
(I've personally never seen |
I'll fix it upstream |
i wonder why this would suddenly be a problem. i don't remember upgrading (or i think i did, it just failed). either way i'm glad we figured out what the problem was ^^ |
You upgraded nightly probably, which made rustup execute the patching, and created the bad wrapper. Maybe you had a very old nightly before that didn't default to rust-lld yet and also didn't have the patching? |
Code
any code works, even that which doesn't link to c libraries. to reproduce it, you can try this:
i expected it to compile, but it said this:
Version it worked on
according to the
.comment
section of one of my applications, it wasrustc version 1.85.0-nightly (d4025ee45 2024-12-12)
, but this is not likely the latest version that successfully compiles it, as i hadn't updated rust in a while, as indicated by the last year build date in the version.Version with regression
rustc --version --verbose
:the regression occurred between 2 nightly versions. i don't know what to do in that case
The text was updated successfully, but these errors were encountered: