You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Ninja hides the exit status of failing subprocesses #1507
In build.cc, Ninja checks if the subprocess succeeded or failed
// Print the command that is spewing before printing its output.
if (!success) {
string outputs;
for (vector<Node*>::const_iterator o = edge->outputs_.begin();
o != edge->outputs_.end(); ++o)
outputs += (*o)->path() + " ";
printer_.PrintOnNewLine("FAILED: " + outputs + "\n");
printer_.PrintOnNewLine(edge->EvaluateCommand() + "\n");
}
But by this point in the build, Ninja has already discarded the actual exit value from the subprocess.
There are a variety of tools that don't print anything to the console when they fail to run, relying on the user to instead check the exit status to see what the reason for failure was.
This is especially problematic for third party tools where the source code is not available.
It's, of course, possible to get the exit status printed to the console using a wrapper script, but as discussed at extreme length, wrapper scripts are desired by basically no one.
Ninja should print the exit status of failing subprocesses.
Reacted by Bobby Reynolds, Jonathan, Fastering, Oren Ben-Kiki, Arsen Arsenović, kuchara and Tristan Labelle
@jimis if you are not seeing any "FAILED:" message this seems like a different issue. #1805 only adds to the "FAILED:" string. #1805 has no changes that would cause that "FAILED:" string to appear when it currently does not.
@jimis thats obvious. The problem is that github CI does not fail because that exit code is hidden because its a ninja subproces... which is exactly what this issue is reporting.
@jonatino ninja exits with its own error code in case of failure. It is your bash script that hides that. Try adding set -e at the beginning of your script and it will exit on the first error. It has nothing to do with this ticket or in general with ninja.
I've been hit hard with this when ccache started SIGBUS-ing on me and I had no way of figuring out why all the compilation jobs are suddenly failing with no output.
@jonatino ninja exits with its own error code in case of failure. It is your bash script that hides that. Try adding set -e at the beginning of your script and it will exit on the first error. It has nothing to do with this ticket or in general with ninja.
I have set -e set, check for the exit status of ninja and return it, and yet my script continues on as if ninja's exit code were zero. I'm pretty sure this ticket is valid.
Activity
jimis commentedon Sep 30, 2020
I don't see any "FAILED:" message, but instead
ninja: build stopped: subcommand failedIs it the same issue?
@schultetwin1 Would #1805 address this situation too, and reveal the exit code of the failed subcommand?
schultetwin1 commentedon Sep 30, 2020
@jimis if you are not seeing any "FAILED:" message this seems like a different issue. #1805 only adds to the "FAILED:" string. #1805 has no changes that would cause that "FAILED:" string to appear when it currently does not.
jimis commentedon Sep 30, 2020
Thanks @schultetwin1. Indeed it seems the "subcommand failed" message is coming from
ninja/src/build.cc
Line 883 in 54959b0
The effect is the same however: an exit code that is lost, while it could have been printed.
jonatino commentedon Dec 28, 2020
@jonesmz @jimis @schultetwin1 have you guys figured this out?
My make file:
Error in github actions (it still thinks the build is successful):
jimis commentedon Jan 9, 2021
@jonatino you have a clear indication of what's wrong in your case:
clang: error: no such file or directory: '/SUBSYSTEM:CONSOLE'Please file separate issues for irrelevant problems.
jonatino commentedon Jan 9, 2021
@jimis thats obvious. The problem is that github CI does not fail because that exit code is hidden because its a ninja subproces... which is exactly what this issue is reporting.
jimis commentedon Jan 10, 2021
@jonatino ninja exits with its own error code in case of failure. It is your bash script that hides that. Try adding
set -eat the beginning of your script and it will exit on the first error. It has nothing to do with this ticket or in general with ninja.mgorny commentedon Jan 2, 2023
I've been hit hard with this when ccache started
SIGBUS-ing on me and I had no way of figuring out why all the compilation jobs are suddenly failing with no output.cassandracomar commentedon Apr 6, 2023
I have set -e set, check for the exit status of ninja and return it, and yet my script continues on as if ninja's exit code were zero. I'm pretty sure this ticket is valid.
Felixoid commentedon Dec 3, 2024
I am trying to address it in #2540
jonatino commentedon Jan 15, 2025
@Felixoid you sir, are simply the best! Thank you for fixing this!!!!!!