From 790c238ef431639997730eb9e5f21fe043d4adf2 Mon Sep 17 00:00:00 2001 From: Oneirical Date: Fri, 21 Jun 2024 15:30:51 -0400 Subject: [PATCH 1/3] rewrite pdb-alt-path to rmake --- .../tidy/src/allowed_run_make_makefiles.txt | 1 - tests/run-make/pdb-alt-path/Makefile | 20 ---------- tests/run-make/pdb-alt-path/rmake.rs | 37 +++++++++++++++++++ 3 files changed, 37 insertions(+), 21 deletions(-) delete mode 100644 tests/run-make/pdb-alt-path/Makefile create mode 100644 tests/run-make/pdb-alt-path/rmake.rs diff --git a/src/tools/tidy/src/allowed_run_make_makefiles.txt b/src/tools/tidy/src/allowed_run_make_makefiles.txt index f32413540498d..3c6bb33813162 100644 --- a/src/tools/tidy/src/allowed_run_make_makefiles.txt +++ b/src/tools/tidy/src/allowed_run_make_makefiles.txt @@ -131,7 +131,6 @@ run-make/pass-linker-flags-flavor/Makefile run-make/pass-linker-flags-from-dep/Makefile run-make/pass-linker-flags/Makefile run-make/pass-non-c-like-enum-to-c/Makefile -run-make/pdb-alt-path/Makefile run-make/pdb-buildinfo-cl-cmd/Makefile run-make/pgo-gen-lto/Makefile run-make/pgo-gen-no-imp-symbols/Makefile diff --git a/tests/run-make/pdb-alt-path/Makefile b/tests/run-make/pdb-alt-path/Makefile deleted file mode 100644 index 7a0ae3bf2ef0d..0000000000000 --- a/tests/run-make/pdb-alt-path/Makefile +++ /dev/null @@ -1,20 +0,0 @@ -include ../tools.mk - -# only-windows-msvc - -all: - # Test that we don't have the full path to the PDB file in the binary - $(RUSTC) main.rs -g --crate-name my_crate_name --crate-type bin -Cforce-frame-pointers - $(CGREP) "my_crate_name.pdb" < $(TMPDIR)/my_crate_name.exe - $(CGREP) -v "\\my_crate_name.pdb" < $(TMPDIR)/my_crate_name.exe - - # Test that backtraces still can find debuginfo by checking that they contain symbol names and - # source locations. - $(TMPDIR)/my_crate_name.exe &> $(TMPDIR)/backtrace.txt - $(CGREP) "my_crate_name::fn_in_backtrace" < $(TMPDIR)/backtrace.txt - $(CGREP) "main.rs:15" < $(TMPDIR)/backtrace.txt - - # Test that explicitly passed `-Clink-arg=/PDBALTPATH:...` is respected - $(RUSTC) main.rs -g --crate-name my_crate_name --crate-type bin -Clink-arg=/PDBALTPATH:abcdefg.pdb -Cforce-frame-pointers - $(CGREP) "abcdefg.pdb" < $(TMPDIR)/my_crate_name.exe - $(CGREP) -v "my_crate_name.pdb" < $(TMPDIR)/my_crate_name.exe diff --git a/tests/run-make/pdb-alt-path/rmake.rs b/tests/run-make/pdb-alt-path/rmake.rs new file mode 100644 index 0000000000000..197768d82c114 --- /dev/null +++ b/tests/run-make/pdb-alt-path/rmake.rs @@ -0,0 +1,37 @@ +// The information inside a .exe file contains a string of the PDB file name. +// This could be a security concern if the full path was exposed, as it could +// reveal information about the filesystem where the bin was first compiled. +// This should only be overridden by `-Clink-arg=/PDBALTPATH:...` - this test +// checks that no full file paths are exposed and that the override flag is respected. +// See https://github.com/rust-lang/rust/pull/121297 + +//@ only-windows-msvc + +fn main() { + // Test that we don't have the full path to the PDB file in the binary + rustc() + .input("main.rs") + .arg("-g") + .crate_name("my_crate_name") + .crate_type("bin") + .arg("-Cforce-frame-pointers") + .run(); + invalid_utf8_contains(bin_name("my_crate_name"), "my_crate_name.pdb"); + invalid_utf8_not_contains(bin_name("my_crate_name"), r#"\my_crate_name.pdb"#); + // Test that backtraces still can find debuginfo by checking that they contain symbol names and + // source locations. + let out = run(bin_name(my_crate_name)); + out.assert_stdout_contains("my_crate_name::fn_in_backtrace"); + out.assert_stdout_contains("main.rs:15"); + // Test that explicitly passed `-Clink-arg=/PDBALTPATH:...` is respected + rustc() + .input("main.rs") + .arg("-g") + .crate_name("my_crate_name") + .crate_type("bin") + .link_arg("/PDBALTPATH:abcdefg.pdb") + .arg("-Cforce-frame-pointers") + .run(); + invalid_utf8_contains(bin_name("my_crate_name"), "abcdefg.pdb"); + invalid_utf8_not_contains(bin_name("my_crate_name"), "my_crate_name.pdb"); +} From 9dff8a33e1abcf8f0455acf7befd5366cc3d800f Mon Sep 17 00:00:00 2001 From: Oneirical Date: Fri, 21 Jun 2024 15:46:34 -0400 Subject: [PATCH 2/3] rewrite mismatching-target-triples to rmake --- src/tools/tidy/src/allowed_run_make_makefiles.txt | 1 - .../run-make/mismatching-target-triples/Makefile | 11 ----------- .../run-make/mismatching-target-triples/rmake.rs | 15 +++++++++++++++ tests/run-make/pdb-alt-path/rmake.rs | 2 +- 4 files changed, 16 insertions(+), 13 deletions(-) delete mode 100644 tests/run-make/mismatching-target-triples/Makefile create mode 100644 tests/run-make/mismatching-target-triples/rmake.rs diff --git a/src/tools/tidy/src/allowed_run_make_makefiles.txt b/src/tools/tidy/src/allowed_run_make_makefiles.txt index 3c6bb33813162..f8b0742a55c87 100644 --- a/src/tools/tidy/src/allowed_run_make_makefiles.txt +++ b/src/tools/tidy/src/allowed_run_make_makefiles.txt @@ -111,7 +111,6 @@ run-make/many-crates-but-no-match/Makefile run-make/metadata-dep-info/Makefile run-make/min-global-align/Makefile run-make/mingw-export-call-convention/Makefile -run-make/mismatching-target-triples/Makefile run-make/missing-crate-dependency/Makefile run-make/mixing-libs/Makefile run-make/msvc-opt-minsize/Makefile diff --git a/tests/run-make/mismatching-target-triples/Makefile b/tests/run-make/mismatching-target-triples/Makefile deleted file mode 100644 index 409388e041478..0000000000000 --- a/tests/run-make/mismatching-target-triples/Makefile +++ /dev/null @@ -1,11 +0,0 @@ -include ../tools.mk - -# Issue #10814 -# -# these are no_std to avoid having to have the standard library or any -# linkers/assemblers for the relevant platform - -all: - $(RUSTC) foo.rs --target=i686-unknown-linux-gnu - $(RUSTC) bar.rs --target=x86_64-unknown-linux-gnu 2>&1 \ - | $(CGREP) 'couldn'"'"'t find crate `foo` with expected target triple x86_64-unknown-linux-gnu' diff --git a/tests/run-make/mismatching-target-triples/rmake.rs b/tests/run-make/mismatching-target-triples/rmake.rs new file mode 100644 index 0000000000000..6f41eac8cdaf4 --- /dev/null +++ b/tests/run-make/mismatching-target-triples/rmake.rs @@ -0,0 +1,15 @@ +// In this test, foo links against 32-bit architecture, and then, bar, which depends +// on foo, links against 64-bit architecture, causing a metadata mismatch due to the +// differences in target architectures. This used to cause an internal compiler error, +// now replaced by a clearer normal error message. This test checks that this aforementioned +// error message is used. +// See https://github.com/rust-lang/rust/issues/10814 + +use run_make_support::rustc; + +fn main() { + rustc().input("foo.rs").target("i686-unknown-linux-gnu").run(); + rustc().input("bar.rs").target("x86_64-unknown-linux-gnu").run_fail().assert_stderr_contains( + r#"couldn't find crate `foo` with expected target triple x86_64-unknown-linux-gnu"#, + ); +} diff --git a/tests/run-make/pdb-alt-path/rmake.rs b/tests/run-make/pdb-alt-path/rmake.rs index 197768d82c114..15497be4ecfe2 100644 --- a/tests/run-make/pdb-alt-path/rmake.rs +++ b/tests/run-make/pdb-alt-path/rmake.rs @@ -5,7 +5,7 @@ // checks that no full file paths are exposed and that the override flag is respected. // See https://github.com/rust-lang/rust/pull/121297 -//@ only-windows-msvc +//@ only-windows fn main() { // Test that we don't have the full path to the PDB file in the binary From a2ed16cc061f4b25c673d0f53264e5c7c389eb9b Mon Sep 17 00:00:00 2001 From: Oneirical Date: Fri, 21 Jun 2024 16:00:53 -0400 Subject: [PATCH 3/3] rewrite mingw-export-call-convention to rmake --- src/tools/tidy/src/allowed_run_make_makefiles.txt | 1 - .../run-make/mingw-export-call-convention/Makefile | 9 --------- .../run-make/mingw-export-call-convention/rmake.rs | 13 +++++++++++++ tests/run-make/pdb-alt-path/rmake.rs | 14 ++++++++------ 4 files changed, 21 insertions(+), 16 deletions(-) delete mode 100644 tests/run-make/mingw-export-call-convention/Makefile create mode 100644 tests/run-make/mingw-export-call-convention/rmake.rs diff --git a/src/tools/tidy/src/allowed_run_make_makefiles.txt b/src/tools/tidy/src/allowed_run_make_makefiles.txt index f8b0742a55c87..a029c20dec30f 100644 --- a/src/tools/tidy/src/allowed_run_make_makefiles.txt +++ b/src/tools/tidy/src/allowed_run_make_makefiles.txt @@ -110,7 +110,6 @@ run-make/manual-link/Makefile run-make/many-crates-but-no-match/Makefile run-make/metadata-dep-info/Makefile run-make/min-global-align/Makefile -run-make/mingw-export-call-convention/Makefile run-make/missing-crate-dependency/Makefile run-make/mixing-libs/Makefile run-make/msvc-opt-minsize/Makefile diff --git a/tests/run-make/mingw-export-call-convention/Makefile b/tests/run-make/mingw-export-call-convention/Makefile deleted file mode 100644 index 4a60059cc5441..0000000000000 --- a/tests/run-make/mingw-export-call-convention/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -include ../tools.mk - -# only-windows-gnu - -all: - $(RUSTC) foo.rs - # FIXME: we should make sure __stdcall calling convention is used here - # but that only works with LLD right now - nm -g "$(call IMPLIB,foo)" | $(CGREP) bar diff --git a/tests/run-make/mingw-export-call-convention/rmake.rs b/tests/run-make/mingw-export-call-convention/rmake.rs new file mode 100644 index 0000000000000..d1fb745a64de9 --- /dev/null +++ b/tests/run-make/mingw-export-call-convention/rmake.rs @@ -0,0 +1,13 @@ +// On windows-gnu, symbol exporting used to fail to export names +// with no_mangle. #72049 brought this feature up to par with msvc, +// and this test checks that the symbol "bar" is successfully exported. +// See https://github.com/rust-lang/rust/issues/50176 + +//@ only-x86_64-pc-windows-gnu + +use run_make_support::{llvm_readobj, rustc}; + +fn main() { + rustc().input("foo.rs").run(); + llvm_readobj().arg("--all").input("libfoo.dll.a").run().assert_stdout_contains("bar"); +} diff --git a/tests/run-make/pdb-alt-path/rmake.rs b/tests/run-make/pdb-alt-path/rmake.rs index 15497be4ecfe2..6311d6d9ed7d0 100644 --- a/tests/run-make/pdb-alt-path/rmake.rs +++ b/tests/run-make/pdb-alt-path/rmake.rs @@ -5,7 +5,9 @@ // checks that no full file paths are exposed and that the override flag is respected. // See https://github.com/rust-lang/rust/pull/121297 -//@ only-windows +//@ only-x86_64-pc-windows-msvc + +use run_make_support::{bin_name, invalid_utf8_contains, invalid_utf8_not_contains, run, rustc}; fn main() { // Test that we don't have the full path to the PDB file in the binary @@ -16,11 +18,11 @@ fn main() { .crate_type("bin") .arg("-Cforce-frame-pointers") .run(); - invalid_utf8_contains(bin_name("my_crate_name"), "my_crate_name.pdb"); - invalid_utf8_not_contains(bin_name("my_crate_name"), r#"\my_crate_name.pdb"#); + invalid_utf8_contains(&bin_name("my_crate_name"), "my_crate_name.pdb"); + invalid_utf8_not_contains(&bin_name("my_crate_name"), r#"\my_crate_name.pdb"#); // Test that backtraces still can find debuginfo by checking that they contain symbol names and // source locations. - let out = run(bin_name(my_crate_name)); + let out = run(&bin_name("my_crate_name")); out.assert_stdout_contains("my_crate_name::fn_in_backtrace"); out.assert_stdout_contains("main.rs:15"); // Test that explicitly passed `-Clink-arg=/PDBALTPATH:...` is respected @@ -32,6 +34,6 @@ fn main() { .link_arg("/PDBALTPATH:abcdefg.pdb") .arg("-Cforce-frame-pointers") .run(); - invalid_utf8_contains(bin_name("my_crate_name"), "abcdefg.pdb"); - invalid_utf8_not_contains(bin_name("my_crate_name"), "my_crate_name.pdb"); + invalid_utf8_contains(&bin_name("my_crate_name"), "abcdefg.pdb"); + invalid_utf8_not_contains(&bin_name("my_crate_name"), "my_crate_name.pdb"); }