public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Iain D Sandoe <iains@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc r11-11334] c++, driver: Fix -static-libstdc++ for targets without Bstatic/dynamic.
Date: Mon, 22 Apr 2024 13:10:04 +0000 (GMT)	[thread overview]
Message-ID: <20240422131004.E5CD53858D38@sourceware.org> (raw)

https://gcc.gnu.org/g:8af693c4ae1a0f8cecef34e98dad1752ebf0bb75

commit r11-11334-g8af693c4ae1a0f8cecef34e98dad1752ebf0bb75
Author: Iain Sandoe <iain@sandoe.co.uk>
Date:   Thu Jan 6 08:37:18 2022 +0000

    c++, driver: Fix -static-libstdc++ for targets without Bstatic/dynamic.
    
    The current implementation for swapping between the static and shared c++
    runtimes relies on the static linker supporting Bstatic/dynamic which is
    not available for every target (Darwin's linker does not support this).
    
    Specs substitution (%s) is an alternative solution for this (which is what
    Darwin uses for Fortran, D and Objective-C).  However, specs substitution
    requires that the '-static-libstdc++' be preserved in the driver's command
    line.  The patch here arranges for this to be done when the configuration
    determines that linker support for Bstatic/dynamic is missing.
    
    Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
    
    gcc/cp/ChangeLog:
    
            * g++spec.c (lang_specific_driver): Preserve -static-libstdc++ in
            the driver command line for targets without -Bstatic/dynamic support
            in their static linker.
    
    (cherry picked from commit a846817739c1e7b930d593cd51963d6b46b5dfc6)

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

diff --git a/gcc/cp/g++spec.c b/gcc/cp/g++spec.c
index 3c9bd1490b4..984106f10dd 100644
--- a/gcc/cp/g++spec.c
+++ b/gcc/cp/g++spec.c
@@ -222,7 +222,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_:

                 reply	other threads:[~2024-04-22 13:10 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20240422131004.E5CD53858D38@sourceware.org \
    --to=iains@gcc.gnu.org \
    --cc=gcc-cvs@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).