-
-
Notifications
You must be signed in to change notification settings - Fork 14.7k
no_mangle/used static is only present in output when in reachable module #47384
Copy link
Copy link
Closed
Labels
A-incr-compArea: Incremental compilationArea: Incremental compilationA-linkageArea: linking into static, shared libraries and binariesArea: linking into static, shared libraries and binariesC-bugCategory: This is a bug.Category: This is a bug.T-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.T-langRelevant to the language teamRelevant to the language team
Metadata
Metadata
Assignees
Labels
A-incr-compArea: Incremental compilationArea: Incremental compilationA-linkageArea: linking into static, shared libraries and binariesArea: linking into static, shared libraries and binariesC-bugCategory: This is a bug.Category: This is a bug.T-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.T-langRelevant to the language teamRelevant to the language team
Type
Fields
Give feedbackNo fields configured for issues without a type.
Statics that are marked
no_mangleand/orusedonly get to the linker if they are in a reachable module of a reachable crate. The static itself does not need to be used in code, only some function in the same module. This previously worked in our project, so this seems like a regression.Example
The issue is best explained with a small example crate named
bug_test, which can be found here:src/lib.rs:src/main.rs:Linker script
linker.ld:Build using:
Show contents of
.staticsection:Comment out one of the
STATIC not present if commented outlines and recompile. ThenSTATICno longer exist in the output and the.staticsection is empty:Versions
Edit: Added the
usedattribute.