fix(libpython): link libintl so _localemodule resolves on macOS#450
Open
hjmjohnson wants to merge 1 commit into
Open
fix(libpython): link libintl so _localemodule resolves on macOS#450hjmjohnson wants to merge 1 commit into
hjmjohnson wants to merge 1 commit into
Conversation
_localemodule.c calls libintl_* (bindtextdomain, dcgettext, ...) when HAVE_LIBINTL_H is defined. HAVE_LIBINTL (the intl library) was added only to CMAKE_REQUIRED_LIBRARIES for configure checks, never to the libpython link libraries. On platforms where libintl is a separate library (e.g. macOS gettext), every target linking libpython -- including the _freeze_importlib bootstrap tool -- then fails with undefined _libintl_* symbols. glibc keeps these functions in libc, so HAVE_LIBINTL is unset there and this is a no-op. Append HAVE_LIBINTL to LIBPYTHON_TARGET_LIBRARIES when found, mirroring the existing HAVE_LIBDL handling and CPython configure's `LIBS += -lintl`.
hjmjohnson
marked this pull request as ready for review
July 5, 2026 12:58
Author
|
@thewtex This fix was needed to get Slicer built on mac using a pixi environment set of compilers. |
Contributor
|
ping @jcfr |
Author
|
ping @jamesobutler Do you have merge capabilities here? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
On macOS, every target linking
libpython(including the_freeze_importlibbootstrap tool) fails with undefined_libintl_bindtextdomain/_libintl_dcgettext/_libintl_bind_textdomain_codesetsymbols when a separatelibintl(gettext) is present._localemodule.ccalls thelibintl_*functions wheneverHAVE_LIBINTL_His defined, butHAVE_LIBINTL(the foundintllibrary) was only added toCMAKE_REQUIRED_LIBRARIESfor configure checks — never to the libpython link libraries. This mirrors CPython's ownconfigure, which appends-lintltoLIBS. On glibc the gettext functions live in libc, soHAVE_LIBINTLis unset and this is a no-op.Fix: append
HAVE_LIBINTLtoLIBPYTHON_TARGET_LIBRARIESwhen found, mirroring the adjacentHAVE_LIBDLhandling.Reproduction / validation
Surfaced building CPython 3.12.10 on arm64 macOS with a conda-forge gettext on the prefix path (via 3D Slicer's SuperBuild). Before:
_freeze_importliblink fails with the undefined_libintl_*symbols. After:_freeze_importlib,libpython3.12.dylib, and thepythonexecutable all link and build to completion (397/397).