diff options
| author | bjorn3 <17426603+bjorn3@users.noreply.github.com> | 2022-12-16 09:55:27 +0000 |
|---|---|---|
| committer | bjorn3 <17426603+bjorn3@users.noreply.github.com> | 2022-12-16 09:57:07 +0000 |
| commit | ec92c3e5dca69cf0ed02d11fb7a3bfae9f41c0ca (patch) | |
| tree | 15f8f5f6f4988fc34766ab391ca0eba9bd973379 /src | |
| parent | b5ac64b4cf33809b182a6f7c63a7c4e874fb3056 (diff) | |
| download | rust-ec92c3e5dca69cf0ed02d11fb7a3bfae9f41c0ca.tar.gz rust-ec92c3e5dca69cf0ed02d11fb7a3bfae9f41c0ca.zip | |
Fix ICE on incompatible declarations of entry symbol
Fixes #1313
Diffstat (limited to 'src')
| -rw-r--r-- | src/main_shim.rs | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/main_shim.rs b/src/main_shim.rs index c10054e7f0d..556d7b8e51a 100644 --- a/src/main_shim.rs +++ b/src/main_shim.rs @@ -70,7 +70,13 @@ pub(crate) fn maybe_create_entry_wrapper( }; let entry_name = tcx.sess.target.options.entry_name.as_ref(); - let cmain_func_id = m.declare_function(entry_name, Linkage::Export, &cmain_sig).unwrap(); + let cmain_func_id = match m.declare_function(entry_name, Linkage::Export, &cmain_sig) { + Ok(func_id) => func_id, + Err(err) => { + tcx.sess + .fatal(&format!("entry symbol `{entry_name}` declared multiple times: {err}")); + } + }; let instance = Instance::mono(tcx, rust_main_def_id).polymorphize(tcx); @@ -162,7 +168,11 @@ pub(crate) fn maybe_create_entry_wrapper( bcx.seal_all_blocks(); bcx.finalize(); } - m.define_function(cmain_func_id, &mut ctx).unwrap(); + + if let Err(err) = m.define_function(cmain_func_id, &mut ctx) { + tcx.sess.fatal(&format!("entry symbol `{entry_name}` defined multiple times: {err}")); + } + unwind_context.add_function(cmain_func_id, &ctx, m.isa()); } } |
