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 RFA: Add -static-libstdc++ option to g++


* Ian Lance Taylor wrote on Sat, Jun 20, 2009 at 08:05:43AM CEST:
> --- cp/g++spec.c	(revision 148727)
> +++ cp/g++spec.c	(working copy)

> @@ -63,7 +65,8 @@ lang_specific_driver (int *in_argc, cons
>    /* This is a tristate:

No, this isn't a tristate any more.  :-)

>       -1 means we should not link in libstdc++
>       0  means we should link in libstdc++ if it is needed
> -     1  means libstdc++ is needed and should be linked in.  */
> +     1  means libstdc++ is needed and should be linked in.
> +     2  means libstdc++ is needed and should be linked statically.  */
>    int library = 0;
>  
>    /* The number of arguments being added to what's in argv, other than

> @@ -200,9 +206,15 @@ lang_specific_driver (int *in_argc, cons
>  		 cause a warning.  */
>  	      library = -1;
>  	    }
> -	  else if (strcmp (argv[i], "-static-libgcc") == 0
> -		   || strcmp (argv[i], "-static") == 0)
> +	  else if (strcmp (argv[i], "-static") == 0)
> +	    static_link = 1;
> +	  else if (strcmp (argv[i], "-static-libgcc") == 0)
>  	    shared_libgcc = 0;
> +	  else if (strcmp (argv[i], "-static-libstdc++") == 0)
> +	    {
> +	      library = library >= 0 ? 2 : library;

For tools like libtool it would be nice to know for certain that
  -nodefaultlibs -static-libstdc++

(or -nostdlib) does not add libstdc++ to the link.  Actually, for
libtool it would be nice if it did add libstdc++ to the link statically,
but that would be a deviation from current practice with the other
-{static,shared}-*lib flags.  I guess the fact that -nodefaultlibs and
-nostdlib overrides these flags could be a separate, documentation-only
patch (and I suppose I can write it, if there is agreement that that is
the semantics desired by GCC).

> +	      args[i] |= SKIPOPT;
> +	    }
>  	  else if (DEFAULT_WORD_SWITCH_TAKES_ARG (&argv[i][1]))
>  	    i++;
>  	  else

> --- doc/invoke.texi	(revision 148727)
> +++ doc/invoke.texi	(working copy)

> @@ -8240,6 +8241,18 @@ for the languages used in the program, o
>  @option{-shared-libgcc}, such that it is linked with the shared
>  @file{libgcc}.
>  
> +@item -static-libstdc++
> +When the @command{g++} program is used to link a C++ program, it will
> +normally automatically link against @option{libstdc++}.  If
> +@file{libstdc++} is available as a shared library, and the
> +@option{-static} option is not used, then this will link against the
> +shared version of @file{libstdc++}.  That is normally fine.  However, it
> +is sometimes useful to freeze the version of @file{libstdc++} used by
> +the program without going all the way to a fully static link.  The
> +@option{-static-libstdc++} option directs the @command{g++} driver to
> +link @file{libstdc++} statically, without necessarily linking other
> +libraries statically.

Cheers,
Ralf


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