incubator-stdcxx-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Martin Sebor <se...@roguewave.com>
Subject Re: svn commit: r463535 - in /incubator/stdcxx/trunk: etc/config/makefile.common etc/config/makefile.rules util/cmdopt.cpp util/display.cpp util/output.cpp util/runall.cpp util/target.h
Date Thu, 19 Oct 2006 21:36:32 GMT
Andrew Black wrote:

> Martin Sebor wrote:
> [...]
> 
>>
>>
>> $ echo foo; echo bar | wc -l
>> foo
>> 1
>>
>> Here's a simple experiment that tries to duplicate what you're
>> doing in the patch. AFAICT, it doesn't behave the way we want.
>> What am I missing?
>>
>> Martin
> 
> 
> Ok...
> 
> What happened was I was focusing on the return code propagation, and 
> overlooked the output.  I had assumed that the output was being 
> correctly propagated, as it was being displayed on the console, but this 
> assumption was incorrect.  Attached is a different approach to the 
> solution, where the output is redirected to the target log file, then 
> echoed back to the console (and teed to LOGFILE) after the 
> compile/linking completes.

I'm not completely comfortable with this approach. Often it takes
a while for the compilation of a file to finish, even when there
are errors or other diagnostics. Redirecting the output to a file
and displaying the contents of the file only after translation has
completed would change the perceived behavior of the compiler (or
linker) in these cases. I would have no problem with this in batch
mode but I wouldn't like it in interactive mode.

> 
> A disadvantage of this method is that the output may live in the disk 
> buffer for a time before being flushed.  If the system happens to crash 
> during this time, the log will be lost.

That can happen in any case if the OS goes down.

> If the crash was caused by the 
> compiler or linker, this would lead to a loss of potentially useful 
> information.
> 
> I tried altering things to use a command similar to the following, but 
> the result propagation failed (It seemed to work in bash, but the 
> behavior wasn't quite the same in gmake).
> { $(COMMAND) 2>&1 ; cache=$$?; } | tee $@.log; (exit $$cache)

If it works in the shell it should work in make. If it's not
portable, though (e.g., because it's a Bash extension), it
might be better to avoid it and use the same portable
solution everywhere (e.g., our own implementation of the
pipe under our own command).

Martin

> 
> --Andrew Black
> 
> 
> ------------------------------------------------------------------------
> 
> Index: etc/config/makefile.common
> ===================================================================
> --- etc/config/makefile.common	(revision 465655)
> +++ etc/config/makefile.common	(working copy)
> @@ -141,10 +141,16 @@
>  # file to write log of the build to
>  LOGFILE = /dev/null
>  
> -# if LOGFILE is being created, tee command output into it
> +# file target output is logged to (file used in exec utility)
> +TARGETLOGFILE = $@.log
> +
> +# if LOGFILE is not being created, tee command output into TARGETLOGFILE
> +# otherwise, tee command output into both TARGETLOGFILE and LOGFILE.
>  # IMPORTANT: $(TEEOPTS) must be last on the command line
> -ifneq ($(LOGFILE),/dev/null)
> -  TEEOPTS = 2>&1 | tee -a $(LOGFILE)
> +ifeq ($(LOGFILE),/dev/null)
> +  TEEOPTS = >$(TARGETLOGFILE) 2>&1 ; cache=$$?; cat $(TARGETLOGFILE); (exit
$$cache)
> +else
> +  TEEOPTS = >$(TARGETLOGFILE) 2>&1 ; cache=$$?; cat $(TARGETLOGFILE) | tee
-a $(LOGFILE); (exit $$cache)
>  endif
>  
>  # determine the name of the results file against which to compute regressions
> Index: etc/config/makefile.rules
> ===================================================================
> --- etc/config/makefile.rules	(revision 465655)
> +++ etc/config/makefile.rules	(working copy)
> @@ -60,16 +60,16 @@
>      ifneq ($(AS_EXT),".")
>  
>  %.o: %$(AS_EXT)
> -	$(CXX) -c $(CPPFLAGS) $(CXXFLAGS) $<
> +	$(CXX) -c $(CPPFLAGS) $(CXXFLAGS) $< $(TEEOPTS)
>  
>      endif   # ifneq ($(AS_EXT),".")
>    endif   # ifneq ($(AS_EXT),)
>  
>  %.o: %.cpp
> -	$(CXX) -c $(CPPFLAGS) $(CXXFLAGS) $<
> +	$(CXX) -c $(CPPFLAGS) $(CXXFLAGS) $< $(TEEOPTS)
>  
>  %: %.o
> -	$(LD) $< -o $@ $(LDFLAGS) $(LDLIBS)
> +	$(LD) $< -o $@ $(LDFLAGS) $(LDLIBS) $(TEEOPTS)
>  
>  # disable compilation and linking in the same step
>  # %: %.cpp
> @@ -78,7 +78,7 @@
>  
>  # compile and link in one step to eliminate the space overhead of .o files
>  %: %.cpp
> -	$(CXX) $< -o $@ $(CPPFLAGS) $(CXXFLAGS) $(LDFLAGS) $(LDLIBS)
> +	$(CXX) $< -o $@ $(CPPFLAGS) $(CXXFLAGS) $(LDFLAGS) $(LDLIBS) $(TEEOPTS)
>  
>  endif   # eq ($(NO_DOT_O),)
>  


Mime
View raw message