-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-linkageArea: linking into static, shared libraries and binariesArea: linking into static, shared libraries and binariesE-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.Call for participation: An issue has been fixed and does not reproduce, but no test has been added.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.
Description
The #[linkage]
feature has some code that generates a symbol, e.g. for foo
it generates extern_with_linkage_foo
.
We have some code that causes the compilation to fail if it can detect that the generated symbol is the source of a collision.
rust/src/librustc_codegen_llvm/consts.rs
Lines 130 to 147 in 4680580
// Declare an internal global `extern_with_linkage_foo` which | |
// is initialized with the address of `foo`. If `foo` is | |
// discarded during linking (for example, if `foo` has weak | |
// linkage and there are no definitions), then | |
// `extern_with_linkage_foo` will instead be initialized to | |
// zero. | |
let mut real_name = "_rust_extern_with_linkage_".to_string(); | |
real_name.push_str(&sym); | |
let g2 = cx.define_global(&real_name, llty).unwrap_or_else(||{ | |
if let Some(span) = span { | |
cx.sess().span_fatal( | |
span, | |
&format!("symbol `{}` is already defined", &sym) | |
) | |
} else { | |
bug!("symbol `{}` is already defined", &sym) | |
} | |
}); |
But as far as I can tell, we have no tests of this feature.
While I was working on PR #61231, I tried to manufacture such a test, but it was not obvious to me how to actually set things up to make the scenario happen. I don't want to forget about the need for this test after I put that task aside, so I'm filing this issue.
Metadata
Metadata
Assignees
Labels
A-linkageArea: linking into static, shared libraries and binariesArea: linking into static, shared libraries and binariesE-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.Call for participation: An issue has been fixed and does not reproduce, but no test has been added.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.