Skip to content

rustc fails to build with in-tree libunwind and lld #93349

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

Closed
gburgessiv opened this issue Jan 26, 2022 · 0 comments · Fixed by #93350
Closed

rustc fails to build with in-tree libunwind and lld #93349

gburgessiv opened this issue Jan 26, 2022 · 0 comments · Fixed by #93350
Labels
C-bug Category: This is a bug.

Comments

@gburgessiv
Copy link
Contributor

Trying to build rustc on Debian with the following config used to work, but now fails:

changelog-seen = 2

[llvm]
ninja = true

[rust]
use-lld = true
llvm-libunwind = 'in-tree'

./x.py build exits with:

error: linking with `cc` failed: exit status: 1                                                                       
  |                                                                                                                   
  = note: "cc" "-m64" "/home/george/code/github/rust/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/rustc_main-f54cdb57b4be29de.rustc_main.fcfbea46-cgu.0.rcgu.o" "/home/george/code/github/rust/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/rustc_main-f54cdb57b4be29de.rustc_main.fcfbea46-cgu.1.rcgu.o" "/home/george/code/github/rust/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/re
lease/deps/rustc_main-f54cdb57b4be29de.rustc_main.fcfbea46-cgu.2.rcgu.o" "-Wl,--as-needed" "-L" "/home/george/code/github/rust/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps" "-L" "/home/george/code/github/rust/build/x86_64-unknown-linux-gnu/stage0-rustc/release/deps" "-L" "/home/george/code/github/rust/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/build/psm-b9043e4a2f1f60fc/out" "-L" "/home/george/code/g
ithub/rust/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/build/rustc_llvm-bb58500732d87599/out" "-L" "/home/george/code/github/rust/build/x86_64-unknown-linux-gnu/llvm/build/lib" "-L" "/home/george/code/github/rust/build/x86_64-unknown-linux-gnu/stage0-sysroot/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-L" "/home/george/code/github/rust/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps" "-lrustc_driver-823f1
f0eeb9a9bf8" "-Wl,--start-group" "-L" "/home/george/code/github/rust/build/x86_64-unknown-linux-gnu/stage0-sysroot/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-lstd-2b94913ec1c710dc" "-Wl,--end-group" "-Wl,-Bstatic" "/home/george/code/github/rust/build/x86_64-unknown-linux-gnu/stage0-sysroot/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcompiler_builtins-4ab75a05eb98bf89.rlib" "-Wl,-Bdynamic" "-lrt" "-ldl" "-lpthread" "-lm" "-lz" "-lstdc++" "-ldl" "-lutil" "-lrt" "-lpthrea
d" "-lm" "-ldl" "-lc" "-Wl,--eh-frame-hdr" "-Wl,-znoexecstack" "-L" "/home/george/code/github/rust/build/x86_64-unknown-linux-gnu/stage0-sysroot/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-o" "/home/george/code/github/rust/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/rustc_main-f54cdb57b4be29de" "-Wl,--gc-sections" "-pie" "-Wl,-zrelro,-znow" "-Wl,-O1" "-nodefaultlibs" "-Wl,-z,origin" "-Wl,-rpath,$ORIGIN/../lib" "-fuse-ld=lld"
  = note: ld.lld: error: /home/george/code/github/rust/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/librustc_driver-823f1f0eeb9a9bf8.so: undefined reference to _Unwind_Backtrace [--no-allow-shlib-undefined]

git bisect points to 1c07096 as the culprit. It seems that the changes to libunwind.rs at line 237 accidentally dropped #[link(name = "unwind", kind = "static")] from _Unwind_Backtrace; readding this attribute allows rustc to build successfully.

I have a fix for this I'll upload shortly; just wanted to file an issue to reference first. :)

@gburgessiv gburgessiv added the C-bug Category: This is a bug. label Jan 26, 2022
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Mar 7, 2022
libunwind: readd link attrs to _Unwind_Backtrace

It seems the removal of these in 1c07096 was unintended; readding them fixes the build.

fixes rust-lang#93349

r? `@alexcrichton`
@bors bors closed this as completed in 4d25c51 Mar 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant