From bf23f3aa8373a026129761463c12e94708f2fc71 Mon Sep 17 00:00:00 2001 From: Titouan Christophe Date: Sun, 31 May 2026 00:50:29 +0200 Subject: [PATCH] package/samba4: fix build on uclibc with GCC 14+ iconv types are defined differently in glibc (as pointers) and uclibc (as integers). With changes in GCC14, -Wint-conversion has now become an error, which shed some light on the issue. The actual fix for that problem is released in uclibc 1.0.58 [1]. However, because these type definitions are in toolchain headers, this means that the toolchain used to build samba must also include uclibc>=1.0.58 (either an external toolchain that includes the uclibc fix, or a Buildroot toolchain after the uclibc fix is merged in Buildroot [2]). Until then, provide a workaround for samba itself. No autobuilder failure on this (yet). It can be reproduced with > ./utils/test-pkg -p samba4 -T bootlin-armv5-uclibc [1] https://github.com/wbx-github/uclibc-ng/commit/328e14e55f35ee333e5a19c5717cb4bbf426c3f1 [2] https://lore.kernel.org/buildroot/ahPrm_0gVDGw5B5-@waldemar-brodkorb.de/ Assisted-by: Claude:claude-opus-4.8 Signed-off-by: Titouan Christophe Signed-off-by: Marcus Hoffmann (cherry picked from commit e136494e918090296284214ca06736e2dafb83fe) Signed-off-by: Thomas Perale --- ...-iconv-fix-build-when-iconv_t-is-not.patch | 98 +++++++++++++++++++ 1 file changed, 98 insertions(+) create mode 100644 package/samba4/0002-lib-util-charset-iconv-fix-build-when-iconv_t-is-not.patch diff --git a/package/samba4/0002-lib-util-charset-iconv-fix-build-when-iconv_t-is-not.patch b/package/samba4/0002-lib-util-charset-iconv-fix-build-when-iconv_t-is-not.patch new file mode 100644 index 0000000000..b270deaf98 --- /dev/null +++ b/package/samba4/0002-lib-util-charset-iconv-fix-build-when-iconv_t-is-not.patch @@ -0,0 +1,98 @@ +From aab0668cc358e443b243528939947c3eea93ca27 Mon Sep 17 00:00:00 2001 +From: Titouan Christophe +Date: Sat, 30 May 2026 00:30:00 +0200 +Subject: [PATCH] charset: fix iconv_t int/pointer conversion on uClibc + +The iconv handles cd_pull, cd_push and cd_direct are stored as 'void *' +in struct smb_iconv_s, but iconv_open() returns and iconv()/iconv_close() +take an iconv_t. On glibc this is harmless because iconv_t is itself a +'void *', so the implicit conversions are between identical types. + +On uClibc however iconv_t is a 'long int', so storing iconv_open()'s +result into a 'void *' field (and passing those fields back to iconv() +and iconv_close()) is an implicit integer<->pointer conversion. Since +GCC 14 -Wint-conversion is an error by default, this breaks the build: + + iconv.c: In function 'sys_iconv': + iconv.c:166:38: error: passing argument 1 of 'iconv' makes integer + from pointer without a cast [-Wint-conversion] + iconv.c: In function 'smb_iconv_open_ex': + iconv.c:403:30: error: assignment to 'void *' from 'iconv_t' + {aka 'long int'} makes pointer from integer without a cast + [-Wint-conversion] + +Add explicit casts between iconv_t and void * so the conversions are +intentional and the code builds on both glibc and uClibc. + +Upstream: not applicable to samba, because uclibc has already released + a fix, but this isn't included yet in Buildroot prebuilt toolchains. + The problem is therefore to be patched in Buildroot itself. + +Signed-off-by: Titouan Christophe +--- + lib/util/charset/iconv.c | 30 +++++++++++++++--------------- + 1 file changed, 15 insertions(+), 15 deletions(-) + +diff --git a/lib/util/charset/iconv.c b/lib/util/charset/iconv.c +index 074794a26e3..90389d6a954 100644 +--- a/lib/util/charset/iconv.c ++++ b/lib/util/charset/iconv.c +@@ -163,7 +163,7 @@ static size_t sys_iconv(void *cd, + size_t ret = iconv((iconv_t)cd, + discard_const_p(char *, inbuf), inbytesleft, + outbuf, outbytesleft); +- if (ret == (size_t)-1) iconv(cd, NULL, NULL, NULL, NULL); ++ if (ret == (size_t)-1) iconv((iconv_t)cd, NULL, NULL, NULL, NULL); + return ret; + } + #endif +@@ -345,12 +345,12 @@ static int smb_iconv_t_destructor(smb_iconv_t hwd) + } + #endif + #ifdef HAVE_NATIVE_ICONV +- if (hwd->cd_pull != NULL && hwd->cd_pull != (iconv_t)-1) +- iconv_close(hwd->cd_pull); +- if (hwd->cd_push != NULL && hwd->cd_push != (iconv_t)-1) +- iconv_close(hwd->cd_push); +- if (hwd->cd_direct != NULL && hwd->cd_direct != (iconv_t)-1) +- iconv_close(hwd->cd_direct); ++ if (hwd->cd_pull != NULL && hwd->cd_pull != (void *)(iconv_t)-1) ++ iconv_close((iconv_t)hwd->cd_pull); ++ if (hwd->cd_push != NULL && hwd->cd_push != (void *)(iconv_t)-1) ++ iconv_close((iconv_t)hwd->cd_push); ++ if (hwd->cd_direct != NULL && hwd->cd_direct != (void *)(iconv_t)-1) ++ iconv_close((iconv_t)hwd->cd_direct); + #endif + + return 0; +@@ -400,19 +400,19 @@ _PUBLIC_ smb_iconv_t smb_iconv_open_ex(TALLOC_CTX *mem_ctx, const char *tocode, + * conversions */ + + if (from == NULL) { +- ret->cd_pull = iconv_open("UTF-16LE", fromcode); +- if (ret->cd_pull == (iconv_t)-1) +- ret->cd_pull = iconv_open("UCS-2LE", fromcode); +- if (ret->cd_pull != (iconv_t)-1) { ++ ret->cd_pull = (void *)iconv_open("UTF-16LE", fromcode); ++ if (ret->cd_pull == (void *)(iconv_t)-1) ++ ret->cd_pull = (void *)iconv_open("UCS-2LE", fromcode); ++ if (ret->cd_pull != (void *)(iconv_t)-1) { + ret->pull = sys_iconv; + } + } + + if (to == NULL) { +- ret->cd_push = iconv_open(tocode, "UTF-16LE"); +- if (ret->cd_push == (iconv_t)-1) +- ret->cd_push = iconv_open(tocode, "UCS-2LE"); +- if (ret->cd_push != (iconv_t)-1) { ++ ret->cd_push = (void *)iconv_open(tocode, "UTF-16LE"); ++ if (ret->cd_push == (void *)(iconv_t)-1) ++ ret->cd_push = (void *)iconv_open(tocode, "UCS-2LE"); ++ if (ret->cd_push != (void *)(iconv_t)-1) { + ret->push = sys_iconv; + } + } +-- +2.54.0 +