Auto merge of #126484 - Oneirical:test-in-peace, r=jieyouxu,kobzol

Migrate `std-core-cycle`, `obey-crate-type-flag`, `mixing-libs` and `issue-18943` `run-make` tests to `rmake.rs`

Part of #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-apple-1
try-job: x86_64-msvc
try-job: aarch64-gnu
This commit is contained in:
bors 2024-07-16 19:25:51 +00:00
commit 032be6f7bb
10 changed files with 83 additions and 50 deletions

View File

@ -46,7 +46,6 @@ run-make/interdependent-c-libraries/Makefile
run-make/issue-107094/Makefile
run-make/issue-14698/Makefile
run-make/issue-15460/Makefile
run-make/issue-18943/Makefile
run-make/issue-22131/Makefile
run-make/issue-25581/Makefile
run-make/issue-26006/Makefile
@ -80,13 +79,11 @@ run-make/macos-fat-archive/Makefile
run-make/manual-link/Makefile
run-make/min-global-align/Makefile
run-make/missing-crate-dependency/Makefile
run-make/mixing-libs/Makefile
run-make/native-link-modifier-bundle/Makefile
run-make/native-link-modifier-whole-archive/Makefile
run-make/no-alloc-shim/Makefile
run-make/no-builtins-attribute/Makefile
run-make/no-duplicate-libs/Makefile
run-make/obey-crate-type-flag/Makefile
run-make/panic-abort-eh_frame/Makefile
run-make/pass-non-c-like-enum-to-c/Makefile
run-make/pdb-buildinfo-cl-cmd/Makefile
@ -123,7 +120,6 @@ run-make/static-dylib-by-default/Makefile
run-make/static-extern-type/Makefile
run-make/staticlib-blank-lib/Makefile
run-make/staticlib-dylib-linkage/Makefile
run-make/std-core-cycle/Makefile
run-make/symbol-mangling-hashed/Makefile
run-make/symbol-visibility/Makefile
run-make/sysroot-crates-are-unstable/Makefile

View File

@ -1,7 +0,0 @@
include ../tools.mk
# Regression test for ICE #18943 when compiling as lib
all:
$(RUSTC) foo.rs --crate-type lib
$(call REMOVE_RLIBS,foo) && exit 0 || exit 1

View File

@ -0,0 +1,14 @@
// Inside a library, implementing a trait for another trait
// with a lifetime used to cause an internal compiler error (ICE).
// This test checks that this bug does not make a resurgence -
// first by ensuring successful compilation, then verifying that
// the lib crate-type flag was actually followed.
// See https://github.com/rust-lang/rust/issues/18943
use run_make_support::{rust_lib_name, rustc};
use std::path::Path;
fn main() {
rustc().input("foo.rs").crate_type("lib").run();
assert!(Path::new(&rust_lib_name("foo")).exists());
}

View File

@ -1,8 +0,0 @@
# ignore-cross-compile
include ../tools.mk
all:
$(RUSTC) rlib.rs --crate-type=rlib --crate-type=dylib
$(RUSTC) dylib.rs # no -Cprefer-dynamic so statically linking librlib.rlib
$(call REMOVE_DYLIBS,rlib) # remove librlib.so to test that prog.rs doesn't get confused about the removed dylib version of librlib
$(RUSTC) prog.rs && exit 1 || exit 0

View File

@ -0,0 +1,21 @@
// Having multiple upstream crates available in different formats
// should result in failed compilation. This test causes multiple
// libraries to exist simultaneously as rust libs and dynamic libs,
// causing prog.rs to fail compilation.
// See https://github.com/rust-lang/rust/issues/10434
//@ ignore-cross-compile
use run_make_support::{dynamic_lib_name, fs_wrapper, rustc};
fn main() {
rustc().input("rlib.rs").crate_type("rlib").crate_type("dylib").run();
// Not putting `-C prefer-dynamic` here allows for static linking of librlib.rlib.
rustc().input("dylib.rs").run();
// librlib's dynamic version needs to be removed here to prevent prog.rs from fetching
// the wrong one.
fs_wrapper::remove_file(dynamic_lib_name("rlib"));
rustc().input("prog.rs").run_fail();
}

View File

@ -1,14 +0,0 @@
# ignore-cross-compile
include ../tools.mk
# check that rustc builds all crate_type attributes
# delete rlib
# delete whatever dylib is made for this system
# check that rustc only builds --crate-type flags, ignoring attributes
# fail if an rlib was built
all:
$(RUSTC) test.rs
$(call REMOVE_RLIBS,test)
$(call REMOVE_DYLIBS,test)
$(RUSTC) --crate-type dylib test.rs
$(call REMOVE_RLIBS,test) && exit 1 || exit 0

View File

@ -0,0 +1,21 @@
// test.rs should produce both an rlib and a dylib
// by default. When the crate_type flag is passed and
// forced to dylib, no rlibs should be produced.
// See https://github.com/rust-lang/rust/issues/11573
//@ ignore-cross-compile
use run_make_support::{
cwd, dynamic_lib_name, fs_wrapper, has_extension, rust_lib_name, rustc, shallow_find_files,
};
use std::path::Path;
fn main() {
rustc().input("test.rs").run();
assert!(Path::new(&dynamic_lib_name("test")).exists());
assert!(Path::new(&rust_lib_name("test")).exists());
fs_wrapper::remove_file(rust_lib_name("test"));
rustc().crate_type("dylib").input("test.rs").run();
assert!(shallow_find_files(cwd(), |path| { has_extension(path, "rlib") }).is_empty());
}

View File

@ -1,17 +0,0 @@
# ignore-cross-compile
include ../tools.mk
ifeq ($(UNAME),Darwin)
FLAGS :=
else
ifdef IS_WINDOWS
FLAGS :=
else
FLAGS := -C link-args=-Wl,--no-undefined
endif
endif
all:
$(RUSTC) bar.rs
$(RUSTC) foo.rs $(FLAGS)
$(RUSTC) foo.rs $(FLAGS) -C panic=abort

View File

@ -0,0 +1,27 @@
// In some cases, linking libraries with GNU used to fail due to how
// `std` and `core` possess a circular dependency with one another, and
// how the linker could not go back through its symbol processing to resolve
// the circular link. #49316 fixed this, and this test reproduces a minimal
// version of one such linking attempt which used to fail.
// See https://github.com/rust-lang/rust/issues/18807
//@ ignore-cross-compile
use run_make_support::{is_darwin, is_windows, rustc};
fn main() {
rustc().input("bar.rs").run();
let mut rustc_foo = rustc();
rustc_foo.input("foo.rs");
let mut rustc_foo_panic = rustc();
rustc_foo_panic.input("foo.rs").panic("abort");
if !is_darwin() && !is_windows() {
rustc_foo.arg("-Clink-args=-Wl,--no-undefined");
rustc_foo_panic.arg("-Clink-args=-Wl,--no-undefined");
}
rustc_foo.run();
rustc_foo_panic.run();
}