This is the mail archive of the 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]

[patch] fix %b resetting

In gcc.c we reset the input to the first input filename so that %b
behavior works reasonably well. The problem is that for drivers other
than c this wasn't working. With the following type of spec addition:

#define LINK_SPEC "-soname=%b"

and the command line:

g++ -Wl,-Tfoo -o bar.x

We'd get a soname of -Wl,

Which is definitely not what we wanted. This appears to fix the problem
by using the first infile with a language.

Bootstrapped and regtested on x86-linux (and tested on s390x-ibm-tpf for
that matter). No regressions.



2005-06-02  Eric Christopher  <>

	* gcc.c (main): Reset input to the first object with
	a language.

Index: gcc/gcc.c
RCS file: /cvs/gcc/gcc/gcc/gcc.c,v
retrieving revision 1.458
diff -u -p -w -r1.458 gcc.c
--- gcc/gcc.c	15 May 2005 17:06:16 -0000	1.458
+++ gcc/gcc.c	2 Jun 2005 17:35:41 -0000
@@ -6540,11 +6540,24 @@ main (int argc, const char **argv)
       clear_failure_queue ();
-  /* Reset the output file name to the first input file name, for use
-     with %b in LINK_SPEC on a target that prefers not to emit a.out
-     by default.  */
+  /* Reset the input file name to the first compile/object file name,
for use
+     with %b in LINK_SPEC. We use the first input file that we can find
+     a compiler to compile it instead of using infiles.language since
+     languages other than C we use aliases that we then lookup later.
   if (n_infiles > 0)
-    set_input (infiles[0].name);
+    {
+      int i;
+      for (i = 0; i < n_infiles ; i++)
+	{
+	  struct compiler *cp =
+	    lookup_compiler (infiles[i].name, strlen (infiles[i].name),
+			     infiles[i].language);
+	  if (cp)
+	    set_input (infiles[i].name);
+	}
+    }
   if (error_count == 0)

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