diff options
author | Torbjörn SVENSSON <torbjorn.svensson@foss.st.com> | 2025-01-19 18:33:24 +0100 |
---|---|---|
committer | Torbjörn SVENSSON <torbjorn.svensson@foss.st.com> | 2025-01-23 10:50:43 +0100 |
commit | 57b706d141b87c06dfbba577048a1e4903d33f70 (patch) | |
tree | e3990f5dbeafff420764d64459e43c4f0a42783f | |
parent | f30edd17e62e9474f90785a5915959cd6d8c3f62 (diff) | |
download | gcc-57b706d141b87c06dfbba577048a1e4903d33f70.zip gcc-57b706d141b87c06dfbba577048a1e4903d33f70.tar.gz gcc-57b706d141b87c06dfbba577048a1e4903d33f70.tar.bz2 |
testsuite: Only run test if alarm is available
Most baremetal toolchains will not have an implementation for alarm and
sigaction as they are target specific.
For arm-none-eabi with newlib, function signatures are exposed, but
there is no implmentation and thus the test cases causes a undefined
symbol link error.
gcc/testsuite/ChangeLog:
* gcc.dg/pr78185.c: Remove dg-do and replace with
with dg-require-effective-target of signal and alarm.
* gcc.dg/pr116906-1.c: Likewise.
* gcc.dg/pr116906-2.c: Likewise.
* gcc.dg/vect/pr101145inf.c: Use effective-target alarm.
* gcc.dg/vect/pr101145inf_1.c: Likewise.
* lib/target-supports.exp(check_effective_target_alarm): New.
gcc/ChangeLog:
* doc/sourcebuild.texi (Effective-Target Keywords): Document
'alarm'.
Signed-off-by: Torbjörn SVENSSON <torbjorn.svensson@foss.st.com>
-rw-r--r-- | gcc/doc/sourcebuild.texi | 3 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/pr116906-1.c | 3 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/pr116906-2.c | 3 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/pr78185.c | 3 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/vect/pr101145inf.c | 1 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/vect/pr101145inf_1.c | 1 | ||||
-rw-r--r-- | gcc/testsuite/lib/target-supports.exp | 27 |
7 files changed, 38 insertions, 3 deletions
diff --git a/gcc/doc/sourcebuild.texi b/gcc/doc/sourcebuild.texi index b5c1b23..98ede70 100644 --- a/gcc/doc/sourcebuild.texi +++ b/gcc/doc/sourcebuild.texi @@ -2808,6 +2808,9 @@ both scalar and vector modes. @subsubsection Environment attributes @table @code +@item alarm +Target supports @code{alarm}. + @item c The language for the compiler under test is C. diff --git a/gcc/testsuite/gcc.dg/pr116906-1.c b/gcc/testsuite/gcc.dg/pr116906-1.c index 27b1fda..7187507 100644 --- a/gcc/testsuite/gcc.dg/pr116906-1.c +++ b/gcc/testsuite/gcc.dg/pr116906-1.c @@ -1,4 +1,5 @@ -/* { dg-do run { target *-*-linux* *-*-gnu* *-*-uclinux* } } */ +/* { dg-require-effective-target alarm } */ +/* { dg-require-effective-target signal } */ /* { dg-options "-O2" } */ #include <stdint.h> diff --git a/gcc/testsuite/gcc.dg/pr116906-2.c b/gcc/testsuite/gcc.dg/pr116906-2.c index 3478771..41a352b 100644 --- a/gcc/testsuite/gcc.dg/pr116906-2.c +++ b/gcc/testsuite/gcc.dg/pr116906-2.c @@ -1,4 +1,5 @@ -/* { dg-do run { target *-*-linux* *-*-gnu* *-*-uclinux* } } */ +/* { dg-require-effective-target alarm } */ +/* { dg-require-effective-target signal } */ /* { dg-options "-O2 -fno-tree-ch" } */ #include <unistd.h> diff --git a/gcc/testsuite/gcc.dg/pr78185.c b/gcc/testsuite/gcc.dg/pr78185.c index d7781b2..ada8b1b 100644 --- a/gcc/testsuite/gcc.dg/pr78185.c +++ b/gcc/testsuite/gcc.dg/pr78185.c @@ -1,4 +1,5 @@ -/* { dg-do run { target *-*-linux* *-*-gnu* *-*-uclinux* } } */ +/* { dg-require-effective-target alarm } */ +/* { dg-require-effective-target signal } */ /* { dg-options "-O" } */ #include <unistd.h> diff --git a/gcc/testsuite/gcc.dg/vect/pr101145inf.c b/gcc/testsuite/gcc.dg/vect/pr101145inf.c index aa59887..70aea94 100644 --- a/gcc/testsuite/gcc.dg/vect/pr101145inf.c +++ b/gcc/testsuite/gcc.dg/vect/pr101145inf.c @@ -1,3 +1,4 @@ +/* { dg-require-effective-target alarm } */ /* { dg-require-effective-target signal } */ /* { dg-additional-options "-O3" } */ #include <limits.h> diff --git a/gcc/testsuite/gcc.dg/vect/pr101145inf_1.c b/gcc/testsuite/gcc.dg/vect/pr101145inf_1.c index 0465788c..fe00828 100644 --- a/gcc/testsuite/gcc.dg/vect/pr101145inf_1.c +++ b/gcc/testsuite/gcc.dg/vect/pr101145inf_1.c @@ -1,3 +1,4 @@ +/* { dg-require-effective-target alarm } */ /* { dg-require-effective-target signal } */ /* { dg-additional-options "-O3" } */ #include <limits.h> diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp index 1785a9d..9ad1e19 100644 --- a/gcc/testsuite/lib/target-supports.exp +++ b/gcc/testsuite/lib/target-supports.exp @@ -14271,3 +14271,30 @@ proc add_options_for_nvptx_alloca_ptx { flags } { return $flags } + +# Return true if alarm is supported on the target. + +proc check_effective_target_alarm { } { + if { ![check_effective_target_signal] } { + return 0 + } + + return [check_no_compiler_messages alarm executable { + #include <signal.h> + #include <stdlib.h> + #include <unistd.h> + void do_exit(int i) { exit (0); } + int main (void) { + struct sigaction s; + sigemptyset (&s.sa_mask); + s.sa_handler = exit; + s.sa_flags = 0; + sigaction (SIGALRM, &s, NULL); + alarm (1); + + /* Infinite loop to simulate work... */ + while (1); + abort (); + } + }] +} |