Skip to content

Commit

Permalink
Auto merge of rust-lang#127044 - Oneirical:fantestic-journey, r=Kobzo…
Browse files Browse the repository at this point in the history
…l,jieyouxu

Migrate `dylib-chain`, `rlib-chain`, `issue-47384`, `msvc-opt-minsize` and `test-harness` `run-make` tests to ui/rmake

Part of rust-lang#121876 and the associated [Google Summer of Code project](https://blog.rust-lang.org/2024/05/01/gsoc-2024-selected-projects.html).

try-job: x86_64-msvc
try-job: aarch64-apple
  • Loading branch information
bors committed Jul 3, 2024
2 parents 2b90614 + 45313a6 commit aa1d4f6
Show file tree
Hide file tree
Showing 16 changed files with 134 additions and 76 deletions.
5 changes: 0 additions & 5 deletions src/tools/tidy/src/allowed_run_make_makefiles.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ run-make/dep-info-spaces/Makefile
run-make/dep-info/Makefile
run-make/dump-ice-to-disk/Makefile
run-make/dump-mono-stats/Makefile
run-make/dylib-chain/Makefile
run-make/emit-path-unhashed/Makefile
run-make/emit-shared-files/Makefile
run-make/emit-to-stdout/Makefile
Expand Down Expand Up @@ -66,7 +65,6 @@ run-make/issue-35164/Makefile
run-make/issue-36710/Makefile
run-make/issue-37839/Makefile
run-make/issue-40535/Makefile
run-make/issue-47384/Makefile
run-make/issue-47551/Makefile
run-make/issue-69368/Makefile
run-make/issue-83045/Makefile
Expand Down Expand Up @@ -98,7 +96,6 @@ run-make/metadata-dep-info/Makefile
run-make/min-global-align/Makefile
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-whole-archive/Makefile
run-make/no-alloc-shim/Makefile
Expand Down Expand Up @@ -136,7 +133,6 @@ run-make/remap-path-prefix-dwarf/Makefile
run-make/reproducible-build-2/Makefile
run-make/reproducible-build/Makefile
run-make/return-non-c-like-enum-from-c/Makefile
run-make/rlib-chain/Makefile
run-make/rlib-format-packed-bundled-libs-2/Makefile
run-make/rlib-format-packed-bundled-libs-3/Makefile
run-make/rlib-format-packed-bundled-libs/Makefile
Expand Down Expand Up @@ -166,7 +162,6 @@ run-make/target-cpu-native/Makefile
run-make/target-specs/Makefile
run-make/target-without-atomic-cas/Makefile
run-make/test-benches/Makefile
run-make/test-harness/Makefile
run-make/thumb-none-cortex-m/Makefile
run-make/thumb-none-qemu/Makefile
run-make/track-path-dep-info/Makefile
Expand Down
2 changes: 1 addition & 1 deletion src/tools/tidy/src/ui_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use std::path::{Path, PathBuf};
// should all be 1000 or lower. Limits significantly smaller than 1000 are also
// desirable, because large numbers of files are unwieldy in general. See issue
// #73494.
const ENTRY_LIMIT: u32 = 900;
const ENTRY_LIMIT: u32 = 901;
// FIXME: The following limits should be reduced eventually.

const ISSUES_ENTRY_LIMIT: u32 = 1672;
Expand Down
13 changes: 0 additions & 13 deletions tests/run-make/dylib-chain/Makefile

This file was deleted.

23 changes: 23 additions & 0 deletions tests/run-make/dylib-chain/rmake.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// In this test, m4 depends on m3, which depends on m2, which depends on m1.
// Even though dependencies are chained like this and there is no direct mention
// of m1 or m2 in m4.rs, compilation and execution should still succeed. Unlike the
// rlib-chain test, dynamic libraries contain upstream dependencies, and breaking
// the chain by removing the dylibs causes execution to fail.
// See https://github.com/rust-lang/rust/issues/10434

//@ ignore-cross-compile
// Reason: the compiled binary is executed

use run_make_support::{dynamic_lib_name, fs_wrapper, run, run_fail, rustc};

