PMFJI, but I may have something to add here instead of spending my time lurking.
I've seen cases where the recipe happens to be a shell script that includes a loop. If the loop doesn't check the return code of the steps, the build script will "successfully" complete when one of the compiles didn't. Technically, this is something we found in ClearCase's clearmake. At one point, we directly executed some loop constructs in build scripts, so we would catch these middle-of-the-loop errors. When we simplified our make to act more like normal make, we had customers who would complain that builds that shouldn't be working were failing further on because the make didn't catch the failure in the middle of the compile loop. ================================================================= Brian Cowan Advisory Software Engineer ClearCase Software Advisory Team (SWAT) Rational Software IBM Software Group 550 King St Littleton, MA 01460 Phone: 1.978.899.5436 Web: http://www.ibm.com/software/rational/support/ From: Paul Smith <psm...@gnu.org> To: David Aldrich <david.aldr...@emea.nec.com> Cc: "help-make@gnu.org" <help-make@gnu.org> Date: 02/09/2015 12:35 PM Subject: Re: make is setting exit code to 0 when gcc command fails Sent by: help-make-bounces+brcowan=us.ibm....@gnu.org On Mon, 2015-02-09 at 16:19 +0000, David Aldrich wrote: > If I deliberately introduce a syntax error into one of my C files, > make calls gcc to build the file, as expected, and an error is > reported as text in bash. However, the exit code (checked using echo > $?) returns 0. If I run the gcc command from the bash command line, > the exit code is 1. > > Why might make return 0 instead of 1 in the case of this compiler > error? Why don't you provide a sample of the makefile that doesn't work? That would be much simpler than us guessing at all the reasons it could be wrong with no other information. Typically this happens because your recipe does something AFTER the compile command, and you aren't preserving the exit code and using it when you exit from the recipe. > I am running gnu make 3.81 on Centos 5, with a bash shell. Note that make ALWAYS uses "/bin/sh", regardless of the user's shell, unless you set the make SHELL variable in your makefile. Of course, on Red Hat-based systems, /bin/sh is bash (although running in a slightly more standard mode). _______________________________________________ Help-make mailing list Help-make@gnu.org https://lists.gnu.org/mailman/listinfo/help-make _______________________________________________ Help-make mailing list Help-make@gnu.org https://lists.gnu.org/mailman/listinfo/help-make