public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc(refs/users/aoliva/heads/testme)] Introduce -nostdlib++ option
@ 2022-06-23 14:02 Alexandre Oliva
  0 siblings, 0 replies; 2+ messages in thread
From: Alexandre Oliva @ 2022-06-23 14:02 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:2c2e064be5ebdc8e87cf2ebb7acc756174c9ccc0

commit 2c2e064be5ebdc8e87cf2ebb7acc756174c9ccc0
Author: Alexandre Oliva <oliva@adacore.com>
Date:   Mon Jun 20 19:44:23 2022 -0300

    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++.

Diff:
---
 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 32917aafcae..0845e083247 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 8174d652776..b63d8350ba1 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 fb506364702..a7ab29335c8 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 538e2cb097a..59eaf225620 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* } }


^ permalink raw reply	[flat|nested] 2+ messages in thread

* [gcc(refs/users/aoliva/heads/testme)] Introduce -nostdlib++ option
@ 2022-06-23  5:10 Alexandre Oliva
  0 siblings, 0 replies; 2+ messages in thread
From: Alexandre Oliva @ 2022-06-23  5:10 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:65b6495c0f6ec5caccdb153c16b53d83c1fc06d9

commit 65b6495c0f6ec5caccdb153c16b53d83c1fc06d9
Author: Alexandre Oliva <oliva@adacore.com>
Date:   Mon Jun 20 19:44:23 2022 -0300

    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++.

Diff:
---
 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 32917aafcae..0845e083247 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 8174d652776..b63d8350ba1 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 fb506364702..a7ab29335c8 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 538e2cb097a..59eaf225620 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* } }


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-06-23 14:02 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-23 14:02 [gcc(refs/users/aoliva/heads/testme)] Introduce -nostdlib++ option Alexandre Oliva
  -- strict thread matches above, loose matches on Subject: below --
2022-06-23  5:10 Alexandre Oliva

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).