bartp5 / libtexprintf

Library providing printf-style formatted output routines with tex-like syntax support.
GNU General Public License v3.0
27 stars 2 forks source link

v1.18 build failure on Linux & macOS #14

Closed p-linnane closed 1 year ago

p-linnane commented 1 year ago

Hello 👋 . I'm a maintainer for the Homebrew project. While packaging v1.18 of utftex we are encountering a build failure:

  make[1]: Entering directory '/tmp/utftex-20230524-5877-efo77/libtexprintf-1.18/src'
  /bin/bash ./gen_errorflags.sh ./boxes.c ./drawbox.c ./lexer.c ./parser.c
  /bin/bash ./gen_errorflags.sh ./boxes.c ./drawbox.c ./lexer.c ./parser.c
  Collecting error flags from ./boxes.c
  Collecting error flags from ./boxes.c
  Collecting error flags from ./drawbox.c
  Collecting error flags from ./drawbox.c
  Collecting error flags from ./lexer.c
  Collecting error flags from ./lexer.c
  Collecting error flags from ./parser.c
  Collecting error flags from ./parser.c
  rm: cannot remove 'tmperrflags': No such file or directory
  make[1]: *** [Makefile:1079: errorflags.h] Error 1
  make[1]: Leaving directory '/tmp/utftex-20230524-5877-efo77/libtexprintf-1.18/src'
  make: *** [Makefile:674: install-recursive] Error 1

The relevant GitHub Actions run can be found here.

Relates to https://github.com/Homebrew/homebrew-core/pull/131899

stevengj commented 1 year ago

This is a race condition that can be generated repeatedly by running rm src/errorflags.h src/errormessages.h && make -j16

Making all in src
/bin/sh ./gen_errorflags.sh ./boxes.c ./drawbox.c ./lexer.c ./parser.c
/bin/sh ./gen_errorflags.sh ./boxes.c ./drawbox.c ./lexer.c ./parser.c
Collecting error flags from ./boxes.c
Collecting error flags from ./boxes.c
Collecting error flags from ./drawbox.c
Collecting error flags from ./drawbox.c
Collecting error flags from ./lexer.c
Collecting error flags from ./lexer.c
Collecting error flags from ./parser.c
Collecting error flags from ./parser.c
rm: tmperrflags: No such file or directory
make[1]: *** [errormessages.h] Error 1
make: *** [all-recursive] Error 1

The problem is that it's trying to build both src/errorflags.h and src/errormessages.h in parallel, but these are generated by the same script using the same temp file.

A workaround for now is to use a serial build.

stevengj commented 1 year ago

The solution to generating multiple source files with a single rule is described in the automake manual: https://www.gnu.org/software/automake/manual/html_node/Multiple-Outputs.html

I'll send a PR shortly.

(It would be good to set up github actions CI as well, to catch these bugs by doing parallel builds from scratch for all PRs.)

p-linnane commented 1 year ago

Thank you for the quick fix @stevengj!