diff options
| author | bors <bors@rust-lang.org> | 2021-05-10 00:42:31 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2021-05-10 00:42:31 +0000 |
| commit | d29289c509c60c52b16277b0cce5abfc5cf06985 (patch) | |
| tree | 6a2acded658f23aa72493144a765bb951dce645f /compiler/rustc_codegen_ssa/src | |
| parent | c55c26cb36a988d5df8b9f4442dc8af93e687a39 (diff) | |
| parent | 89a67051a76f8511372d7b9f14610474b1dba6aa (diff) | |
Auto merge of #84507 - crlf0710:codegen_nonlocal_main_wrapper, r=nagisa
Add primary marker on codegen unit and generate main wrapper on primary codegen. This is the codegen part of changes extracted from #84062. This add a marker called `primary` on each codegen units, where exactly one codegen unit will be `primary = true` at a time. This specific codegen unit will take charge of generating `main` wrapper when `main` is imported from a foreign crate after the implementation of RFC 1260. cc #28937 I'm not sure who should i ask for review for codegen changes, so feel free to reassign. r? `@nagisa`
Diffstat (limited to 'compiler/rustc_codegen_ssa/src')
| -rw-r--r-- | compiler/rustc_codegen_ssa/src/base.rs | 17 |
1 files changed, 3 insertions, 14 deletions
diff --git a/compiler/rustc_codegen_ssa/src/base.rs b/compiler/rustc_codegen_ssa/src/base.rs index e045a23eb0c..7a19b0e4d5a 100644 --- a/compiler/rustc_codegen_ssa/src/base.rs +++ b/compiler/rustc_codegen_ssa/src/base.rs @@ -357,20 +357,9 @@ pub fn maybe_create_entry_wrapper<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>( if !cx.codegen_unit().contains_item(&MonoItem::Fn(instance)) { return None; } - } else { - // FIXME: Add support for non-local main fn codegen - let span = cx.tcx().main_def.unwrap().span; - let n = 28937; - cx.sess() - .struct_span_err(span, "entry symbol `main` from foreign crate is not yet supported.") - .note(&format!( - "see issue #{} <https://github.com/rust-lang/rust/issues/{}> \ - for more information", - n, n, - )) - .emit(); - cx.sess().abort_if_errors(); - bug!(); + } else if !cx.codegen_unit().is_primary() { + // We want to create the wrapper only when the codegen unit is the primary one + return None; } let main_llfn = cx.get_fn_addr(instance); |
