[tlbuild] test build for system extensions

Karl Berry karl at freefriends.org
Mon Apr 29 00:34:26 CEST 2024


Luigi and I have globally enabled "system extensions" for compilation,
like _GNU_SOURCE, via Autoconf's AC_USE_SYSTEM_EXTENSIONS. There is
plenty of opportunity for things to go awry as a result, so if you feel
like firing up a test build on the current sources, that would be all to
the good.

We made the change because 1) in general, the system extensions were
already being enabled by some libraries and programs, so it seemed more
consistent to do it globally; and 2) in particular, evidently it's
needed for luasocket on some(?) systems. Luigi noticed this in the
"busytex" Makefile, which said the below (for the archives). He might
rework luasocket to be more portable, but that doesn't obviate the
seeming desirability of enabling the extensions throughout.

Thanks,
Karl

(from the busytex Makefile:)

# LuaTeX unconditionally builds the `luasocket` module:
https://github.com/TeX-Live/texlive-source/blob/tags/texlive-2023.0/texk/web2c/Makefile.am#L292
# `luasocket` depends on various macros that require additional feature
test macros. For example `gethostbyaddr()` requires `_GNU_SOURCE` or
similar:
#
https://github.com/TeX-Live/texlive-source/blob/tags/texlive-2023.0/texk/web2c/luatexdir/luasocket/src/usocket.c#L381
# The `configure.ac` for `web2c` (which also configures LuaTeX) should
therefore contain something like `AC_USE_SYSTEM_EXTENSIONS`:
#
https://www.gnu.org/software/autoconf/manual/autoconf-2.67/html_node/Posix-Variants.html
# However, it doesn't. The build still works with musl because some of its
headers indirectly include `features.h` that defaults to `_BSD_SOURCE`,
which is enough:
# https://git.musl-libc.org/cgit/musl/tree/include/features.h?h=v1.2.4#n15
# Cosmopolitan doesn't include `features.h` indirectly, so we have to
define a sufficiently powerful macro (`_GNU_SOURCE`) right here.
# Also, the default `socket_waitfd()` implementation in `luasocket`
includes a non-standard `sys/poll.h` header, which doesn't contain `struct
pollfd` in Cosmopolitan:
#
https://github.com/TeX-Live/texlive-source/blob/tags/texlive-2023.0/texk/web2c/luatexdir/luasocket/src/usocket.c#L19
# By defining `SOCKET_SELECT`, we fall back to a simple `socket_waitfd()`
implementation that uses `select()` instead, which is perfectly fine for
LuaTeX.


More information about the tlbuild mailing list.