This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [patch] Broken script in gcc/Makefile.in


On Wed, May 19, 2004 at 02:44:16PM -0400, Daniel Jacobowitz wrote:
> On Wed, May 19, 2004 at 01:52:13PM -0400, DJ Delorie wrote:
> > 
> > >  t='$(program_transform_name)'; echo nm | sed -e $$t ;
> > > 
> > > which expands to t='s,^,arm-none-elf-,;'; echo ar | sed -e  ;
> > 
> > It shouldn't :-P
> 
> Ian and I spent some time on IRC with Paul working this out.
> 
> The problem occurs in libgcc.mk.  AR_CREATE_FOR_TARGET is inherited
> from the environment, via an export statement in gcc/Makefile.in.  It
> starts out in gcc/Makefile as (simplified):
> 
> AR_FOR_TARGET = ` t=foo; foo | sed $$t `
> AR_CREATE_FOR_TARGET = $(AR_FOR_TARGET) flags
> 
> Variables are expanded, but backticks are not evaluated, before
> exporting.  So the environment contains:
> AR_CREATE_FOR_TARGET = ` t=foo; foo | sed $t ` flags
> 
> In libgcc.mk, $(AR_CREATE_FOR_TARGET) is used.  Now $t becomes the
> expansion of the Make variable 't'.
> 
> The simplest fix is to avoid the issue entirely.  I haven't fully
> tested this yet, but casual testing seemed OK: Change the backticks to
> $(shell ).  For extra bonus points change the = to :=, cutting down on
> piles of chatter in the Make logs and wasted forking.  I'll cut a patch
> when I'm done testing the other.

Now I've tested it, so I'll submit it.  This patch works fine on a
native build on i386-pc-linux-gnu, and the correct expanded version of
AR_FOR_TARGET is passed to libgcc.mk.  This is all the backtick-defined
variables except for EXPECT and RUNTEST; those can't be evaluated using
:= or $(shell) because they rely on shell variables set where they are
invoked.

OK?

-- 
Daniel Jacobowitz

2004-05-20  Daniel Jacobowitz  <dan@debian.org>

	* Makefile.in (AR_FOR_TARGET, RANLIB_FOR_TARGET)
	(NM_FOR_TARGET): Use := and $(shell).
	(mainversion): Remove unused variable.

Index: gcc/Makefile.in
===================================================================
RCS file: /big/fsf/rsync/gcc-cvs/gcc/gcc/Makefile.in,v
retrieving revision 1.1278
diff -u -p -r1.1278 Makefile.in
--- a/gcc/Makefile.in	18 May 2004 17:32:52 -0000	1.1278
+++ b/gcc/Makefile.in	20 May 2004 16:49:49 -0000
@@ -316,7 +316,7 @@ GCC_CFLAGS=$(INTERNAL_CFLAGS) $(X_CFLAGS
 # Programs which produce files for the target machine
 # ---------------------------------------------------
 
-AR_FOR_TARGET = ` \
+AR_FOR_TARGET := $(shell \
   if [ -f $(objdir)/../binutils/ar ] ; then \
     echo $(objdir)/../binutils/ar ; \
   else \
@@ -325,11 +325,11 @@ AR_FOR_TARGET = ` \
     else \
        t='$(program_transform_name)'; echo ar | sed -e $$t ; \
     fi; \
-  fi`
+  fi)
 AR_FLAGS_FOR_TARGET =
 AR_CREATE_FOR_TARGET = $(AR_FOR_TARGET) $(AR_FLAGS_FOR_TARGET) rc
 AR_EXTRACT_FOR_TARGET = $(AR_FOR_TARGET) $(AR_FLAGS_FOR_TARGET) x
-RANLIB_FOR_TARGET = ` \
+RANLIB_FOR_TARGET := $(shell \
   if [ -f $(objdir)/../binutils/ranlib ] ; then \
     echo $(objdir)/../binutils/ranlib ; \
   else \
@@ -338,8 +338,8 @@ RANLIB_FOR_TARGET = ` \
     else \
        t='$(program_transform_name)'; echo ranlib | sed -e $$t ; \
     fi; \
-  fi`
-NM_FOR_TARGET = ` \
+  fi)
+NM_FOR_TARGET := $(shell \
   if [ -f ./nm ] ; then \
     echo ./nm ; \
   elif [ -f $(objdir)/../binutils/nm-new ] ; then \
@@ -350,7 +350,7 @@ NM_FOR_TARGET = ` \
     else \
        t='$(program_transform_name)'; echo nm | sed -e $$t ; \
     fi; \
-  fi`
+  fi)
 
 # --------
 # UNSORTED
@@ -416,7 +416,6 @@ host_hook_obj=@out_host_hook_obj@
 gcc_version=@gcc_version@
 gcc_version_trigger=@gcc_version_trigger@
 version=$(gcc_version)
-mainversion=`grep version_string $(srcdir)/version.c | sed -e 's/.*\"\([0-9]*\.[0-9]*\).*/\1/'`
 
 # ------------------------
 # Installation directories


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]