Skip to content

rustc: Handle some libstd symbole exports better#45710

Merged
bors merged 1 commit into
rust-lang:masterfrom
alexcrichton:std-symbols
Nov 5, 2017
Merged

rustc: Handle some libstd symbole exports better#45710
bors merged 1 commit into
rust-lang:masterfrom
alexcrichton:std-symbols

Conversation

@alexcrichton

Copy link
Copy Markdown
Member

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.

@rust-highfive

Copy link
Copy Markdown
Contributor

r? @arielb1

(rust_highfive has picked a reviewer for you, use r? to override)

@alexcrichton

Copy link
Copy Markdown
Member Author

r? @michaelwoerister

@kennytm kennytm added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Nov 2, 2017
@michaelwoerister

Copy link
Copy Markdown
Member

Nice! Thanks @alexcrichton.

@bors r+

@bors

bors commented Nov 3, 2017

Copy link
Copy Markdown
Collaborator

📌 Commit e913be0 has been approved by michaelwoerister

@michaelwoerister michaelwoerister added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Nov 3, 2017
@shepmaster

Copy link
Copy Markdown
Member

symbole exports

Image

@bors

bors commented Nov 4, 2017

Copy link
Copy Markdown
Collaborator

⌛ Testing commit e913be083f4f322d2874ffdabcff8a1aef9255f8 with merge e53898d66af9ab77071cf832170fc2972d1af3e8...

@bors

bors commented Nov 4, 2017

Copy link
Copy Markdown
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.
@alexcrichton

Copy link
Copy Markdown
Member Author

@bors: r=michaelwoerister

@bors

bors commented Nov 5, 2017

Copy link
Copy Markdown
Collaborator

📌 Commit fbf9869 has been approved by michaelwoerister

@bors

bors commented Nov 5, 2017

Copy link
Copy Markdown
Collaborator

⌛ Testing commit fbf9869 with merge 44183f5...

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.
@bors

bors commented Nov 5, 2017

Copy link
Copy Markdown
Collaborator

☀️ Test successful - status-appveyor, status-travis
Approved by: michaelwoerister
Pushing 44183f5 to master...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants