Skip to content
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

rust_begin_unwind symbol doesn't have the right visibility #52795

Closed
japaric opened this issue Jul 27, 2018 · 1 comment
Closed

rust_begin_unwind symbol doesn't have the right visibility #52795

japaric opened this issue Jul 27, 2018 · 1 comment
Assignees

Comments

@japaric
Copy link
Member

japaric commented Jul 27, 2018

when emitted from a bin crate.

STR

$ cat foo.rs
#![feature(panic_implementation)]
#![no_main]
#![no_std]

use core::panic::PanicInfo;

#[panic_implementation]
fn panic(_info: &PanicInfo) -> ! {
    loop {}
}
$ rustc -C panic=abort --crate-type=bin --emit=obj foo.rs

$ nm -C foo.o
0000000000000000 t rust_begin_unwind

$ rustc -C panic=abort --crate-type=lib --emit=obj foo.rs

$ nm -C foo.o
0000000000000000 T rust_begin_unwind

rust_begin_unwind being an internal / private symbol (t) causes linker errors of the form "undefined reference to rust_begin_unwind".

Meta

$ rustc -V
rustc 1.29.0-nightly (6a1c0637c 2018-07-23)
@alexcrichton
Copy link
Member

I believe this is fixed in #52993

alexcrichton added a commit to alexcrichton/rust that referenced this issue Aug 7, 2018
This commit tweaks the linker-level visibility of some lang items that rustc
uses and defines. Notably this means that `#[panic_implementation]` and
`#[alloc_error_handler]` functions are never marked as `internal`. It's up to
the linker to eliminate these, not rustc.

Additionally `#[global_allocator]` generated symbols are no longer forced to
`Default` visibility (fully exported), but rather they're relaxed to `Hidden`
visibility). This symbols are *not* needed across DLL boundaries, only as a
local implementation detail of the compiler-injected allocator symbols, so
`Hidden` should suffice.

Closes rust-lang#51342
Closes rust-lang#52795
bors added a commit that referenced this issue Aug 8, 2018
rustc: Tweak visibility of some lang items

This commit tweaks the linker-level visibility of some lang items that rustc
uses and defines. Notably this means that `#[panic_implementation]` and
`#[alloc_error_handler]` functions are never marked as `internal`. It's up to
the linker to eliminate these, not rustc.

Additionally `#[global_allocator]` generated symbols are no longer forced to
`Default` visibility (fully exported), but rather they're relaxed to `Hidden`
visibility). This symbols are *not* needed across DLL boundaries, only as a
local implementation detail of the compiler-injected allocator symbols, so
`Hidden` should suffice.

Closes #51342
Closes #52795
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants