]> git.lizzy.rs Git - rust.git/commit
rustc: Handle some libstd symbole exports better
authorAlex Crichton <alex@alexcrichton.com>
Wed, 1 Nov 2017 20:16:36 +0000 (13:16 -0700)
committerAlex Crichton <alex@alexcrichton.com>
Sun, 5 Nov 2017 03:01:11 +0000 (20:01 -0700)
commitfbf98697021173a30b84d9145df0966a23a2f9d2
tree61dcbdd472b1d6e099f3e8fbaa1a4bbf033173de
parent12e6b53744a0101f28855f25e6e4551e2d664857
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.
src/liballoc_jemalloc/lib.rs
src/librustc_allocator/expand.rs
src/librustc_trans/back/symbol_export.rs
src/libstd/heap.rs
src/libsyntax/feature_gate.rs
src/test/run-make/cdylib-fewer-symbols/Makefile [new file with mode: 0644]
src/test/run-make/cdylib-fewer-symbols/foo.rs [new file with mode: 0644]