Skip to content

stop exporting every symbol #37530

Closed
Closed

Description

On Linux, a typical rust ELF dynamic library will export every symbol on earth, e.g.:

objdump -T ~/projects/goblin/target/debug/libgoblin.so | wc -l
2558

which looks like most of core and std, e.g.:

107680 _ZN4core3num52_$LT$impl$u20$core..str..FromStr$u20$for$u20$u16$GT$8from_str17he60266b17184e647E (114)

Why not do this? Well, it's just The Right Thing To Do ™️ but also, technically it unnecessarily increases the size of the binary by adding dynamic symbol entries + string table entires, in addition to bloom filter words.

It might slightly increase dynamic loading time but I'm probably lying now to increase bullet points for why we shouldn't export all the symbols.

I suspect this may have come up already but I can't seem to find it, but I recall perhaps it had something to do with a requirement of std to make all their symbols public and this is somehow reflected in the binary? or perhaps it was something to do with more 3rd party linker nonsense.

Anyway, if there's a technical possibility to stop it, we should try and be good binary citizens.

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

Metadata

Assignees

No one assigned

    Labels

    A-linkageArea: linking into static, shared libraries and binariesArea: linking into static, shared libraries and binariesT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions