From cf94a02d070159f33eec2fb34a55cba8330cc130 Mon Sep 17 00:00:00 2001 From: Pablo Galindo Salgado Date: Sun, 24 May 2026 20:32:01 +0100 Subject: [PATCH 1/2] gh-149800: Fix macOS universal2 build of perf trampoline (GH-149894 follow-up) After the perf trampoline assembly was split into per-architecture files, the macOS universal2 build failed at the lipo step: 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 PY_CORE_CFLAGS on universal2 contains "-arch arm64 -arch x86_64", so each .S file was assembled into a fat .o containing both slices (with one slice empty because of the #ifdef guards). lipo then refused to merge two fat objects that share architectures. Compile each per-arch object with a single -arch flag before merging. --- Makefile.pre.in | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/Makefile.pre.in b/Makefile.pre.in index e8b44c4b874e95..22f6f390d4981f 100644 --- a/Makefile.pre.in +++ b/Makefile.pre.in @@ -3120,8 +3120,18 @@ 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 $@ $< -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 +# On macOS universal2 builds, $(PY_CORE_CFLAGS) contains "-arch arm64 -arch x86_64", +# which would produce fat .o files containing both architectures for each .S input. +# lipo -create then refuses to combine them because they share architectures. +# Build each per-arch object with a single -arch flag before merging with lipo. +Python/asm_trampoline_universal2.o: $(srcdir)/Python/asm_trampoline_aarch64.S $(srcdir)/Python/asm_trampoline_x86_64.S + $(CC) -c $(filter-out -arch arm64 x86_64,$(PY_CORE_CFLAGS)) -arch arm64 \ + -o Python/asm_trampoline_arm64-apple-darwin.o $(srcdir)/Python/asm_trampoline_aarch64.S + $(CC) -c $(filter-out -arch arm64 x86_64,$(PY_CORE_CFLAGS)) -arch x86_64 \ + -o Python/asm_trampoline_x86_64-apple-darwin.o $(srcdir)/Python/asm_trampoline_x86_64.S + lipo -create -output $@ \ + Python/asm_trampoline_arm64-apple-darwin.o \ + Python/asm_trampoline_x86_64-apple-darwin.o 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. From 1c7c9065c309f0745a98585d878bf4888cfe5816 Mon Sep 17 00:00:00 2001 From: Pablo Galindo Salgado Date: Sun, 24 May 2026 22:10:56 +0100 Subject: [PATCH 2/2] Update Makefile.pre.in --- Makefile.pre.in | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Makefile.pre.in b/Makefile.pre.in index 22f6f390d4981f..c9366703ee555b 100644 --- a/Makefile.pre.in +++ b/Makefile.pre.in @@ -3132,6 +3132,8 @@ Python/asm_trampoline_universal2.o: $(srcdir)/Python/asm_trampoline_aarch64.S $( lipo -create -output $@ \ Python/asm_trampoline_arm64-apple-darwin.o \ Python/asm_trampoline_x86_64-apple-darwin.o + rm -f Python/asm_trampoline_arm64-apple-darwin.o \ + Python/asm_trampoline_x86_64-apple-darwin.o 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.