Skip to content

Don't assume NV_INF / NV_NAN #22882

Open
@jbglaw

Description

The pkgsrc repository (a large tree of build instructions for lots of software, used as a package source for NetBSD and many other unix-like distributions) recently updated Perl5 from 5.38 to 5.40, which now no longer builts for VAX targets:

gcc -c -DPERL_CORE -O2 -pthread -I/usr/include -fwrapv -fno-strict-aliasing -pipe -std=c99 -O2 -pthread -I/usr/include -Wall -Werror=pointer-arith -Werror=vla -Wextra -Wno-long-long -Wno-decl
aration-after-statement -Wc++-compat -Wwrite-strings -DPIC -fPIC builtin.c
In file included from perl.h:6225,
                 from builtin.c:16:
builtin.c: In function 'XS_builtin_inf':  
builtin.c:100:17: error: 'NV_INF' undeclared (first use in this function); did you mean 'NV_MIN'?
  100 |     XSRETURN_NV(NV_INF);
      |                 ^~~~~~
embed.h:649:71: note: in definition of macro 'sv_2mortal'
  649 | # define sv_2mortal(a)                          Perl_sv_2mortal(aTHX_ a)
embed.h:649:71: note: in definition of macro 'sv_2mortal'
  649 | # define sv_2mortal(a)                          Perl_sv_2mortal(aTHX_ a)
      |                                                                       ^
XSUB.h:317:43: note: in expansion of macro 'newSVnv'
  317 | #define XST_mNV(i,v)  (ST(i) = sv_2mortal(newSVnv(v))  )
      |                                           ^~~~~~~
XSUB.h:334:40: note: in expansion of macro 'XST_mNV'
  334 | #define XSRETURN_NV(v)    STMT_START { XST_mNV(0,v);    XSRETURN(1); } STMT_END
      |                                        ^~~~~~~
builtin.c:100:5: note: in expansion of macro 'XSRETURN_NV'
  100 |     XSRETURN_NV(NV_INF);
      |     ^~~~~~~~~~~  
builtin.c:100:17: note: each undeclared identifier is reported only once for each function it appears in
  100 |     XSRETURN_NV(NV_INF);
      |                 ^~~~~~
embed.h:649:71: note: in definition of macro 'sv_2mortal'
  649 | # define sv_2mortal(a)                          Perl_sv_2mortal(aTHX_ a)
      |                                                                       ^
XSUB.h:317:43: note: in expansion of macro 'newSVnv'
  317 | #define XST_mNV(i,v)  (ST(i) = sv_2mortal(newSVnv(v))  )
      |                                           ^~~~~~~
XSUB.h:334:40: note: in expansion of macro 'XST_mNV'
  334 | #define XSRETURN_NV(v)    STMT_START { XST_mNV(0,v);    XSRETURN(1); } STMT_END
      |                                        ^~~~~~~
builtin.c:100:5: note: in expansion of macro 'XSRETURN_NV'
  100 |     XSRETURN_NV(NV_INF);
      |     ^~~~~~~~~~~
builtin.c: In function 'XS_builtin_nan':
builtin.c:110:17: error: 'NV_NAN' undeclared (first use in this function); did you mean 'FP_NAN'?
  110 |     XSRETURN_NV(NV_NAN);
      |                 ^~~~~~
embed.h:649:71: note: in definition of macro 'sv_2mortal'
  649 | # define sv_2mortal(a)                          Perl_sv_2mortal(aTHX_ a)
      |                                                                       ^ 
XSUB.h:317:43: note: in expansion of macro 'newSVnv'
  317 | #define XST_mNV(i,v)  (ST(i) = sv_2mortal(newSVnv(v))  )
      |                                           ^~~~~~~
XSUB.h:334:40: note: in expansion of macro 'XST_mNV'
  334 | #define XSRETURN_NV(v)    STMT_START { XST_mNV(0,v);    XSRETURN(1); } STMT_END
      |                                        ^~~~~~~ 
builtin.c:110:5: note: in expansion of macro 'XSRETURN_NV' 
  110 |     XSRETURN_NV(NV_NAN);
      |     ^~~~~~~~~~~ 
builtin.c: In function 'ck_builtin_const':
builtin.c:138:54: error: 'NV_INF' undeclared (first use in this function); did you mean 'NV_MIN'?
  138 |         case BUILTIN_CONST_INF:   constval = newSVnv(NV_INF); break;
      |                                                      ^~~~~~
embed.h:437:68: note: in definition of macro 'newSVnv'
  437 | # define newSVnv(a)                             Perl_newSVnv(aTHX_ a)
      |                                                                    ^
builtin.c:139:54: error: 'NV_NAN' undeclared (first use in this function); did you mean 'FP_NAN'?
      |                                                                    ^
builtin.c:139:54: error: 'NV_NAN' undeclared (first use in this function); did you mean 'FP_NAN'?
  139 |         case BUILTIN_CONST_NAN:   constval = newSVnv(NV_NAN); break;  
      |                                                      ^~~~~~
embed.h:437:68: note: in definition of macro 'newSVnv'
  437 | # define newSVnv(a)                             Perl_newSVnv(aTHX_ a)
      |                                                                    ^
*** Error code 1

This was introduced with 5fdf6e9, where INF and NAN support was expected to always exist. However, this is an IEEE fp feature and the VAX CPU predates that spec. Perl used to reasonable support VAX systems (cf. d_double_style_vax, d_double_has_inf and d_double_has_nan.) So I guess that INF/NAN support wasn't tested on a non-IEEE fp system. Reverting this patch makes it build again. Simply guarding that functionality with any of the above config options should just do the trick.

Thanks a lot!

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions