https://gcc.gnu.org/bugzilla/show_bug.cgi?id=126875

--- Comment #5 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Kyrylo Tkachov <[email protected]>:

https://gcc.gnu.org/g:7130a3856cbb9d36293ee2a285917ac049966bb0

commit r17-3923-g7130a3856cbb9d36293ee2a285917ac049966bb0
Author: Kyrylo Tkachov <[email protected]>
Date:   Fri Aug 14 22:05:20 2026 +0200

    Makefile.tpl: make the parallel bootstrap comparison portable [PR126875]

    The comparison writes a makefile and runs it under $(MAKE).  Building and
    running that makefile assumed GNU sed, and assumed more of the shell than
    several hosts provide.  Four defects, all from 54c3bdc8ad6.

    The comparison command was escaped for the generated makefile with

      printf '%s' "$cmp_raw" | sed 's,\$,$$,g'

    whose input carries no trailing newline.  GNU sed passes that through
    unchanged, a POSIX sed terminates the last line, and Solaris /usr/bin/sed
    drops it.  The first splits the recipe in two, and the sub-make stops with

      compare.42895.mk:5: *** missing separator.  Stop.

    The second leaves a bare redirection where the comparison should be, so
every
    object is judged equal and the bootstrap reports "Comparison successful"
    having compared nothing.  Double the '$' characters with $(subst), which
make
    can do on its own.

    The exit traps use "trap - 0", which Solaris 10 /bin/sh takes for a command
    named '-', and recover the status with "$?", which Solaris 10 /bin/sh
answers
    with the status of the command before the "exit" rather than its argument.
    The recipe reports a comparison failure with "exit 1" right after a
successful
    "mv", so on that shell the trap recovers zero and lets the failure through
as
    success.  A trap that only removes files needs neither.  Let the shell exit
    with the status it already has, and start the trap body with ':' so that it
is
    not the single cleanup command whose exit status bash before 3.1 fails to
    preserve.  make runs a recipe as "$(SHELL) -c", which is the affected case:
    with bash 2.05b as $(SHELL) and one object differing, "make compare"
without
    that ':' prints the difference and exits zero.  On mksh the "exit" in the
    signal trap now returns the cleanup command's status rather than 1, which
    leaves an interrupted comparison unstamped either way.

    The comparator fallback installs its trap in a subshell that ends in "cmp",
    and several shells do not run an exit trap from a subshell whose last
command
    is not a builtin.  Now that the temporaries are process specific, a trap
that
    does not run leaks a pair of files per object.  End the subshell with a
    builtin.

    The generated makefile did not name the shell.  make neither exports SHELL
    nor lets a sub-make inherit it, so the comparisons ran under /bin/sh rather
    than the shell configure chose.

    The serial comparison removed .bad_compare before starting.  That file is
now
    written only by a comparison that completes and finds a difference, so a
    sub-make that fails first leaves the previous run's result in place, still
    named in the failure message.  Shards from a run killed with SIGKILL
survive
    too, keyed on a pid a later comparison can draw.  Remove both up front.

    ChangeLog:

            PR bootstrap/126875
            * Makefile.tpl ([+compare-target+]): Escape the comparison command
            with $(subst) rather than a sed pipe.  Clean up from the exit trap
            without resetting it or re-deriving the exit status.  Name the
shell
            in the generated makefile.  Remove any previous result file and
            result shards before comparing.
            * Makefile.in: Regenerate.
            * configure: Regenerate.

    config/ChangeLog:

            PR bootstrap/126875
            * acx.m4 (ACX_PROG_CMP_IGNORE_INITIAL): Clean up from the exit trap
            without resetting it or re-deriving the exit status, and end the
            fallback subshell with a builtin so that the trap runs.

    Signed-off-by: Kyrylo Tkachov <[email protected]>
  • [Bug bootstrap/126875] [17 regr... cvs-commit at gcc dot gnu.org via Gcc-bugs

Reply via email to