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]

[PATCH] Some inconsistency in collect2, with respect to gcc and libtool


Collect2 has some code to parse arguments which is less than perfect,
especially when one takes libtool into account.

Specifically, gcc specs documentation explicitly says that any file that does
not have default rules will be transparently passed to the linker.

On the other hand, collect2's parser does only recognize .o files as proper
object files.

What this means is that libtool CAN'T support .lo on any platform that relies
on collect2 to do its job. 

This is especially important for C++, where g++ -shared might be the only
sane way to ensure constructors are going to be called.

So, I'm wondering about how to fix that. A simple fix would be tell collect2
that .lo are also object files. Here it is:

Mon Jul 10 17:10:09 MET DST 2000		Marc Espie <espie@openbsd.org>
	* collect2.c (main):  Recognize .lo as object files.
Index: collect2.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/collect2.c,v
retrieving revision 1.96
diff -u -r1.96 collect2.c
--- collect2.c	2000/06/24 22:19:45	1.96
+++ collect2.c	2000/07/10 15:11:49
@@ -1222,7 +1222,7 @@
 	}
       else if ((p = rindex (arg, '.')) != (char *) 0
 	       && (strcmp (p, ".o") == 0 || strcmp (p, ".a") == 0
-		   || strcmp (p, ".so") == 0))
+		   || strcmp (p, ".so") == 0 || strcmp (p, ".lo") == 0))
 	{
 	  if (first_file)
 	    {
@@ -1237,7 +1237,7 @@
 		  *ld2++ = arg;
 		}
 	    }
-	  if (p[1] == 'o')
+	  if (p[1] == 'o' || p[1] == 'l')
 	    *object++ = arg;
 #ifdef COLLECT_EXPORT_LIST
 	  /* libraries can be specified directly, i.e. without -l flag.  */


The only problem is with special casing stuff... the only clean solution
I see is to get gcc aware that it is spewing stuff out to collect2, so that
it could flag stuff for collect2 explicitly...
-- 
	Marc Espie		
|anime, sf, juggling, unicycle, acrobatics, comics...
|AmigaOS, OpenBSD, C++, perl, Icon, PostScript...
| `real programmers don't die, they just get out of beta'

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