From 128df7f84df3f84eb3a36668f41e9003293c287c Mon Sep 17 00:00:00 2001 From: "Hans J. Johnson" Date: Sun, 5 Jul 2026 07:48:25 -0500 Subject: [PATCH] fix(libpython): link libintl so _localemodule resolves on macOS _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`. --- cmake/libpython/CMakeLists.txt | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/cmake/libpython/CMakeLists.txt b/cmake/libpython/CMakeLists.txt index c344b674..3317b532 100644 --- a/cmake/libpython/CMakeLists.txt +++ b/cmake/libpython/CMakeLists.txt @@ -471,6 +471,14 @@ set(LIBPYTHON_TARGET_LIBRARIES if(HAVE_LIBDL) list(APPEND LIBPYTHON_TARGET_LIBRARIES ${HAVE_LIBDL}) endif() +if(HAVE_LIBINTL) + # _localemodule uses libintl_* (bindtextdomain, dcgettext, ...) when + # HAVE_LIBINTL_H is set. Where libintl is a separate library (e.g. macOS + # gettext), link it so those symbols resolve; mirrors CPython configure's + # `LIBS += -lintl`. On glibc the functions are in libc and HAVE_LIBINTL is + # unset, so this is a no-op there. + list(APPEND LIBPYTHON_TARGET_LIBRARIES ${HAVE_LIBINTL}) +endif() if(WITH_THREAD OR PY_VERSION VERSION_GREATER_EQUAL "3.7") list(APPEND LIBPYTHON_TARGET_LIBRARIES ${CMAKE_THREAD_LIBS_INIT}) endif()