Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix various gcc 14/g++ POSIX build issues #22257

Merged
merged 6 commits into from
Jun 23, 2024

Conversation

tonycoz
Copy link
Contributor

@tonycoz tonycoz commented Jun 3, 2024

Fixes #22211

This produced build errors with gcc 14.
For a 64-bit build on Windows, pointers are 64-bits, while
long is 32-bits, so PTR2ul() discards some bits.
C99 requires that isnan() is a generic macro that accepts the
standard floating point types (float, double, long double).

We always include math.h eventually, so this macro should be
available.

This is complicated by C++.  C++98 depends on C89, which does
not require isnan(), but since we do require C99, I think we
need to require a minimum of C++11, which follows C99.

C++11 does *not* define isnan() as a macro, but as a set of
overloaded functions, which produces almost the same result,
the difference being that the macro test that was done by this
code is no longer valid.

The old code would fail to build with C++ long double builds
with gcc on Window:

..\sv.c: In function 'size_t S_infnan_2pv(NV, char*, size_t, char)':
..\perl.h:2680:34: error: 'isnanl' was not declared in this scope; did you mean 'isnan'?
 2680 | #           define Perl_isnan(x) isnanl(x)
      |                                  ^~~~~~
..\sv.c:2882:14: note: in expansion of macro 'Perl_isnan'
 2882 |     else if (Perl_isnan(nv)) {
      |              ^~~~~~~~~~
..\sv.c: In function 'U8* S_hextract(NV, int*, bool*, U8*, U8*)':
..\perl.h:2680:34: error: 'isnanl' was not declared in this scope; did you mean 'isnan'?
 2680 | #           define Perl_isnan(x) isnanl(x)
      |                                  ^~~~~~
..\perl.h:8605:69: note: in expansion of macro 'Perl_isnan'
 8605 | #  define Perl_fp_class_denorm(x) ((x) != 0.0 && !Perl_isinf(x) && !Perl_isnan(x) && PERL_ABS(x) < NV_MIN)
      |                                                                     ^~~~~~~~~~
..\sv.c:11604:49: note: in expansion of macro 'Perl_fp_class_denorm'
11604 | #define HEXTRACT_GET_SUBNORMAL(nv) *subnormal = Perl_fp_class_denorm(nv)
      |                                                 ^~~~~~~~~~~~~~~~~~~~
..\sv.c:11672:9: note: in expansion of macro 'HEXTRACT_GET_SUBNORMAL'
11672 |         HEXTRACT_GET_SUBNORMAL(nv);
      |         ^~~~~~~~~~~~~~~~~~~~~~

and with gcc 14.2, which requires prototypes per C99:

In file included from ..\sv.c:32:
..\sv.c: In function 'S_infnan_2pv':
..\perl.h:2680:34: error: implicit declaration of function 'isnanl'; did you mean 'isnan'? [-Wimplicit-function-declaration]
 2680 | #           define Perl_isnan(x) isnanl(x)
      |                                  ^~~~~~
..\sv.c:2882:14: note: in expansion of macro 'Perl_isnan'
 2882 |     else if (Perl_isnan(nv)) {
      |              ^~~~~~~~~~
gmake: *** [GNUmakefile:1430: mini\sv.o] Error 1
ext/POSIX/POSIX.xs Outdated Show resolved Hide resolved
@sisyphus
Copy link
Contributor

sisyphus commented Jun 3, 2024

Thank you, @tonycoz .
This looks good and tests fine for me on both mingw-w64 and VS-2022 builds of perl-5.40.0-RC1.

If this can't be stuck into 5.40.0, what do we need to do to ensure it gets ported into 5.40.1 ?

And doesn't provide a way to make them visible, even though they
are visible by default for MSVC UCRT builds.

The __MINGW32__ macro is set for both 32-bit and 64-bit MINGW builds.
@tonycoz tonycoz force-pushed the 22211-gcc-posix-build-issues branch from 94d3607 to d89a2c4 Compare June 3, 2024 23:45
@jkeenan
Copy link
Contributor

jkeenan commented Jun 12, 2024

@tonycoz, @sisyphus: Is this p.r. sufficiently well tested (particularly on Windows) so as to be ready to merge?

@sisyphus
Copy link
Contributor

It will receive more extensive Windows testing in the building of Strawberry Perl-5.40.0.
So, even though I reckon it's right to go, it might be prudent to wait until SP-5.40.0 has been released.
My own testing has been reasonably extensive, but only using gcc-14.1.0 and only on Windows.

@shawnlaffan, am I correct in my beliefs that the SP-5.40.0 builds will:

  1. include all of the patches contained in this PR;
  2. be done using gcc-13.2.0.

I think we can afford wait for the Strawberry Perl release of 5.40.0 - unless it suffers a lengthy delay.

@shawnlaffan
Copy link

am I correct in my beliefs that the SP-5.40.0 builds will:

  1. include all of the patches contained in this PR;

Yes, unless someone can provide reasons not to.

  1. be done using gcc-13.2.0.

Yes.

@tonycoz tonycoz merged commit 56d5b6e into Perl:blead Jun 23, 2024
29 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
5 participants