Skip to content

Commit 16df91b

Browse files
committed
rewrite extern-flag-pathless to rmake
1 parent c4c0897 commit 16df91b

File tree

3 files changed

+40
-35
lines changed

3 files changed

+40
-35
lines changed

src/tools/tidy/src/allowed_run_make_makefiles.txt

-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ run-make/env-dep-info/Makefile
3333
run-make/export-executable-symbols/Makefile
3434
run-make/extern-diff-internal-name/Makefile
3535
run-make/extern-flag-disambiguates/Makefile
36-
run-make/extern-flag-pathless/Makefile
3736
run-make/extern-fn-explicit-align/Makefile
3837
run-make/extern-fn-generic/Makefile
3938
run-make/extern-fn-mangle/Makefile

tests/run-make/extern-flag-pathless/Makefile

-34
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
// It is possible, since #64882, to use the --extern flag without an explicit
2+
// path. In the event of two --extern flags, the explicit one with a path will take
3+
// priority, but otherwise, it is a more concise way of fetching specific libraries.
4+
// This test checks that the default priority of explicit extern flags and rlibs is
5+
// respected.
6+
// See https://github.com/rust-lang/rust/pull/64882
7+
8+
use run_make_support::{dynamic_lib_name, fs_wrapper, run, run_fail, rust_lib_name, rustc};
9+
10+
fn main() {
11+
rustc().input("bar.rs").crate_type("rlib").crate_type("dylib").arg("-Cprefer-dynamic").run();
12+
13+
// By default, the rlib has priority over the dylib.
14+
rustc().input("foo.rs").arg("--extern").arg("bar").run();
15+
fs_wrapper::rename(dynamic_lib_name("bar"), "bar.tmp");
16+
run("foo");
17+
fs_wrapper::rename("bar.tmp", dynamic_lib_name("bar"));
18+
19+
rustc().input("foo.rs").extern_("bar", rust_lib_name("bar")).arg("--extern").arg("bar").run();
20+
fs_wrapper::rename(dynamic_lib_name("bar"), "bar.tmp");
21+
run("foo");
22+
fs_wrapper::rename("bar.tmp", dynamic_lib_name("bar"));
23+
24+
// The first explicit usage of extern overrides the second pathless --extern bar.
25+
rustc()
26+
.input("foo.rs")
27+
.extern_("bar", dynamic_lib_name("bar"))
28+
.arg("--extern")
29+
.arg("bar")
30+
.run();
31+
fs_wrapper::rename(dynamic_lib_name("bar"), "bar.tmp");
32+
run_fail("foo");
33+
fs_wrapper::rename("bar.tmp", dynamic_lib_name("bar"));
34+
35+
// With prefer-dynamic, execution fails as it refuses to use the rlib.
36+
rustc().input("foo.rs").arg("--extern").arg("bar").arg("-Cprefer-dynamic").run();
37+
fs_wrapper::rename(dynamic_lib_name("bar"), "bar.tmp");
38+
run_fail("foo");
39+
fs_wrapper::rename("bar.tmp", dynamic_lib_name("bar"));
40+
}

0 commit comments

Comments
 (0)