[4/n] modula-2, driver: Handle static-libstd++ for targets without static/dynamic

Message ID 20221230105821.61331-1-iain@sandoe.co.uk
State Committed
Commit 2421470867f198c3aa57e0a7ab0d473aac4cdd38
Headers
Series [4/n] modula-2, driver: Handle static-libstd++ for targets without static/dynamic |

Commit Message

Iain Sandoe Dec. 30, 2022, 10:58 a.m. UTC
  The follows the pattern used in C++ and D drivers to pass -static-libstdc++
onto the target driver to allow spec substitution of static libraries.

NOTE: The general handling of Bstatic/dynamic and the possible use of static
libgm2 libraries is unimplemented in this driver so far.  It seems likely
that the driver construction could be greatly simplified if the modula-2
runtimes were combined into fewer (hopefully, one) libraries.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>

gcc/m2/ChangeLog:

	* gm2spec.cc (lang_specific_driver): Pass -static-libstdc++ on to
	the target driver if the linker does not support Bstatic/dynamic.
---
 gcc/m2/gm2spec.cc | 5 +++++
 1 file changed, 5 insertions(+)
  

Comments

Iain Sandoe Dec. 30, 2022, 11 a.m. UTC | #1
Oops pressed ‘send' too soon - this is part of the series for Darwin:

There are several modula-2 issues on Darwin, some blocking bootstrap on
one or more system versions.

This has been tested on powerpc/i688-darwin9 .. x86_64-darwin10,17,21 and
the prototype aarch64-darwin branch on darwin21.

OK for trunk?
thanks
Iain

> On 30 Dec 2022, at 10:58, Iain Sandoe <iains.gcc@gmail.com> wrote:
> 
> The follows the pattern used in C++ and D drivers to pass -static-libstdc++
> onto the target driver to allow spec substitution of static libraries.
> 
> NOTE: The general handling of Bstatic/dynamic and the possible use of static
> libgm2 libraries is unimplemented in this driver so far.  It seems likely
> that the driver construction could be greatly simplified if the modula-2
> runtimes were combined into fewer (hopefully, one) libraries.
> 
> Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
> 
> gcc/m2/ChangeLog:
> 
> 	* gm2spec.cc (lang_specific_driver): Pass -static-libstdc++ on to
> 	the target driver if the linker does not support Bstatic/dynamic.
> ---
> gcc/m2/gm2spec.cc | 5 +++++
> 1 file changed, 5 insertions(+)
> 
> diff --git a/gcc/m2/gm2spec.cc b/gcc/m2/gm2spec.cc
> index 680dd3602ef..b9a5c4e79bb 100644
> --- a/gcc/m2/gm2spec.cc
> +++ b/gcc/m2/gm2spec.cc
> @@ -767,7 +767,12 @@ lang_specific_driver (struct cl_decoded_option **in_decoded_options,
> 
> 	case OPT_static_libstdc__:
> 	  library = library >= 0 ? 2 : library;
> +#ifdef HAVE_LD_STATIC_DYNAMIC
> +	  /* Remove -static-libstdc++ from the command only if target supports
> +	     LD_STATIC_DYNAMIC.  When not supported, it is left in so that a
> +	     back-end target can use outfile substitution.  */
> 	  args[i] |= SKIPOPT;
> +#endif
> 	  break;
> 
> 	case OPT_stdlib_:
> -- 
> 2.37.1 (Apple Git-137.1)
>
  
Gaius Mulley Jan. 5, 2023, 2:33 a.m. UTC | #2
Iain Sandoe <iain@sandoe.co.uk> writes:

> Oops pressed ‘send' too soon - this is part of the series for Darwin:
>
> There are several modula-2 issues on Darwin, some blocking bootstrap on
> one or more system versions.
>
> This has been tested on powerpc/i688-darwin9 .. x86_64-darwin10,17,21 and
> the prototype aarch64-darwin branch on darwin21.
>
> OK for trunk?
> thanks
> Iain

sure, LGTM

regards,
Gaius

>> On 30 Dec 2022, at 10:58, Iain Sandoe <iains.gcc@gmail.com> wrote:
>> 
>> The follows the pattern used in C++ and D drivers to pass -static-libstdc++
>> onto the target driver to allow spec substitution of static libraries.
>> 
>> NOTE: The general handling of Bstatic/dynamic and the possible use of static
>> libgm2 libraries is unimplemented in this driver so far.  It seems likely
>> that the driver construction could be greatly simplified if the modula-2
>> runtimes were combined into fewer (hopefully, one) libraries.
>> 
>> Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
>> 
>> gcc/m2/ChangeLog:
>> 
>> 	* gm2spec.cc (lang_specific_driver): Pass -static-libstdc++ on to
>> 	the target driver if the linker does not support Bstatic/dynamic.
>> ---
>> gcc/m2/gm2spec.cc | 5 +++++
>> 1 file changed, 5 insertions(+)
>> 
>> diff --git a/gcc/m2/gm2spec.cc b/gcc/m2/gm2spec.cc
>> index 680dd3602ef..b9a5c4e79bb 100644
>> --- a/gcc/m2/gm2spec.cc
>> +++ b/gcc/m2/gm2spec.cc
>> @@ -767,7 +767,12 @@ lang_specific_driver (struct cl_decoded_option **in_decoded_options,
>> 
>> 	case OPT_static_libstdc__:
>> 	  library = library >= 0 ? 2 : library;
>> +#ifdef HAVE_LD_STATIC_DYNAMIC
>> +	  /* Remove -static-libstdc++ from the command only if target supports
>> +	     LD_STATIC_DYNAMIC.  When not supported, it is left in so that a
>> +	     back-end target can use outfile substitution.  */
>> 	  args[i] |= SKIPOPT;
>> +#endif
>> 	  break;
>> 
>> 	case OPT_stdlib_:
>> -- 
>> 2.37.1 (Apple Git-137.1)
>>
  

Patch

diff --git a/gcc/m2/gm2spec.cc b/gcc/m2/gm2spec.cc
index 680dd3602ef..b9a5c4e79bb 100644
--- a/gcc/m2/gm2spec.cc
+++ b/gcc/m2/gm2spec.cc
@@ -767,7 +767,12 @@  lang_specific_driver (struct cl_decoded_option **in_decoded_options,
 
 	case OPT_static_libstdc__:
 	  library = library >= 0 ? 2 : library;
+#ifdef HAVE_LD_STATIC_DYNAMIC
+	  /* Remove -static-libstdc++ from the command only if target supports
+	     LD_STATIC_DYNAMIC.  When not supported, it is left in so that a
+	     back-end target can use outfile substitution.  */
 	  args[i] |= SKIPOPT;
+#endif
 	  break;
 
 	case OPT_stdlib_: