llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
29.11k stars 12.01k forks source link

Unwinding fails when linking object file produced by rustc #24587

Closed tamird closed 3 years ago

tamird commented 9 years ago
Bugzilla Link 24213
Resolution WONTFIX
Resolved on Feb 19, 2021 15:58
Version unspecified
OS MacOS X
CC @int3,@lhames

Extended Description

Full repro is here: https://github.com/tamird/rust_lld, but you'll need a working rust compiler and might need to massage build.sh for your system.

TL;DR unwinding fails with fatal runtime error: Could not unwind stack, error = 5.

Here's the symbol table diff between what ld produces vs lld: https://gist.github.com/tamird/1af0c8d9a7132fd9915e

int3 commented 3 years ago

Closing this as it applies to the old iteration of LLD-MachO which is not being developed. (The new one is named ld64.lld.darwinnew, and will be receiving active feature development and bug fixes.)

tamird commented 6 years ago

This repro is much easier with a rust compiler that includes https://github.com/rust-lang/rust/pull/46255/commits/c30d8f2f1f2d904544af0b6eab89f0e3bb586c75.

With that compiler, given hello_world.rs:

fn main() {
    println!("hello world!");
    panic!("goodbye world!");
}

Using ld64:

$ ld -v
@(#)PROGRAM:ld  PROJECT:ld64-302.3.1
configured to support archs: armv6 armv7 armv7s arm64 i386 x86_64 x86_64h armv6m armv7k armv7m armv7em (tvOS)
LTO support using: LLVM version 9.0.0, (clang-900.0.38) (static support for 21, runtime is 21)
TAPI support using: Apple TAPI version 900.0.14 (tapi-900.0.14)

$ ./build/x86_64-apple-darwin/stage1/bin/rustc hello_world.rs && ./hello_world
hello world!
thread 'main' panicked at 'goodbye world!', hello_world.rs:3:4
note: Run with `RUST_BACKTRACE=1` for a backtrace.

Using LLD 6.0.0 (https://llvm.org/git/lld.git 70cb0908a7a1efc8b81f7a0848e36e2dfcf05d1e):

$ ./build/x86_64-apple-darwin/stage1/bin/rustc -Z linker-flavor=ld -C linker=$(brew --prefix llvm)/bin/ld64.lld hello_world.rs && ./hello_world
hello world!

thread 'main' has overflowed its stack
fatal runtime error: stack overflow
Abort trap: 6
silvasean commented 8 years ago

Moving to more specific "MachO" LLD component (instead of generic "All Bugs").

tamird commented 9 years ago

Any news on this? I just tested with LLD HEAD and the problem appears to persist.

tamird commented 9 years ago

[statically linked: https://user-images.githubusercontent.com/92601824/143751747-5cb44b42-9a37-45ce-88a6-ea193b0610bd.gz)

tamird commented 9 years ago

[dynamically linked: https://user-images.githubusercontent.com/92601824/143751748-882077da-e537-4789-8130-bddc6c06963a.gz)

tamird commented 9 years ago

There are 5 rust libraries involved, and they range from 2.3M to 19M. The attachment limit is 1M, so I can't attach those.

I'll attach the resulting *.o files.

lhames commented 9 years ago

Hi Tamir,

How big are the rust libraries? Would it be possible for you to attach the raw *.o files and libraries you're linking?

Cheers, Lang.

tamird commented 9 years ago

assigned to @lhames