Skip to content

Commit

Permalink
rewrite native-link-modifier-linker to rmake
Browse files Browse the repository at this point in the history
  • Loading branch information
Oneirical committed Jun 17, 2024
1 parent 5f2b47f commit 1abe51f
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 19 deletions.
1 change: 0 additions & 1 deletion src/tools/tidy/src/allowed_run_make_makefiles.txt
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,6 @@ run-make/missing-crate-dependency/Makefile
run-make/mixing-libs/Makefile
run-make/msvc-opt-minsize/Makefile
run-make/native-link-modifier-bundle/Makefile
run-make/native-link-modifier-verbatim-linker/Makefile
run-make/native-link-modifier-whole-archive/Makefile
run-make/no-alloc-shim/Makefile
run-make/no-builtins-attribute/Makefile
Expand Down
15 changes: 0 additions & 15 deletions tests/run-make/native-link-modifier-verbatim-linker/Makefile

This file was deleted.

38 changes: 38 additions & 0 deletions tests/run-make/native-link-modifier-verbatim-linker/rmake.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// `verbatim` is a native link modifier that forces rustc to only accept libraries with
// a specified name. This test checks that this modifier works as intended.
// This test is the same as native-link-modifier-rustc, but without rlibs.
// See https://github.com/rust-lang/rust/issues/99425

use run_make_support::rustc;

fn main() {
// Verbatim allows for the specification of a precise name
// - in this case, the unconventional ".ext" extension.
rustc()
.input("local_native_dep.rs")
.crate_type("staticlib")
.output("local_some_strange_name.ext")
.run();
rustc().input("main.rs").arg("-lstatic:+verbatim=local_some_strange_name.ext").run();

// This section voluntarily avoids using static_lib_name helpers to be verbatim.
// With verbatim, even these common library names are refused
// - it wants local_native_dep without
// any file extensions.
rustc()
.input("local_native_dep.rs")
.crate_type("staticlib")
.output("liblocal_native_dep.a")
.run();
rustc().input("local_native_dep.rs").crate_type("staticlib").output("local_native_dep.a").run();
rustc()
.input("local_native_dep.rs")
.crate_type("staticlib")
.output("local_native_dep.lib")
.run();
rustc()
.input("main.rs")
.arg("-lstatic:+verbatim=local_native_dep")
.run_fail()
.assert_stderr_contains("local_native_dep");
}
7 changes: 5 additions & 2 deletions tests/run-make/native-link-modifier-verbatim-rustc/rmake.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
// `verbatim` is a native link modifier that forces rustc to only accept libraries with
// a specified name. This test checks that this modifier works as intended.
// This test is the same as native-link-modifier-linker, but with rlibs.
// See https://github.com/rust-lang/rust/issues/99425

use run_make_support::rustc;

fn main() {
// Verbatim allows for the specification of a precise name - in this case, the unconventional ".ext" extension.
// Verbatim allows for the specification of a precise name
// - in this case, the unconventional ".ext" extension.
rustc()
.input("upstream_native_dep.rs")
.crate_type("staticlib")
Expand All @@ -18,7 +20,8 @@ fn main() {
.run();

// This section voluntarily avoids using static_lib_name helpers to be verbatim.
// With verbatim, even these common library names are refused - it wants upstream_native_dep without
// With verbatim, even these common library names are refused
// - it wants upstream_native_dep without
// any file extensions.
rustc()
.input("upstream_native_dep.rs")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,8 @@ use run_make_support::{fs_wrapper, rustc};

fn main() {
fs_wrapper::create_dir("foo");
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""#);
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""#,
);
}

0 comments on commit 1abe51f

Please sign in to comment.