-
-
Notifications
You must be signed in to change notification settings - Fork 14.9k
tests/run-make/used-proc-macro is flaky as it relies on linker behavior #155434
Copy link
Copy link
Open
Labels
A-linkersArea: linkers... you gotta love linkersArea: linkers... you gotta love linkersA-testsuiteArea: The testsuite used to check the correctness of rustcArea: The testsuite used to check the correctness of rustcC-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.
Metadata
Metadata
Assignees
Labels
A-linkersArea: linkers... you gotta love linkersArea: linkers... you gotta love linkersA-testsuiteArea: The testsuite used to check the correctness of rustcArea: The testsuite used to check the correctness of rustcC-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.
Type
Fields
Give feedbackNo fields configured for issues without a type.
The stated expectation of the test is:
However, the
#[used]attribute only guarantees that a static variable will be preserved in the compiler's output object file (see the Rust reference). The linker is completely free to discard such symbols as it's unaware of the presence of the#[used]attribute in the Rust source code.Dylibs are partially linked ("relocatable") objects so the compiler will invoke the linker to perform the partially linking. The process of partially linking the dylib can discard the
VERY_IMPORTANT_SYMBOLstatic which this test then checks it's present in the final dylib artifact (.sofile). Therefore, as written this test is flaky as it relies on the linker not discarding the symbol.In Ferrocene CI, we have observed this test fail on an
aarch64-unknown-linux-gnuhost running the test natively (compilation target is the host tuple). The Ferrocene CI environment for that host tuple uses GCC 10 as the linker which may be different from the version that the Rust project uses and that could explain the different outcome.As this is the Ferrocene source code, the git revision is different but the closest rust-lang/rust revision is e8e4541
To make this test more reliable, the proc-macro crate should access the
VERY_IMPORTANT_SYMBOLvariable via FFI to prevent it from being discarded by the linker.