]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
driver: Forward '-lstdc++' to offloading compilation [PR101544]
authorThomas Schwinge <thomas@codesourcery.com>
Tue, 19 Jul 2022 13:42:17 +0000 (15:42 +0200)
committerThomas Schwinge <tschwinge@baylibre.com>
Wed, 26 Mar 2025 13:20:20 +0000 (14:20 +0100)
..., 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
gcc/config/nvptx/mkoffload.cc
gcc/gcc.cc
libgomp/testsuite/libgomp.c++/pr101544-1-O0.C
libgomp/testsuite/libgomp.c++/pr101544-1.C
libgomp/testsuite/libgomp.oacc-c++/pr101544-1.C

index fbd68a6cd8c9cd491895f8313f52ea5d84b1c477..f5b89c9fee7ab66596a7f48cedcaad5daae84af1 100644 (file)
@@ -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");
index 958e16f3918e78107784fc7df5ee125d379f834c..bdfe7f58b166e268bd259f9c3c84e253bb0856a0 100644 (file)
@@ -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");
index c7b2aa6df166e57c958c0ff7f14a6f1d953d0bac..3edd21fb09e18bea48627db032c137e1f57125cd 100644 (file)
@@ -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.  */
index 19a8cad232866e7567f7417e0a3d6d9c85d5b8b4..c8a73dcfa19f8c8b4109a3cc04480c45df2aac91 100644 (file)
@@ -1,4 +1,3 @@
-// { dg-additional-options -foffload-options=-lstdc++ }
 // { dg-additional-options -O0 }
 
 #include "pr101544-1.C"
index 8ea70a242bc5ba13fab501c93d0f9fbbc417af65..fcd3e970bd89fddea50eed54036113f3d3143944 100644 (file)
@@ -1,4 +1,3 @@
-// { dg-additional-options -foffload-options=-lstdc++ }
 // See also '../libgomp.oacc-c++/pr101544-1.C'.
 #ifndef ALWAYS_INLINE
 # define ALWAYS_INLINE
index 004cd49353be24beabeac5e3df4f44cec382f241..d4d28a6115975170d59cdd466e651f8f4c9934f9 100644 (file)
@@ -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))