public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH g++ driver] Push -static-libstdc++ back onto the command line to allow spec substitutions to use it.
@ 2015-06-18  8:37 Iain Sandoe
  2015-07-12 23:20 ` Iain Sandoe
  2015-07-14 17:40 ` Jason Merrill
  0 siblings, 2 replies; 5+ messages in thread
From: Iain Sandoe @ 2015-06-18  8:37 UTC (permalink / raw)
  To: gcc-patches List; +Cc: Jonathan Wakely, Jason Merrill

Hi,

This came up in a User question last night and reminded me that I had a patch for it in my Q.

----

Usually g++ driver support for -static-libstdc++ is provided by "-Bstatic -lstdc++ -Bdynamic" and is currently disabled for targets without that linker support.  However, actually, there is still an opportunity for those targets to implement the functionality with a spec substituation like:

%{static-libstdc++:%:replace-outfile(-lstdc++ libstdc++.a%s)}

However, this doesn't currently work because the g++ driver swallows "-static-libstdc++" so it's never seen by the specs.
The patch below pushes -static-libstdc++ onto the output command line (for targets without -Bstatic/dynamic)  so that such specs have an opportunity to fire.

OK for trunk?
Iain

gcc/cp:
	* g++spec.c (lang_specific_driver): Push "-static-libstdc++" back to the output
	command line when the target linker does not support -Bstatic/dynamic so that it
	is available for spec substitions to act on.


---
gcc/cp/g++spec.c | 9 +++++++++
1 file changed, 9 insertions(+)

diff --git a/gcc/cp/g++spec.c b/gcc/cp/g++spec.c
index 6536d7e..48a9708 100644
--- a/gcc/cp/g++spec.c
+++ b/gcc/cp/g++spec.c
@@ -363,6 +363,15 @@ lang_specific_driver (struct cl_decoded_option **in_decoded_options,
			   &new_decoded_options[j]);
	  j++;
	}
+#else
+      /* For linkers that don't support Bstatic/dynamic push the flag back
+         so that spec substitution can see it.  */
+      if (library > 1 && !static_link)
+        {
+          generate_option (OPT_static_libstdc__, NULL, 0, CL_DRIVER,
+                           &new_decoded_options[j]);
+          j++;
+        }
#endif
    }
  if (saw_math)
-- 
2.2.1

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

* Re: [PATCH g++ driver] Push -static-libstdc++ back onto the command line to allow spec substitutions to use it.
  2015-06-18  8:37 [PATCH g++ driver] Push -static-libstdc++ back onto the command line to allow spec substitutions to use it Iain Sandoe
@ 2015-07-12 23:20 ` Iain Sandoe
  2015-07-14 17:40 ` Jason Merrill
  1 sibling, 0 replies; 5+ messages in thread
From: Iain Sandoe @ 2015-07-12 23:20 UTC (permalink / raw)
  To: Jason Merrill; +Cc: gcc-patches List, Jonathan Wakely

Ping

On 18 Jun 2015, at 09:12, Iain Sandoe wrote:

> Hi,
> 
> This came up in a User question last night and reminded me that I had a patch for it in my Q.
> 
> ----
> 
> Usually g++ driver support for -static-libstdc++ is provided by "-Bstatic -lstdc++ -Bdynamic" and is currently disabled for targets without that linker support.  However, actually, there is still an opportunity for those targets to implement the functionality with a spec substituation like:
> 
> %{static-libstdc++:%:replace-outfile(-lstdc++ libstdc++.a%s)}
> 
> However, this doesn't currently work because the g++ driver swallows "-static-libstdc++" so it's never seen by the specs.
> The patch below pushes -static-libstdc++ onto the output command line (for targets without -Bstatic/dynamic)  so that such specs have an opportunity to fire.
> 
> OK for trunk?
> Iain
> 
> gcc/cp:
> 	* g++spec.c (lang_specific_driver): Push "-static-libstdc++" back to the output
> 	command line when the target linker does not support -Bstatic/dynamic so that it
> 	is available for spec substitions to act on.
> 
> 
> ---
> gcc/cp/g++spec.c | 9 +++++++++
> 1 file changed, 9 insertions(+)
> 
> diff --git a/gcc/cp/g++spec.c b/gcc/cp/g++spec.c
> index 6536d7e..48a9708 100644
> --- a/gcc/cp/g++spec.c
> +++ b/gcc/cp/g++spec.c
> @@ -363,6 +363,15 @@ lang_specific_driver (struct cl_decoded_option **in_decoded_options,
> 			   &new_decoded_options[j]);
> 	  j++;
> 	}
> +#else
> +      /* For linkers that don't support Bstatic/dynamic push the flag back
> +         so that spec substitution can see it.  */
> +      if (library > 1 && !static_link)
> +        {
> +          generate_option (OPT_static_libstdc__, NULL, 0, CL_DRIVER,
> +                           &new_decoded_options[j]);
> +          j++;
> +        }
> #endif
>    }
>  if (saw_math)
> -- 
> 2.2.1
> 

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

* Re: [PATCH g++ driver] Push -static-libstdc++ back onto the command line to allow spec substitutions to use it.
  2015-06-18  8:37 [PATCH g++ driver] Push -static-libstdc++ back onto the command line to allow spec substitutions to use it Iain Sandoe
  2015-07-12 23:20 ` Iain Sandoe
@ 2015-07-14 17:40 ` Jason Merrill
  2015-07-14 17:58   ` Iain Sandoe
  1 sibling, 1 reply; 5+ messages in thread
From: Jason Merrill @ 2015-07-14 17:40 UTC (permalink / raw)
  To: Iain Sandoe, gcc-patches List; +Cc: Jonathan Wakely

On 06/18/2015 04:12 AM, Iain Sandoe wrote:
> The patch below pushes -static-libstdc++ onto the output command line (for targets without -Bstatic/dynamic)  so that such specs have an opportunity to fire.

Won't that produce an unrecognized flag error from the linker?

Jason


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

* Re: [PATCH g++ driver] Push -static-libstdc++ back onto the command line to allow spec substitutions to use it.
  2015-07-14 17:40 ` Jason Merrill
@ 2015-07-14 17:58   ` Iain Sandoe
  2015-09-07 18:24     ` Iain Sandoe
  0 siblings, 1 reply; 5+ messages in thread
From: Iain Sandoe @ 2015-07-14 17:58 UTC (permalink / raw)
  To: Jason Merrill; +Cc: gcc-patches List, Jonathan Wakely


On 14 Jul 2015, at 18:24, Jason Merrill wrote:

> On 06/18/2015 04:12 AM, Iain Sandoe wrote:
>> The patch below pushes -static-libstdc++ onto the output command line (for targets without -Bstatic/dynamic)  so that such specs have an opportunity to fire.
> 
> Won't that produce an unrecognized flag error from the linker?

IFF the target doesn't support -Bstatic/dynamic  *and* doesn't provide a spec %{static-libstdc++:...
then, that could happen.

There's a fairly small group of non-binutils targets - other than Darwin that would be maybe AIX and some Solaris versions (and I believe that the native linkers there do support -Bstatic/dynamic), however, I'll double-check with the maintainers.
Iain

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

* Re: [PATCH g++ driver] Push -static-libstdc++ back onto the command line to allow spec substitutions to use it.
  2015-07-14 17:58   ` Iain Sandoe
@ 2015-09-07 18:24     ` Iain Sandoe
  0 siblings, 0 replies; 5+ messages in thread
From: Iain Sandoe @ 2015-09-07 18:24 UTC (permalink / raw)
  To: Jason Merrill; +Cc: gcc-patches List, Jonathan Wakely


On 14 Jul 2015, at 18:45, Iain Sandoe wrote:

> 
> On 14 Jul 2015, at 18:24, Jason Merrill wrote:
> 
>> On 06/18/2015 04:12 AM, Iain Sandoe wrote:
>>> The patch below pushes -static-libstdc++ onto the output command line (for targets without -Bstatic/dynamic)  so that such specs have an opportunity to fire.
>> 
>> Won't that produce an unrecognized flag error from the linker?
> 
> IFF the target doesn't support -Bstatic/dynamic  *and* doesn't provide a spec %{static-libstdc++:...
> then, that could happen.
> 
> There's a fairly small group of non-binutils targets - other than Darwin that would be maybe AIX and some Solaris versions (and I believe that the native linkers there do support -Bstatic/dynamic), however, I'll double-check with the maintainers.

I checked with David (AIX) and Rainer (Solaris) as the only other two platforms I could think of off-hand that use non-binutils linkers.  Neither should be affected by the change,
OK for trunk?
Iain

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

end of thread, other threads:[~2015-09-07 18:04 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-06-18  8:37 [PATCH g++ driver] Push -static-libstdc++ back onto the command line to allow spec substitutions to use it Iain Sandoe
2015-07-12 23:20 ` Iain Sandoe
2015-07-14 17:40 ` Jason Merrill
2015-07-14 17:58   ` Iain Sandoe
2015-09-07 18:24     ` Iain Sandoe

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).