Skip to content

Fix Linux build (C23 bool, strlcpy, parallel yacc header, gettext/msgfmt, byacc) - #116

Open
chenrui333 wants to merge 5 commits into
Juniper:mainfrom
chenrui333:linux-build-fixes
Open

Fix Linux build (C23 bool, strlcpy, parallel yacc header, gettext/msgfmt, byacc)#116
chenrui333 wants to merge 5 commits into
Juniper:mainfrom
chenrui333:linux-build-fixes

Conversation

@chenrui333

Copy link
Copy Markdown

Fix building libxo on Linux with a modern toolchain (GCC 16 / C23, parallel make, glibc).

Linux build failures & root causes

  • C23: bool is used as an identifier in the XPath filter, which C23 makes a keyword. Renamed the locals (filter/xo_filter.c).
  • strlcpy/strlcat: not portably declared (glibc does not expose them without _DEFAULT_SOURCE), so they were left undefined at link. Replaced with standard snprintf/strncat (libxo/xo_syslog.c, tests/gettext/gt_01.c).
  • Parallel build race: xo_xpath.{o,lo} include the generated xo_xpath.tab.h but had no prerequisite on it, racing under make -j. Added the dependency (filter/Makefile.am).
  • gettext/msgfmt: detection assumed a separate libintl; on glibc gettext lives in libc, so the -lintl probes failed and the msgfmt check aborted even when gettext is usable. Detect whether -lintl is needed, add <stddef.h> so NULL is defined, gate the msgfmt lookup on gettext being present, and also search PATH. Overlaps Fix undefined NULL in gettext() configure snippets #114 and configure.ac: don't require msgfmt when --disable-gettext is passed #115 — their fixes are incorporated/credited here.
  • YACC: the grammar relies on byacc extensions (reentrant parser exposing yystate + byacc-generated tables) that GNU bison does not provide. Removed the misleading bison -y fallback and made configure fail clearly when byacc is unavailable.

Validation

Linux, GCC 16, byacc: bootstrap + configure (gettext enabled on glibc) + parallel make -j4 + make test all pass. configure YACC=bison now fails with a clear "byacc is required" error. macOS/FreeBSD are unaffected (their yacc is byacc).

References

C23 makes bool a keyword; rename the local variables in xo_filter.c so the XPath filter builds with C23 compilers (e.g. GCC 15+).

Signed-off-by: Rui Chen <rui@chenrui.dev>
strlcpy/strlcat are not universally declared (e.g. glibc does not expose them without _DEFAULT_SOURCE), leaving them undefined at link time. Use snprintf/strncat, which are standard C.

Signed-off-by: Rui Chen <rui@chenrui.dev>
xo_xpath.{o,lo} include xo_xpath.tab.h but lacked a prerequisite on it, racing under parallel make. Add the missing dependency.

Signed-off-by: Rui Chen <rui@chenrui.dev>
On glibc, gettext lives in libc with no separate libintl, so the -lintl link probes failed and the msgfmt check aborted even when gettext is usable. Detect whether -lintl is needed, add <stddef.h> so NULL is defined, gate the msgfmt lookup on gettext being present, and also search PATH for msgfmt. Overlaps Juniper#114 and Juniper#115.

Signed-off-by: Rui Chen <rui@chenrui.dev>
The XPath grammar uses byacc extensions (reentrant parser exposing yystate and byacc-generated tables) that GNU bison does not provide. Drop the misleading 'bison -y' fallback and fail configure clearly when byacc is unavailable or the detected yacc is bison.

Signed-off-by: Rui Chen <rui@chenrui.dev>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant