From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1698) id E5CD53858D38; Mon, 22 Apr 2024 13:10:04 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E5CD53858D38 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1713791404; bh=u9KOnAj3Gjt7KmWbVWvquKNXEgI7hCBu53V39eDPnrQ=; h=From:To:Subject:Date:From; b=fW4nw0IwRrsw/ZPaEyGIHNB2bOqhupUrAicNHxh81cv19Mt5g6PqO9Oh4Mi6kBIK6 Ec1GgK89gZQHQtbO9gs/xCC+NNR72d4hoBueJT3+ZDIwJDq6qvtmXHyZZ5r4mIxYmm esRWJx/YWm5ySJHwlBN+yD9I0acnnuRTtAWx2Xrk= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Iain D Sandoe To: gcc-cvs@gcc.gnu.org Subject: [gcc r11-11334] c++, driver: Fix -static-libstdc++ for targets without Bstatic/dynamic. X-Act-Checkin: gcc X-Git-Author: Iain Sandoe X-Git-Refname: refs/heads/releases/gcc-11 X-Git-Oldrev: 45385f6932567f1b0ce5e1f809135c73c6b70df5 X-Git-Newrev: 8af693c4ae1a0f8cecef34e98dad1752ebf0bb75 Message-Id: <20240422131004.E5CD53858D38@sourceware.org> Date: Mon, 22 Apr 2024 13:10:04 +0000 (GMT) List-Id: https://gcc.gnu.org/g:8af693c4ae1a0f8cecef34e98dad1752ebf0bb75 commit r11-11334-g8af693c4ae1a0f8cecef34e98dad1752ebf0bb75 Author: Iain Sandoe 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 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_: