]> 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>
Thu, 27 Mar 2025 08:53:17 +0000 (09:53 +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.

(cherry picked from commit 3b36e96b575b493a21510c877b273608113108ed)

gcc/ChangeLog.omp
gcc/config/gcn/mkoffload.cc
gcc/config/nvptx/mkoffload.cc
gcc/gcc.cc
libgomp/ChangeLog.omp
libgomp/testsuite/libgomp.c++/pr101544-1-O0.C
libgomp/testsuite/libgomp.c++/pr101544-1.C
libgomp/testsuite/libgomp.oacc-c++/pr101544-1.C

index d26fc33b9a093cc5a27e00c4079efe6311bf811c..7643b4610125384849886ef2143dd3ea02d0dba4 100644 (file)
@@ -1,3 +1,14 @@
+2025-03-27  Thomas Schwinge  <tschwinge@baylibre.com>
+
+       Backported from trunk:
+       2025-03-26  Thomas Schwinge  <thomas@codesourcery.com>
+
+       PR driver/101544
+       * gcc.cc (driver_handle_option): Forward host '-lstdc++' to
+       offloading compilation.
+       * config/gcn/mkoffload.cc (main): Adjust.
+       * config/nvptx/mkoffload.cc (main): Likewise.
+
 2025-03-25  Thomas Schwinge  <tschwinge@baylibre.com>
 
        Backported from trunk:
index 810298a799bf5bf33cf84352d2a67b043b175998..d80e15afe04fcf607e0eaddc2609fc6a59f99c05 100644 (file)
@@ -1043,7 +1043,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 19064deb622a67b431375bc0c7191c31cfca9a6a..57ca3becdc7ba12de7a6edee5a07be419e96b768 100644 (file)
@@ -742,7 +742,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 8690f15a8c9a18d26fe0a502a33c7a6ff33ed874..016f809a510f2cb91804c6aa18be635c9dcfd7e9 100644 (file)
@@ -4147,7 +4147,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 34f8f9f162f59e9e1016f2d005e2a3cd07958af8..16090224caca41c14175c37f5b19e2766935ee80 100644 (file)
@@ -1,4 +1,15 @@
-2025-03-25  Thomas Schwinge  <thomas@codesourcery.com>
+2025-03-27  Thomas Schwinge  <tschwinge@baylibre.com>
+
+       Backported from trunk:
+       2025-03-26  Thomas Schwinge  <thomas@codesourcery.com>
+
+       PR driver/101544
+       * 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.
+
+2025-03-25  Thomas Schwinge  <tschwinge@baylibre.com>
 
        Backported from trunk:
        2025-03-24  Thomas Schwinge  <tschwinge@baylibre.com>
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))