aboutsummaryrefslogtreecommitdiff
path: root/gcc/d
diff options
context:
space:
mode:
authorIain Buclaw <ibuclaw@gdcproject.org>2021-11-19 09:09:54 +0100
committerIain Buclaw <ibuclaw@gdcproject.org>2021-12-01 19:49:44 +0100
commit185b307b03db20bfc7105a519ef19e2cafea7196 (patch)
tree9476f0aac681d7d0bcf432a74d8e0258ad211f34 /gcc/d
parent53caa4723d8de73fe21e63ba264082f3071b2887 (diff)
downloadgcc-185b307b03db20bfc7105a519ef19e2cafea7196.zip
gcc-185b307b03db20bfc7105a519ef19e2cafea7196.tar.gz
gcc-185b307b03db20bfc7105a519ef19e2cafea7196.tar.bz2
darwin, d: Support outfile substitution for libphobos
In the gdc driver, this takes the previous fix for the Darwin D bootstrap, and extends it to the -static-libphobos option as well. Rather than pushing the -static-libphobos option back onto the command line, the setting of SKIPOPT is instead conditionally removed. The same change has been repeated for -static-libstdc++ so there is now no need to call generate_option to re-add it. In the gcc driver, -static-libphobos has been added as a common option, validated, and a new outfile substition added to config/darwin.h to correctly replace -lgphobos with libgphobos.a. gcc/ChangeLog: * common.opt (static-libphobos): Add option. * config/darwin.h (LINK_SPEC): Substitute -lgphobos with libgphobos.a when linking statically. * gcc.c (driver_handle_option): Set -static-libphobos as always valid. gcc/d/ChangeLog: * d-spec.cc (lang_specific_driver): Set SKIPOPT on -static-libstdc++ and -static-libphobos only when target supports LD_STATIC_DYNAMIC. Remove generate_option to re-add -static-libstdc++. libphobos/ChangeLog: * testsuite/testsuite_flags.in: Add libphobos library directory as search path to --gdcldflags.
Diffstat (limited to 'gcc/d')
-rw-r--r--gcc/d/d-spec.cc18
1 files changed, 11 insertions, 7 deletions
diff --git a/gcc/d/d-spec.cc b/gcc/d/d-spec.cc
index b12d28f..1304126 100644
--- a/gcc/d/d-spec.cc
+++ b/gcc/d/d-spec.cc
@@ -253,13 +253,23 @@ lang_specific_driver (cl_decoded_option **in_decoded_options,
case OPT_static_libstdc__:
saw_static_libcxx = true;
+#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_static_libphobos:
if (phobos_library != PHOBOS_NOLINK)
phobos_library = PHOBOS_STATIC;
+#ifdef HAVE_LD_STATIC_DYNAMIC
+ /* Remove -static-libphobos 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_shared_libphobos:
@@ -460,7 +470,7 @@ lang_specific_driver (cl_decoded_option **in_decoded_options,
#endif
}
- if (saw_libcxx || need_stdcxx)
+ if (saw_libcxx || saw_static_libcxx || need_stdcxx)
{
#ifdef HAVE_LD_STATIC_DYNAMIC
if (saw_static_libcxx && !static_link)
@@ -468,12 +478,6 @@ lang_specific_driver (cl_decoded_option **in_decoded_options,
generate_option (OPT_Wl_, LD_STATIC_OPTION, 1, CL_DRIVER,
&new_decoded_options[j++]);
}
-#else
- /* Push the -static-libstdc++ option back onto the command so that
- a target without LD_STATIC_DYNAMIC can use outfile substitution. */
- if (saw_static_libcxx && !static_link)
- generate_option (OPT_static_libstdc__, NULL, 1, CL_DRIVER,
- &new_decoded_options[j++]);
#endif
if (saw_libcxx)
new_decoded_options[j++] = *saw_libcxx;