Hi,
I've just hacked up a -Dusequadmath build of perl-5.44.0-RC2 on freebsd-15.1, using the gcc compiler.
The same should be achievable using the clang compiler, and I'll get to doing that - but there might be some additional hoops to jump through.
The question that has been bugging me for a while is "why do most builders of perl on freebsd choose clang over gcc as the compiler ?"
I assume there is some rationality involved, but it's not evident to me.
I don't think there's much interest here in quadmath builds but, for anyone interested, here is the hack:
It is necessary to firstly hack ext/POSIX/POSIX.xs
$ diff -u POSIX.xs_orig POSIX.xs
--- POSIX.xs_orig 2026-07-15 11:31:26.616152200 +1000
+++ POSIX.xs 2026-07-15 21:19:36.225074300 +1000
@@ -467,14 +467,14 @@
#endif
/* Check both the Configure symbol and the macro-ness (like C99 promi
+ses). */
-#if defined(HAS_FPCLASSIFY) && defined(fpclassify)
+#if defined(HAS_FPCLASSIFY) && defined(fpclassify) && !defined(__Free
+BSD__)
# define c99_fpclassify fpclassify
#endif
/* Like isnormal(), the isfinite(), isinf(), and isnan() are also C99
and also (sizeof-arg-aware) macros, but they are already well take
+n
care of by Configure et al, and defined in perl.h as
Perl_isfinite(), Perl_isinf(), and Perl_isnan(). */
-#ifdef isnormal
+#if defined(isnormal) && !defined(__FreeBSD__)
# define c99_isnormal isnormal
#endif
#ifdef isgreater /* canary for all the C99 is*<cmp>* macros. */
Then perl built without any issues with:
sh Configure -des -Dcc=gcc -Accflags=-I/usr/local/lib/gcc14/gcc/x86_64
+-portbld-freebsd15.0/14.2.0/include -Alibpth=/usr/local/lib/gcc14 -Al
+ddlflags=-L/usr/local/lib/gcc14 -Dprefix=/home/sis/perl-5.44.0-RC2-gc
+c-q -Dusequadmath && make && make test
All tests passed.
without the -A.... flags, lib/ExtUtils/t/Embed.t failed one of its tests because quadmath functions were not being resolved.
Those same flags will be needed by some other CPAN modules.
I'll update this post with the requisite Configure command, once I've established what it is.
Is that hack to POSIX.xs acceptable as is ?
I feel that it's okay - though it probably should be extended to cover other BSD systems. (I've no way of testing that.)
UPDATE:
For the clang -Dusequadmath build I've used pretty much the same as for the gcc build - but I've removed the -Dcc=gcc Configure arg, and added -Aldflags=-L/usr/local/lib/gcc14 (without which Configure could not locate the quadmath library):
sh Configure -des -Accflags=-I/usr/local/lib/gcc14/gcc/x86_64-portbld-
+freebsd15.0/14.2.0/include -Alibpth=/usr/local/lib/gcc14 -Alddlflags=
+-L/usr/local/lib/gcc14 -Dprefix=/home/sis/perl-5.44.0-RC2-clang-q -Du
+sequadmath -Aldflags=-L/usr/local/lib/gcc14 && make && make test
This time, however, one test script (ext/POSIX/t/fenv.t fails the FLT_ROUNDS tests), though all of the very same tests passed on the gcc build :
$ perl ext/POSIX/t/fenv.t
ok 1 - fegetround
ok 2 - FLT_ROUNDS
ok 3 - fesetround
ok 4 - fesetround/fegetround round-trip
ok 5 - fesetround(FE_TOWARDZERO)
ok 6 - fegetround() under FE_TOWARDZERO
not ok 7 - FLT_ROUNDS under FE_TOWARDZERO
# Failed test 'FLT_ROUNDS under FE_TOWARDZERO'
# at ext/POSIX/t/fenv.t line 41.
# got: 1
# expected: 0
ok 8 - fesetround(FE_TONEAREST)
ok 9 - fegetround() under FE_TONEAREST
ok 10 - FLT_ROUNDS under FE_TONEAREST
ok 11 - fesetround(FE_UPWARD)
ok 12 - fegetround() under FE_UPWARD
not ok 13 - FLT_ROUNDS under FE_UPWARD
# Failed test 'FLT_ROUNDS under FE_UPWARD'
# at ext/POSIX/t/fenv.t line 41.
# got: 1
# expected: 2
ok 14 - fesetround(FE_DOWNWARD)
ok 15 - fegetround() under FE_DOWNWARD
not ok 16 - FLT_ROUNDS under FE_DOWNWARD
# Failed test 'FLT_ROUNDS under FE_DOWNWARD'
# at ext/POSIX/t/fenv.t line 41.
# got: 1
# expected: 3
1..16
# Looks like you failed 3 tests of 16.
My immediate conclusion is to blame this on "clang recalcitrance", but I should probably also consider other possibilities ;-)
UPDATE 2:
I was able to work around the ext/POSIX/t/fenv.t test failures on the clang quadmath build by a small hack to POSIX.xs
The diff on that file has now become:
$ diff -u POSIX.xs_orig POSIX.xs
--- POSIX.xs_orig 2026-07-15 11:31:26.616152200 +1000
+++ POSIX.xs 2026-07-15 21:19:36.225074300 +1000
@@ -46,7 +46,11 @@
#ifdef WIN32
#include <sys/errno2.h>
#endif
-#include <float.h>
+#if defined(__clang__) && defined(__FreeBSD__) && defined(USE_QUADMAT
+H)
+# include <x86/float.h> /* load the correct float.h */
+#else
+# include <float.h>
+#endif
#ifdef I_FENV
#if !(defined(__vax__) && defined(__NetBSD__))
#include <fenv.h>
@@ -467,14 +471,14 @@
#endif
/* Check both the Configure symbol and the macro-ness (like C99 promi
+ses). */
-#if defined(HAS_FPCLASSIFY) && defined(fpclassify)
+#if defined(HAS_FPCLASSIFY) && defined(fpclassify) && !defined(__Free
+BSD__)
# define c99_fpclassify fpclassify
#endif
/* Like isnormal(), the isfinite(), isinf(), and isnan() are also C99
and also (sizeof-arg-aware) macros, but they are already well take
+n
care of by Configure et al, and defined in perl.h as
Perl_isfinite(), Perl_isinf(), and Perl_isnan(). */
-#ifdef isnormal
+#if defined(isnormal) && !defined(__FreeBSD__)
# define c99_isnormal isnormal
#endif
#ifdef isgreater /* canary for all the C99 is*<cmp>* macros. */
#ifdef isgreater /* canary for all the C99 is*<cmp>* macros. */
I suspect that at least some of the hacking I've done could better be replaced with some astute alterations to the Configure script and/or the hints file.
Advice on that aspect would be most welcome.
Cheers, Rob
|