Skip to content

Commit 5fc67f9

Browse files
committed
rewrite and rename issue-97463-abi-param-passing to rmake
1 parent f1747f4 commit 5fc67f9

File tree

7 files changed

+41
-25
lines changed

7 files changed

+41
-25
lines changed

src/tools/run-make-support/src/external_deps/llvm.rs

+2
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,8 @@ impl LlvmAr {
229229
Self { cmd }
230230
}
231231

232+
/// Automatically pass the commonly used arguments `rcus`, used for combining one or more
233+
/// input object files into one output static library file.
232234
pub fn obj_to_ar(&mut self) -> &mut Self {
233235
self.cmd.arg("rcus");
234236
self

src/tools/tidy/src/allowed_run_make_makefiles.txt

-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ run-make/issue-47551/Makefile
4848
run-make/issue-69368/Makefile
4949
run-make/issue-84395-lto-embed-bitcode/Makefile
5050
run-make/issue-88756-default-output/Makefile
51-
run-make/issue-97463-abi-param-passing/Makefile
5251
run-make/jobserver-error/Makefile
5352
run-make/libs-through-symlinks/Makefile
5453
run-make/libtest-json/Makefile

tests/run-make/issue-97463-abi-param-passing/Makefile

-15
This file was deleted.

tests/run-make/rlib-format-packed-bundled-libs-3/rmake.rs

+14-9
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,16 @@
66
// See https://github.com/rust-lang/rust/pull/105601
77

88
use run_make_support::{
9-
build_native_static_lib, fs_wrapper, is_msvc, llvm_ar, regex, rust_lib_name, rustc,
10-
static_lib_name,
9+
build_native_static_lib, is_msvc, llvm_ar, regex, rfs, rust_lib_name, rustc, static_lib_name,
1110
};
1211

13-
// FIXME only-linux test-various
12+
//@ ignore-cross-compile
13+
// Reason: Invalid library format (not ELF) causes compilation failure
14+
// in the final `rustc` call.
15+
16+
//@ only-linux
17+
// Reason: differences in the native lib compilation process causes differences
18+
// in the --print link-args output
1419

1520
fn main() {
1621
build_native_static_lib("native_dep_1");
@@ -40,12 +45,12 @@ fn main() {
4045
.arg("t")
4146
.arg(static_lib_name("main"))
4247
.run()
43-
.assert_stdout_contains(object_file_name("native_dep_1"));
48+
.assert_stdout_contains("native_dep_1.o");
4449
llvm_ar()
4550
.arg("t")
4651
.arg(static_lib_name("main"))
4752
.run()
48-
.assert_stdout_not_contains(object_file_name("native_dep_2"));
53+
.assert_stdout_not_contains("native_dep_2.o");
4954

5055
// Test bundle with whole archive.
5156
rustc().input("rust_dep.rs").crate_type("rlib").run();
@@ -64,8 +69,8 @@ fn main() {
6469
.assert_stdout_not_contains("native_dep_4");
6570

6671
// The compiler shouldn't use files which it doesn't know about.
67-
fs_wrapper::remove_file(static_lib_name("native_dep_1"));
68-
fs_wrapper::remove_file(static_lib_name("native_dep_3"));
72+
rfs::remove_file(static_lib_name("native_dep_1"));
73+
rfs::remove_file(static_lib_name("native_dep_3"));
6974

7075
let out = rustc()
7176
.input("main.rs")
@@ -83,6 +88,6 @@ fn main() {
8388
}
8489

8590
//FIXME(Oneirical): potential helper fn if this works on msvc too
86-
fn object_file_name(name: &str) -> String {
87-
if is_msvc() { format!("{name}.obj") } else { format!("{name}.o") }
91+
fn name: &str) -> String {
92+
if is_msvc() { format!(.o"name}.obj") } else { format!("{name}.o") }
8893
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// This test was created in response to an obscure miscompilation bug, only
2+
// visible with the -O3 flag passed to the cc compiler when trying to obtain
3+
// a native static library for the sake of foreign function interface. This
4+
// flag could cause certain integer types to fail to be zero-extended, resulting
5+
// in type casting errors. After the fix in #97800, this test attempts integer casting
6+
// while simultaneously interfacing with a C library and using the -O3 flag.
7+
// See https://github.com/rust-lang/rust/issues/97463
8+
9+
//@ ignore-msvc
10+
// Reason: the rustc compilation fails due to an unresolved external symbol
11+
12+
//@ ignore-cross-compile
13+
// Reason: The compiled binary is executed.
14+
15+
use run_make_support::{cc, is_msvc, llvm_ar, run, rustc, static_lib_name};
16+
17+
fn main() {
18+
// The issue exercised by this test specifically needs needs `-O`
19+
// flags (like `-O3`) to reproduce. Thus, we call `cc()` instead of
20+
// the nicer `build_native_static_lib`.
21+
cc().arg("-c").arg("-O3").out_exe("bar").input("bad.c").run();
22+
llvm_ar().obj_to_ar().output_input(static_lib_name("bad"), "bad.o").run();
23+
rustc().input("param_passing.rs").arg("-lbad").opt_level("3").run();
24+
run("param_passing");
25+
}

0 commit comments

Comments
 (0)