diff options
| author | Alex Gaynor <alex.gaynor@gmail.com> | 2022-06-30 15:01:38 -0400 |
|---|---|---|
| committer | Alex Gaynor <alex.gaynor@gmail.com> | 2022-10-04 07:39:51 -0400 |
| commit | c65c36242e99ddbf787dcdd9bd2d14f42f7cfce6 (patch) | |
| tree | f929294341d97a5cc916d714f3da894e4fdd3a55 /src | |
| parent | 6b139c5b3e2bad623bdbd8583bc4f2b0f763113a (diff) | |
| download | rust-c65c36242e99ddbf787dcdd9bd2d14f42f7cfce6.tar.gz rust-c65c36242e99ddbf787dcdd9bd2d14f42f7cfce6.zip | |
resolve error when attempting to link a universal library on macOS
Previously attempting to link universal libraries into libraries (but not binaries) would produce an error that "File too small to be an archive". This works around this by using `object` to extract a library for the target platform when passed a univeral library. Fixes #55235
Diffstat (limited to 'src')
| -rw-r--r-- | src/test/run-make/macos-fat-archive/Makefile | 10 | ||||
| -rw-r--r-- | src/test/run-make/macos-fat-archive/lib.rs | 3 | ||||
| -rw-r--r-- | src/test/run-make/macos-fat-archive/native-library.c | 1 |
3 files changed, 14 insertions, 0 deletions
diff --git a/src/test/run-make/macos-fat-archive/Makefile b/src/test/run-make/macos-fat-archive/Makefile new file mode 100644 index 00000000000..cc99375db69 --- /dev/null +++ b/src/test/run-make/macos-fat-archive/Makefile @@ -0,0 +1,10 @@ +# only-macos + +-include ../../run-make-fulldeps/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/src/test/run-make/macos-fat-archive/lib.rs b/src/test/run-make/macos-fat-archive/lib.rs new file mode 100644 index 00000000000..9943a266c3e --- /dev/null +++ b/src/test/run-make/macos-fat-archive/lib.rs @@ -0,0 +1,3 @@ +extern "C" { + pub fn native_func(); +} diff --git a/src/test/run-make/macos-fat-archive/native-library.c b/src/test/run-make/macos-fat-archive/native-library.c new file mode 100644 index 00000000000..d300fdf1c17 --- /dev/null +++ b/src/test/run-make/macos-fat-archive/native-library.c @@ -0,0 +1 @@ +void native_func() {} |
