Message ID | orpmj2d0hd.fsf@lxoliva.fsfla.org |
---|---|
State | Committed |
Headers |
Return-Path: <gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org> X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B6EB4383F952 for <patchwork@sourceware.org>; Tue, 21 Jun 2022 05:56:08 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B6EB4383F952 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1655790968; bh=ZWbczYJlwlwuP0/V6qy925owjhHOirFgymLMhkyYekc=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=xDvohw3shDJk/Vshn5mUXVsvhvJPyr5/r8S1f3DCvuyK/nf38huNgKX3czwv7EZjP 3GT+GVM7RPgKTH4oQUkPjoCGa56tqnX7tm/o69N/KxQr7j+ApWv3llGqBOOUsx9q4s edRrGSp+PddYjMaqlWvwdsKBAWFYXdc6Zn8JsKeE= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from rock.gnat.com (rock.gnat.com [205.232.38.15]) by sourceware.org (Postfix) with ESMTPS id 86517384144C for <gcc-patches@gcc.gnu.org>; Tue, 21 Jun 2022 05:55:39 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 86517384144C Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 429ED1160D9; Tue, 21 Jun 2022 01:55:39 -0400 (EDT) X-Virus-Scanned: Debian amavisd-new at gnat.com Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id EDZOqmPm9EC1; Tue, 21 Jun 2022 01:55:39 -0400 (EDT) Received: from free.home (tron.gnat.com [IPv6:2620:20:4000:0:46a8:42ff:fe0e:e294]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by rock.gnat.com (Postfix) with ESMTPS id C5B7E1160D8; Tue, 21 Jun 2022 01:55:38 -0400 (EDT) Received: from livre (livre.home [172.31.160.2]) by free.home (8.15.2/8.15.2) with ESMTPS id 25L5tQjW693393 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 21 Jun 2022 02:55:26 -0300 To: gcc-patches@gcc.gnu.org Subject: [PATCH] Introduce -nolibstdc++ option Organization: Free thinker, does not speak for AdaCore Date: Tue, 21 Jun 2022 02:55:26 -0300 Message-ID: <orpmj2d0hd.fsf@lxoliva.fsfla.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Scanned-By: MIMEDefang 2.84 X-Spam-Status: No, score=-12.3 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list <gcc-patches.gcc.gnu.org> List-Unsubscribe: <https://gcc.gnu.org/mailman/options/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=unsubscribe> List-Archive: <https://gcc.gnu.org/pipermail/gcc-patches/> List-Post: <mailto:gcc-patches@gcc.gnu.org> List-Help: <mailto:gcc-patches-request@gcc.gnu.org?subject=help> List-Subscribe: <https://gcc.gnu.org/mailman/listinfo/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=subscribe> From: Alexandre Oliva via Gcc-patches <gcc-patches@gcc.gnu.org> Reply-To: Alexandre Oliva <oliva@adacore.com> Cc: Joseph Myers <joseph@codesourcery.com>, Nathan Sidwell <nathan@acm.org> Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" <gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org> |
Series |
Introduce -nolibstdc++ option
|
|
Commit Message
Alexandre Oliva
June 21, 2022, 5:55 a.m. UTC
Using g++ to link without libstdc++, as in g++.dg/abi/pure-virtual1.C, is error prone, because there's no way to tell g++ to drop libstdc++ without also dropping libc and any other libraries that the target implicitly links in. This has often led to the need for manual adjustments to this testcase. I figured adding support for -nolibstdc++, even though redundant, makes some sense. One could presumably use gcc rather than g++ for linking, for the same effect, but sometimes changing the link command is harder than adding an option, as in our testsuite. Regstrapped on x86_64-linux-gnu, also tested with a cross to aarch64-rtems6. Ok to install? for gcc/ChangeLog * common.opt (nolibstdc++): New. * doc/invoke.texi (-nolibstdc++): Document it. for gcc/cp/ChangeLog * g++spec.c (lang_specific_driver): Implement -nolibstdc++. for gcc/testsuite/ChangeLog * g++.dg/abi/pure-virtual1.C: Use -nolibstdc++. --- gcc/common.opt | 3 +++ gcc/cp/g++spec.cc | 1 + gcc/doc/invoke.texi | 6 +++++- gcc/testsuite/g++.dg/abi/pure-virtual1.C | 2 +- 4 files changed, 10 insertions(+), 2 deletions(-)
Comments
On Tue, Jun 21, 2022 at 7:56 AM Alexandre Oliva via Gcc-patches <gcc-patches@gcc.gnu.org> wrote: > > > Using g++ to link without libstdc++, as in g++.dg/abi/pure-virtual1.C, > is error prone, because there's no way to tell g++ to drop libstdc++ > without also dropping libc and any other libraries that the target > implicitly links in. > > This has often led to the need for manual adjustments to this > testcase. > > I figured adding support for -nolibstdc++, even though redundant, > makes some sense. One could presumably use gcc rather than g++ for > linking, for the same effect, but sometimes changing the link command > is harder than adding an option, as in our testsuite. > > Regstrapped on x86_64-linux-gnu, also tested with a cross to > aarch64-rtems6. Ok to install? OK in case nobody objects in 24h. Richard. > > for gcc/ChangeLog > > * common.opt (nolibstdc++): New. > * doc/invoke.texi (-nolibstdc++): Document it. > > for gcc/cp/ChangeLog > > * g++spec.c (lang_specific_driver): Implement -nolibstdc++. > > for gcc/testsuite/ChangeLog > > * g++.dg/abi/pure-virtual1.C: Use -nolibstdc++. > --- > gcc/common.opt | 3 +++ > gcc/cp/g++spec.cc | 1 + > gcc/doc/invoke.texi | 6 +++++- > gcc/testsuite/g++.dg/abi/pure-virtual1.C | 2 +- > 4 files changed, 10 insertions(+), 2 deletions(-) > > diff --git a/gcc/common.opt b/gcc/common.opt > index 32917aafcaec1..e00c6fc2fb098 100644 > --- a/gcc/common.opt > +++ b/gcc/common.opt > @@ -3456,6 +3456,9 @@ Driver > nolibc > Driver > > +nolibstdc++ > +Driver > + > nostdlib > Driver > > diff --git a/gcc/cp/g++spec.cc b/gcc/cp/g++spec.cc > index 8174d652776b1..539e6ca089d85 100644 > --- a/gcc/cp/g++spec.cc > +++ b/gcc/cp/g++spec.cc > @@ -160,6 +160,7 @@ lang_specific_driver (struct cl_decoded_option **in_decoded_options, > { > case OPT_nostdlib: > case OPT_nodefaultlibs: > + case OPT_nolibstdc__: > library = -1; > break; > > diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi > index 50f57877477bc..469b6d97e0dfa 100644 > --- a/gcc/doc/invoke.texi > +++ b/gcc/doc/invoke.texi > @@ -652,7 +652,7 @@ Objective-C and Objective-C++ Dialects}. > @item Linker Options > @xref{Link Options,,Options for Linking}. > @gccoptlist{@var{object-file-name} -fuse-ld=@var{linker} -l@var{library} @gol > --nostartfiles -nodefaultlibs -nolibc -nostdlib @gol > +-nostartfiles -nodefaultlibs -nolibc -nolibstdc++ -nostdlib @gol > -e @var{entry} --entry=@var{entry} @gol > -pie -pthread -r -rdynamic @gol > -s -static -static-pie -static-libgcc -static-libstdc++ @gol > @@ -16787,6 +16787,10 @@ absence of a C library is assumed, for example @option{-lpthread} or > @option{-lm} in some configurations. This is intended for bare-board > targets when there is indeed no C library available. > > +@item -nolibstdc++ > +@opindex nolibstdc++ > +Do not link with standard C++ libraries implicitly. > + > @item -nostdlib > @opindex nostdlib > Do not use the standard system startup files or libraries when linking. > diff --git a/gcc/testsuite/g++.dg/abi/pure-virtual1.C b/gcc/testsuite/g++.dg/abi/pure-virtual1.C > index 538e2cb097a0d..889c33e4952f4 100644 > --- a/gcc/testsuite/g++.dg/abi/pure-virtual1.C > +++ b/gcc/testsuite/g++.dg/abi/pure-virtual1.C > @@ -1,7 +1,7 @@ > // Test that we don't need libsupc++ just for __cxa_pure_virtual. > // { dg-do link } > // { dg-require-weak } > -// { dg-additional-options "-fno-rtti -nodefaultlibs -lc" } > +// { dg-additional-options "-fno-rtti -nolibstdc++" } > // { dg-additional-options "-Wl,-undefined,dynamic_lookup" { target *-*-darwin* } } > // { dg-xfail-if "AIX weak" { powerpc-ibm-aix* } } > > > -- > Alexandre Oliva, happy hacker https://FSFLA.org/blogs/lxo/ > Free Software Activist GNU Toolchain Engineer > Disinformation flourishes because many people care deeply about injustice > but very few check the facts. Ask me about <https://stallmansupport.org>
On Tue, Jun 21, 2022 at 1:43 AM Richard Biener via Gcc-patches <gcc-patches@gcc.gnu.org> wrote: > > On Tue, Jun 21, 2022 at 7:56 AM Alexandre Oliva via Gcc-patches > <gcc-patches@gcc.gnu.org> wrote: > > > > > > Using g++ to link without libstdc++, as in g++.dg/abi/pure-virtual1.C, > > is error prone, because there's no way to tell g++ to drop libstdc++ > > without also dropping libc and any other libraries that the target > > implicitly links in. > > > > This has often led to the need for manual adjustments to this > > testcase. > > > > I figured adding support for -nolibstdc++, even though redundant, > > makes some sense. One could presumably use gcc rather than g++ for > > linking, for the same effect, but sometimes changing the link command > > is harder than adding an option, as in our testsuite. > > > > Regstrapped on x86_64-linux-gnu, also tested with a cross to > > aarch64-rtems6. Ok to install? > > OK in case nobody objects in 24h. > > Richard. Is this similar to clang -nostdlib++ ? When libstdc++ is selected, clang -nostdlib++ removes -lstdc++. > > > > for gcc/ChangeLog > > > > * common.opt (nolibstdc++): New. > > * doc/invoke.texi (-nolibstdc++): Document it. > > > > for gcc/cp/ChangeLog > > > > * g++spec.c (lang_specific_driver): Implement -nolibstdc++. > > > > for gcc/testsuite/ChangeLog > > > > * g++.dg/abi/pure-virtual1.C: Use -nolibstdc++. > > --- > > gcc/common.opt | 3 +++ > > gcc/cp/g++spec.cc | 1 + > > gcc/doc/invoke.texi | 6 +++++- > > gcc/testsuite/g++.dg/abi/pure-virtual1.C | 2 +- > > 4 files changed, 10 insertions(+), 2 deletions(-) > > > > diff --git a/gcc/common.opt b/gcc/common.opt > > index 32917aafcaec1..e00c6fc2fb098 100644 > > --- a/gcc/common.opt > > +++ b/gcc/common.opt > > @@ -3456,6 +3456,9 @@ Driver > > nolibc > > Driver > > > > +nolibstdc++ > > +Driver > > + > > nostdlib > > Driver > > > > diff --git a/gcc/cp/g++spec.cc b/gcc/cp/g++spec.cc > > index 8174d652776b1..539e6ca089d85 100644 > > --- a/gcc/cp/g++spec.cc > > +++ b/gcc/cp/g++spec.cc > > @@ -160,6 +160,7 @@ lang_specific_driver (struct cl_decoded_option **in_decoded_options, > > { > > case OPT_nostdlib: > > case OPT_nodefaultlibs: > > + case OPT_nolibstdc__: > > library = -1; > > break; > > > > diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi > > index 50f57877477bc..469b6d97e0dfa 100644 > > --- a/gcc/doc/invoke.texi > > +++ b/gcc/doc/invoke.texi > > @@ -652,7 +652,7 @@ Objective-C and Objective-C++ Dialects}. > > @item Linker Options > > @xref{Link Options,,Options for Linking}. > > @gccoptlist{@var{object-file-name} -fuse-ld=@var{linker} -l@var{library} @gol > > --nostartfiles -nodefaultlibs -nolibc -nostdlib @gol > > +-nostartfiles -nodefaultlibs -nolibc -nolibstdc++ -nostdlib @gol > > -e @var{entry} --entry=@var{entry} @gol > > -pie -pthread -r -rdynamic @gol > > -s -static -static-pie -static-libgcc -static-libstdc++ @gol > > @@ -16787,6 +16787,10 @@ absence of a C library is assumed, for example @option{-lpthread} or > > @option{-lm} in some configurations. This is intended for bare-board > > targets when there is indeed no C library available. > > > > +@item -nolibstdc++ > > +@opindex nolibstdc++ > > +Do not link with standard C++ libraries implicitly. > > + > > @item -nostdlib > > @opindex nostdlib > > Do not use the standard system startup files or libraries when linking. > > diff --git a/gcc/testsuite/g++.dg/abi/pure-virtual1.C b/gcc/testsuite/g++.dg/abi/pure-virtual1.C > > index 538e2cb097a0d..889c33e4952f4 100644 > > --- a/gcc/testsuite/g++.dg/abi/pure-virtual1.C > > +++ b/gcc/testsuite/g++.dg/abi/pure-virtual1.C > > @@ -1,7 +1,7 @@ > > // Test that we don't need libsupc++ just for __cxa_pure_virtual. > > // { dg-do link } > > // { dg-require-weak } > > -// { dg-additional-options "-fno-rtti -nodefaultlibs -lc" } > > +// { dg-additional-options "-fno-rtti -nolibstdc++" } > > // { dg-additional-options "-Wl,-undefined,dynamic_lookup" { target *-*-darwin* } } > > // { dg-xfail-if "AIX weak" { powerpc-ibm-aix* } } > > > > > > -- > > Alexandre Oliva, happy hacker https://FSFLA.org/blogs/lxo/ > > Free Software Activist GNU Toolchain Engineer > > Disinformation flourishes because many people care deeply about injustice > > but very few check the facts. Ask me about <https://stallmansupport.org>
On Tue, Jun 21, 2022 at 9:53 AM Fangrui Song <maskray@google.com> wrote: > > On Tue, Jun 21, 2022 at 1:43 AM Richard Biener via Gcc-patches > <gcc-patches@gcc.gnu.org> wrote: > > > > On Tue, Jun 21, 2022 at 7:56 AM Alexandre Oliva via Gcc-patches > > <gcc-patches@gcc.gnu.org> wrote: > > > > > > > > > Using g++ to link without libstdc++, as in g++.dg/abi/pure-virtual1.C, > > > is error prone, because there's no way to tell g++ to drop libstdc++ > > > without also dropping libc and any other libraries that the target > > > implicitly links in. > > > > > > This has often led to the need for manual adjustments to this > > > testcase. > > > > > > I figured adding support for -nolibstdc++, even though redundant, > > > makes some sense. One could presumably use gcc rather than g++ for > > > linking, for the same effect, but sometimes changing the link command > > > is harder than adding an option, as in our testsuite. > > > > > > Regstrapped on x86_64-linux-gnu, also tested with a cross to > > > aarch64-rtems6. Ok to install? > > > > OK in case nobody objects in 24h. > > > > Richard. > > Is this similar to clang -nostdlib++ ? > When libstdc++ is selected, clang -nostdlib++ removes -lstdc++. Probably. Note that we have -static-libstdc++ already so -nolibstdc++ matches that. We also have -nolibc, not -noclib. Richard. > > > > > > for gcc/ChangeLog > > > > > > * common.opt (nolibstdc++): New. > > > * doc/invoke.texi (-nolibstdc++): Document it. > > > > > > for gcc/cp/ChangeLog > > > > > > * g++spec.c (lang_specific_driver): Implement -nolibstdc++. > > > > > > for gcc/testsuite/ChangeLog > > > > > > * g++.dg/abi/pure-virtual1.C: Use -nolibstdc++. > > > --- > > > gcc/common.opt | 3 +++ > > > gcc/cp/g++spec.cc | 1 + > > > gcc/doc/invoke.texi | 6 +++++- > > > gcc/testsuite/g++.dg/abi/pure-virtual1.C | 2 +- > > > 4 files changed, 10 insertions(+), 2 deletions(-) > > > > > > diff --git a/gcc/common.opt b/gcc/common.opt > > > index 32917aafcaec1..e00c6fc2fb098 100644 > > > --- a/gcc/common.opt > > > +++ b/gcc/common.opt > > > @@ -3456,6 +3456,9 @@ Driver > > > nolibc > > > Driver > > > > > > +nolibstdc++ > > > +Driver > > > + > > > nostdlib > > > Driver > > > > > > diff --git a/gcc/cp/g++spec.cc b/gcc/cp/g++spec.cc > > > index 8174d652776b1..539e6ca089d85 100644 > > > --- a/gcc/cp/g++spec.cc > > > +++ b/gcc/cp/g++spec.cc > > > @@ -160,6 +160,7 @@ lang_specific_driver (struct cl_decoded_option **in_decoded_options, > > > { > > > case OPT_nostdlib: > > > case OPT_nodefaultlibs: > > > + case OPT_nolibstdc__: > > > library = -1; > > > break; > > > > > > diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi > > > index 50f57877477bc..469b6d97e0dfa 100644 > > > --- a/gcc/doc/invoke.texi > > > +++ b/gcc/doc/invoke.texi > > > @@ -652,7 +652,7 @@ Objective-C and Objective-C++ Dialects}. > > > @item Linker Options > > > @xref{Link Options,,Options for Linking}. > > > @gccoptlist{@var{object-file-name} -fuse-ld=@var{linker} -l@var{library} @gol > > > --nostartfiles -nodefaultlibs -nolibc -nostdlib @gol > > > +-nostartfiles -nodefaultlibs -nolibc -nolibstdc++ -nostdlib @gol > > > -e @var{entry} --entry=@var{entry} @gol > > > -pie -pthread -r -rdynamic @gol > > > -s -static -static-pie -static-libgcc -static-libstdc++ @gol > > > @@ -16787,6 +16787,10 @@ absence of a C library is assumed, for example @option{-lpthread} or > > > @option{-lm} in some configurations. This is intended for bare-board > > > targets when there is indeed no C library available. > > > > > > +@item -nolibstdc++ > > > +@opindex nolibstdc++ > > > +Do not link with standard C++ libraries implicitly. > > > + > > > @item -nostdlib > > > @opindex nostdlib > > > Do not use the standard system startup files or libraries when linking. > > > diff --git a/gcc/testsuite/g++.dg/abi/pure-virtual1.C b/gcc/testsuite/g++.dg/abi/pure-virtual1.C > > > index 538e2cb097a0d..889c33e4952f4 100644 > > > --- a/gcc/testsuite/g++.dg/abi/pure-virtual1.C > > > +++ b/gcc/testsuite/g++.dg/abi/pure-virtual1.C > > > @@ -1,7 +1,7 @@ > > > // Test that we don't need libsupc++ just for __cxa_pure_virtual. > > > // { dg-do link } > > > // { dg-require-weak } > > > -// { dg-additional-options "-fno-rtti -nodefaultlibs -lc" } > > > +// { dg-additional-options "-fno-rtti -nolibstdc++" } > > > // { dg-additional-options "-Wl,-undefined,dynamic_lookup" { target *-*-darwin* } } > > > // { dg-xfail-if "AIX weak" { powerpc-ibm-aix* } } > > > > > > > > > -- > > > Alexandre Oliva, happy hacker https://FSFLA.org/blogs/lxo/ > > > Free Software Activist GNU Toolchain Engineer > > > Disinformation flourishes because many people care deeply about injustice > > > but very few check the facts. Ask me about <https://stallmansupport.org>
On 2022-06-21, Richard Biener wrote: >On Tue, Jun 21, 2022 at 9:53 AM Fangrui Song <maskray@google.com> wrote: >> >> On Tue, Jun 21, 2022 at 1:43 AM Richard Biener via Gcc-patches >> <gcc-patches@gcc.gnu.org> wrote: >> > >> > On Tue, Jun 21, 2022 at 7:56 AM Alexandre Oliva via Gcc-patches >> > <gcc-patches@gcc.gnu.org> wrote: >> > > >> > > >> > > Using g++ to link without libstdc++, as in g++.dg/abi/pure-virtual1.C, >> > > is error prone, because there's no way to tell g++ to drop libstdc++ >> > > without also dropping libc and any other libraries that the target >> > > implicitly links in. >> > > >> > > This has often led to the need for manual adjustments to this >> > > testcase. >> > > >> > > I figured adding support for -nolibstdc++, even though redundant, >> > > makes some sense. One could presumably use gcc rather than g++ for >> > > linking, for the same effect, but sometimes changing the link command >> > > is harder than adding an option, as in our testsuite. >> > > >> > > Regstrapped on x86_64-linux-gnu, also tested with a cross to >> > > aarch64-rtems6. Ok to install? >> > >> > OK in case nobody objects in 24h. >> > >> > Richard. >> >> Is this similar to clang -nostdlib++ ? >> When libstdc++ is selected, clang -nostdlib++ removes -lstdc++. > >Probably. Note that we have -static-libstdc++ already so >-nolibstdc++ matches that. We also have -nolibc, not -noclib. > >Richard. I think the relation between -static-foo and -nofoo is not that large. -nostdlib does not have a corresponding -static-stdlib. Note that gcc has supported -stdlib=libc++ since 2020-12, though the usage is a bit tricky. Having a C++ standard library agnostic name helps libc++:) For -lc, clang has -nolibc. >> > > >> > > for gcc/ChangeLog >> > > >> > > * common.opt (nolibstdc++): New. >> > > * doc/invoke.texi (-nolibstdc++): Document it. >> > > >> > > for gcc/cp/ChangeLog >> > > >> > > * g++spec.c (lang_specific_driver): Implement -nolibstdc++. >> > > >> > > for gcc/testsuite/ChangeLog >> > > >> > > * g++.dg/abi/pure-virtual1.C: Use -nolibstdc++. >> > > --- >> > > gcc/common.opt | 3 +++ >> > > gcc/cp/g++spec.cc | 1 + >> > > gcc/doc/invoke.texi | 6 +++++- >> > > gcc/testsuite/g++.dg/abi/pure-virtual1.C | 2 +- >> > > 4 files changed, 10 insertions(+), 2 deletions(-) >> > > >> > > diff --git a/gcc/common.opt b/gcc/common.opt >> > > index 32917aafcaec1..e00c6fc2fb098 100644 >> > > --- a/gcc/common.opt >> > > +++ b/gcc/common.opt >> > > @@ -3456,6 +3456,9 @@ Driver >> > > nolibc >> > > Driver >> > > >> > > +nolibstdc++ >> > > +Driver >> > > + >> > > nostdlib >> > > Driver >> > > >> > > diff --git a/gcc/cp/g++spec.cc b/gcc/cp/g++spec.cc >> > > index 8174d652776b1..539e6ca089d85 100644 >> > > --- a/gcc/cp/g++spec.cc >> > > +++ b/gcc/cp/g++spec.cc >> > > @@ -160,6 +160,7 @@ lang_specific_driver (struct cl_decoded_option **in_decoded_options, >> > > { >> > > case OPT_nostdlib: >> > > case OPT_nodefaultlibs: >> > > + case OPT_nolibstdc__: >> > > library = -1; >> > > break; >> > > >> > > diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi >> > > index 50f57877477bc..469b6d97e0dfa 100644 >> > > --- a/gcc/doc/invoke.texi >> > > +++ b/gcc/doc/invoke.texi >> > > @@ -652,7 +652,7 @@ Objective-C and Objective-C++ Dialects}. >> > > @item Linker Options >> > > @xref{Link Options,,Options for Linking}. >> > > @gccoptlist{@var{object-file-name} -fuse-ld=@var{linker} -l@var{library} @gol >> > > --nostartfiles -nodefaultlibs -nolibc -nostdlib @gol >> > > +-nostartfiles -nodefaultlibs -nolibc -nolibstdc++ -nostdlib @gol >> > > -e @var{entry} --entry=@var{entry} @gol >> > > -pie -pthread -r -rdynamic @gol >> > > -s -static -static-pie -static-libgcc -static-libstdc++ @gol >> > > @@ -16787,6 +16787,10 @@ absence of a C library is assumed, for example @option{-lpthread} or >> > > @option{-lm} in some configurations. This is intended for bare-board >> > > targets when there is indeed no C library available. >> > > >> > > +@item -nolibstdc++ >> > > +@opindex nolibstdc++ >> > > +Do not link with standard C++ libraries implicitly. >> > > + >> > > @item -nostdlib >> > > @opindex nostdlib >> > > Do not use the standard system startup files or libraries when linking. >> > > diff --git a/gcc/testsuite/g++.dg/abi/pure-virtual1.C b/gcc/testsuite/g++.dg/abi/pure-virtual1.C >> > > index 538e2cb097a0d..889c33e4952f4 100644 >> > > --- a/gcc/testsuite/g++.dg/abi/pure-virtual1.C >> > > +++ b/gcc/testsuite/g++.dg/abi/pure-virtual1.C >> > > @@ -1,7 +1,7 @@ >> > > // Test that we don't need libsupc++ just for __cxa_pure_virtual. >> > > // { dg-do link } >> > > // { dg-require-weak } >> > > -// { dg-additional-options "-fno-rtti -nodefaultlibs -lc" } >> > > +// { dg-additional-options "-fno-rtti -nolibstdc++" } >> > > // { dg-additional-options "-Wl,-undefined,dynamic_lookup" { target *-*-darwin* } } >> > > // { dg-xfail-if "AIX weak" { powerpc-ibm-aix* } } >> > > >> > > >> > > -- >> > > Alexandre Oliva, happy hacker https://FSFLA.org/blogs/lxo/ >> > > Free Software Activist GNU Toolchain Engineer >> > > Disinformation flourishes because many people care deeply about injustice >> > > but very few check the facts. Ask me about <https://stallmansupport.org>
On Jun 21, 2022, Fangrui Song <maskray@google.com> wrote: > Is this similar to clang -nostdlib++ ? > When libstdc++ is selected, clang -nostdlib++ removes -lstdc++. Sounds like they're the same indeed, but the clang option you mention makes little sense to me, so I'd rather to introduce the one that does. If someone feels offering this option with the same spelling as clang, it's easy enough to add a synonym. Now, if others feel we'd be better off following clang's practices, I don't mind adjusting the patch to use the same spelling. It's not like this option is going to have much use one way or another, aside from this testcase.
> On 22 Jun 2022, at 01:36, Alexandre Oliva via Gcc-patches <gcc-patches@gcc.gnu.org> wrote: > > On Jun 21, 2022, Fangrui Song <maskray@google.com> wrote: > >> Is this similar to clang -nostdlib++ ? >> When libstdc++ is selected, clang -nostdlib++ removes -lstdc++. > > Sounds like they're the same indeed, but the clang option you mention > makes little sense to me, so I'd rather to introduce the one that does. > If someone feels offering this option with the same spelling as clang, > it's easy enough to add a synonym. Now, if others feel we'd be better > off following clang's practices, I don't mind adjusting the patch to use > the same spelling. It's not like this option is going to have much use > one way or another, aside from this testcase. we have nostdlib, nodefaultlibs (which also omit the C++ libs) It makes some sense to have the option named -nostdlib++ if a target might add multiple libs (and/or make other changes) for linking C++. (so, fo example, if libstdc++ were separate from libsupc++ I would expect your use-case to wish to exclude both, not just libstdc++)? From the PoV of users and build systems, it’s also helpful to avoid proliferating option names unless there’s some clear distinction in function between compilers - if GCC already has an option spelling, usually clang would follow that - it does not seem unreasonable to reciprocate. 0.02GBP only, of course, Iain > > -- > Alexandre Oliva, happy hacker https://FSFLA.org/blogs/lxo/ > Free Software Activist GNU Toolchain Engineer > Disinformation flourishes because many people care deeply about injustice > but very few check the facts. Ask me about <https://stallmansupport.org>
On Jun 22, 2022, Iain Sandoe <idsandoe@googlemail.com> wrote: > It makes some sense to have the option named -nostdlib++ if a target > might add multiple libs (and/or make other changes) for linking C++. if it was nostdlibc++, I'd agree. lib++ is not something that brings C++ to (my) mind. > (so, fo example, if libstdc++ were separate from libsupc++ I would > expect your use-case to wish to exclude both, not just libstdc++)? That's what the testcase requires, yes. IIRC there's another that would benefit from the ability to link with libsupc++, but not with libstdc++. > if GCC already has an option spelling, usually clang would follow that > - it does not seem unreasonable to reciprocate. Yeah, I suppose that makes sense, it's beneficial for users to avoid the cognitive overload of dealing with equivalent options with different spellings. I'll swallow my dislike for the spelling and change the patch to use -nostdlib++.
On Wed, Jun 22, 2022 at 4:29 PM Alexandre Oliva <oliva@adacore.com> wrote: > > On Jun 22, 2022, Iain Sandoe <idsandoe@googlemail.com> wrote: > > > It makes some sense to have the option named -nostdlib++ if a target > > might add multiple libs (and/or make other changes) for linking C++. > > if it was nostdlibc++, I'd agree. lib++ is not something that brings > C++ to (my) mind. Agree that clang --stdlib= and -nostdlib++ probably should be better named. There are many standard libraries and "stdlib" as a name isn't tied to C++ much. That said, --stdlib= has a very long history and seems not so necessary to change now. For new Clang driver options (I subscribe to clang/lib/Driver files to try catching up the change), I try to keep an eye on and for something useful which may be matched by GCC, I'll notify some GCC folks I know (e.g. Nathan, Martin). > > (so, fo example, if libstdc++ were separate from libsupc++ I would > > expect your use-case to wish to exclude both, not just libstdc++)? > > That's what the testcase requires, yes. IIRC there's another that would > benefit from the ability to link with libsupc++, but not with libstdc++. > > > if GCC already has an option spelling, usually clang would follow that > > - it does not seem unreasonable to reciprocate. Thanks. > Yeah, I suppose that makes sense, it's beneficial for users to avoid the > cognitive overload of dealing with equivalent options with different > spellings. I'll swallow my dislike for the spelling and change the > patch to use -nostdlib++. Thanks:) BTW: even if -static-libstdc++ is a bit of misnomer when a clang user uses libc++, since -static-libc++ or -static-stdlib does not exist, they are still using -static-libstdc++. > -- > Alexandre Oliva, happy hacker https://FSFLA.org/blogs/lxo/ > Free Software Activist GNU Toolchain Engineer > Disinformation flourishes because many people care deeply about injustice > but very few check the facts. Ask me about <https://stallmansupport.org>
On Jun 22, 2022, Alexandre Oliva <oliva@adacore.com> wrote: > Yeah, I suppose that makes sense, it's beneficial for users to avoid the > cognitive overload of dealing with equivalent options with different > spellings. I'll swallow my dislike for the spelling and change the > patch to use -nostdlib++. Here's the patch. Regstrapped on x86_64-linux-gnu, also tested with a cross to aarch64-rtems6. Ok to install? Introduce -nostdlib++ option Using g++ to link without libstdc++, as in g++.dg/abi/pure-virtual1.C, is error prone, because there's no way to tell g++ to drop libstdc++ without also dropping libc and any other libraries that the target implicitly links in. This has often led to the need for manual adjustments to this testcase. I figured adding support for -nostdlib++, even though redundant, makes some sense. One could presumably use gcc rather than g++ for linking, for the same effect, but sometimes changing the link command is harder than adding an option, as in our testsuite. Since clang already had an option with this effect, we've adopted the same spelling. for gcc/ChangeLog * common.opt (nostdlib++): New. * doc/invoke.texi (-nostdlib++): Document it. for gcc/cp/ChangeLog * g++spec.cc (lang_specific_driver): Implement -nostdlib++. for gcc/testsuite/ChangeLog * g++.dg/abi/pure-virtual1.C: Use -nostdlib++. --- gcc/common.opt | 3 +++ gcc/cp/g++spec.cc | 1 + gcc/doc/invoke.texi | 6 +++++- gcc/testsuite/g++.dg/abi/pure-virtual1.C | 2 +- 4 files changed, 10 insertions(+), 2 deletions(-) diff --git a/gcc/common.opt b/gcc/common.opt index 32917aafcaec1..0845e083247af 100644 --- a/gcc/common.opt +++ b/gcc/common.opt @@ -3459,6 +3459,9 @@ Driver nostdlib Driver +nostdlib++ +Driver + o Common Driver Joined Separate Var(asm_file_name) MissingArgError(missing filename after %qs) -o <file> Place output into <file>. diff --git a/gcc/cp/g++spec.cc b/gcc/cp/g++spec.cc index 8174d652776b1..b63d8350ba113 100644 --- a/gcc/cp/g++spec.cc +++ b/gcc/cp/g++spec.cc @@ -159,6 +159,7 @@ lang_specific_driver (struct cl_decoded_option **in_decoded_options, switch (decoded_options[i].opt_index) { case OPT_nostdlib: + case OPT_nostdlib__: case OPT_nodefaultlibs: library = -1; break; diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index fb506364702b7..a7ab29335c84a 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -652,7 +652,7 @@ Objective-C and Objective-C++ Dialects}. @item Linker Options @xref{Link Options,,Options for Linking}. @gccoptlist{@var{object-file-name} -fuse-ld=@var{linker} -l@var{library} @gol --nostartfiles -nodefaultlibs -nolibc -nostdlib @gol +-nostartfiles -nodefaultlibs -nolibc -nostdlib -nostdlib++ @gol -e @var{entry} --entry=@var{entry} @gol -pie -pthread -r -rdynamic @gol -s -static -static-pie -static-libgcc -static-libstdc++ @gol @@ -16822,6 +16822,10 @@ library subroutines. constructors are called; @pxref{Collect2,,@code{collect2}, gccint, GNU Compiler Collection (GCC) Internals}.) +@item -nostdlib++ +@opindex nostdlib++ +Do not implicitly link with standard C++ libraries. + @item -e @var{entry} @itemx --entry=@var{entry} @opindex e diff --git a/gcc/testsuite/g++.dg/abi/pure-virtual1.C b/gcc/testsuite/g++.dg/abi/pure-virtual1.C index 538e2cb097a0d..59eaf22562049 100644 --- a/gcc/testsuite/g++.dg/abi/pure-virtual1.C +++ b/gcc/testsuite/g++.dg/abi/pure-virtual1.C @@ -1,7 +1,7 @@ // Test that we don't need libsupc++ just for __cxa_pure_virtual. // { dg-do link } // { dg-require-weak } -// { dg-additional-options "-fno-rtti -nodefaultlibs -lc" } +// { dg-additional-options "-fno-rtti -nostdlib++" } // { dg-additional-options "-Wl,-undefined,dynamic_lookup" { target *-*-darwin* } } // { dg-xfail-if "AIX weak" { powerpc-ibm-aix* } }
On Jun 23, 2022, Alexandre Oliva <oliva@adacore.com> wrote: > Here's the patch. Regstrapped on x86_64-linux-gnu, also tested with a > cross to aarch64-rtems6. Ok to install? > Introduce -nostdlib++ option Uhh, I went ahead and installed this. The earlier patch was approved if nobody objected, and so, having overcome the objection to the option spelling, it ended up in my "approved" patchset. In case there are objections to it, please let me know, and I'll revert it promptly, but I guess it makes little sense to revert it on the odd change that someone does. Thanks for your understanding.
On 6/24/22 01:23, Alexandre Oliva via Gcc-patches wrote: > On Jun 23, 2022, Alexandre Oliva <oliva@adacore.com> wrote: > >> Here's the patch. Regstrapped on x86_64-linux-gnu, also tested with a >> cross to aarch64-rtems6. Ok to install? > >> Introduce -nostdlib++ option > > Uhh, I went ahead and installed this. The earlier patch was approved if > nobody objected, and so, having overcome the objection to the option > spelling, it ended up in my "approved" patchset. > > In case there are objections to it, please let me know, and I'll revert > it promptly, but I guess it makes little sense to revert it on the odd > change that someone does. Thanks for your understanding. I'm getting failures from pure-virtual1.C with xg++: error: unrecognized command-line option '-nostdlib++' I guess that's because it isn't handled by the specs in the way nostdlib and nodefautlibs are. Maybe the solution is to set SKIPOPT in the driver? Are you not seeing this problem?
On 9/16/22 07:52, Jason Merrill wrote: > On 6/24/22 01:23, Alexandre Oliva via Gcc-patches wrote: >> On Jun 23, 2022, Alexandre Oliva <oliva@adacore.com> wrote: >> >>> Here's the patch. Regstrapped on x86_64-linux-gnu, also tested with a >>> cross to aarch64-rtems6. Ok to install? >> >>> Introduce -nostdlib++ option >> >> Uhh, I went ahead and installed this. The earlier patch was approved if >> nobody objected, and so, having overcome the objection to the option >> spelling, it ended up in my "approved" patchset. >> >> In case there are objections to it, please let me know, and I'll revert >> it promptly, but I guess it makes little sense to revert it on the odd >> change that someone does. Thanks for your understanding. > > I'm getting failures from pure-virtual1.C with > > xg++: error: unrecognized command-line option '-nostdlib++' > > I guess that's because it isn't handled by the specs in the way nostdlib > and nodefautlibs are. Maybe the solution is to set SKIPOPT in the driver? > > Are you not seeing this problem? Now of course I notice that it's been months since you installed the patch, I wonder what broke it...
On 9/16/22 07:52, Jason Merrill wrote: > On 6/24/22 01:23, Alexandre Oliva via Gcc-patches wrote: >> On Jun 23, 2022, Alexandre Oliva <oliva@adacore.com> wrote: >> >>> Here's the patch. Regstrapped on x86_64-linux-gnu, also tested with a >>> cross to aarch64-rtems6. Ok to install? >> >>> Introduce -nostdlib++ option >> >> Uhh, I went ahead and installed this. The earlier patch was approved if >> nobody objected, and so, having overcome the objection to the option >> spelling, it ended up in my "approved" patchset. >> >> In case there are objections to it, please let me know, and I'll revert >> it promptly, but I guess it makes little sense to revert it on the odd >> change that someone does. Thanks for your understanding. > > I'm getting failures from pure-virtual1.C with > > xg++: error: unrecognized command-line option '-nostdlib++' > > I guess that's because it isn't handled by the specs in the way nostdlib > and nodefautlibs are. Maybe the solution is to set SKIPOPT in the driver? > > Are you not seeing this problem? I started seeing this again and decided to track it down more. It seems to be dependent on specs, as explained in this commit message:
On Thu, 23 Jun 2022, Alexandre Oliva via Gcc-patches wrote: > Introduce -nostdlib++ option > > Using g++ to link without libstdc++, as in g++.dg/abi/pure-virtual1.C, > is error prone, because there's no way to tell g++ to drop libstdc++ > without also dropping libc and any other libraries that the target > implicitly links in. % grep -r nostdlib $WWWDOCS % Should this be documented in gcc-13/changes.html? Would you mind proposing a snippet (or going ahead and pushing it)? Gerald
Hello, Gerald, On Feb 11, 2023, Gerald Pfeifer <gerald@pfeifer.com> wrote: > On Thu, 23 Jun 2022, Alexandre Oliva via Gcc-patches wrote: >> Introduce -nostdlib++ option >> >> Using g++ to link without libstdc++, as in g++.dg/abi/pure-virtual1.C, >> is error prone, because there's no way to tell g++ to drop libstdc++ >> without also dropping libc and any other libraries that the target >> implicitly links in. > % grep -r nostdlib $WWWDOCS > % > Should this be documented in gcc-13/changes.html? Would you mind proposing > a snippet (or going ahead and pushing it)? I can't make my mind up about this. At first, the goal of adding the option was just to aid this specific test. But then, it transpired that other compilers offered a similar option, with the spelling that we ended up using, so perhaps it would make sense to document it, after all. How about this, does this seem useful? diff --git a/htdocs/gcc-13/changes.html b/htdocs/gcc-13/changes.html index ff70d2eefecec..c1bbbfa28e18e 100644 --- a/htdocs/gcc-13/changes.html +++ b/htdocs/gcc-13/changes.html @@ -333,6 +333,9 @@ a work-in-progress.</p> <li>The <a href="https://gcc.gnu.org/onlinedocs/gcc/C_002b_002b-Dialect-Options.html#index-Wpessimizing-move"><code>-Wpessimizing-move</code></a> and <a href="https://gcc.gnu.org/onlinedocs/gcc/C_002b_002b-Dialect-Options.html#index-Wredundant-move"><code>-Wredundant-move</code></a> warnings have been extended to warn in more contexts.</li> + <li>The <a href="https://gcc.gnu.org/onlinedocs/gcc/Link_Options.html#index-nostdlib_002b_002b"><code>-nostdlib++</code></a> + option has been added, to enable linking with <code>g++</code> + without implicitly linking in the C++ standard library.</li> </ul> <h4 id="libstdcxx">Runtime Library (libstdc++)</h4>
Hi Alexandre, Alexandre Oliva via Gcc-patches <gcc-patches@gcc.gnu.org> writes: > Hello, Gerald, > > On Feb 11, 2023, Gerald Pfeifer <gerald@pfeifer.com> wrote: > >> On Thu, 23 Jun 2022, Alexandre Oliva via Gcc-patches wrote: >>> Introduce -nostdlib++ option >>> >>> Using g++ to link without libstdc++, as in g++.dg/abi/pure-virtual1.C, >>> is error prone, because there's no way to tell g++ to drop libstdc++ >>> without also dropping libc and any other libraries that the target >>> implicitly links in. > >> % grep -r nostdlib $WWWDOCS >> % > >> Should this be documented in gcc-13/changes.html? Would you mind proposing >> a snippet (or going ahead and pushing it)? > > I can't make my mind up about this. > > At first, the goal of adding the option was just to aid this specific > test. But then, it transpired that other compilers offered a similar > option, with the spelling that we ended up using, so perhaps it would > make sense to document it, after all. IMO, yes - in fact, the libstdc++ manual even has a use-case for this (freestanding when the compiler is *not* built with libstdc++ in freestanding mode) and documents using the gcc driver rather than the g++ one. See libstdc++-v3/doc/xml/manual/using.xml: If you're using a libstdc++ configured for hosted environments, and would like to not involve the libraries libstdc++ would depend on in your programs, you will need to use <command>gcc</command> to link your application with only <filename class="libraryfile">libsupc++.a</filename>, like so: If you think the flag you added fits here, would you mind also including this file in your patch? Note that this flag is only applicable here if MATH_LIBRARY is omitted but libsupc++.a is kept on the linker command line (apologies for not checking ahead of writing this email - I'm not currently in a convenient spot to do so). Thanks in advance, have a lovely day. > How about this, does this seem useful? > > diff --git a/htdocs/gcc-13/changes.html b/htdocs/gcc-13/changes.html > index ff70d2eefecec..c1bbbfa28e18e 100644 > --- a/htdocs/gcc-13/changes.html > +++ b/htdocs/gcc-13/changes.html > @@ -333,6 +333,9 @@ a work-in-progress.</p> > <li>The <a href="https://gcc.gnu.org/onlinedocs/gcc/C_002b_002b-Dialect-Options.html#index-Wpessimizing-move"><code>-Wpessimizing-move</code></a> > and <a href="https://gcc.gnu.org/onlinedocs/gcc/C_002b_002b-Dialect-Options.html#index-Wredundant-move"><code>-Wredundant-move</code></a> > warnings have been extended to warn in more contexts.</li> > + <li>The <a href="https://gcc.gnu.org/onlinedocs/gcc/Link_Options.html#index-nostdlib_002b_002b"><code>-nostdlib++</code></a> > + option has been added, to enable linking with <code>g++</code> > + without implicitly linking in the C++ standard library.</li> > </ul> > > <h4 id="libstdcxx">Runtime Library (libstdc++)</h4>
On Thu, 30 Mar 2023, Alexandre Oliva wrote:
> How about this, does this seem useful?
I like it - helpful and easy to understand. :-)
Gerald
On Mar 30, 2023, Gerald Pfeifer <gerald@pfeifer.com> wrote: > On Thu, 30 Mar 2023, Alexandre Oliva wrote: >> How about this, does this seem useful? > I like it - helpful and easy to understand. :-) 'k, I'm putting it in, thanks On Mar 30, 2023, Arsen Arsenović <arsen@aarsen.me> wrote: > IMO, yes - in fact, the libstdc++ manual even has a use-case for this Yeah, and it also had the means to accomplish that already. -nostdlib++ was for the testsuite, that always uses g++ for linking C++ tests. I suppose libstdc++ now has an alternative it might consider switching to, namely using g++ -nostdlib++ rather than gcc to link itself, but should it? I don't see the upside. Its build process is not broken, it's not even inconvenient, so what's the expected benefit that the change would bring about? As for downsides, I perceive risks of build scripts (e.g. libtool)'s not yet having support for -nostdlib++, and thus trying to use the flag could break rather than improve the state of affairs. It feels like inviting trouble to me. > If you think the flag you added fits here, would you mind also including > this file in your patch? The patch was for the online release documentation, it's not even the same repository as libstdc++, so there's no way to add it to the same patch. Given that, and since I'm not so sure I understand what change you're suggesting to libstdc++'s manual or build procedures, how about you give it a shot yourself?
diff --git a/gcc/common.opt b/gcc/common.opt index 32917aafcaec1..e00c6fc2fb098 100644 --- a/gcc/common.opt +++ b/gcc/common.opt @@ -3456,6 +3456,9 @@ Driver nolibc Driver +nolibstdc++ +Driver + nostdlib Driver diff --git a/gcc/cp/g++spec.cc b/gcc/cp/g++spec.cc index 8174d652776b1..539e6ca089d85 100644 --- a/gcc/cp/g++spec.cc +++ b/gcc/cp/g++spec.cc @@ -160,6 +160,7 @@ lang_specific_driver (struct cl_decoded_option **in_decoded_options, { case OPT_nostdlib: case OPT_nodefaultlibs: + case OPT_nolibstdc__: library = -1; break; diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index 50f57877477bc..469b6d97e0dfa 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -652,7 +652,7 @@ Objective-C and Objective-C++ Dialects}. @item Linker Options @xref{Link Options,,Options for Linking}. @gccoptlist{@var{object-file-name} -fuse-ld=@var{linker} -l@var{library} @gol --nostartfiles -nodefaultlibs -nolibc -nostdlib @gol +-nostartfiles -nodefaultlibs -nolibc -nolibstdc++ -nostdlib @gol -e @var{entry} --entry=@var{entry} @gol -pie -pthread -r -rdynamic @gol -s -static -static-pie -static-libgcc -static-libstdc++ @gol @@ -16787,6 +16787,10 @@ absence of a C library is assumed, for example @option{-lpthread} or @option{-lm} in some configurations. This is intended for bare-board targets when there is indeed no C library available. +@item -nolibstdc++ +@opindex nolibstdc++ +Do not link with standard C++ libraries implicitly. + @item -nostdlib @opindex nostdlib Do not use the standard system startup files or libraries when linking. diff --git a/gcc/testsuite/g++.dg/abi/pure-virtual1.C b/gcc/testsuite/g++.dg/abi/pure-virtual1.C index 538e2cb097a0d..889c33e4952f4 100644 --- a/gcc/testsuite/g++.dg/abi/pure-virtual1.C +++ b/gcc/testsuite/g++.dg/abi/pure-virtual1.C @@ -1,7 +1,7 @@ // Test that we don't need libsupc++ just for __cxa_pure_virtual. // { dg-do link } // { dg-require-weak } -// { dg-additional-options "-fno-rtti -nodefaultlibs -lc" } +// { dg-additional-options "-fno-rtti -nolibstdc++" } // { dg-additional-options "-Wl,-undefined,dynamic_lookup" { target *-*-darwin* } } // { dg-xfail-if "AIX weak" { powerpc-ibm-aix* } }