Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 945817 - sys-devel/gettext-0.23[-nls]: build failure: "relocatable.h:114:37: error: expected expression before ')' token"
Summary: sys-devel/gettext-0.23[-nls]: build failure: "relocatable.h:114:37: error: ex...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal
Assignee: Gentoo's Team for Core System packages
URL:
Whiteboard:
Keywords: PATCH
Depends on:
Blocks:
 
Reported: 2024-12-03 13:20 UTC by Holger Hoffstätte
Modified: 2024-12-06 13:21 UTC (History)
11 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
gettext-0.23 build log (build.log.xz,51.60 KB, application/x-xz)
2024-12-03 13:20 UTC, Holger Hoffstätte
Details
emerge --info (emerge-info.txt,6.60 KB, text/plain)
2024-12-03 13:31 UTC, Holger Hoffstätte
Details
Patch to restore quoting for BISON_LOCALEDIR (0.23-bison_localedir-quoting.patch,714 bytes, patch)
2024-12-03 17:03 UTC, Holger Hoffstätte
Details | Diff
Upstream patch for 0.23.0 (0.23-bison_localedir.patch,2.46 KB, patch)
2024-12-05 10:32 UTC, Holger Hoffstätte
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Holger Hoffstätte 2024-12-03 13:20:34 UTC
As $subject says, trying to build gettext-0.23 fails due to a broken macro expansion:

x86_64-pc-linux-gnu-gcc -DLOCALEDIR=\"/usr/share/locale\" -DBISON_LOCALEDIR= -DUSEJAVA=0 -DGETTEXTJAR=\"/usr/share/gettext\"\"/gettext.jar\" -DBINDIR=\"/usr/bin\" -DLIBDIR=\"/usr/lib64\" -DLIBEXECDIR=\"/usr/libexec\" -DGETTEXTDATADIR=\"/usr/share/gettext\" -DPROJECTSDIR=\"/usr/share/gettext\"\"/projects\" -DEXEEXT=\"\" -DHAVE_CONFIG_H -I. -I/tmp/portage/sys-devel/gettext-0.23/work/gettext-0.23/gettext-tools/src -I..  -I/tmp/portage/sys-devel/gettext-0.23/work/gettext-0.23/gettext-tools -I../libgrep -I/tmp/portage/sys-devel/gettext-0.23/work/gettext-0.23/gettext-tools/libgrep -I../gnulib-lib -I/tmp/portage/sys-devel/gettext-0.23/work/gettext-0.23/gettext-tools/gnulib-lib -I../../gettext-runtime/intl -I/tmp/portage/sys-devel/gettext-0.23/work/gettext-0.23/gettext-tools/../gettext-runtime/intl -DINSTALLDIR=\"/usr/bin\"   -pipe -march=znver2 -O2 -c -o msgcmp-msgcmp.o `test -f 'msgcmp.c' || echo '/tmp/portage/sys-devel/gettext-0.23/work/gettext-0.23/gettext-tools/src/'`msgcmp.c
In file included from /tmp/portage/sys-devel/gettext-0.23/work/gettext-0.23/gettext-tools/src/msgcmp.c:52:
/tmp/portage/sys-devel/gettext-0.23/work/gettext-0.23/gettext-tools/src/msgcmp.c: In function 'main':
/tmp/portage/sys-devel/gettext-0.23/work/gettext-0.23/gettext-tools/gnulib-lib/relocatable.h:114:37: error: expected expression before ')' token
  114 | #define relocate(pathname) (pathname)
      |                                     ^
/tmp/portage/sys-devel/gettext-0.23/work/gettext-0.23/gettext-tools/gnulib-lib/gettext.h:89:43: note: in definition of macro 'bindtextdomain'
   89 |     ((void) (Domainname), (const char *) (Dirname))
      |                                           ^~~~~~~
/tmp/portage/sys-devel/gettext-0.23/work/gettext-0.23/gettext-tools/src/msgcmp.c:109:36: note: in expansion of macro 'relocate'
  109 |   bindtextdomain ("bison-runtime", relocate (BISON_LOCALEDIR));
      |                                    ^~~~~~~~



Reproducible: Always

Steps to Reproduce:
1. try to emerge gettext-0.23
2. build failure
Comment 1 Holger Hoffstätte 2024-12-03 13:20:55 UTC
Created attachment 913231 [details]
gettext-0.23 build log
Comment 2 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2024-12-03 13:26:31 UTC
Please include emerge -info. I also can't reproduce it yet.
Comment 3 Holger Hoffstätte 2024-12-03 13:31:58 UTC
Created attachment 913241 [details]
emerge --info
Comment 4 Holger Hoffstätte 2024-12-03 14:41:03 UTC
The problem is that BISON_LOCALEDIR is undefined and so the macro expansion gets confused. Jamming a random #define BISON_LOCALEDIR "foo" in there makes it compile.
Comment 5 Holger Hoffstätte 2024-12-03 14:59:11 UTC
Adding some macro stringification and the difference between 0.22-r1 and 0.23 is:

