pulseaudio: detect intl and iconv through meson dependency objects

The build probes for dgettext and iconv_open with bare symbol checks,
which succeed against libc even when a standalone GNU libintl or
libiconv is on the include path. Their headers redirect the calls to
libintl_* and libiconv_* symbols, so the objects then need -lintl,
which the Makefile supplied through TARGET_LDFLAGS for every link,
and the standalone libiconv was bypassed through LIBICONV_PLUG.

Add the two patches from upstream merge request 877, which switch the
probes to meson's intl and iconv dependency objects. These compile a
test including the header, so they fall back to linking the library
exactly when the header requires it. With BUILD_NLS this links
libintl-full and libiconv-full where they are used; without it, the
libc implementations are used as before. The second patch makes the
libm link conditional in the same way. Drop the -lintl workaround.

Patches taken from merge request currently under review upstream:
https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/877

Signed-off-by: Mirko Vogt <mirko-openwrt@nanl.de>
This commit is contained in:
Mirko Vogt authored and Mirko Vogt committed 2026-09-14 17:46:54 +02:00
1 parent 7d479353dd
commit 74fbbb485a
3 files changed
+90 -1

No files matched your search

+1 -1
View File
@@ -151,7 +151,7 @@ MESON_ARGS += \
-Dbluez5=disabled
endif
TARGET_LDFLAGS += -Wl,--gc-sections $(if $(INTL_FULL),-lintl)
TARGET_LDFLAGS += -Wl,--gc-sections
define Build/Prepare
$(call Build/Prepare/Default)
@@ -0,0 +1,62 @@
From 2535498c5109f6a5d55544c29528c99fd5781761 Mon Sep 17 00:00:00 2001
From: Rosen Penev <rosenp@gmail.com>
Date: Fri, 11 Sep 2026 15:17:42 -0700
Subject: [PATCH] meson: use intl and iconv dependencies
There's currently some issue with musl + external libintl where linking
is required but it's not doing it. Instead of adjusting, update meson to
61.2 (version in Ubuntu 22.04) and use iconv and intl dependencies,
which tend to work better.
Signed-off-by: Rosen Penev <rosenp@gmail.com>
---
meson.build | 25 ++++---------------------
1 file changed, 4 insertions(+), 21 deletions(-)
--- a/meson.build
+++ b/meson.build
@@ -1,6 +1,6 @@
project('pulseaudio', 'c',
version : run_command(find_program('git-version-gen'), join_paths(meson.current_source_dir(), '.tarball-version'), check : false).stdout().strip(),
- meson_version : '>= 0.56.0',
+ meson_version : '>= 0.61.2',
default_options : [ 'c_std=gnu11', 'cpp_std=c++17' ]
)
@@ -373,15 +373,7 @@ if cc.has_header_symbol('sys/syscall.h',
cdata.set('HAVE_MEMFD', 1)
endif
-if cc.has_function('dgettext')
- if host_machine.system() != 'windows'
- libintl_dep = []
- else
- libintl_dep = cc.find_library('intl')
- endif
-else
- libintl_dep = cc.find_library('intl')
-endif
+libintl_dep = dependency('intl')
# Symbols
@@ -472,17 +464,8 @@ if cc.has_function('dladdr', dependencie
cdata.set('HAVE_DLADDR', 1)
endif
-have_iconv = false
-if cc.has_function('iconv_open')
- iconv_dep = dependency('', required : false)
- have_iconv = true
- # tell the libiconv header to pretend to be libc iconv
- cdata.set('LIBICONV_PLUG', 1)
-else
- iconv_dep = cc.find_library('iconv', required : false)
- have_iconv = iconv_dep.found()
-endif
-if have_iconv
+iconv_dep = dependency('iconv', required: false)
+if iconv_dep.found()
cdata.set('HAVE_ICONV', 1)
iconvconsttest = '''#include <iconv.h>
size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);
@@ -0,0 +1,27 @@
From 3514b5f7c16d8d303b74f0311352f87793c7fea1 Mon Sep 17 00:00:00 2001
From: Rosen Penev <rosenp@gmail.com>
Date: Fri, 11 Sep 2026 15:23:09 -0700
Subject: [PATCH] meson: conditionally use libm
Add a small compile test to figure out whether libm is needed or not.
Signed-off-by: Rosen Penev <rosenp@gmail.com>
---
meson.build | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
--- a/meson.build
+++ b/meson.build
@@ -438,7 +438,11 @@ endif
# Core Dependencies
-libm_dep = cc.find_library('m', required : true)
+if cc.links('#include <math.h>\nint main(){log(0);}')
+ libm_dep = declare_dependency()
+else
+ libm_dep = cc.find_library('m')
+endif
thread_dep = dependency('threads')
foreach f : [