This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH g++ driver] Push -static-libstdc++ back onto the command line to allow spec substitutions to use it.
- From: Iain Sandoe <iain at codesourcery dot com>
- To: Jason Merrill <jason at redhat dot com>
- Cc: gcc-patches List <gcc-patches at gcc dot gnu dot org>, Jonathan Wakely <jwakely at redhat dot com>
- Date: Mon, 13 Jul 2015 00:20:21 +0100
- Subject: Re: [PATCH g++ driver] Push -static-libstdc++ back onto the command line to allow spec substitutions to use it.
- Authentication-results: sourceware.org; auth=none
- References: <6AF41B3F-BB52-4B75-9336-54A9587CD627 at codesourcery dot com>
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
>