From: Pablo Galindo Salgado Date: Mon, 25 May 2026 22:01:27 +0000 (+0100) Subject: gh-149800: Fix macOS universal2 build of perf trampoline (GH-149894 follow-up) (... X-Git-Url: http://git.ipfire.org/gitweb/index.cgi?a=commitdiff_plain;h=e6b17d1d6dc3dcb497502b377b1357076feb41f3;p=thirdparty%2FPython%2Fcpython.git gh-149800: Fix macOS universal2 build of perf trampoline (GH-149894 follow-up) (#150364) 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. --- diff --git a/Makefile.pre.in b/Makefile.pre.in index ea15726a2de5..242aca0dc05e 100644 --- a/Makefile.pre.in +++ b/Makefile.pre.in @@ -3122,8 +3122,20 @@ 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 + 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.