-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
rustc: Handle some libstd symbole exports better #45710
Conversation
r? @arielb1 (rust_highfive has picked a reviewer for you, use r? to override) |
Nice! Thanks @alexcrichton. @bors r+ |
📌 Commit e913be0 has been approved by |
⌛ Testing commit e913be083f4f322d2874ffdabcff8a1aef9255f8 with merge e53898d66af9ab77071cf832170fc2972d1af3e8... |
💔 Test failed - status-appveyor |
Right now symbol exports, particularly in a cdylib, are handled by assuming that `pub extern` combined with `#[no_mangle]` means "export this". This isn't actually what we want for some symbols that the standard library uses to implement itself, for example symbols related to allocation. Additionally other special symbols like `rust_eh_personallity` have no need to be exported from cdylib crate types (only needed in dylib crate types). This commit updates how rustc handles these special symbols by adding to the hardcoded logic of symbols like `rust_eh_personallity` but also adding a new attribute, `#[rustc_std_internal_symbol]`, which forces the export level to be considered the same as all other Rust functions instead of looking like a C function. The eventual goal here is to prevent functions like `__rdl_alloc` from showing up as part of a Rust cdylib as it's just an internal implementation detail. This then further allows such symbols to get gc'd by the linker when creating a cdylib.
e913be0
to
fbf9869
Compare
@bors: r=michaelwoerister |
📌 Commit fbf9869 has been approved by |
rustc: Handle some libstd symbole exports better Right now symbol exports, particularly in a cdylib, are handled by assuming that `pub extern` combined with `#[no_mangle]` means "export this". This isn't actually what we want for some symbols that the standard library uses to implement itself, for example symbols related to allocation. Additionally other special symbols like `rust_eh_personallity` have no need to be exported from cdylib crate types (only needed in dylib crate types). This commit updates how rustc handles these special symbols by adding to the hardcoded logic of symbols like `rust_eh_personallity` but also adding a new attribute, `#[rustc_std_internal_symbol]`, which forces the export level to be considered the same as all other Rust functions instead of looking like a C function. The eventual goal here is to prevent functions like `__rdl_alloc` from showing up as part of a Rust cdylib as it's just an internal implementation detail. This then further allows such symbols to get gc'd by the linker when creating a cdylib.
☀️ Test successful - status-appveyor, status-travis |
Right now symbol exports, particularly in a cdylib, are handled by
assuming that
pub extern
combined with#[no_mangle]
means "exportthis". This isn't actually what we want for some symbols that the
standard library uses to implement itself, for example symbols related
to allocation. Additionally other special symbols like
rust_eh_personallity
have no need to be exported from cdylib cratetypes (only needed in dylib crate types).
This commit updates how rustc handles these special symbols by adding to
the hardcoded logic of symbols like
rust_eh_personallity
but alsoadding a new attribute,
#[rustc_std_internal_symbol]
, which forces theexport level to be considered the same as all other Rust functions
instead of looking like a C function.
The eventual goal here is to prevent functions like
__rdl_alloc
fromshowing up as part of a Rust cdylib as it's just an internal
implementation detail. This then further allows such symbols to get gc'd
by the linker when creating a cdylib.