diff options
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/run-make/issue-97463-abi-param-passing/Makefile | 15 | ||||
| -rw-r--r-- | tests/run-make/rlib-format-packed-bundled-libs-3/rmake.rs | 28 | ||||
| -rw-r--r-- | tests/run-make/zero-extend-abi-param-passing/bad.c (renamed from tests/run-make/issue-97463-abi-param-passing/bad.c) | 0 | ||||
| -rw-r--r-- | tests/run-make/zero-extend-abi-param-passing/param_passing.rs (renamed from tests/run-make/issue-97463-abi-param-passing/param_passing.rs) | 0 | ||||
| -rw-r--r-- | tests/run-make/zero-extend-abi-param-passing/rmake.rs | 25 |
5 files changed, 37 insertions, 31 deletions
diff --git a/tests/run-make/issue-97463-abi-param-passing/Makefile b/tests/run-make/issue-97463-abi-param-passing/Makefile deleted file mode 100644 index 7ce7aaeec57..00000000000 --- a/tests/run-make/issue-97463-abi-param-passing/Makefile +++ /dev/null @@ -1,15 +0,0 @@ -# ignore-cross-compile -include ../tools.mk - -# ignore-msvc - -# The issue exercised by this test, rust-lang/rust#97463, explicitly needs `-O` -# flags (like `-O3`) to reproduce. Thus, we call $(CC) instead of nicer -# alternatives provided by tools.mk like using `COMPILE_OBJ` or using a -# `NATIVE_STATICLIB` dependency. - -all: - $(CC) -c -O3 -o $(TMPDIR)/bad.o bad.c - $(AR) rcs $(TMPDIR)/libbad.a $(TMPDIR)/bad.o - $(RUSTC) param_passing.rs -L$(TMPDIR) -lbad -C opt-level=3 - $(call RUN,param_passing) diff --git a/tests/run-make/rlib-format-packed-bundled-libs-3/rmake.rs b/tests/run-make/rlib-format-packed-bundled-libs-3/rmake.rs index ede4d9f031d..d152047600f 100644 --- a/tests/run-make/rlib-format-packed-bundled-libs-3/rmake.rs +++ b/tests/run-make/rlib-format-packed-bundled-libs-3/rmake.rs @@ -6,11 +6,16 @@ // See https://github.com/rust-lang/rust/pull/105601 use run_make_support::{ - build_native_static_lib, fs_wrapper, is_msvc, llvm_ar, regex, rust_lib_name, rustc, - static_lib_name, + build_native_static_lib, is_msvc, llvm_ar, regex, rfs, rust_lib_name, rustc, static_lib_name, }; -// FIXME only-linux test-various +//@ ignore-cross-compile +// Reason: Invalid library format (not ELF) causes compilation failure +// in the final `rustc` call. + +//@ only-linux +// Reason: differences in the native lib compilation process causes differences +// in the --print link-args output fn main() { build_native_static_lib("native_dep_1"); @@ -36,16 +41,12 @@ fn main() { .arg(rust_lib_name("rust_dep_cfg")) .run() .assert_stdout_contains(static_lib_name("native_dep_2")); + llvm_ar().arg("t").arg(static_lib_name("main")).run().assert_stdout_contains("native_dep_1.o"); llvm_ar() .arg("t") .arg(static_lib_name("main")) .run() - .assert_stdout_contains(object_file_name("native_dep_1")); - llvm_ar() - .arg("t") - .arg(static_lib_name("main")) - .run() - .assert_stdout_not_contains(object_file_name("native_dep_2")); + .assert_stdout_not_contains("native_dep_2.o"); // Test bundle with whole archive. rustc().input("rust_dep.rs").crate_type("rlib").run(); @@ -64,8 +65,8 @@ fn main() { .assert_stdout_not_contains("native_dep_4"); // The compiler shouldn't use files which it doesn't know about. - fs_wrapper::remove_file(static_lib_name("native_dep_1")); - fs_wrapper::remove_file(static_lib_name("native_dep_3")); + rfs::remove_file(static_lib_name("native_dep_1")); + rfs::remove_file(static_lib_name("native_dep_3")); let out = rustc() .input("main.rs") @@ -81,8 +82,3 @@ fn main() { assert!(re.is_match(&out)); } - -//FIXME(Oneirical): potential helper fn if this works on msvc too -fn object_file_name(name: &str) -> String { - if is_msvc() { format!("{name}.obj") } else { format!("{name}.o") } -} diff --git a/tests/run-make/issue-97463-abi-param-passing/bad.c b/tests/run-make/zero-extend-abi-param-passing/bad.c index 013314ab20d..013314ab20d 100644 --- a/tests/run-make/issue-97463-abi-param-passing/bad.c +++ b/tests/run-make/zero-extend-abi-param-passing/bad.c diff --git a/tests/run-make/issue-97463-abi-param-passing/param_passing.rs b/tests/run-make/zero-extend-abi-param-passing/param_passing.rs index c11f3cc72bd..c11f3cc72bd 100644 --- a/tests/run-make/issue-97463-abi-param-passing/param_passing.rs +++ b/tests/run-make/zero-extend-abi-param-passing/param_passing.rs diff --git a/tests/run-make/zero-extend-abi-param-passing/rmake.rs b/tests/run-make/zero-extend-abi-param-passing/rmake.rs new file mode 100644 index 00000000000..aed27f7f5ab --- /dev/null +++ b/tests/run-make/zero-extend-abi-param-passing/rmake.rs @@ -0,0 +1,25 @@ +// This test was created in response to an obscure miscompilation bug, only +// visible with the -O3 flag passed to the cc compiler when trying to obtain +// a native static library for the sake of foreign function interface. This +// flag could cause certain integer types to fail to be zero-extended, resulting +// in type casting errors. After the fix in #97800, this test attempts integer casting +// while simultaneously interfacing with a C library and using the -O3 flag. +// See https://github.com/rust-lang/rust/issues/97463 + +//@ ignore-msvc +// Reason: the rustc compilation fails due to an unresolved external symbol + +//@ ignore-cross-compile +// Reason: The compiled binary is executed. + +use run_make_support::{cc, is_msvc, llvm_ar, run, rustc, static_lib_name}; + +fn main() { + // The issue exercised by this test specifically needs needs `-O` + // flags (like `-O3`) to reproduce. Thus, we call `cc()` instead of + // the nicer `build_native_static_lib`. + cc().arg("-c").arg("-O3").out_exe("bad.o").input("bad.c").run(); + llvm_ar().obj_to_ar().output_input(static_lib_name("bad"), "bad.o").run(); + rustc().input("param_passing.rs").arg("-lbad").opt_level("3").run(); + run("param_passing"); +} |
