config_host.mk.in | 1 + configure.ac | 14 +++++++++++++- sal/osl/unx/thread.cxx | 14 +++++++++----- unotools/Library_utl.mk | 6 ++++++ 4 files changed, 29 insertions(+), 6 deletions(-)
New commits: commit 13975389bd2985f74de621e44a31848065498521 Author: Andras Timar <[email protected]> AuthorDate: Wed Feb 18 17:06:16 2026 +0100 Commit: Miklos Vajna <[email protected]> CommitDate: Thu Feb 19 09:04:03 2026 +0100 fix build with musl libc (Alpine Linux) Three fixes based on Alpine Linux's aports patches, done properly: - configure.ac: add linux-musl* to the Java include path detection, same as linux-gnu* (uses the same /include/linux directory). - sal/osl/unx/thread.cxx: always set explicit thread stack size on Linux, not only for non-optimized builds. musl defaults to 128kB which is too small. Use pthread_attr_getstacksize to read the default and only bump it to 1MB if it is below that, so glibc's 8MB default is preserved. - configure.ac, config_host.mk.in, unotools/Library_utl.mk: detect whether bindtextdomain needs -lintl (musl lacks gettext in libc, unlike glibc) via AC_SEARCH_LIBS, and link it only when needed. Change-Id: I5a7b2c8d1e3f6a9b4c0d7e2f5a8b1c4d7e0f3a6b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/199633 Tested-by: Jenkins CollaboraOffice <[email protected]> Reviewed-by: Miklos Vajna <[email protected]> diff --git a/config_host.mk.in b/config_host.mk.in index cc0ab27ff1fd..48cf25315c6a 100644 --- a/config_host.mk.in +++ b/config_host.mk.in @@ -421,6 +421,7 @@ export LIBEXTTEXTCAT_CFLAGS=$(gb_SPACE)@LIBEXTTEXTCAT_CFLAGS@ export LIBEXTTEXTCAT_LIBS=$(gb_SPACE)@LIBEXTTEXTCAT_LIBS@ export LIBFONTS_JAR=@LIBFONTS_JAR@ export LIBFORMULA_JAR=@LIBFORMULA_JAR@ +export LIBINTL_LIBS=$(gb_SPACE)@LIBINTL_LIBS@ export LIBJPEG_CFLAGS=$(gb_SPACE)@LIBJPEG_CFLAGS@ export LIBJPEG_LIBS=$(gb_SPACE)@LIBJPEG_LIBS@ export LIBLANGTAG_CFLAGS=$(gb_SPACE)@LIBLANGTAG_CFLAGS@ diff --git a/configure.ac b/configure.ac index d60e4203e3cd..100636d46c4e 100644 --- a/configure.ac +++ b/configure.ac @@ -1477,6 +1477,18 @@ if test "$usable_dlapi" != no; then fi AC_SUBST(UNIX_DLAPI_LIBS) +# Check if libintl is needed (musl libc provides a stub bindtextdomain in libc, +# but <libintl.h> from gettext-dev redefines it to libintl_bindtextdomain which +# only exists in libintl.so) +LIBINTL_LIBS= +if test "$_os" = "Linux"; then + save_LIBS="$LIBS" + AC_SEARCH_LIBS([libintl_bindtextdomain], [intl], + [case "$ac_cv_search_libintl_bindtextdomain" in -l*) LIBINTL_LIBS="$ac_cv_search_libintl_bindtextdomain";; esac]) + LIBS="$save_LIBS" +fi +AC_SUBST(LIBINTL_LIBS) + # Check for a (GNU) backtrace implementation AC_ARG_VAR([BACKTRACE_CFLAGS], [Compiler flags needed to use backtrace(3)]) AC_ARG_VAR([BACKTRACE_LIBS], [Linker flags needed to use backtrace(3)]) @@ -9549,7 +9561,7 @@ if test -n "$ENABLE_JAVA" -a -z "$JAVAINC"; then test -d "$JAVA_HOME/include/native_thread" && JAVAINC="$JAVAINC -I$JAVA_HOME/include/native_thread" ;; - linux-gnu*) + linux-gnu*|linux-musl*) JAVAINC="-I$JAVA_HOME/include" JAVAINC="$JAVAINC -I$JAVA_HOME/include/linux" test -d "$JAVA_HOME/include/native_thread" && JAVAINC="$JAVAINC -I$JAVA_HOME/include/native_thread" diff --git a/sal/osl/unx/thread.cxx b/sal/osl/unx/thread.cxx index 7dd2e923e433..3ee709737de4 100644 --- a/sal/osl/unx/thread.cxx +++ b/sal/osl/unx/thread.cxx @@ -255,7 +255,7 @@ static oslThread osl_thread_create_Impl ( short nFlags) { Thread_Impl* pImpl; -#if defined OPENBSD || defined MACOSX || (defined LINUX && !ENABLE_RUNTIME_OPTIMIZATIONS) +#if defined OPENBSD || defined MACOSX || defined LINUX pthread_attr_t attr; size_t stacksize; #endif @@ -271,7 +271,7 @@ static oslThread osl_thread_create_Impl ( pthread_mutex_lock (&(pImpl->m_Lock)); -#if defined OPENBSD || defined MACOSX || (defined LINUX && !ENABLE_RUNTIME_OPTIMIZATIONS) +#if defined OPENBSD || defined MACOSX || defined LINUX if (pthread_attr_init(&attr) != 0) return nullptr; @@ -280,7 +280,11 @@ static oslThread osl_thread_create_Impl ( #elif !ENABLE_RUNTIME_OPTIMIZATIONS stacksize = 12 * 1024 * 1024; // 8MB is not enough for ASAN on x86-64 #else - stacksize = 1 * 1024 * 1024; // macOS default for non-main threads (512kB) is not enough... + // Enforce a minimum of 1MB — macOS defaults to 512kB and musl to 128kB, + // both too small. On glibc (8MB default) this is a no-op. + pthread_attr_getstacksize(&attr, &stacksize); + if (stacksize < 1024 * 1024) + stacksize = 1024 * 1024; #endif if (pthread_attr_setstacksize(&attr, stacksize) != 0) { pthread_attr_destroy(&attr); @@ -290,7 +294,7 @@ static oslThread osl_thread_create_Impl ( if ((nRet = pthread_create ( &(pImpl->m_hThread), -#if defined OPENBSD || defined MACOSX || (defined LINUX && !ENABLE_RUNTIME_OPTIMIZATIONS) +#if defined OPENBSD || defined MACOSX || defined LINUX &attr, #else PTHREAD_ATTR_DEFAULT, @@ -308,7 +312,7 @@ static oslThread osl_thread_create_Impl ( return nullptr; } -#if defined OPENBSD || defined MACOSX || (defined LINUX && !ENABLE_RUNTIME_OPTIMIZATIONS) +#if defined OPENBSD || defined MACOSX || defined LINUX pthread_attr_destroy(&attr); #endif diff --git a/unotools/Library_utl.mk b/unotools/Library_utl.mk index 9764cdc695bd..e5a8bf725f76 100644 --- a/unotools/Library_utl.mk +++ b/unotools/Library_utl.mk @@ -16,6 +16,12 @@ $(eval $(call gb_Library_use_externals,utl,\ boost_locale \ )) +ifneq ($(LIBINTL_LIBS),) +$(eval $(call gb_Library_add_libs,utl,\ + $(LIBINTL_LIBS) \ +)) +endif + $(eval $(call gb_Library_use_custom_headers,utl,\ officecfg/registry \ ))
