public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PING {c,c++}-driver review needed] Fix PR41594 and help build libstdc++  as DLL on windows.
@ 2009-11-25 21:29 Dave Korn
  2009-12-17 14:00 ` [PING] " Dave Korn
  0 siblings, 1 reply; 2+ messages in thread
From: Dave Korn @ 2009-11-25 21:29 UTC (permalink / raw)
  To: GCC Patches; +Cc: IainS

[-- Attachment #1: Type: text/plain, Size: 3061 bytes --]



    Hi all,


  The attached patch is extracted from the patch(*) to build libstdc++ as a
DLL on windows platforms that I've been painstakingly shepherding through
review and approval over the past few months.  (The rest of that patch is
already approved.)

  During that time, GCC grew a new option(****), --static-libstdc++, which I
had to update the patch to handle, but although I mentioned that it was
"respun" in the subject lines, I forgot to draw attention to this new aspect
of it that needed approval from a new maintainorial area.  So, I'm now pinging
it separately to make it more visible.

  The problem it addresses is that special handling of the --static-libstdc++
option in g++spec.c removes it from the command-line arg vector before specs
processing takes place.  The Cygwin target needs to handle things slightly
differently for static and shared linking, but if the option is removed, the
target link spec can't react to it.  Another facet of this problem has also
been reported as PR41594; the plain 'gcc' driver can't handle the option at
all, but errors out.  (Yes, g++ should always be used for mixed language
links; refer to the original thread(***) for the motivation.)  PR41596 is a
related PR in which it is necessary to test for --static-libstdc++ in a target
spec (although it does not resolve the PR which is more involved than just
that, but to support the fix for that PR it is necessary for the gcc.c driver
to not error out when it sees the option; hence 41594.)

  The attached patch resolves this, by not removing it from argv, and by
allowing it to be accepted and harmlessly ignored where not otherwise used by
adding it to the default LINK_COMMAND_SPEC, in the same fashion as --static is
handled.  This is based on advice Ian Taylor gave me in a follow-up
thread(*****) to the original thread that added the option.

gcc/ChangeLog:

	* gcc.c (LINK_COMMAND_SPEC): Allow and ignore -static-libstdc++
	similarly to -static.

gcc/cp/ChangeLog:

	* g++spec.c (SKIPOPT): Delete.
	(lang_specific_driver): Do not skip -static-libstdc++ option.


  Bootstrapped and tested many times over the past few months on
i686-pc-cygwin without regressions(**).  It would be easier to commit as part
of the libstdc++ dll patch, but I could do it separately if required.

  OK for head?

    cheers,
      DaveK
-- 
References:

(*) - Latest spin of libstdc++ dll patch, now approved for everything except
gcc.c and g++spec.c parts:
    http://gcc.gnu.org/ml/gcc-patches/2009-11/msg01107.html

(**) - Corresponding latest test results:
    http://gcc.gnu.org/ml/gcc-testresults/2009-11/msg01084.html

(***) - Original thread relating to PR41594:
    http://gcc.gnu.org/ml/gcc-patches/2009-10/threads.html#00332

(****) - Thread when --static-libstdc++ was added:
    http://gcc.gnu.org/ml/gcc-patches/2009-06/threads.html#01635

(*****) - Follow-up thread:
    http://gcc.gnu.org/ml/gcc-patches/2009-08/threads.html#01569

PRs:
    http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41594
    http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41596


[-- Attachment #2: static-libstdcxx-spec-fix.diff --]
[-- Type: text/x-c, Size: 2505 bytes --]

Index: gcc-patched/gcc/gcc.c
===================================================================
--- gcc-patched/gcc/gcc.c	(revision 151703)
+++ gcc-patched/gcc/gcc.c	(working copy)
@@ -760,7 +760,10 @@ proper position among the other output files.  */
 
 /* -u* was put back because both BSD and SysV seem to support it.  */
 /* %{static:} simply prevents an error message if the target machine
-   doesn't handle -static.  */
+   doesn't handle -static; %{static-libstdc++} is not handled by any
+   target machine but entirely in cp/g++spec.c, yet we cannot just
+   remove it from the command-line there or it cannot be tested in
+   spec processing, so we simply ignore it here similarly.  */
 /* We want %{T*} after %{L*} and %D so that it can be used to specify linker
    scripts which exist in user specified directories, or in standard
    directories.  */
@@ -769,7 +772,7 @@ proper position among the other output files.  */
 %{!fsyntax-only:%{!c:%{!M:%{!MM:%{!E:%{!S:\
     %(linker) %l " LINK_PIE_SPEC "%X %{o*} %{A} %{d} %{e*} %{m} %{N} %{n} %{r}\
     %{s} %{t} %{u*} %{x} %{z} %{Z} %{!A:%{!nostdlib:%{!nostartfiles:%S}}}\
-    %{static:} %{L*} %(mfwrap) %(link_libgcc) %o\
+    %{static:} %{static-libstdc++:} %{L*} %(mfwrap) %(link_libgcc) %o\
     %{fopenmp|ftree-parallelize-loops=*:%:include(libgomp.spec)%(link_gomp)} %(mflib)\
     %{fprofile-arcs|fprofile-generate*|coverage:-lgcov}\
     %{!nostdlib:%{!nodefaultlibs:%(link_ssp) %(link_gcc_c_sequence)}}\
Index: gcc-patched/gcc/cp/g++spec.c
===================================================================
--- gcc-patched/gcc/cp/g++spec.c	(revision 151703)
+++ gcc-patched/gcc/cp/g++spec.c	(working copy)
@@ -30,8 +30,6 @@ along with GCC; see the file COPYING3.  If not see
 #define MATHLIB		(1<<2)
 /* This bit is set if they did `-lc'.  */
 #define WITHLIBC	(1<<3)