/tmp/portage/sys-devel/gettext-0.22.5-r1/work/gettext-0.22.5/gettext-tools/src/msgcmp.c: In function 'main':
/tmp/portage/sys-devel/gettext-0.22.5-r1/work/gettext-0.22.5/gettext-tools/src/msgcmp.c:108:9: note: '#pragma message: BISON_LOCALEDIR=`""`'
  108 | #pragma message PRINT_MACRO_AT_COMPILE_TIME(BISON_LOCALEDIR)
      |         ^~~~~~~


vs.

/tmp/portage/sys-devel/gettext-0.23/work/gettext-0.23/gettext-tools/src/msgcmp.c: In function 'main':
/tmp/portage/sys-devel/gettext-0.23/work/gettext-0.23/gettext-tools/src/msgcmp.c:111:9: note: '#pragma message: BISON_LOCALEDIR=``'
  111 | #pragma message PRINT_MACRO_AT_COMPILE_TIME(BISON_LOCALEDIR)
      |         ^~~~~~~

i.e. "" vs. nothing.
Comment 7 Holger Hoffstätte 2024-12-03 16:28:25 UTC
\o/

--snip--
diff --git a/var/db/repos/gentoo/sys-devel/gettext/gettext-0.23.ebuild b/gettext-0.23.ebuild
index 377edcb7..5c51a338 100644
--- a/var/db/repos/gentoo/sys-devel/gettext/gettext-0.23.ebuild
+++ b/gettext-0.23.ebuild
@@ -114,6 +114,9 @@ src_prepare() {
    if use elibc_musl || use elibc_Darwin; then
        eapply "${FILESDIR}"/${PN}-0.21-musl-omit_setlocale_lock.patch
    fi
+
+   # BISON_LOCALEDIR lost its quoting, breaking macro expansion
+   sed -i 's/$(BISON_LOCALEDIR_c_make)/\\"$(BISON_LOCALEDIR_c_make)\\"/g' gettext-tools/src/Makefile.am || die
 }
 
 multilib_src_configure() {
--snip--

This restores the quoting, and the resulting BISON_LOCALEDIR passed to gcc now looks like in 0.22-r1.
Could also make this a patch, I just used sed to get somewhere.
Comment 8 Holger Hoffstätte 2024-12-03 17:03:41 UTC
Created attachment 913251 [details, diff]
Patch to restore quoting for BISON_LOCALEDIR

Here is the fix in patch form, drop it into /etc/portage/patches/sys-devel/gettext and 0.23 should build again.
Comment 9 Holger Hoffstätte 2024-12-03 17:22:08 UTC
Thinking about this some more, maybe the real fix is to make BISON_LOCALEDIR_c_make always contain the quotes (like LOCALEDIR apparently?) but I don't know where in this twisted maze of macro salad. Maybe gnulib-m4/bison-i18n.m4?
Comment 10 Holger Hoffstätte 2024-12-03 17:45:15 UTC
hmm..

--snip--
diff -up ./gettext-0.22.5-r1/work/gettext-0.22.5/gettext-tools/gnulib-m4/bison-i18n.m4 ./gettext-0.23/work/gettext-0.23/gettext-tools/gnulib-m4/bison-i18n.m4
--- ./gettext-0.22.5-r1/work/gettext-0.22.5/gettext-tools/gnulib-m4/bison-i18n.m4	2024-02-21 11:44:26.000000000 +0100
+++ ./gettext-0.23/work/gettext-0.23/gettext-tools/gnulib-m4/bison-i18n.m4	2024-10-21 15:50:22.000000000 +0200
@@ -1,8 +1,10 @@
-# bison-i18n.m4 serial 4
+# bison-i18n.m4
+# serial 5
 dnl Copyright (C) 2005-2006, 2009-2024 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
+dnl This file is offered as-is, without any warranty.
 
 dnl From Bruno Haible.
 
@@ -55,6 +57,26 @@ AC_DEFUN([BISON_I18N],
       fi
     fi
     AC_SUBST([BISON_LOCALEDIR])
+
+    dnl Define BISON_LOCALEDIR_c and BISON_LOCALEDIR_c_make.
+    dnl Find the final value of BISON_LOCALEDIR.
+    gl_saved_prefix="${prefix}"
+    gl_saved_datarootdir="${datarootdir}"
+    gl_saved_localedir="${localedir}"
+    gl_saved_bisonlocaledir="${BISON_LOCALEDIR}"
+    dnl Unfortunately, prefix gets only finally determined at the end of
+    dnl configure.
+    if test "X$prefix" = "XNONE"; then
+      prefix="$ac_default_prefix"
+    fi
+    eval datarootdir="$datarootdir"
+    eval localedir="$localedir"
+    eval BISON_LOCALEDIR="$BISON_LOCALEDIR"
+    gl_BUILD_TO_HOST([BISON_LOCALEDIR])
+    BISON_LOCALEDIR="${gl_saved_bisonlocaledir}"
+    localedir="${gl_saved_localedir}"
+    datarootdir="${gl_saved_datarootdir}"
+    prefix="${gl_saved_prefix}"
   fi
   if test $BISON_USE_NLS = yes; then
     AC_DEFINE([YYENABLE_NLS], [1],
--snip--

It claims to define BISON_LOCALEDIR_c_make but that's just .. nowhere?
Which would explain why the expansion in Makefile.am is completely empty.
Comment 11 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2024-12-04 11:37:00 UTC
I've asked upstream for advice.
Comment 12 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2024-12-04 20:19:44 UTC
I can reproduce using a vanilla upstream 0.230. tarball plus the upstream libxml2 patch applied with:
```
$ ./configure --disable-nls && make -j32 -l32
[...]
gcc -DLOCALEDIR=\"/usr/local/share/locale\" -DBISON_LOCALEDIR= -DUSEJAVA=0 -DGETTEXTJAR=\"/usr/local/share/gettext\"\"/gettext.jar\" -DBINDIR=\"/usr/local/bin\" -DLIBDIR=\"/usr/local/lib\" -DLIBEXECDIR=\"/usr/local/libexec\" -DGETTEXTDATADIR=\"/usr/local/share/gettext\" -DPROJECTSDIR=\"/usr/local/share/gettext\"\"/projects\" -DEXEEXT=\"\" -DHAVE_CONFIG_H -I. -I..  -I.. -I../libgrep -I../libgrep -I../gnulib-lib -I../gnulib-lib -I../../gettext-runtime/intl -I../../gettext-runtime/intl -DINSTALLDIR=\"/usr/local/bin\"   -g -O2 -MT msgcmp-msgcmp.o -MD -MP -MF .deps/msgcmp-msgcmp.Tpo -c -o msgcmp-msgcmp.o `test -f 'msgcmp.c' || echo './'`msgcmp.c
In file included from msgcmp.c:52:
msgcmp.c: In function ‘main’:
../gnulib-lib/relocatable.h:114:37: error: expected expression before ‘)’ token
  114 | #define relocate(pathname) (pathname)
      |                                     ^
../gnulib-lib/gettext.h:89:43: note: in definition of macro ‘bindtextdomain’
   89 |     ((void) (Domainname), (const char *) (Dirname))
      |                                           ^~~~~~~
msgcmp.c:109:36: note: in expansion of macro ‘relocate’
  109 |   bindtextdomain ("bison-runtime", relocate (BISON_LOCALEDIR));
      |                                    ^~~~~~~~
make[5]: *** [Makefile:5693: msgcmp-msgcmp.o] Error 1
```
Comment 13 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2024-12-04 20:20:25 UTC
(In reply to Sam James from comment #12)
> I can reproduce using a vanilla upstream 0.23.0. tarball plus the upstream
> libxml2 patch applied with:

Uh, 0.23.0, that is. Also, this only affects USE=-nls (non-default), obviously.
Comment 14 Holger Hoffstätte 2024-12-05 09:47:58 UTC
Thanks for reporting upstream, Sam.

There is already a fix at:
https://git.savannah.gnu.org/gitweb/?p=gnulib.git;a=commitdiff;h=4a2fe717080b34a2770a674235bb2b6e3e3dd86f

The Changelog hunk does not apply (as usual) but it's not needed for an interim fix. After disabling my patch and fixing the hunk path from
/m4/ to /gettext-tools/gnulib-m4/ fixes the problem correctly: BISON_LOCALEDIR is properly quoted now.
Comment 15 Holger Hoffstätte 2024-12-05 10:32:07 UTC
Created attachment 913373 [details, diff]
Upstream patch for 0.23.0

Here is the upstream patch in fixed format.
Comment 16 Larry the Git Cow gentoo-dev 2024-12-06 11:33:39 UTC
The bug has been closed via the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=b98e752aa895627618844487b0223186e4d85347

commit b98e752aa895627618844487b0223186e4d85347
Author:     Sam James <sam@gentoo.org>
AuthorDate: 2024-12-06 11:32:53 +0000
Commit:     Sam James <sam@gentoo.org>
CommitDate: 2024-12-06 11:33:16 +0000

    sys-devel/gettext: fix build w/ USE=-nls
    
    Closes: https://bugs.gentoo.org/945817
    Signed-off-by: Sam James <sam@gentoo.org>

 sys-devel/gettext/files/gettext-0.23-no-nls.patch | 163 ++++++++++++++++++++++
 sys-devel/gettext/gettext-0.23.ebuild             |   1 +
 2 files changed, 164 insertions(+)