[PATCH] PR 17537: Add -lstdc++ with linking unknown libraries

Roger Sayle roger@eyesopen.com
Sat Sep 25 15:33:00 GMT 2004


The following "simple" patch addresses PR driver/17537 which is a
regression in gcc 3.4 and mainline, where g++ fails to pass -lstdc++
to the linker when libraries other than -lc and -lm are specified
on the command line.  When using "g++" to drive the linker, its not
unreasonable that unrecognized libraries such as "-lfoo" may have
dependencies on the g++ runtime/STL.

The following patch has been tested on i686-pc-linux-gnu with a full
"make bootstrap", and regression tested with a top-level "make -k check"
with no new failures.

Ok for mainline and the gcc-3_4-branch?



2004-09-25  Roger Sayle  <roger@eyesopen.com>

	PR driver/17537
	* g++spec.c (lang_specific_driver): Unrecognized libraries, other
	than -lc and -lm, may require linking against libstc++.


Index: g++spec.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/g++spec.c,v
retrieving revision 1.46
diff -c -3 -p -r1.46 g++spec.c
*** g++spec.c	3 Sep 2004 18:09:27 -0000	1.46
--- g++spec.c	25 Sep 2004 03:42:06 -0000
*************** lang_specific_driver (int *in_argc, cons
*** 174,179 ****
--- 174,182 ----
  	    }
  	  else if (strncmp (argv[i], "-Wl,", 4) == 0)
  	    library = (library == 0) ? 1 : library;
+ 	  /* Unrecognized libraries (e.g. -lfoo) may require libstdc++.  */
+ 	  else if (strncmp (argv[i], "-l", 2) == 0)
+ 	    library = (library == 0) ? 1 : library;
  	  else if (((argv[i][2] == '\0'
  		     && strchr ("bBVDUoeTuIYmLiA", argv[i][1]) != NULL)
  		    || strcmp (argv[i], "-Tdata") == 0))


Roger
--
Roger Sayle,                         E-mail: roger@eyesopen.com
OpenEye Scientific Software,         WWW: http://www.eyesopen.com/
Suite 1107, 3600 Cerrillos Road,     Tel: (+1) 505-473-7385
Santa Fe, New Mexico, 87507.         Fax: (+1) 505-473-0833



More information about the Gcc-patches mailing list