From: Iain Buclaw <ibuclaw@gdcproject.org>
To: gcc-patches@gcc.gnu.org
Subject: [committed] d: gdc driver ignores -static-libstdc++ when automatically linking libstdc++ library
Date: Mon, 4 Oct 2021 18:00:46 +0200 [thread overview]
Message-ID: <20211004160046.566990-1-ibuclaw@gdcproject.org> (raw)
Hi,
This patch adds handling of `-static-libstc++' to the gdc driver, so
that libstdc++ is appropriately linked if it is either needed or seen on
the command-line.
This is required for bootstrapping the self hosted D front-end, so will
also be backported to all supported releases.
Bootstrapped and regression tested, and committed to mainline.
Regards
Iain.
---
PR d/102574
gcc/d/ChangeLog:
* d-spec.cc (lang_specific_driver): Link libstdc++ statically if
-static-libstdc++ was given on command-line.
---
gcc/d/d-spec.cc | 43 ++++++++++++++++++++++++++++++++++---------
1 file changed, 34 insertions(+), 9 deletions(-)
diff --git a/gcc/d/d-spec.cc b/gcc/d/d-spec.cc
index 16ff1539e9f..5adc662c6f2 100644
--- a/gcc/d/d-spec.cc
+++ b/gcc/d/d-spec.cc
@@ -83,6 +83,9 @@ lang_specific_driver (cl_decoded_option **in_decoded_options,
/* "-lstdc++" if it appears on the command line. */
const cl_decoded_option *saw_libcxx = 0;
+ /* True if we saw `-static-libstdc++'. */
+ bool saw_static_libcxx = false;
+
/* Whether we need the C++ STD library. */
bool need_stdcxx = false;
@@ -248,6 +251,11 @@ lang_specific_driver (cl_decoded_option **in_decoded_options,
shared_libgcc = false;
break;
+ case OPT_static_libstdc__:
+ saw_static_libcxx = true;
+ args[i] |= SKIPOPT;
+ break;
+
case OPT_static_libphobos:
if (phobos_library != PHOBOS_NOLINK)
phobos_library = PHOBOS_STATIC;
@@ -452,16 +460,33 @@ lang_specific_driver (cl_decoded_option **in_decoded_options,
#endif
}
- if (saw_libcxx)
- new_decoded_options[j++] = *saw_libcxx;
- else if (need_stdcxx)
+ if (saw_libcxx || need_stdcxx)
{
- generate_option (OPT_l,
- (saw_profile_flag
- ? LIBSTDCXX_PROFILE
- : LIBSTDCXX),
- 1, CL_DRIVER, &new_decoded_options[j++]);
- added_libraries++;
+#ifdef HAVE_LD_STATIC_DYNAMIC
+ if (saw_static_libcxx && !static_link)
+ {
+ generate_option (OPT_Wl_, LD_STATIC_OPTION, 1, CL_DRIVER,
+ &new_decoded_options[j++]);
+ }
+#endif
+ if (saw_libcxx)
+ new_decoded_options[j++] = *saw_libcxx;
+ else if (need_stdcxx)
+ {
+ generate_option (OPT_l,
+ (saw_profile_flag
+ ? LIBSTDCXX_PROFILE
+ : LIBSTDCXX),
+ 1, CL_DRIVER, &new_decoded_options[j++]);
+ added_libraries++;
+ }
+#ifdef HAVE_LD_STATIC_DYNAMIC
+ if (saw_static_libcxx && !static_link)
+ {
+ generate_option (OPT_Wl_, LD_DYNAMIC_OPTION, 1, CL_DRIVER,
+ &new_decoded_options[j++]);
+ }
+#endif
}
if (shared_libgcc && !static_link)
--
2.30.2
next reply other threads:[~2021-10-04 16:00 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-04 16:00 Iain Buclaw [this message]
2021-10-04 16:48 ` Iain Sandoe
2021-10-05 8:02 ` ibuclaw
2021-10-05 20:03 ` Iain Sandoe
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20211004160046.566990-1-ibuclaw@gdcproject.org \
--to=ibuclaw@gdcproject.org \
--cc=gcc-patches@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).