From 1d010ee38366b8d780a28c07bd68f67ac21a3eb4 Mon Sep 17 00:00:00 2001 From: Pieter Eendebak Date: Sun, 24 May 2026 21:25:08 +0200 Subject: [PATCH] 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`. --- Makefile.pre.in | 7 ++++++- .../Build/2026-05-24-19-24-28.gh-issue-149800.Mq994d.rst | 3 +++ 2 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 Misc/NEWS.d/next/Build/2026-05-24-19-24-28.gh-issue-149800.Mq994d.rst diff --git a/Makefile.pre.in b/Makefile.pre.in index e8b44c4b874e954..d66172910718874 100644 --- a/Makefile.pre.in +++ b/Makefile.pre.in @@ -3120,8 +3120,13 @@ Python/asm_trampoline_aarch64.o: $(srcdir)/Python/asm_trampoline_aarch64.S Python/asm_trampoline_riscv64.o: $(srcdir)/Python/asm_trampoline_riscv64.S $(CC) -c $(PY_CORE_CFLAGS) -o $@ $< +# Extract the matching slice from each fat per-arch object before lipo -create, +# which rejects two fat inputs that share architectures. Python/asm_trampoline_universal2.o: Python/asm_trampoline_aarch64.o Python/asm_trampoline_x86_64.o - lipo -create -output $@ Python/asm_trampoline_aarch64.o Python/asm_trampoline_x86_64.o + lipo -thin arm64 Python/asm_trampoline_aarch64.o -output $@.arm64 + lipo -thin x86_64 Python/asm_trampoline_x86_64.o -output $@.x86_64 + lipo -create -output $@ $@.arm64 $@.x86_64 + rm -f $@.arm64 $@.x86_64 Python/emscripten_trampoline_inner.wasm: $(srcdir)/Python/emscripten_trampoline_inner.c # emcc has a path that ends with emsdk/upstream/emscripten/emcc, we're looking for emsdk/upstream/bin/clang. diff --git a/Misc/NEWS.d/next/Build/2026-05-24-19-24-28.gh-issue-149800.Mq994d.rst b/Misc/NEWS.d/next/Build/2026-05-24-19-24-28.gh-issue-149800.Mq994d.rst new file mode 100644 index 000000000000000..0e7a19dfcf1c092 --- /dev/null +++ b/Misc/NEWS.d/next/Build/2026-05-24-19-24-28.gh-issue-149800.Mq994d.rst @@ -0,0 +1,3 @@ +Fix macOS universal2 build of the perf trampoline. After the per-architecture +split in :gh:`149800`, the ``arm64`` and ``x86_64`` trampoline objects were +each compiled as fat Mach-O files, and ``lipo -create`` refused to merge them.