This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [lto] Add timevars and propagate -v and -save-temps
- From: Ollie Wild <aaw at google dot com>
- To: Diego Novillo <dnovillo at google dot com>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Sun, 30 Nov 2008 15:50:06 -0800
- Subject: Re: [lto] Add timevars and propagate -v and -save-temps
- References: <20081129172822.GA18090@google.com>
On Sat, Nov 29, 2008 at 9:28 AM, Diego Novillo <dnovillo@google.com> wrote:
>
> -# We have to clear these to avoid problems with this make invocations getting
> +# We have to clear these to avoid problems with this make invocation getting
> # confused with variables set by (for example) "make -j 2 check".
> unset MAKEFLAGS
> unset MAKEINFO
. . . and. . .
> +# Use some simple heuristics to determine how much parallelism to use
> +# when invoking make. Note that this probably only works reliably on
> +# Linux. Also, the load may spike right after the calculation, so
> +# it's not foolproof.
> +awk=/usr/bin/awk
> +uptime=/usr/bin/uptime
> +getconf=/usr/bin/getconf
> +par=1
> +if [ -x $awk -a -x $uptime -a -x $getconf ] ; then
> + loadavg=$($uptime | $awk '{ l = $(NF - 2); print int (strtonum (l)); }')
> + nprocs=$($getconf _NPROCESSORS_ONLN)
> + if [ $loadavg -lt $nprocs ] ; then
> + par=$[($nprocs - $loadavg) * 2]
> + fi
> fi
> +${MAKE-make} $quiet -f $makefile -j $par all
> +exit $?
When I wrote the ltrans-driver script, it was my explicit intention to
honor the MAKEFLAGS environment variable in order to manage
parallelism with the parent process. From the make documentation:
The `-j' option is a special case (*note Parallel Execution:
Parallel.). If you set it to some numeric value `N' and your operating
system supports it (most any UNIX system will; others typically won't),
the parent `make' and all the sub-`make's will communicate to ensure
that there are only `N' jobs running at the same time between them all.
Note that any job that is marked recursive (*note Instead of Executing
the Commands: Instead of Execution.) doesn't count against the total
jobs (otherwise we could get `N' sub-`make's running and have no slots
left over for any real work!)
This only works if MAKEFLAGS is inherited from the parent make. It
looks like you broke this mechanism in a previous change and are now
hacking around that fact. I'm not quite sure what the issue was that
prompted unsetting MAKEFLAGS, but maybe a better solution is to unset
MAKEFLAGS in the test harness.
Ollie