FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

fix(libpython): link libintl so _localemodule resolves on macOS by hjmjohnson · Pull Request #450 · python-cmake-buildsystem/python-cmake-buildsystem · GitHub

fix(libpython): link libintl so _localemodule resolves on macOS - #450

Open
hjmjohnson wants to merge 1 commit into
python-cmake-buildsystem:masterfrom
hjmjohnson:fix/link-libintl-localemodule-macos
Open

fix(libpython): link libintl so _localemodule resolves on macOS#450
hjmjohnson wants to merge 1 commit into
python-cmake-buildsystem:masterfrom
hjmjohnson:fix/link-libintl-localemodule-macos

Conversation

Copy link
Copy Markdown

On macOS, every target linking libpython (including the _freeze_importlib bootstrap tool) fails with undefined _libintl_bindtextdomain / _libintl_dcgettext / _libintl_bind_textdomain_codeset symbols when a separate libintl (gettext) is present.

_localemodule.c calls the libintl_* functions whenever HAVE_LIBINTL_H is defined, but HAVE_LIBINTL (the found intl library) was only added to CMAKE_REQUIRED_LIBRARIES for configure checks — never to the libpython link libraries. This mirrors CPython's own configure, which appends -lintl to LIBS. On glibc the gettext functions live in libc, so HAVE_LIBINTL is unset and this is a no-op.

Fix: append HAVE_LIBINTL to LIBPYTHON_TARGET_LIBRARIES when found, mirroring the adjacent HAVE_LIBDL handling.

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_importlib link fails with the undefined _libintl_* symbols. After: _freeze_importlib, libpython3.12.dylib, and the python executable all link and build to completion (397/397).

_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

Copy link
Copy Markdown
Author

@thewtex This fix was needed to get Slicer built on mac using a pixi environment set of compilers.

thewtex left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

This looks good to me

thewtex commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

ping @jcfr

Copy link
Copy Markdown
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

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants


Back | FazBrowse Home | New Git URL