diff options
| author | Charles Lew <crlf0710@gmail.com> | 2021-04-24 13:16:34 +0800 |
|---|---|---|
| committer | Charles Lew <crlf0710@gmail.com> | 2021-05-09 10:52:03 +0800 |
| commit | 89a67051a76f8511372d7b9f14610474b1dba6aa (patch) | |
| tree | 275bbf42c8ef07c9d86bfb8a159dec246798c588 /compiler/rustc_codegen_ssa/src | |
| parent | 49920bc581743d6edb9f82fbff4cbafebc212619 (diff) | |
| download | rust-89a67051a76f8511372d7b9f14610474b1dba6aa.tar.gz rust-89a67051a76f8511372d7b9f14610474b1dba6aa.zip | |
Add primary marker on codegen unit to take charge of main_wrapper for non-local cases.
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); |
