diff options
| author | León Orell Valerian Liehr <me@fmease.dev> | 2024-05-15 14:21:39 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-05-15 14:21:39 +0200 |
| commit | 2659ff3882ea57c680a6bfc6533e95be346ed9ad (patch) | |
| tree | ef5577bc3a3de970c9952f5366873be747b02478 /tests | |
| parent | 4f7d9d4ad815b6a48e1cd41fcc63e37875d3341d (diff) | |
| parent | 1f61cc3078ce6bcca8095778310f73fc45f7193e (diff) | |
| download | rust-2659ff3882ea57c680a6bfc6533e95be346ed9ad.tar.gz rust-2659ff3882ea57c680a6bfc6533e95be346ed9ad.zip | |
Rollup merge of #125104 - Oneirical:test6, r=jieyouxu
Migrate `run-make/no-cdylib-as-rdylib` to `rmake`
Part of #121876 and the associated [Google Summer of Code project](https://blog.rust-lang.org/2024/05/01/gsoc-2024-selected-projects.html).
> "the test will fail if the cdylib is picked, because it doesn't export any rust symbols"
Is that true? Is there a way to verify?
I suggest maybe extending the test with: (after cleaning the directory)
```rust
rustc()
.input("bar.rs")
.crate_type("cdylib")
.run();
rustc()
.input("foo.rs")
.prefer_dynamic()
.run();
fail();
```
to make sure we're actually testing something here.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/run-make/no-cdylib-as-rdylib/Makefile | 16 | ||||
| -rw-r--r-- | tests/run-make/no-cdylib-as-rdylib/rmake.rs | 16 |
2 files changed, 16 insertions, 16 deletions
diff --git a/tests/run-make/no-cdylib-as-rdylib/Makefile b/tests/run-make/no-cdylib-as-rdylib/Makefile deleted file mode 100644 index 4d2be0aea91..00000000000 --- a/tests/run-make/no-cdylib-as-rdylib/Makefile +++ /dev/null @@ -1,16 +0,0 @@ -# ignore-cross-compile -include ../tools.mk - -# Test that rustc will not attempt to link against a cdylib as if -# it is a rust dylib when an rlib for the same crate is available. -# Previously rustc didn't actually check if any further formats of -# a crate which has been loaded are of the same version and if -# they are actually valid. This caused a cdylib to be interpreted -# as rust dylib as soon as the corresponding rlib was loaded. As -# cdylibs don't export any rust symbols, linking would fail if -# rustc decides to link against the cdylib rather than the rlib. - -all: - $(RUSTC) bar.rs --crate-type=rlib --crate-type=cdylib - $(RUSTC) foo.rs -C prefer-dynamic - $(call RUN,foo) diff --git a/tests/run-make/no-cdylib-as-rdylib/rmake.rs b/tests/run-make/no-cdylib-as-rdylib/rmake.rs new file mode 100644 index 00000000000..42e89df6c2b --- /dev/null +++ b/tests/run-make/no-cdylib-as-rdylib/rmake.rs @@ -0,0 +1,16 @@ +// This test produces an rlib and a cdylib from bar.rs. +// Then, foo.rs attempts to link to the bar library. +// If the test passes, that means rustc favored the rlib and ignored the cdylib. +// If the test fails, that is because the cdylib was picked, which does not export +// any Rust symbols. +// See https://github.com/rust-lang/rust/pull/113695 + +//@ ignore-cross-compile + +use run_make_support::{run, rustc}; + +fn main() { + rustc().input("bar.rs").crate_type("rlib").crate_type("cdylib").run(); + rustc().input("foo.rs").arg("-Cprefer-dynamic").run(); + run("foo"); +} |
