Repository navigation
gh-144942: Fix macOS dylib build by adding $(MODLIBS) and removing -undefined dy… - #145186
gourijain029-del wants to merge 1 commit into
Conversation
|
Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool. If this change has little impact on Python users, wait for a maintainer to apply the |
|
Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool. If this change has little impact on Python users, wait for a maintainer to apply the |
|
Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool. If this change has little impact on Python users, wait for a maintainer to apply the |
eeb5f4f to
10eb5ad
Compare
…ing -undefined dynamic_lookup
10eb5ad to
b76620c
Compare
|
This PR is stale because it has been open for 30 days with no activity. |
|
Could this be reviewed please? @ned-deily maybe you could route this to the appropriate team? thanks 🙏 |
…ork (#159966) The rules that link `libpython$(LDVERSION).dylib` and the macOS and iOS frameworks don't pass `$(MODLIBS)`, unlike the `libpython$(LDVERSION).so` rule. When a module is built in, for example via `Modules/Setup.local`, the libraries that module needs are left out: - **`--enable-framework`:** the build fails with undefined symbols. - **`--enable-shared`:** the dylib is linked with `-undefined dynamic_lookup`, so the build succeeds and the failure only shows up at runtime. To reproduce, build on macOS with this `Modules/Setup.local`: ``` *static* _blake2 blake2module.c ``` On `main`: - **`--enable-framework`:** linking `Python.framework` fails with 12 undefined `_Py_LibHacl_*` symbols. - **`--enable-shared`:** `nm -u libpython3.16.dylib` lists the same 12 symbols. After `make install`, `python3 -c "import _blake2; _blake2.blake2b(b'abc')"` aborts with `dyld: missing symbol called`, and so does a C program that embeds Python. With this change, both builds link with no undefined HACL symbols, and `_blake2` works as a built-in module. In default builds `$(MODLIBS)` is empty, so they are unaffected. `test_hashlib`, `test_hmac`, `test_embed` and `test_sysconfig` pass for shared and framework builds, both with and without the `Setup.local` above (macOS 14, arm64). I haven't tested the iOS framework rule, which gets the same one-line change. python-build-standalone already carries the dylib part of this as a patch ([astral-sh/python-build-standalone#870](astral-sh/python-build-standalone#870)). This PR doesn't remove `-undefined dynamic_lookup`, as the earlier gh-145186 did.
… framework (GH-159966) (#160160) gh-144942: Link `$(MODLIBS)` into the macOS shared library and framework (GH-159966) The rules that link `libpython$(LDVERSION).dylib` and the macOS and iOS frameworks don't pass `$(MODLIBS)`, unlike the `libpython$(LDVERSION).so` rule. When a module is built in, for example via `Modules/Setup.local`, the libraries that module needs are left out: - **`--enable-framework`:** the build fails with undefined symbols. - **`--enable-shared`:** the dylib is linked with `-undefined dynamic_lookup`, so the build succeeds and the failure only shows up at runtime. To reproduce, build on macOS with this `Modules/Setup.local`: ``` *static* _blake2 blake2module.c ``` On `main`: - **`--enable-framework`:** linking `Python.framework` fails with 12 undefined `_Py_LibHacl_*` symbols. - **`--enable-shared`:** `nm -u libpython3.16.dylib` lists the same 12 symbols. After `make install`, `python3 -c "import _blake2; _blake2.blake2b(b'abc')"` aborts with `dyld: missing symbol called`, and so does a C program that embeds Python. With this change, both builds link with no undefined HACL symbols, and `_blake2` works as a built-in module. In default builds `$(MODLIBS)` is empty, so they are unaffected. `test_hashlib`, `test_hmac`, `test_embed` and `test_sysconfig` pass for shared and framework builds, both with and without the `Setup.local` above (macOS 14, arm64). I haven't tested the iOS framework rule, which gets the same one-line change. python-build-standalone already carries the dylib part of this as a patch ([astral-sh/python-build-standalone#870](astral-sh/python-build-standalone#870)). This PR doesn't remove `-undefined dynamic_lookup`, as the earlier gh-145186 did. (cherry picked from commit 03864a2) Co-authored-by: Itamar Oren <itamarost@gmail.com>
… framework (GH-159966) (#160158) gh-144942: Link `$(MODLIBS)` into the macOS shared library and framework (GH-159966) The rules that link `libpython$(LDVERSION).dylib` and the macOS and iOS frameworks don't pass `$(MODLIBS)`, unlike the `libpython$(LDVERSION).so` rule. When a module is built in, for example via `Modules/Setup.local`, the libraries that module needs are left out: - **`--enable-framework`:** the build fails with undefined symbols. - **`--enable-shared`:** the dylib is linked with `-undefined dynamic_lookup`, so the build succeeds and the failure only shows up at runtime. To reproduce, build on macOS with this `Modules/Setup.local`: ``` *static* _blake2 blake2module.c ``` On `main`: - **`--enable-framework`:** linking `Python.framework` fails with 12 undefined `_Py_LibHacl_*` symbols. - **`--enable-shared`:** `nm -u libpython3.16.dylib` lists the same 12 symbols. After `make install`, `python3 -c "import _blake2; _blake2.blake2b(b'abc')"` aborts with `dyld: missing symbol called`, and so does a C program that embeds Python. With this change, both builds link with no undefined HACL symbols, and `_blake2` works as a built-in module. In default builds `$(MODLIBS)` is empty, so they are unaffected. `test_hashlib`, `test_hmac`, `test_embed` and `test_sysconfig` pass for shared and framework builds, both with and without the `Setup.local` above (macOS 14, arm64). I haven't tested the iOS framework rule, which gets the same one-line change. python-build-standalone already carries the dylib part of this as a patch ([astral-sh/python-build-standalone#870](astral-sh/python-build-standalone#870)). This PR doesn't remove `-undefined dynamic_lookup`, as the earlier gh-145186 did. (cherry picked from commit 03864a2) Co-authored-by: Itamar Oren <itamarost@gmail.com>
PR Title
gh-144942: Add $(MODLIBS) to macOS dylib build and remove -undefined dynamic_lookup
PR Description
Summary
This PR fixes an issue where the macOS libpython.dylib was missing $(MODLIBS) in its link command. This caused modules built statically (e.g., via
Modules/Setup.local
) to have their symbols omitted from the dynamic library, leading to runtime failures.
Additionally, this PR removes -undefined dynamic_lookup from the dylib link command. This ensures that any missing symbols are caught at build-time rather than resulting in null pointer dereferences or silent failures at runtime.
Changes
Updated
Makefile.pre.in$(MODLIBS) when linking libpython$ (LDVERSION).dylib.
to include
Removed -undefined dynamic_lookup from the same link command to enforce symbol resolution at build-time.