compiletest: Don't assume aux-crate becomes a *.so with no-prefer-dynamic

Since it does not make sense to do so. If someone prefers no dynamic
stuff, the last thing they want to look for is an `.so` file. Also add a
regression test. Without the fix, the test fails with:

    error: test compilation failed although it shouldn't!
    --- stderr -------------------------------
    error: extern location for no_prefer_dynamic_lib does not exist: .../auxiliary/libno_prefer_dynamic_lib.so
      --> .../no-prefer-dynamic-means-no-so.rs:9:5
       |
    LL |     no_prefer_dynamic_lib::return_42();
       |     ^^^^^^^^^^^^^^^^^^^^^
This commit is contained in:
Martin Nordholts 2026-01-15 06:12:57 +01:00
parent 5ac8ecea36
commit f14e3ee38f
3 changed files with 21 additions and 1 deletions

View file

@ -1438,7 +1438,7 @@ impl<'test> TestCx<'test> {
} else if aux_type.is_some() {
panic!("aux_type {aux_type:?} not expected");
} else if aux_props.no_prefer_dynamic {
(AuxType::Dylib, None)
(AuxType::Lib, None)
} else if self.config.target.contains("emscripten")
|| (self.config.target.contains("musl")
&& !aux_props.force_host

View file

@ -0,0 +1,10 @@
//@ no-prefer-dynamic
//! Since this is `no-prefer-dynamic` we expect compiletest to _not_ look for
//! this create as `libno_prefer_dynamic_lib.so`.
#![crate_type = "rlib"]
pub fn return_42() -> i32 {
42
}

View file

@ -0,0 +1,10 @@
//! Since we and our `aux-crate` is `no-prefer-dynamic`, we expect compiletest
//! to _not_ look for `libno_prefer_dynamic_lib.so`.
//@ check-pass
//@ no-prefer-dynamic
//@ aux-crate: no_prefer_dynamic_lib=no_prefer_dynamic_lib.rs
fn main() {
no_prefer_dynamic_lib::return_42();
}