Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 3fb0cd2

Browse files
committedJul 22, 2024
rewrite and rename issue-97463-abi-param-passing to rmake
1 parent f1747f4 commit 3fb0cd2

File tree

7 files changed

+39
-32
lines changed

7 files changed

+39
-32
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

+12-16
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");
@@ -36,16 +41,12 @@ fn main() {
3641
.arg(rust_lib_name("rust_dep_cfg"))
3742
.run()
3843
.assert_stdout_contains(static_lib_name("native_dep_2"));
44+
llvm_ar().arg("t").arg(static_lib_name("main")).run().assert_stdout_contains("native_dep_1.o");
3945
llvm_ar()
4046
.arg("t")
4147
.arg(static_lib_name("main"))
4248
.run()
43-
.assert_stdout_contains(object_file_name("native_dep_1"));
44-
llvm_ar()
45-
.arg("t")
46-
.arg(static_lib_name("main"))
47-
.run()
48-
.assert_stdout_not_contains(object_file_name("native_dep_2"));
49+
.assert_stdout_not_contains("native_dep_2.o");
4950

5051
// Test bundle with whole archive.
5152
rustc().input("rust_dep.rs").crate_type("rlib").run();
@@ -64,8 +65,8 @@ fn main() {
6465
.assert_stdout_not_contains("native_dep_4");
6566

6667
// 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"));
68+
rfs::remove_file(static_lib_name("native_dep_1"));
69+
rfs::remove_file(static_lib_name("native_dep_3"));
6970

7071
let out = rustc()
7172
.input("main.rs")
@@ -81,8 +82,3 @@ fn main() {
8182

8283
assert!(re.is_match(&out));
8384
}
84-
85-
//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") }
88-
}
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)
Failed to load comments.