Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 6fffe84

Browse files
committedJun 17, 2024
rewrite native-link-modifier-linker to rmake
1 parent 5f2b47f commit 6fffe84

File tree

5 files changed

+50
-19
lines changed

5 files changed

+50
-19
lines changed
 

‎src/tools/tidy/src/allowed_run_make_makefiles.txt

-1
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,6 @@ run-make/missing-crate-dependency/Makefile
142142
run-make/mixing-libs/Makefile
143143
run-make/msvc-opt-minsize/Makefile
144144
run-make/native-link-modifier-bundle/Makefile
145-
run-make/native-link-modifier-verbatim-linker/Makefile
146145
run-make/native-link-modifier-whole-archive/Makefile
147146
run-make/no-alloc-shim/Makefile
148147
run-make/no-builtins-attribute/Makefile

‎tests/run-make/native-link-modifier-verbatim-linker/Makefile

-15
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
// `verbatim` is a native link modifier that forces rustc to only accept libraries with
2+
// a specified name. This test checks that this modifier works as intended.
3+
// This test is the same as native-link-modifier-rustc, but without rlibs.
4+
// See https://github.com/rust-lang/rust/issues/99425
5+
6+
//@ ignore-apple
7+
// Reason: linking fails due to the unusual ".ext" staticlib name.
8+
9+
use run_make_support::rustc;
10+
11+
fn main() {
12+
// Verbatim allows for the specification of a precise name
13+
// - in this case, the unconventional ".ext" extension.
14+
rustc()
15+
.input("local_native_dep.rs")
16+
.crate_type("staticlib")
17+
.output("local_some_strange_name.ext")
18+
.run();
19+
rustc().input("main.rs").arg("-lstatic:+verbatim=local_some_strange_name.ext").run();
20+
21+
// This section voluntarily avoids using static_lib_name helpers to be verbatim.
22+
// With verbatim, even these common library names are refused
23+
// - it wants local_native_dep without
24+
// any file extensions.
25+
rustc()
26+
.input("local_native_dep.rs")
27+
.crate_type("staticlib")
28+
.output("liblocal_native_dep.a")
29+
.run();
30+
rustc().input("local_native_dep.rs").crate_type("staticlib").output("local_native_dep.a").run();
31+
rustc()
32+
.input("local_native_dep.rs")
33+
.crate_type("staticlib")
34+
.output("local_native_dep.lib")
35+
.run();
36+
rustc()
37+
.input("main.rs")
38+
.arg("-lstatic:+verbatim=local_native_dep")
39+
.run_fail()
40+
.assert_stderr_contains("local_native_dep");
41+
}

‎tests/run-make/native-link-modifier-verbatim-rustc/rmake.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
// `verbatim` is a native link modifier that forces rustc to only accept libraries with
22
// a specified name. This test checks that this modifier works as intended.
3+
// This test is the same as native-link-modifier-linker, but with rlibs.
34
// See https://github.com/rust-lang/rust/issues/99425
45

56
use run_make_support::rustc;
67

78
fn main() {
8-
// Verbatim allows for the specification of a precise name - in this case, the unconventional ".ext" extension.
9+
// Verbatim allows for the specification of a precise name
10+
// - in this case, the unconventional ".ext" extension.
911
rustc()
1012
.input("upstream_native_dep.rs")
1113
.crate_type("staticlib")
@@ -18,7 +20,8 @@ fn main() {
1820
.run();
1921

2022
// This section voluntarily avoids using static_lib_name helpers to be verbatim.
21-
// With verbatim, even these common library names are refused - it wants upstream_native_dep without
23+
// With verbatim, even these common library names are refused
24+
// - it wants upstream_native_dep without
2225
// any file extensions.
2326
rustc()
2427
.input("upstream_native_dep.rs")

‎tests/run-make/output-filename-conflicts-with-directory/rmake.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// ignore-tidy-linelength
12
// When the compiled executable would conflict with a directory, a
23
// rustc error should be displayed instead of a verbose and
34
// potentially-confusing linker error.
@@ -7,5 +8,7 @@ use run_make_support::{fs_wrapper, rustc};
78

89
fn main() {
910
fs_wrapper::create_dir("foo");
10-
rustc().input("foo.rs").output("foo").run_fail().assert_stderr_contains(r#"the generated executable for the input file "foo.rs" conflicts with the existing directory "foo""#);
11+
rustc().input("foo.rs").output("foo").run_fail().assert_stderr_contains(
12+
r#"the generated executable for the input file "foo.rs" conflicts with the existing directory "foo""#,
13+
);
1114
}

0 commit comments

Comments
 (0)
Failed to load comments.