rewrite extern-flag-pathless to rmake
This commit is contained in:
parent
c4c0897a26
commit
16df91b97a
@ -33,7 +33,6 @@ run-make/env-dep-info/Makefile
|
||||
run-make/export-executable-symbols/Makefile
|
||||
run-make/extern-diff-internal-name/Makefile
|
||||
run-make/extern-flag-disambiguates/Makefile
|
||||
run-make/extern-flag-pathless/Makefile
|
||||
run-make/extern-fn-explicit-align/Makefile
|
||||
run-make/extern-fn-generic/Makefile
|
||||
run-make/extern-fn-mangle/Makefile
|
||||
|
@ -1,34 +0,0 @@
|
||||
# ignore-cross-compile
|
||||
include ../tools.mk
|
||||
|
||||
# Test mixing pathless --extern with paths.
|
||||
|
||||
# Test for static linking by checking that the binary runs if the dylib
|
||||
# is removed and test for dynamic linking by checking that the binary
|
||||
# fails to run if the dylib is removed.
|
||||
|
||||
all:
|
||||
$(RUSTC) bar.rs --crate-type=rlib --crate-type=dylib -Cprefer-dynamic
|
||||
|
||||
# rlib preferred over dylib
|
||||
$(RUSTC) foo.rs --extern bar
|
||||
mv $(call DYLIB,bar) $(TMPDIR)/bar.tmp
|
||||
$(call RUN,foo)
|
||||
mv $(TMPDIR)/bar.tmp $(call DYLIB,bar)
|
||||
|
||||
$(RUSTC) foo.rs --extern bar=$(TMPDIR)/libbar.rlib --extern bar
|
||||
mv $(call DYLIB,bar) $(TMPDIR)/bar.tmp
|
||||
$(call RUN,foo)
|
||||
mv $(TMPDIR)/bar.tmp $(call DYLIB,bar)
|
||||
|
||||
# explicit --extern overrides pathless
|
||||
$(RUSTC) foo.rs --extern bar=$(call DYLIB,bar) --extern bar
|
||||
mv $(call DYLIB,bar) $(TMPDIR)/bar.tmp
|
||||
$(call FAIL,foo)
|
||||
mv $(TMPDIR)/bar.tmp $(call DYLIB,bar)
|
||||
|
||||
# prefer-dynamic does what it says
|
||||
$(RUSTC) foo.rs --extern bar -C prefer-dynamic
|
||||
mv $(call DYLIB,bar) $(TMPDIR)/bar.tmp
|
||||
$(call FAIL,foo)
|
||||
mv $(TMPDIR)/bar.tmp $(call DYLIB,bar)
|
40
tests/run-make/extern-flag-pathless/rmake.rs
Normal file
40
tests/run-make/extern-flag-pathless/rmake.rs
Normal file
@ -0,0 +1,40 @@
|
||||
// It is possible, since #64882, to use the --extern flag without an explicit
|
||||
// path. In the event of two --extern flags, the explicit one with a path will take
|
||||
// priority, but otherwise, it is a more concise way of fetching specific libraries.
|
||||
// This test checks that the default priority of explicit extern flags and rlibs is
|
||||
// respected.
|
||||
// See https://github.com/rust-lang/rust/pull/64882
|
||||
|
||||
use run_make_support::{dynamic_lib_name, fs_wrapper, run, run_fail, rust_lib_name, rustc};
|
||||
|
||||
fn main() {
|
||||
rustc().input("bar.rs").crate_type("rlib").crate_type("dylib").arg("-Cprefer-dynamic").run();
|
||||
|
||||
// By default, the rlib has priority over the dylib.
|
||||
rustc().input("foo.rs").arg("--extern").arg("bar").run();
|
||||
fs_wrapper::rename(dynamic_lib_name("bar"), "bar.tmp");
|
||||
run("foo");
|
||||
fs_wrapper::rename("bar.tmp", dynamic_lib_name("bar"));
|
||||
|
||||
rustc().input("foo.rs").extern_("bar", rust_lib_name("bar")).arg("--extern").arg("bar").run();
|
||||
fs_wrapper::rename(dynamic_lib_name("bar"), "bar.tmp");
|
||||
run("foo");
|
||||
fs_wrapper::rename("bar.tmp", dynamic_lib_name("bar"));
|
||||
|
||||
// The first explicit usage of extern overrides the second pathless --extern bar.
|
||||
rustc()
|
||||
.input("foo.rs")
|
||||
.extern_("bar", dynamic_lib_name("bar"))
|
||||
.arg("--extern")
|
||||
.arg("bar")
|
||||
.run();
|
||||
fs_wrapper::rename(dynamic_lib_name("bar"), "bar.tmp");
|
||||
run_fail("foo");
|
||||
fs_wrapper::rename("bar.tmp", dynamic_lib_name("bar"));
|
||||
|
||||
// With prefer-dynamic, execution fails as it refuses to use the rlib.
|
||||
rustc().input("foo.rs").arg("--extern").arg("bar").arg("-Cprefer-dynamic").run();
|
||||
fs_wrapper::rename(dynamic_lib_name("bar"), "bar.tmp");
|
||||
run_fail("foo");
|
||||
fs_wrapper::rename("bar.tmp", dynamic_lib_name("bar"));
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user