Skip to content

Commit 1d010ee

Browse files
committed
gh-149800: Fix macOS universal2 build of perf trampoline
After splitting the perf trampoline into per-architecture .S files, PY_CORE_CFLAGS still carries `-arch arm64 -arch x86_64` on universal2 builds, so each per-arch object becomes a fat Mach-O whose wrong-arch slice is empty (thanks to the `#ifdef` guards in the sources). `lipo -create` then refused to merge two fat inputs sharing both architectures: fatal error: lipo: Python/asm_trampoline_aarch64.o and Python/asm_trampoline_x86_64.o have the same architectures (x86_64) and can't be in the same fat output file Extract the matching slice from each per-arch object with `lipo -thin` before recombining into `asm_trampoline_universal2.o`.
1 parent cb72193 commit 1d010ee

2 files changed

Lines changed: 9 additions & 1 deletion

File tree

Makefile.pre.in

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3120,8 +3120,13 @@ Python/asm_trampoline_aarch64.o: $(srcdir)/Python/asm_trampoline_aarch64.S
31203120
Python/asm_trampoline_riscv64.o: $(srcdir)/Python/asm_trampoline_riscv64.S
31213121
$(CC) -c $(PY_CORE_CFLAGS) -o $@ $<
31223122

3123+
# Extract the matching slice from each fat per-arch object before lipo -create,
3124+
# which rejects two fat inputs that share architectures.
31233125
Python/asm_trampoline_universal2.o: Python/asm_trampoline_aarch64.o Python/asm_trampoline_x86_64.o
3124-
lipo -create -output $@ Python/asm_trampoline_aarch64.o Python/asm_trampoline_x86_64.o
3126+
lipo -thin arm64 Python/asm_trampoline_aarch64.o -output $@.arm64
3127+
lipo -thin x86_64 Python/asm_trampoline_x86_64.o -output $@.x86_64
3128+
lipo -create -output $@ $@.arm64 $@.x86_64
3129+
rm -f $@.arm64 $@.x86_64
31253130

31263131
Python/emscripten_trampoline_inner.wasm: $(srcdir)/Python/emscripten_trampoline_inner.c
31273132
# emcc has a path that ends with emsdk/upstream/emscripten/emcc, we're looking for emsdk/upstream/bin/clang.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Fix macOS universal2 build of the perf trampoline. After the per-architecture
2+
split in :gh:`149800`, the ``arm64`` and ``x86_64`` trampoline objects were
3+
each compiled as fat Mach-O files, and ``lipo -create`` refused to merge them.

0 commit comments

Comments
 (0)