Skip to content

Commit cf94a02

Browse files
committed
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.
1 parent 43c60ec commit cf94a02

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

Makefile.pre.in

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3120,8 +3120,18 @@ 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-
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
3123+
# On macOS universal2 builds, $(PY_CORE_CFLAGS) contains "-arch arm64 -arch x86_64",
3124+
# which would produce fat .o files containing both architectures for each .S input.
3125+
# lipo -create then refuses to combine them because they share architectures.
3126+
# Build each per-arch object with a single -arch flag before merging with lipo.
3127+
Python/asm_trampoline_universal2.o: $(srcdir)/Python/asm_trampoline_aarch64.S $(srcdir)/Python/asm_trampoline_x86_64.S
3128+
$(CC) -c $(filter-out -arch arm64 x86_64,$(PY_CORE_CFLAGS)) -arch arm64 \
3129+
-o Python/asm_trampoline_arm64-apple-darwin.o $(srcdir)/Python/asm_trampoline_aarch64.S
3130+
$(CC) -c $(filter-out -arch arm64 x86_64,$(PY_CORE_CFLAGS)) -arch x86_64 \
3131+
-o Python/asm_trampoline_x86_64-apple-darwin.o $(srcdir)/Python/asm_trampoline_x86_64.S
3132+
lipo -create -output $@ \
3133+
Python/asm_trampoline_arm64-apple-darwin.o \
3134+
Python/asm_trampoline_x86_64-apple-darwin.o
31253135

31263136
Python/emscripten_trampoline_inner.wasm: $(srcdir)/Python/emscripten_trampoline_inner.c
31273137
# emcc has a path that ends with emsdk/upstream/emscripten/emcc, we're looking for emsdk/upstream/bin/clang.

0 commit comments

Comments
 (0)