From 1b5d546d5f8b6dd800e9fbda5037b37aac39753c Mon Sep 17 00:00:00 2001 From: Itamar Oren Date: Tue, 20 Oct 2026 14:19:56 -0700 Subject: [PATCH] gh-144942: Link $(MODLIBS) into the macOS shared library and framework The rules for the libpython dylib and for the macOS and iOS frameworks did not pass $(MODLIBS), unlike the rule for libpython.so. When a module is built in (for example via Modules/Setup.local), the libraries it needs, such as the HACL* objects used by _blake2, were left out. The framework link then fails with undefined symbols, while the dylib, which is linked with -undefined dynamic_lookup, fails only when the missing symbol is called at runtime. Co-Authored-By: Claude Opus 5.5 --- Makefile.pre.in | 6 +++--- .../Build/2026-10-20-20-00-00.gh-issue-144942.MdLibs.rst | 3 +++ 2 files changed, 6 insertions(+), 3 deletions(-) create mode 100644 Misc/NEWS.d/next/Build/2026-10-20-20-00-00.gh-issue-144942.MdLibs.rst diff --git a/Makefile.pre.in b/Makefile.pre.in index c49a16f1edc3be..1b5185a3a53f18 100644 --- a/Makefile.pre.in +++ b/Makefile.pre.in @@ -1016,7 +1016,7 @@ libpython3.so: libpython$(LDVERSION).so $(BLDSHARED) $(NO_AS_NEEDED) -o $@ -Wl,-h$@ $^ libpython$(LDVERSION).dylib: $(LIBRARY_OBJS) - $(CC) -dynamiclib $(PY_CORE_LDFLAGS) -undefined dynamic_lookup -Wl,-install_name,$(prefix)/lib/libpython$(LDVERSION).dylib -Wl,-compatibility_version,$(VERSION) -Wl,-current_version,$(VERSION) -o $@ $(LIBRARY_OBJS) $(DTRACE_OBJS) $(SHLIBS) $(LIBC) $(LIBM); \ + $(CC) -dynamiclib $(PY_CORE_LDFLAGS) -undefined dynamic_lookup -Wl,-install_name,$(prefix)/lib/libpython$(LDVERSION).dylib -Wl,-compatibility_version,$(VERSION) -Wl,-current_version,$(VERSION) -o $@ $(LIBRARY_OBJS) $(DTRACE_OBJS) $(MODLIBS) $(SHLIBS) $(LIBC) $(LIBM); \ libpython$(VERSION).sl: $(LIBRARY_OBJS) @@ -1050,7 +1050,7 @@ $(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK): \ -install_name $(PYTHONFRAMEWORKINSTALLNAMEPREFIX)/$(PYTHONFRAMEWORK) \ -compatibility_version $(VERSION) \ -current_version $(VERSION) \ - -framework CoreFoundation $(LIBS); + -framework CoreFoundation $(MODLIBS) $(LIBS); $(INSTALL) -d -m $(DIRMODE) \ $(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/Resources/English.lproj $(INSTALL_DATA) $(RESSRCDIR)/Info.plist \ @@ -1071,7 +1071,7 @@ $(PYTHONFRAMEWORKDIR)/$(PYTHONFRAMEWORK): \ -install_name $(PYTHONFRAMEWORKINSTALLNAMEPREFIX)/$(PYTHONFRAMEWORK) \ -compatibility_version $(VERSION) \ -current_version $(VERSION) \ - -framework CoreFoundation $(LIBS); + -framework CoreFoundation $(MODLIBS) $(LIBS); $(INSTALL_DATA) $(RESSRCDIR)/Info.plist $(PYTHONFRAMEWORKDIR)/Info.plist # This rule builds the Cygwin Python DLL and import library if configured diff --git a/Misc/NEWS.d/next/Build/2026-10-20-20-00-00.gh-issue-144942.MdLibs.rst b/Misc/NEWS.d/next/Build/2026-10-20-20-00-00.gh-issue-144942.MdLibs.rst new file mode 100644 index 00000000000000..94b25d67af2fe4 --- /dev/null +++ b/Misc/NEWS.d/next/Build/2026-10-20-20-00-00.gh-issue-144942.MdLibs.rst @@ -0,0 +1,3 @@ +Fix the macOS shared library and framework builds not linking the libraries +required by built-in modules, such as the HACL* objects needed by ``_blake2`` +when it is built in via :file:`Modules/Setup.local`.