rewrite macos-fat-archive to rmake

This commit is contained in:
Oneirical 2024-07-16 14:59:56 -04:00
parent 52f3c71c8d
commit 06dcdbb2ee
3 changed files with 20 additions and 11 deletions

View File

@ -72,7 +72,6 @@ run-make/lto-linkage-used-attr/Makefile
run-make/lto-no-link-whole-rlib/Makefile run-make/lto-no-link-whole-rlib/Makefile
run-make/lto-smoke-c/Makefile run-make/lto-smoke-c/Makefile
run-make/macos-deployment-target/Makefile run-make/macos-deployment-target/Makefile
run-make/macos-fat-archive/Makefile
run-make/manual-link/Makefile run-make/manual-link/Makefile
run-make/min-global-align/Makefile run-make/min-global-align/Makefile
run-make/missing-crate-dependency/Makefile run-make/missing-crate-dependency/Makefile

View File

@ -1,10 +0,0 @@
# only-apple
include ../tools.mk
"$(TMPDIR)"/libnative-library.a: native-library.c
$(CC) -arch arm64 -arch x86_64 native-library.c -c -o "$(TMPDIR)"/native-library.o
$(AR) crs "$(TMPDIR)"/libnative-library.a "$(TMPDIR)"/native-library.o
all: "$(TMPDIR)"/libnative-library.a
$(RUSTC) lib.rs --crate-type=lib -L "native=$(TMPDIR)" -l static=native-library

View File

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