Hi! On 2022-12-02T13:03:09+0100, I wrote: > --- a/gcc/testsuite/lib/target-supports.exp > +++ b/gcc/testsuite/lib/target-supports.exp
> -# Check to see if a target is "freestanding". This is as per the definition > -# in Section 4 of C99 standard. Effectively, it is a target which supports no > -# extra headers or libraries other than what is considered essential. > -proc check_effective_target_freestanding { } { > - if { [istarget nvptx-*-*] } { > - return 1 > - } > - return 0 > -} I have, for now, pushed a simpler variant of this to trunk branch in commit 65c7616c251a6697134b2a3ac7fe6460d308d2ed "nvptx: Disable effective-target 'freestanding'", see attached. Grüße Thomas
>From 65c7616c251a6697134b2a3ac7fe6460d308d2ed Mon Sep 17 00:00:00 2001 From: Thomas Schwinge <tho...@codesourcery.com> Date: Mon, 28 Nov 2022 13:49:06 +0100 Subject: [PATCH] nvptx: Disable effective-target 'freestanding' After 2014's commit 157e859ffe3b5d43db1e19475711c1a3d21ab57a "remove picochip", the effective-target 'freestanding' (later) was only ever used for nvptx. However, the relevant I/O library functions have long been implemented in nvptx newlib. These test cases generally PASS, just a few need to get XFAILed; see <https://docs.nvidia.com/cuda/ptx-writers-guide-to-interoperability/#system-calls>, and then supposedly <https://docs.nvidia.com/cuda/cuda-c-programming-guide/#formatted-output> for description of the non-standard PTX 'vprintf' return value: > Unlike the C-standard 'printf()', which returns the number of characters > printed, CUDA's 'printf()' returns the number of arguments parsed. If no > arguments follow the format string, 0 is returned. If the format string is > NULL, -1 is returned. If an internal error occurs, -2 is returned. (I've tried a few variants to confirm that PTX 'vprintf' -- which supposedly is underlying the CUDA 'printf' -- is what's implementing this behavior.) Probably, we ought to fix that up in nvptx newlib. gcc/testsuite/ * gcc.c-torture/execute/printf-1.c: XFAIL for nvptx. * gcc.c-torture/execute/printf-chk-1.c: Likewise. * gcc.c-torture/execute/vprintf-1.c: Likewise. * gcc.c-torture/execute/vprintf-chk-1.c: Likewise. * lib/target-supports.exp (check_effective_target_freestanding): Disable for nvptx. --- gcc/testsuite/gcc.c-torture/execute/printf-1.c | 1 + gcc/testsuite/gcc.c-torture/execute/printf-chk-1.c | 1 + gcc/testsuite/gcc.c-torture/execute/vprintf-1.c | 1 + gcc/testsuite/gcc.c-torture/execute/vprintf-chk-1.c | 1 + gcc/testsuite/lib/target-supports.exp | 3 --- 5 files changed, 4 insertions(+), 3 deletions(-) diff --git a/gcc/testsuite/gcc.c-torture/execute/printf-1.c b/gcc/testsuite/gcc.c-torture/execute/printf-1.c index 654e62766a8..e1201365c1f 100644 --- a/gcc/testsuite/gcc.c-torture/execute/printf-1.c +++ b/gcc/testsuite/gcc.c-torture/execute/printf-1.c @@ -1,4 +1,5 @@ /* { dg-skip-if "requires io" { freestanding } } */ +/* { dg-xfail-run-if {unexpected PTX 'vprintf' return value} { nvptx-*-* } } */ #include <stdio.h> #include <stdlib.h> diff --git a/gcc/testsuite/gcc.c-torture/execute/printf-chk-1.c b/gcc/testsuite/gcc.c-torture/execute/printf-chk-1.c index aab43062bae..6418957edae 100644 --- a/gcc/testsuite/gcc.c-torture/execute/printf-chk-1.c +++ b/gcc/testsuite/gcc.c-torture/execute/printf-chk-1.c @@ -1,4 +1,5 @@ /* { dg-skip-if "requires io" { freestanding } } */ +/* { dg-xfail-run-if {unexpected PTX 'vprintf' return value} { nvptx-*-* } } */ #include <stdio.h> #include <stdlib.h> diff --git a/gcc/testsuite/gcc.c-torture/execute/vprintf-1.c b/gcc/testsuite/gcc.c-torture/execute/vprintf-1.c index 259397ebda3..0fb1ade94e0 100644 --- a/gcc/testsuite/gcc.c-torture/execute/vprintf-1.c +++ b/gcc/testsuite/gcc.c-torture/execute/vprintf-1.c @@ -1,4 +1,5 @@ /* { dg-skip-if "requires io" { freestanding } } */ +/* { dg-xfail-run-if {unexpected PTX 'vprintf' return value} { nvptx-*-* } } */ #ifndef test #include <stdio.h> diff --git a/gcc/testsuite/gcc.c-torture/execute/vprintf-chk-1.c b/gcc/testsuite/gcc.c-torture/execute/vprintf-chk-1.c index 04ecc4df4d9..7ea3617e184 100644 --- a/gcc/testsuite/gcc.c-torture/execute/vprintf-chk-1.c +++ b/gcc/testsuite/gcc.c-torture/execute/vprintf-chk-1.c @@ -1,4 +1,5 @@ /* { dg-skip-if "requires io" { freestanding } } */ +/* { dg-xfail-run-if {unexpected PTX 'vprintf' return value} { nvptx-*-* } } */ #ifndef test #include <stdio.h> diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp index 459af8e58c6..1c9bbf64817 100644 --- a/gcc/testsuite/lib/target-supports.exp +++ b/gcc/testsuite/lib/target-supports.exp @@ -859,9 +859,6 @@ proc check_profiling_available { test_what } { # in Section 4 of C99 standard. Effectively, it is a target which supports no # extra headers or libraries other than what is considered essential. proc check_effective_target_freestanding { } { - if { [istarget nvptx-*-*] } { - return 1 - } return 0 } -- 2.34.1