[COMMITTED] Link various tests against libm
Commit Message
Tested on hppa64-hp-hpux11.11. Committed to trunk.
Dave
---
Link various tests against libm
The following torture tests need to link against libm on
hppa64-hp-hpux11.11.
2026-10-09 John David Anglin <danglin@gcc.gnu.org>
gcc/testsuite/ChangeLog:
* gcc.dg/torture/fp-double-convert-float-1.c: Add -lm to
dg-additional-options.
* gcc.dg/torture/fp-uint64-convert-double-1.c: Likewise.
* gcc.dg/torture/fp-uint64-convert-double-2.c: Likewise.
* gcc.dg/torture/fp-int-convert-timode-2.c: Add -lm to
dg-options.
* gcc.dg/torture/fp-int-convert-timode-3.c: Likewise.
* gcc.dg/torture/fp-int-convert-timode-4.c: Likewise.
* gcc.dg/torture/pr41094.c: Likewise.
Comments
Hi Dave!
On 2026-10-09T15:55:02-0400, John David Anglin <dave.anglin@bell.net> wrote:
> Tested on hppa64-hp-hpux11.11. Committed to trunk.
> Link various tests against libm
In my understanding, you "should", unless overridden, already be getting
'-lm' via DejaGnu 'target.exp:default_target_compile':
[...]
# This probably isn't such a good idea, but it avoids nasty
# hackiness in the testsuites.
# The math library must be linked in before the C library. The C
# library is linked in by the linker script, so this must be before
# the linker script.
if {[board_info $dest exists mathlib]} {
append extra_ldflags " [board_info $dest mathlib]"
} else {
append extra_ldflags " -lm"
}
[...]
(I've put "should" in quotes, as I personally also consider this
"isn't such a good idea"...)
What is different in your case, and why for these few test cases only?
Grüße
Thomas
> The following torture tests need to link against libm on
> hppa64-hp-hpux11.11.
>
> 2026-10-09 John David Anglin <danglin@gcc.gnu.org>
>
> gcc/testsuite/ChangeLog:
>
> * gcc.dg/torture/fp-double-convert-float-1.c: Add -lm to
> dg-additional-options.
> * gcc.dg/torture/fp-uint64-convert-double-1.c: Likewise.
> * gcc.dg/torture/fp-uint64-convert-double-2.c: Likewise.
> * gcc.dg/torture/fp-int-convert-timode-2.c: Add -lm to
> dg-options.
> * gcc.dg/torture/fp-int-convert-timode-3.c: Likewise.
> * gcc.dg/torture/fp-int-convert-timode-4.c: Likewise.
> * gcc.dg/torture/pr41094.c: Likewise.
>
> diff --git a/gcc/testsuite/gcc.dg/torture/fp-double-convert-float-1.c b/gcc/testsuite/gcc.dg/torture/fp-double-convert-float-1.c
> index 12070975b9f..48a193611ca 100644
> --- a/gcc/testsuite/gcc.dg/torture/fp-double-convert-float-1.c
> +++ b/gcc/testsuite/gcc.dg/torture/fp-double-convert-float-1.c
> @@ -2,7 +2,7 @@
> /* { dg-do run { xfail { arm_mixed_fp } } } */
> /* { dg-require-effective-target fenv } */
> /* { dg-require-effective-target hard_float } */
> -/* { dg-additional-options "-frounding-math" } */
> +/* { dg-additional-options "-frounding-math -lm" } */
>
> #include <fenv.h>
> #include <stdlib.h>
> diff --git a/gcc/testsuite/gcc.dg/torture/fp-int-convert-timode-2.c b/gcc/testsuite/gcc.dg/torture/fp-int-convert-timode-2.c
> index a82f03d079c..6ea85e8f805 100644
> --- a/gcc/testsuite/gcc.dg/torture/fp-int-convert-timode-2.c
> +++ b/gcc/testsuite/gcc.dg/torture/fp-int-convert-timode-2.c
> @@ -3,7 +3,7 @@
> /* { dg-do run } */
> /* { dg-require-effective-target int128 } */
> /* { dg-require-effective-target fenv } */
> -/* { dg-options "-frounding-math" } */
> +/* { dg-options "-frounding-math -lm" } */
>
> #include <fenv.h>
> #include <stdlib.h>
> diff --git a/gcc/testsuite/gcc.dg/torture/fp-int-convert-timode-3.c b/gcc/testsuite/gcc.dg/torture/fp-int-convert-timode-3.c
> index 6f9a8d3f0d3..e1d27be8543 100644
> --- a/gcc/testsuite/gcc.dg/torture/fp-int-convert-timode-3.c
> +++ b/gcc/testsuite/gcc.dg/torture/fp-int-convert-timode-3.c
> @@ -4,7 +4,7 @@
> /* { dg-require-effective-target int128 } */
> /* { dg-require-effective-target fenv } */
> /* { dg-require-effective-target hard_float } */
> -/* { dg-options "-frounding-math" } */
> +/* { dg-options "-frounding-math -lm" } */
>
> #include <fenv.h>
> #include <stdlib.h>
> diff --git a/gcc/testsuite/gcc.dg/torture/fp-int-convert-timode-4.c b/gcc/testsuite/gcc.dg/torture/fp-int-convert-timode-4.c
> index 15f478d15e2..94f8fca36cd 100644
> --- a/gcc/testsuite/gcc.dg/torture/fp-int-convert-timode-4.c
> +++ b/gcc/testsuite/gcc.dg/torture/fp-int-convert-timode-4.c
> @@ -4,7 +4,7 @@
> /* { dg-require-effective-target int128 } */
> /* { dg-require-effective-target fenv } */
> /* { dg-require-effective-target hard_float } */
> -/* { dg-options "-frounding-math" } */
> +/* { dg-options "-frounding-math -lm" } */
>
> #include <fenv.h>
> #include <stdlib.h>
> diff --git a/gcc/testsuite/gcc.dg/torture/fp-uint64-convert-double-1.c b/gcc/testsuite/gcc.dg/torture/fp-uint64-convert-double-1.c
> index 8f437e2efb1..1431a67981b 100644
> --- a/gcc/testsuite/gcc.dg/torture/fp-uint64-convert-double-1.c
> +++ b/gcc/testsuite/gcc.dg/torture/fp-uint64-convert-double-1.c
> @@ -2,7 +2,7 @@
> /* { dg-do run { xfail { arm-*-* } } } */
> /* { dg-require-effective-target fenv } */
> /* { dg-require-effective-target hard_float } */
> -/* { dg-additional-options "-frounding-math -fexcess-precision=standard" } */
> +/* { dg-additional-options "-frounding-math -fexcess-precision=standard -lm" } */
>
> #include <fenv.h>
> #include <stdlib.h>
> diff --git a/gcc/testsuite/gcc.dg/torture/fp-uint64-convert-double-2.c b/gcc/testsuite/gcc.dg/torture/fp-uint64-convert-double-2.c
> index fd3f4cbfb83..903acfb4d71 100644
> --- a/gcc/testsuite/gcc.dg/torture/fp-uint64-convert-double-2.c
> +++ b/gcc/testsuite/gcc.dg/torture/fp-uint64-convert-double-2.c
> @@ -2,7 +2,7 @@
> /* { dg-do run { xfail { arm-*-* } } } */
> /* { dg-require-effective-target fenv } */
> /* { dg-require-effective-target hard_float } */
> -/* { dg-additional-options "-frounding-math" } */
> +/* { dg-additional-options "-frounding-math -lm" } */
>
> #include <fenv.h>
> #include <stdlib.h>
> diff --git a/gcc/testsuite/gcc.dg/torture/pr41094.c b/gcc/testsuite/gcc.dg/torture/pr41094.c
> index 9219a1741a3..2ef30bcee1d 100644
> --- a/gcc/testsuite/gcc.dg/torture/pr41094.c
> +++ b/gcc/testsuite/gcc.dg/torture/pr41094.c
> @@ -1,5 +1,5 @@
> /* { dg-do run } */
> -/* { dg-options "-ffast-math" } */
> +/* { dg-options "-ffast-math -lm" } */
>
> #include <math.h>
>
On 2026-10-09 4:06 p.m., Thomas Schwinge wrote:
> On 2026-10-09T15:55:02-0400, John David Anglin <dave.anglin@bell.net> wrote:
>> Tested on hppa64-hp-hpux11.11. Committed to trunk.
>> Link various tests against libm
> In my understanding, you "should", unless overridden, already be getting
> '-lm' via DejaGnu 'target.exp:default_target_compile':
>
> [...]
> # This probably isn't such a good idea, but it avoids nasty
> # hackiness in the testsuites.
> # The math library must be linked in before the C library. The C
> # library is linked in by the linker script, so this must be before
> # the linker script.
> if {[board_info $dest exists mathlib]} {
> append extra_ldflags " [board_info $dest mathlib]"
> } else {
> append extra_ldflags " -lm"
> }
> [...]
>
> (I've put "should" in quotes, as I personally also consider this
> "isn't such a good idea"...)
>
> What is different in your case, and why for these few test cases only?
I see the above hunk in dejagnu, so I have to assume the first part of the if was used
and didn't add " -lm". Don't know why. A fair number of tests add " -lm" in their
options.
Dave
On 2026-10-09 5:03 p.m., John David Anglin wrote:
> I see the above hunk in dejagnu, so I have to assume the first part of the if was used
> and didn't add " -lm". Don't know why. A fair number of tests add " -lm" in their
> options.
I checked the gcc.log file and " -lm" was being added twice, so I reverted the patch.
Dave
@@ -2,7 +2,7 @@
/* { dg-do run { xfail { arm_mixed_fp } } } */
/* { dg-require-effective-target fenv } */
/* { dg-require-effective-target hard_float } */
-/* { dg-additional-options "-frounding-math" } */
+/* { dg-additional-options "-frounding-math -lm" } */
#include <fenv.h>
#include <stdlib.h>
@@ -3,7 +3,7 @@
/* { dg-do run } */
/* { dg-require-effective-target int128 } */
/* { dg-require-effective-target fenv } */
-/* { dg-options "-frounding-math" } */
+/* { dg-options "-frounding-math -lm" } */
#include <fenv.h>
#include <stdlib.h>
@@ -4,7 +4,7 @@
/* { dg-require-effective-target int128 } */
/* { dg-require-effective-target fenv } */
/* { dg-require-effective-target hard_float } */
-/* { dg-options "-frounding-math" } */
+/* { dg-options "-frounding-math -lm" } */
#include <fenv.h>
#include <stdlib.h>
@@ -4,7 +4,7 @@
/* { dg-require-effective-target int128 } */
/* { dg-require-effective-target fenv } */
/* { dg-require-effective-target hard_float } */
-/* { dg-options "-frounding-math" } */
+/* { dg-options "-frounding-math -lm" } */
#include <fenv.h>
#include <stdlib.h>
@@ -2,7 +2,7 @@
/* { dg-do run { xfail { arm-*-* } } } */
/* { dg-require-effective-target fenv } */
/* { dg-require-effective-target hard_float } */
-/* { dg-additional-options "-frounding-math -fexcess-precision=standard" } */
+/* { dg-additional-options "-frounding-math -fexcess-precision=standard -lm" } */
#include <fenv.h>
#include <stdlib.h>
@@ -2,7 +2,7 @@
/* { dg-do run { xfail { arm-*-* } } } */
/* { dg-require-effective-target fenv } */
/* { dg-require-effective-target hard_float } */
-/* { dg-additional-options "-frounding-math" } */
+/* { dg-additional-options "-frounding-math -lm" } */
#include <fenv.h>
#include <stdlib.h>
@@ -1,5 +1,5 @@
/* { dg-do run } */
-/* { dg-options "-ffast-math" } */
+/* { dg-options "-ffast-math -lm" } */
#include <math.h>