Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow global references via ForeignItem and Item for the same symbol name during LLVM codegen #66534

Merged
merged 1 commit into from
Nov 28, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/librustc_codegen_llvm/consts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -233,11 +233,13 @@ impl CodegenCx<'ll, 'tcx> {
ref attrs, span, kind: hir::ItemKind::Static(..), ..
}) => {
let sym_str = sym.as_str();
if self.get_declared_value(&sym_str).is_some() {
span_bug!(span, "Conflicting symbol names for static?");
if let Some(g) = self.get_declared_value(&sym_str) {
if self.val_ty(g) != self.type_ptr_to(llty) {
span_bug!(span, "Conflicting types for static");
}
}

let g = self.define_global(&sym_str, llty).unwrap();
let g = self.declare_global(&sym_str, llty);

if !self.tcx.is_reachable_non_generic(def_id) {
unsafe {
Expand Down