Skip to content

Building Python as a macOS framework fails on macos >= 15.4 #138070

@erikjv

Description

@erikjv

Bug report

Bug description:

When building as a framework, a duplicate -rpath option is specified when linking the Python "shared library" as well as when linking python.exe. Since macos 15.4, the dyld will reject all duplicate paths, meaning that python.exe cannot find the Python shared library, and the build fails.

Below is the last bit of the build output, including the failure to run python.exe.

Note: this happens on both Intel and Apple Silicon. The output below is while building on Intel.

/usr/bin/clang -o Python.framework/Versions/3.13/Python -Wl,-ld_classic -Wl,-rpath,/Users/erik/work/craft-stuff/build-craft-cache/macos-64-clang/lib -L/Users/erik/work/craft-stuff/build-craft-cache/macos-64-clang/lib -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk -mmacosx-version-min=11  -L/Users/erik/work/craft-stuff/build-craft-cache/macos-64-clang/lib   -Wl,-ld_classic -Wl,-rpath,/Users/erik/work/craft-stuff/build-craft-cache/macos-64-clang/lib -L/Users/erik/work/craft-stuff/build-craft-cache/macos-64-clang/lib -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk -mmacosx-version-min=11  -L/Users/erik/work/craft-stuff/build-craft-cache/macos-64-clang/lib    -dynamiclib \
-all_load libpython3.13.a \
-install_name /Users/erik/work/craft-stuff/build-craft-cache/macos-64-clang/lib/Python.framework/Versions/3.13/Python \
-compatibility_version 3.13 \
-current_version 3.13 \
-framework CoreFoundation -lintl -ldl  -framework CoreFoundation;
ld: warning: duplicate -rpath '/Users/erik/work/craft-stuff/build-craft-cache/macos-64-clang/lib' ignored
ld: warning: -ld_classic is deprecated and will be removed in a future release
/usr/bin/install -c -d -m 755  \
Python.framework/Versions/3.13/Resources/English.lproj
/usr/bin/install -c -m 644 Mac/Resources/framework/Info.plist \
Python.framework/Versions/3.13/Resources/Info.plist
ln -fsn 3.13 Python.framework/Versions/Current
ln -fsn Versions/Current/Python Python.framework/Python
ln -fsn Versions/Current/Resources Python.framework/Resources
/usr/bin/clang -Wl,-ld_classic -Wl,-rpath,/Users/erik/work/craft-stuff/build-craft-cache/macos-64-clang/lib -L/Users/erik/work/craft-stuff/build-craft-cache/macos-64-clang/lib -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk -mmacosx-version-min=11  -L/Users/erik/work/craft-stuff/build-craft-cache/macos-64-clang/lib   -Wl,-ld_classic -Wl,-rpath,/Users/erik/work/craft-stuff/build-craft-cache/macos-64-clang/lib -L/Users/erik/work/craft-stuff/build-craft-cache/macos-64-clang/lib -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk -mmacosx-version-min=11  -L/Users/erik/work/craft-stuff/build-craft-cache/macos-64-clang/lib    -Wl,-stack_size,1000000  -framework CoreFoundation Python.framework/Versions/3.13/Python -o python.exe Programs/python.o  -lintl -ldl  -framework CoreFoundation
/usr/bin/clang -Wl,-ld_classic -Wl,-rpath,/Users/erik/work/craft-stuff/build-craft-cache/macos-64-clang/lib -L/Users/erik/work/craft-stuff/build-craft-cache/macos-64-clang/lib -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk -mmacosx-version-min=11  -L/Users/erik/work/craft-stuff/build-craft-cache/macos-64-clang/lib   -Wl,-ld_classic -Wl,-rpath,/Users/erik/work/craft-stuff/build-craft-cache/macos-64-clang/lib -L/Users/erik/work/craft-stuff/build-craft-cache/macos-64-clang/lib -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk -mmacosx-version-min=11  -L/Users/erik/work/craft-stuff/build-craft-cache/macos-64-clang/lib    -Wl,-stack_size,1000000  -framework CoreFoundation Python.framework/Versions/3.13/Python -o Programs/_testembed Programs/_testembed.o  -lintl -ldl  -framework CoreFoundation
ld: warning: duplicate -rpath '/Users/erik/work/craft-stuff/build-craft-cache/macos-64-clang/lib' ignored
ld: warning: duplicate -rpath '/Users/erik/work/craft-stuff/build-craft-cache/macos-64-clang/lib' ignored
ld: warning: -ld_classic is deprecated and will be removed in a future release
ld: warning: -ld_classic is deprecated and will be removed in a future release
DYLD_FRAMEWORK_PATH=/Users/erik/work/craft-stuff/build-craft-cache/macos-64-clang/build/libs/python/work/build ./python.exe -E -S -m sysconfig --generate-posix-vars ;\
if test $? -ne 0 ; then \
echo "generate-posix-vars failed" ; \
rm -f ./pybuilddir.txt ; \
exit 1 ; \
fi
dyld[79008]: Library not loaded: /Users/erik/work/craft-stuff/build-craft-cache/macos-64-clang/lib/Python.framework/Versions/3.13/Python
Referenced from: <B495CB5D-1C36-3B06-939D-0BF8EBB85227> /Users/erik/work/craft-stuff/build-craft-cache/macos-64-clang/build/libs/python/work/build/python.exe
Reason: tried: '/Users/erik/work/craft-stuff/build-craft-cache/macos-64-clang/build/libs/python/work/build/Python.framework/Versions/3.13/Python' (duplicate LC_RPATH '/Users/erik/work/craft-stuff/build-craft-cache/macos-64-clang/lib'), '/Users/erik/work/craft-stuff/build-craft-cache/macos-64-clang/lib/Python.framework/Versions/3.13/Python' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/Users/erik/work/craft-stuff/build-craft-cache/macos-64-clang/lib/Python.framework/Versions/3.13/Python' (no such file), '/Users/erik/work/craft-stuff/build-craft-cache/macos-64-clang/lib/Python.framework/Versions/3.13/Python' (no such file)
/bin/sh: line 1: 79008 Abort trap: 6           DYLD_FRAMEWORK_PATH=/Users/erik/work/craft-stuff/build-craft-cache/macos-64-clang/build/libs/python/work/build ./python.exe -E -S -m sysconfig --generate-posix-vars
make: *** [pybuilddir.txt] Error 134

CPython versions tested on:

3.11, 3.13

Operating systems tested on:

macOS

Metadata

Metadata

Assignees

No one assigned

    Labels

    OS-macbuildThe build process and cross-buildtype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions