-
Couldn't load subscription status.
- Fork 13.9k
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.