This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: PATCH: PR binutils/12280: Makefiles don't support LTO
- From: Ralf Wildenhues <Ralf dot Wildenhues at gmx dot de>
- To: "H.J. Lu" <hongjiu dot lu at intel dot com>
- Cc: binutils at sourceware dot org
- Date: Thu, 2 Dec 2010 08:15:41 +0100
- Subject: Re: PATCH: PR binutils/12280: Makefiles don't support LTO
- References: <20101202053456.GA10376@intel.com>
Hello H.J.,
* H.J. Lu wrote on Thu, Dec 02, 2010 at 06:34:56AM CET:
> This patch adds + to LINK in Makefile for GNU make. OK for trunk?
> diff --git a/config/gnumake.m4 b/config/gnumake.m4
> new file mode 100644
> index 0000000..2d21e12
> --- /dev/null
> +++ b/config/gnumake.m4
> @@ -0,0 +1,22 @@
> +dnl Placed after AC_OUTPUT to add `+' to LINK for GNU make.
That is not reliable: a config.status run updating Makefile may be
triggered from make rules, by-passing configure completely.
Also, $(LINK) is not the only link-related variable, there can be
prog_LINK for programs and libraries.
The common way to do this is to have a new config.status action (which
however is also not recheck-safe) or to tack it onto the existing
Makefile action; e.g.:
AC_CONFIG_FILES([Makefile], [sed ... Makefile ...])
But why not go a different (and IMVHO simpler) route completely: have a
variable $(LTO) or so that expands to empty, or to '+' if LTO is used,
and then prepending that to *LINK values unconditionally.
That has the advantage that you can still get 'make -n' right if using
GNU make but not LTO.
Thanks,
Ralf
> +AC_DEFUN([GCC_CHECK_GNU_MAKE], [
> + AC_CACHE_CHECK([whether make is GNU make],
> + gcc_cv_gnu_make, [
> + GNU_MAKE=${MAKE-make}
> + case `$GNU_MAKE -v 2>&1` in
> + *GNU*Make*)
> + gcc_cv_gnu_make=yes
> + ;;
> + *)
> + gcc_cv_gnu_make=no
> + ;;
> + esac])
> + if test "$gcc_cv_gnu_make" = "yes" ; then
> + if test -f Makefile; then
> + tmpmakefile=Makefile.$$
> + sed -e "s/^LINK = \\$/LINK = +$/" Makefile > $tmpmakefile
> + mv $tmpmakefile Makefile
> + else
> + AC_MSG_ERROR([Makefile doesn't exist])
> + fi
> + fi])