Open
Description
libunwind
currently need a c/cpp library that provide _Unwind_*
symbols to work. libgcc_s.so/libgcc_eh.a
from gcc or libunwind.so/libunwind.a
from llvm can provide those symbols.
The libunwind
crate is built when compiler bootstrap, and there is a flag in config.toml
that choose which implementation to use. User can't change the implementation after bootstrap ( unless build-std add a flag for this )
# Use LLVM libunwind as the implementation for Rust's unwinder.
# Accepted values are 'in-tree' (formerly true), 'system' or 'no' (formerly false).
#llvm-libunwind = 'no'
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' system
But the current situation is a mess:
The probems are:
- if user set
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
- musl target don't follow the
llvm-libunwind
feature andsystem-llvm-libunwind
feature. - when cc=clang, and
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' #69222 - Because musl target don't follow the
system-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. - Other target such as fuchsia or BSDs will also break if
system-llvm-libunwind
feature is enabled.
My suggestion:
- limit the
llvm-libunwind=system
option to linux only, as all other system only have one working unwind implementation. ( some changes tobuild.rs
) - musl target should follow the
llvm-libunwind
feature andsystem-llvm-libunwind
feature. ( some changes tolib.rs
) - check whether 8d2f80b is unnecessary now
- fix Building rustc in Clang 9.0 error: invalid argument '-std=c++11' not allowed with 'C' #69222