rustc: Handle some libstd symbole exports better#45710
Merged
bors merged 1 commit intorust-lang:masterfrom Nov 5, 2017
Merged
Conversation
Contributor
|
r? @arielb1 (rust_highfive has picked a reviewer for you, use r? to override) |
Member
Author
Member
|
Nice! Thanks @alexcrichton. @bors r+ |
Collaborator
|
📌 Commit e913be0 has been approved by |
Member
Collaborator
|
⌛ Testing commit e913be083f4f322d2874ffdabcff8a1aef9255f8 with merge e53898d66af9ab77071cf832170fc2972d1af3e8... |
Collaborator
|
💔 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
Member
Author
|
@bors: r=michaelwoerister |
Collaborator
|
📌 Commit fbf9869 has been approved by |
Collaborator
bors
added a commit
that referenced
this pull request
Nov 5, 2017
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.
Collaborator
|
☀️ Test successful - status-appveyor, status-travis |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Right now symbol exports, particularly in a cdylib, are handled by
assuming that
pub externcombined 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_personallityhave 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_personallitybut 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_allocfromshowing 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.