help-make
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: make is setting exit code to 0 when gcc command fails


From: Brian R Cowan
Subject: Re: make is setting exit code to 0 when gcc command fails
Date: Mon, 9 Feb 2015 20:11:43 -0500

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 <address@hidden>
To:     David Aldrich <address@hidden>
Cc:     "address@hidden" <address@hidden>
Date:   02/09/2015 12:35 PM
Subject:        Re: make is setting exit code to 0 when gcc command fails
Sent by:        address@hidden



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
address@hidden
https://lists.gnu.org/mailman/listinfo/help-make




reply via email to

[Prev in Thread] Current Thread [Next in Thread]