Skip to content

Commit 39ccb8a

Browse files
authored
Rollup merge of #127825 - Oneirical:self-testeem, r=jieyouxu
Migrate `macos-fat-archive`, `manual-link` and `archive-duplicate-names` `run-make` tests to rmake Part of #121876 and the associated [Google Summer of Code project](https://blog.rust-lang.org/2024/05/01/gsoc-2024-selected-projects.html). Please try: try-job: x86_64-msvc try-job: aarch64-apple
2 parents 986d6bf + 47c2101 commit 39ccb8a

File tree

7 files changed

+73
-36
lines changed

7 files changed

+73
-36
lines changed

src/tools/tidy/src/allowed_run_make_makefiles.txt

-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
run-make/archive-duplicate-names/Makefile
21
run-make/branch-protection-check-IBT/Makefile
32
run-make/c-dynamic-dylib/Makefile
43
run-make/c-dynamic-rlib/Makefile
@@ -64,8 +63,6 @@ run-make/lto-linkage-used-attr/Makefile
6463
run-make/lto-no-link-whole-rlib/Makefile
6564
run-make/lto-smoke-c/Makefile
6665
run-make/macos-deployment-target/Makefile
67-
run-make/macos-fat-archive/Makefile
68-
run-make/manual-link/Makefile
6966
run-make/min-global-align/Makefile
7067
run-make/native-link-modifier-bundle/Makefile
7168
run-make/native-link-modifier-whole-archive/Makefile

tests/run-make/archive-duplicate-names/Makefile

-16
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
// When two object archives with the same filename are present, an iterator is supposed to
2+
// inspect each object, recognize the duplication and extract each one to a different directory.
3+
// This test checks that this duplicate handling behaviour has not been broken.
4+
// See https://github.com/rust-lang/rust/pull/24439
5+
6+
//@ ignore-cross-compile
7+
// Reason: the compiled binary is executed
8+
9+
use run_make_support::{cc, is_msvc, llvm_ar, rfs, run, rustc};
10+
11+
fn main() {
12+
rfs::create_dir("a");
13+
rfs::create_dir("b");
14+
compile_obj_force_foo("a", "foo");
15+
compile_obj_force_foo("b", "bar");
16+
let mut ar = llvm_ar();
17+
ar.obj_to_ar().arg("libfoo.a");
18+
if is_msvc() {
19+
ar.arg("a/foo.obj").arg("b/foo.obj").run();
20+
} else {
21+
ar.arg("a/foo.o").arg("b/foo.o").run();
22+
}
23+
rustc().input("foo.rs").run();
24+
rustc().input("bar.rs").run();
25+
run("bar");
26+
}
27+
28+
#[track_caller]
29+
pub fn compile_obj_force_foo(dir: &str, lib_name: &str) {
30+
let obj_file = if is_msvc() { format!("{dir}/foo") } else { format!("{dir}/foo.o") };
31+
let src = format!("{lib_name}.c");
32+
if is_msvc() {
33+
cc().arg("-c").out_exe(&obj_file).input(src).run();
34+
} else {
35+
cc().arg("-v").arg("-c").out_exe(&obj_file).input(src).run();
36+
};
37+
}

tests/run-make/macos-fat-archive/Makefile

-10
This file was deleted.
+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// macOS (and iOS) has a concept of universal (fat) binaries which contain code for multiple CPU
2+
// architectures in the same file. Apple is migrating from x86_64 to aarch64 CPUs,
3+
// so for the next few years it will be important for macOS developers to
4+
// build "fat" binaries (executables and cdylibs).
5+
6+
// Rustc used to be unable to handle these special libraries, which was fixed in #98736. If
7+
// compilation in this test is successful, the native fat library was successfully linked to.
8+
// See https://github.com/rust-lang/rust/issues/55235
9+
10+
//@ only-apple
11+
12+
use run_make_support::{cc, llvm_ar, rustc};
13+
14+
fn main() {
15+
cc().args(&["-arch", "arm64", "-arch", "x86_64", "native-library.c", "-c"])
16+
.out_exe("native-library.o")
17+
.run();
18+
llvm_ar().obj_to_ar().output_input("libnative-library.a", "native-library.o").run();
19+
rustc().input("lib.rs").crate_type("lib").arg("-lstatic=native-library").run();
20+
}

tests/run-make/manual-link/Makefile

-7
This file was deleted.

tests/run-make/manual-link/rmake.rs

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// A smoke test for the `-l` command line rustc flag, which manually links to the selected
2+
// library. Useful for native libraries, this is roughly equivalent to `#[link]` in Rust code.
3+
// If compilation succeeds, the flag successfully linked the native library.
4+
// See https://github.com/rust-lang/rust/pull/18470
5+
6+
//@ ignore-cross-compile
7+
// Reason: the compiled binary is executed
8+
9+
use run_make_support::{build_native_static_lib, run, rustc};
10+
11+
fn main() {
12+
build_native_static_lib("bar");
13+
rustc().input("foo.rs").arg("-lstatic=bar").run();
14+
rustc().input("main.rs").run();
15+
run("main");
16+
}

0 commit comments

Comments
 (0)