-/* Skip this option.  */
-#define SKIPOPT		(1<<4)
 
 #ifndef MATH_LIBRARY
 #define MATH_LIBRARY "-lm"
@@ -211,10 +209,7 @@ lang_specific_driver (int *in_argc, const char *co
 	  else if (strcmp (argv[i], "-static-libgcc") == 0)
 	    shared_libgcc = 0;
 	  else if (strcmp (argv[i], "-static-libstdc++") == 0)
-	    {
 	      library = library >= 0 ? 2 : library;
-	      args[i] |= SKIPOPT;
-	    }
 	  else if (DEFAULT_WORD_SWITCH_TAKES_ARG (&argv[i][1]))
 	    i++;
 	  else
@@ -324,9 +319,6 @@ lang_specific_driver (int *in_argc, const char *co
 	  arglist[j] = "-xnone";
 	}
 
-      if ((args[i] & SKIPOPT) != 0)
-	--j;
-
       i++;
       j++;
     }

^ permalink raw reply	[flat|nested] 2+ messages in thread

* [PING] Re: [PING {c,c++}-driver review needed] Fix PR41594 and help  build libstdc++ as DLL on windows.
  2009-11-25 21:29 [PING {c,c++}-driver review needed] Fix PR41594 and help build libstdc++ as DLL on windows Dave Korn
@ 2009-12-17 14:00 ` Dave Korn
  0 siblings, 0 replies; 2+ messages in thread
From: Dave Korn @ 2009-12-17 14:00 UTC (permalink / raw)
  To: Dave Korn; +Cc: GCC Patches, IainS

Dave Korn wrote:

> gcc/ChangeLog:
> 
> 	* gcc.c (LINK_COMMAND_SPEC): Allow and ignore -static-libstdc++
> 	similarly to -static.
> 
> gcc/cp/ChangeLog:
> 
> 	* g++spec.c (SKIPOPT): Delete.
> 	(lang_specific_driver): Do not skip -static-libstdc++ option.
> 
> 
>   Bootstrapped and tested many times over the past few months on
> i686-pc-cygwin without regressions(**).  It would be easier to commit as part
> of the libstdc++ dll patch, but I could do it separately if required.

  The point became moot; I committed the rest of the patch (which had all been
approved for some time) before stage3 ended.  This bit is still outstanding;
as there's a choice between two proposed patches for this problem I'm pinging
this patch so that both it and Iain's are at the top of the current threads
for quick reference.

  Just so everything is nicely cross-referenced, Iain's alternative approach
is posted at:

http://gcc.gnu.org/ml/gcc-patches/2009-12/msg00855.html

    cheers,
      DaveK



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2009-12-17 13:34 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-11-25 21:29 [PING {c,c++}-driver review needed] Fix PR41594 and help build libstdc++ as DLL on windows Dave Korn
2009-12-17 14:00 ` [PING] " Dave Korn

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).