about summary refs log tree commit diff
diff options
context:
space:
mode:
authorOneirical <manchot@videotron.ca>2024-07-16 14:59:56 -0400
committerOneirical <manchot@videotron.ca>2024-07-18 09:28:30 -0400
commit06dcdbb2eea7eef79eff3f8cd1419c4e05a0e642 (patch)
tree5e65c391469971dc60b6fb735e2826e92f19fba6
parent52f3c71c8dc4aaed71e3035995fcbdd6d78c98c6 (diff)
downloadrust-06dcdbb2eea7eef79eff3f8cd1419c4e05a0e642.tar.gz
rust-06dcdbb2eea7eef79eff3f8cd1419c4e05a0e642.zip
rewrite macos-fat-archive to rmake
-rw-r--r--src/tools/tidy/src/allowed_run_make_makefiles.txt1
-rw-r--r--tests/run-make/macos-fat-archive/Makefile10
-rw-r--r--tests/run-make/macos-fat-archive/rmake.rs20
3 files changed, 20 insertions, 11 deletions
diff --git a/src/tools/tidy/src/allowed_run_make_makefiles.txt b/src/tools/tidy/src/allowed_run_make_makefiles.txt
index f33cde110a5..d562a5f4d1b 100644
--- a/src/tools/tidy/src/allowed_run_make_makefiles.txt
+++ b/src/tools/tidy/src/allowed_run_make_makefiles.txt
@@ -72,7 +72,6 @@ run-make/lto-linkage-used-attr/Makefile
 run-make/lto-no-link-whole-rlib/Makefile
 run-make/lto-smoke-c/Makefile
 run-make/macos-deployment-target/Makefile
-run-make/macos-fat-archive/Makefile
 run-make/manual-link/Makefile
 run-make/min-global-align/Makefile
 run-make/missing-crate-dependency/Makefile
diff --git a/tests/run-make/macos-fat-archive/Makefile b/tests/run-make/macos-fat-archive/Makefile
deleted file mode 100644
index 0feb39a23cb..00000000000
--- a/tests/run-make/macos-fat-archive/Makefile
+++ /dev/null
@@ -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
diff --git a/tests/run-make/macos-fat-archive/rmake.rs b/tests/run-make/macos-fat-archive/rmake.rs
new file mode 100644
index 00000000000..c9f0fa07693
--- /dev/null
+++ b/tests/run-make/macos-fat-archive/rmake.rs
@@ -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();
+}