From: Thomas Schwinge <tho...@codesourcery.com>

..., so that users don't manually need to specify '-foffload-options=-lstdc++'
in addition to '-lstdc++' (specified manually, or implicitly by the driver).
Do like commit 4bcb46b3ade1796c5a57b294f5cca25f00671cac
"driver: Forward '-lgfortran', '-lm' to offloading compilation".

        PR driver/101544
        gcc/
        * gcc.cc (driver_handle_option): Forward host '-lstdc++' to
        offloading compilation.
        * config/gcn/mkoffload.cc (main): Adjust.
        * config/nvptx/mkoffload.cc (main): Likewise.
        libgomp/
        * testsuite/libgomp.c++/pr101544-1-O0.C: Remove
        '-foffload-options=-lstdc++'.
        * testsuite/libgomp.c++/pr101544-1.C: Likewise.
        * testsuite/libgomp.oacc-c++/pr101544-1.C: Likewise.
---
 gcc/config/gcn/mkoffload.cc                     | 3 ++-
 gcc/config/nvptx/mkoffload.cc                   | 3 ++-
 gcc/gcc.cc                                      | 3 ++-
 libgomp/testsuite/libgomp.c++/pr101544-1-O0.C   | 1 -
 libgomp/testsuite/libgomp.c++/pr101544-1.C      | 1 -
 libgomp/testsuite/libgomp.oacc-c++/pr101544-1.C | 1 -
 6 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/gcc/config/gcn/mkoffload.cc b/gcc/config/gcn/mkoffload.cc
index fbd68a6cd8c9..f5b89c9fee7a 100644
--- a/gcc/config/gcn/mkoffload.cc
+++ b/gcc/config/gcn/mkoffload.cc
@@ -1070,7 +1070,8 @@ main (int argc, char **argv)
 #undef STR
       /* Translate host into offloading libraries.  */
       else if (strcmp (argv[i], "-l_GCC_gfortran") == 0
-              || strcmp (argv[i], "-l_GCC_m") == 0)
+              || strcmp (argv[i], "-l_GCC_m") == 0
+              || strcmp (argv[i], "-l_GCC_stdc++") == 0)
        {
          /* Elide '_GCC_'.  */
          size_t i_dst = strlen ("-l");
diff --git a/gcc/config/nvptx/mkoffload.cc b/gcc/config/nvptx/mkoffload.cc
index 958e16f3918e..bdfe7f58b166 100644
--- a/gcc/config/nvptx/mkoffload.cc
+++ b/gcc/config/nvptx/mkoffload.cc
@@ -741,7 +741,8 @@ main (int argc, char **argv)
        dumppfx = argv[++i];
       /* Translate host into offloading libraries.  */
       else if (strcmp (argv[i], "-l_GCC_gfortran") == 0
-              || strcmp (argv[i], "-l_GCC_m") == 0)
+              || strcmp (argv[i], "-l_GCC_m") == 0
+              || strcmp (argv[i], "-l_GCC_stdc++") == 0)
        {
          /* Elide '_GCC_'.  */
          size_t i_dst = strlen ("-l");
diff --git a/gcc/gcc.cc b/gcc/gcc.cc
index c7b2aa6df166..3edd21fb09e1 100644
--- a/gcc/gcc.cc
+++ b/gcc/gcc.cc
@@ -4154,7 +4154,8 @@ forward_offload_option (size_t opt_index, const char 
*arg, bool validated)
         are injected by default in offloading compilation, and therefore not
         forwarded here.  */
       /* GCC libraries.  */
-      if (/* '-lgfortran' */ strcmp (arg, "gfortran") == 0 )
+      if (/* '-lgfortran' */ strcmp (arg, "gfortran") == 0
+         || /* '-lstdc++' */ strcmp (arg, "stdc++") == 0)
        save_switch (concat ("-foffload-options=-l_GCC_", arg, NULL),
                     0, NULL, validated, true);
       /* Other libraries.  */
diff --git a/libgomp/testsuite/libgomp.c++/pr101544-1-O0.C 
b/libgomp/testsuite/libgomp.c++/pr101544-1-O0.C
index 19a8cad23286..c8a73dcfa19f 100644
--- a/libgomp/testsuite/libgomp.c++/pr101544-1-O0.C
+++ b/libgomp/testsuite/libgomp.c++/pr101544-1-O0.C
@@ -1,4 +1,3 @@
-// { dg-additional-options -foffload-options=-lstdc++ }
 // { dg-additional-options -O0 }
 
 #include "pr101544-1.C"
diff --git a/libgomp/testsuite/libgomp.c++/pr101544-1.C 
b/libgomp/testsuite/libgomp.c++/pr101544-1.C
index 8ea70a242bc5..fcd3e970bd89 100644
--- a/libgomp/testsuite/libgomp.c++/pr101544-1.C
+++ b/libgomp/testsuite/libgomp.c++/pr101544-1.C
@@ -1,4 +1,3 @@
-// { dg-additional-options -foffload-options=-lstdc++ }
 // See also '../libgomp.oacc-c++/pr101544-1.C'.
 #ifndef ALWAYS_INLINE
 # define ALWAYS_INLINE
diff --git a/libgomp/testsuite/libgomp.oacc-c++/pr101544-1.C 
b/libgomp/testsuite/libgomp.oacc-c++/pr101544-1.C
index 004cd49353be..d4d28a611597 100644
--- a/libgomp/testsuite/libgomp.oacc-c++/pr101544-1.C
+++ b/libgomp/testsuite/libgomp.oacc-c++/pr101544-1.C
@@ -1,4 +1,3 @@
-// { dg-additional-options -foffload-options=-lstdc++ }
 // { dg-additional-options -fno-inline } for stable results regarding OpenACC 
'routine'.
 // But actually, as none of the '#pragma acc routine' syntax is accepted, 
force inlining:
 #define ALWAYS_INLINE __attribute__((always_inline))
-- 
2.34.1

Reply via email to