-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Refactor the linkage handling of libunwind #84040
Comments
If this is implemented, then I suggest following the approach from #72274 ("Distribute libc.a as a separate library instead of bundling it into liblibc.rlib on musl and wasi") for the in-tree case. |
There is no such target for Rust yet but on Windows with mingw-w64 there are toolchains allowing switching between libgcc and libunwind, also there are even toolchains using libunwind exclusively. |
Currently libgcc_s on windows_gnu is pulled in rust/compiler/rustc_target/src/spec/windows_gnu_base.rs Lines 42 to 60 in 6f9df55
It's possible to migrate the logic to libunwind Lines 40 to 43 in 6f9df55
|
Yeah, it was outlined in #72241 (comment) but I haven't got time to investigate it further. |
This needs compiler support (evaluation of |
libunwind
currently need a c/cpp library that provide_Unwind_*
symbols to work.libgcc_s.so/libgcc_eh.a
from gcc orlibunwind.so/libunwind.a
from llvm can provide those symbols.The
libunwind
crate is built when compiler bootstrap, and there is a flag inconfig.toml
that choose which implementation to use. User can't change the implementation after bootstrap ( unless build-std add a flag for this )in-tree
will enablellvm-libunwind
feature oflibunwind
system
will enablesystem-llvm-libunwind
feature oflibunwind
no
won't enable any feature oflibunwind
Ideally, the behavior of this flags would be:
in-tree
will compile the intree copy of llvm-libunwind, and link it into libunwind.rlibsystem
will link thelibunwind.so/libunwind.a
from users' systemno
will link thelibgcc_s.so/libgcc_eh.a
from users' systemBut the current situation is a mess:
The probems are:
target-feature=+crt-static
, glibc/uclibc will always linklibgcc_eh.a
bylibc
crate, see Support static linking with glibc and target-feature=+crt-static #77386. Butlibunwind.a
is still linked ifllvm-libunwind
feature is enabled:rust/library/unwind/src/libunwind.rs
Lines 80 to 84 in e43c200
llvm-libunwind
feature andsystem-llvm-libunwind
feature.llvm-libunwind
feature is enabled, clang don't accept-std=c++11
and cause bootstrap failed, see Building rustc in Clang 9.0 error: invalid argument '-std=c++11' not allowed with 'C' #69222system-llvm-libunwind
feature at all, my previous PR Don't build in-tree llvm-libunwind if system-llvm-libunwind is enable #80818 break the unwinder if settarget-feature=+crt-static
and enablesystem-llvm-libunwind
feature.system-llvm-libunwind
feature is enabled.My suggestion:
llvm-libunwind=system
option to linux only, as all other system only have one working unwind implementation. ( some changes tobuild.rs
)llvm-libunwind
feature andsystem-llvm-libunwind
feature. ( some changes tolib.rs
)The text was updated successfully, but these errors were encountered: