Repository navigation
Commit a5285c7
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>
1 parent ef1cf22 commit a5285c7
2 files changed
Lines changed: 6 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1049 | 1049 | | |
1050 | 1050 | | |
1051 | 1051 | | |
1052 | | - | |
| 1052 | + | |
1053 | 1053 | | |
1054 | 1054 | | |
1055 | 1055 | | |
| |||
1083 | 1083 | | |
1084 | 1084 | | |
1085 | 1085 | | |
1086 | | - | |
| 1086 | + | |
1087 | 1087 | | |
1088 | 1088 | | |
1089 | 1089 | | |
| |||
1104 | 1104 | | |
1105 | 1105 | | |
1106 | 1106 | | |
1107 | | - | |
| 1107 | + | |
1108 | 1108 | | |
1109 | 1109 | | |
1110 | 1110 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
0 commit comments