Skip to content

Refactor the linkage handling of libunwind #84040

Open
@12101111

Description

@12101111

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 enable llvm-libunwind feature of libunwind
  • system will enable system-llvm-libunwind feature of libunwind
  • no won't enable any feature of libunwind

Ideally, the behavior of this flags would be:

  • in-tree will compile the intree copy of llvm-libunwind, and link it into libunwind.rlib
  • system will link the libunwind.so/libunwind.a from users' system
  • no will link the libgcc_s.so/libgcc_eh.a from users' system

But the current situation is a mess:

image

The probems are:

My suggestion:

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-linkageArea: linking into static, shared libraries and binariesA-runtimeArea: std's runtime and "pre-main" init for handling backtraces, unwinds, stack overflowsC-enhancementCategory: An issue proposing an enhancement or a PR with one.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions