Rollup merge of #156319 - bjorn3:eii_dylib_require_def, r=jdonszelmann

Require EIIs to be defined when we compile a rust dylib

The linker will complain about undefined symbols otherwise and on object file formats with two level namespaces (Mach-O and PE/COFF) it is required to know which dylib a symbol will be imported from when linking a dylib or executable.

r? @jdonszelmann
This commit is contained in:
Jonathan Brouwer
2026-05-15 20:11:41 +02:00
committed by GitHub
3 changed files with 19 additions and 2 deletions
+2 -2
View File
@@ -18,8 +18,8 @@ enum CheckingMode {
}
fn get_checking_mode(tcx: TyCtxt<'_>) -> CheckingMode {
// if any of the crate types is not rlib or dylib, we must check for existence.
if tcx.crate_types().iter().any(|i| !matches!(i, CrateType::Rlib | CrateType::Dylib)) {
// if any of the crate types is not rlib, we must check for existence.
if tcx.crate_types().iter().any(|i| !matches!(i, CrateType::Rlib)) {
CheckingMode::CheckExistence
} else {
CheckingMode::CheckDuplicates
+7
View File
@@ -0,0 +1,7 @@
//@ no-prefer-dynamic
//@ needs-crate-type: dylib
#![crate_type = "dylib"]
#![feature(extern_item_impls)]
#[eii(eii1)] //~ ERROR `#[eii1]` required, but not found
fn decl1(x: u64);
+10
View File
@@ -0,0 +1,10 @@
error: `#[eii1]` required, but not found
--> $DIR/dylib_needs_impl.rs:6:7
|
LL | #[eii(eii1)]
| ^^^^ expected because `#[eii1]` was declared here in crate `dylib_needs_impl`
|
= help: expected at least one implementation in crate `dylib_needs_impl` or any of its dependencies
error: aborting due to 1 previous error