fn main() {
rustc().input("m1.rs").arg("-Cprefer-dynamic").run();
rustc().input("m2.rs").arg("-Cprefer-dynamic").run();
rustc().input("m3.rs").arg("-Cprefer-dynamic").run();
rustc().input("m4.rs").run();
run("m4");
fs_wrapper::remove_file(dynamic_lib_name("m1"));
fs_wrapper::remove_file(dynamic_lib_name("m2"));
fs_wrapper::remove_file(dynamic_lib_name("m3"));
run_fail("m4");
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
31 changes: 31 additions & 0 deletions tests/run-make/include-all-symbols-linking/rmake.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// Linkers treat archives differently from object files: all object files participate in linking,
// while archives will only participate in linking if they can satisfy at least one undefined
// reference (version scripts doesn't count). This causes `#[no_mangle]` or `#[used]` items to
// be ignored by the linker, and since they never participate in the linking, using `KEEP` in the
// linker scripts can't keep them either. This causes #47384. After the fix in #95604, this test
// checks that these symbols and sections successfully appear in the output dynamic library.
// See https://github.com/rust-lang/rust/pull/95604
// See https://github.com/rust-lang/rust/issues/47384

//@ only-linux
// Reason: differences in object file formats on OSX and Windows
// causes errors in the llvm_objdump step

use run_make_support::{dynamic_lib_name, llvm_objdump, llvm_readobj, rustc};

fn main() {
rustc().crate_type("lib").input("lib.rs").run();
rustc().crate_type("cdylib").link_args("-Tlinker.ld").input("main.rs").run();
// Ensure `#[used]` and `KEEP`-ed section is there
llvm_objdump()
.arg("--full-contents")
.arg("--section=.static")
.input(dynamic_lib_name("main"))
.run();
// Ensure `#[no_mangle]` symbol is there
llvm_readobj()
.arg("--symbols")
.input(dynamic_lib_name("main"))
.run()
.assert_stdout_contains("bar");
}
12 changes: 0 additions & 12 deletions tests/run-make/issue-47384/Makefile

This file was deleted.

6 changes: 0 additions & 6 deletions tests/run-make/msvc-opt-minsize/Makefile

This file was deleted.

19 changes: 0 additions & 19 deletions tests/run-make/msvc-opt-minsize/foo.rs

This file was deleted.

11 changes: 0 additions & 11 deletions tests/run-make/rlib-chain/Makefile

This file was deleted.

23 changes: 23 additions & 0 deletions tests/run-make/rlib-chain/rmake.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// In this test, m4 depends on m3, which depends on m2, which depends on m1.
// Even though dependencies are chained like this and there is no direct mention
// of m1 or m2 in m4.rs, compilation and execution should still succeed. Unlike
// the dylib-chain test, rlibs do not contain upstream dependencies, and removing
// the libraries still allows m4 to successfully execute.
// See https://github.com/rust-lang/rust/issues/10434

//@ ignore-cross-compile
// Reason: the compiled binary is executed

use run_make_support::{fs_wrapper, run, rust_lib_name, rustc};

fn main() {
rustc().input("m1.rs").run();
rustc().input("m2.rs").run();
rustc().input("m3.rs").run();
rustc().input("m4.rs").run();
run("m4");
fs_wrapper::remove_file(rust_lib_name("m1"));
fs_wrapper::remove_file(rust_lib_name("m2"));
fs_wrapper::remove_file(rust_lib_name("m3"));
run("m4");
}
9 changes: 0 additions & 9 deletions tests/run-make/test-harness/Makefile

This file was deleted.

25 changes: 25 additions & 0 deletions tests/run-make/test-harness/rmake.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// The way test suites run can be modified using configuration flags,
// ignoring certain tests while running others. This test contains two
// functions, one which must run and the other which must not. The standard
// output is checked to verify that the ignore configuration is doing its job,
// and that output is successfully minimized with the --quiet flag.
// See https://github.com/rust-lang/rust/commit/f7ebe23ae185991b0fee05b32fbb3e29b89a41bf

//@ ignore-cross-compile
// Reason: the compiled binary is executed

use run_make_support::{run, run_with_args, rustc};

fn main() {
rustc().arg("--test").input("test-ignore-cfg.rs").cfg("ignorecfg").run();
// check that #[cfg_attr(..., ignore)] does the right thing.
run("test-ignore-cfg")
.assert_stdout_contains("shouldnotignore ... ok")
.assert_stdout_contains("shouldignore ... ignored");
assert_eq!(
// One of the lines is exactly "i."
run_with_args("test-ignore-cfg", &["--quiet"]).stdout_utf8().lines().find(|&x| x == "i."),
Some("i.")
);
run_with_args("test-ignore-cfg", &["--quiet"]).assert_stdout_not_contains("should");
}
31 changes: 31 additions & 0 deletions tests/ui/msvc-opt-minsize.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// A previously outdated version of LLVM caused compilation failures on Windows
// specifically with optimization level `z`. After the update to a more recent LLVM
// version, this test checks that compilation and execution both succeed.
// See https://github.com/rust-lang/rust/issues/45034

//@ ignore-cross-compile
// Reason: the compiled binary is executed
//@ only-windows
// Reason: the observed bug only occurs on Windows
//@ run-pass
//@ compile-flags: -C opt-level=z

#![feature(test)]
extern crate test;

fn foo(x: i32, y: i32) -> i64 {
(x + y) as i64
}

#[inline(never)]
fn bar() {
let _f = Box::new(0);
// This call used to trigger an LLVM bug in opt-level z where the base
// pointer gets corrupted, see issue #45034
let y: fn(i32, i32) -> i64 = test::black_box(foo);
test::black_box(y(1, 2));
}

fn main() {
bar();
}

0 comments on commit aa1d4f6

Please sign in to comment.