Hi Jakub,

>> +   { dg-output-file target-cdtor-2.output { xfail *-*-solaris2* } }
>
> This looks wrong to me, the original dg-output has different effective
> targets, but there is just one output file, so it will either fail
> for offload_device, or fail without that.

drats, I just blindly copied the Linux output into *.output, ignoring
the offload_device cases ;-(

Here's what I've done now: I use two output files, one without target
offload_device (xfail'ed on Solaris), one with it.  The offload_device
file doesn't need to care about Solaris: this case will never happen.

AFAICS we don't have to worry about different newline conventions:
dg-output-file resp. gcc-dg.exp's ${tool}_load use gets to read the
file, which discards newlines.  I'm uncertain if there can be multiple
newlines, though, which are allowed by the original patterns.

Here's the revised patch:

---------------------------------------------------------------------------

The libgomp.c++/target-cdtor-2.C test FAILs on Solaris:

FAIL: libgomp.c++/target-cdtor-2.C output pattern test

Compared to the Linux output

~S, 5, 1
[...]
finiDH1, 1

the Solaris output has a different order:

finiDH1, 1
[...]
~S, 5, 1

This is another instance of the long-standing PR c++/81337.  As detailed
there, the relative order of ~S::S() and __attribute__((destructor()))
functions isn't guaranteed.  Since xfail'ing the dg-output parts isn't
practical, this patch switches the test to using dg-output-file.  One
file is used in the ! offload_device case, the other for offload_device.

Tested on i386-pc-solaris2.11, x86_64-pc-linux-gnu, and
x86_64-apple-darwin25.1.0 (unsupported since there's no init_priority
support).

Ok for trunk?

        Rainer

-- 
-----------------------------------------------------------------------------
Rainer Orth, Center for Biotechnology, Bielefeld University


2025-12-16  Rainer Orth  <[email protected]>

        libgomp:
        PR c++/81337
        * testsuite/libgomp.c++/target-cdtor-2.output: New file.
        * testsuite/libgomp.c++/target-cdtor-2-output.output: New file.
        * testsuite/libgomp.c++/target-cdtor-2.C: Use them instead of
        dg-output.
        xfail target-cdtor-2.output on Solaris.

# HG changeset patch
# Parent  6393fdc4cb5f4a6d0ff2ac3e4ffad02b13664729
libgomp: xfail libgomp.c++/target-cdtor-2.C on Solaris [PR81337]

diff --git a/libgomp/testsuite/libgomp.c++/target-cdtor-2-offload.output b/libgomp/testsuite/libgomp.c++/target-cdtor-2-offload.output
new file mode 100644
--- /dev/null
+++ b/libgomp/testsuite/libgomp.c++/target-cdtor-2-offload.output
@@ -0,0 +1,26 @@
+S, 3, 1
+S, -1, 1
+S, -1, 1
+S, 7, 1
+S, 5, 1
+initH1, 1
+initDH1, 1
+main:1, 1
+S, -1, 0
+S, -1, 0
+S, 5, 0
+initDH1, 0
+main:2, 0
+main:3, 0
+main:4, 1
+~S, 5, 0
+~S, -1, 0
+~S, -1, 0
+finiDH1, 0
+~S, 5, 1
+~S, 7, 1
+~S, -1, 1
+~S, -1, 1
+~S, 3, 1
+finiDH1, 1
+finiH1, 1
diff --git a/libgomp/testsuite/libgomp.c++/target-cdtor-2.C b/libgomp/testsuite/libgomp.c++/target-cdtor-2.C
--- a/libgomp/testsuite/libgomp.c++/target-cdtor-2.C
+++ b/libgomp/testsuite/libgomp.c++/target-cdtor-2.C
@@ -114,32 +114,6 @@ int main()
 */
 
 /* Defined order in which 'constructor' functions, and 'destructor' functions are run, and C++ objects are constructed (..., and destructed in reverse order).
-   { dg-output {S, 3, 1[\r\n]+} }
-   { dg-output {S, -1, 1[\r\n]+} }
-   { dg-output {S, -1, 1[\r\n]+} }
-   { dg-output {S, 7, 1[\r\n]+} }
-   { dg-output {S, 5, 1[\r\n]+} }
-   { dg-output {initH1, 1[\r\n]+} }
-   { dg-output {initDH1, 1[\r\n]+} }
-   { dg-output {main:1, 1[\r\n]+} }
-   { dg-output {S, -1, 0[\r\n]+} { target offload_device } }
-   { dg-output {S, -1, 0[\r\n]+} { target offload_device } }
-   { dg-output {S, 5, 0[\r\n]+} { target offload_device } }
-   { dg-output {initDH1, 0[\r\n]+} { target offload_device } }
-   { dg-output {main:2, 1[\r\n]+} { target  { ! offload_device } } }
-   { dg-output {main:2, 0[\r\n]+} { target offload_device } }
-   { dg-output {main:3, 1[\r\n]+} { target { ! offload_device } } }
-   { dg-output {main:3, 0[\r\n]+} { target offload_device } }
-   { dg-output {main:4, 1[\r\n]+} }
-   { dg-output {~S, 5, 0[\r\n]+} { target offload_device } }
-   { dg-output {~S, -1, 0[\r\n]+} { target offload_device } }
-   { dg-output {~S, -1, 0[\r\n]+} { target offload_device } }
-   { dg-output {finiDH1, 0[\r\n]+} { target offload_device } }
-   { dg-output {~S, 5, 1[\r\n]+} }
-   { dg-output {~S, 7, 1[\r\n]+} }
-   { dg-output {~S, -1, 1[\r\n]+} }
-   { dg-output {~S, -1, 1[\r\n]+} }
-   { dg-output {~S, 3, 1[\r\n]+} }
-   { dg-output {finiDH1, 1[\r\n]+} }
-   { dg-output {finiH1, 1[\r\n]+} }
+   { dg-output-file target-cdtor-2.output { target { ! offload_device } xfail *-*-solaris2* } }
+   { dg-output-file target-cdtor-2-offload.output { target offload_device } }
 */
diff --git a/libgomp/testsuite/libgomp.c++/target-cdtor-2.output b/libgomp/testsuite/libgomp.c++/target-cdtor-2.output
new file mode 100644
--- /dev/null
+++ b/libgomp/testsuite/libgomp.c++/target-cdtor-2.output
@@ -0,0 +1,18 @@
+S, 3, 1
+S, -1, 1
+S, -1, 1
+S, 7, 1
+S, 5, 1
+initH1, 1
+initDH1, 1
+main:1, 1
+main:2, 1
+main:3, 1
+main:4, 1
+~S, 5, 1
+~S, 7, 1
+~S, -1, 1
+~S, -1, 1
+~S, 3, 1
+finiDH1, 1
+finiH1, 1

Reply via email to