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

update config patch files for 5.34 and 5.36? #56

Closed
shawnlaffan opened this issue Feb 26, 2023 · 40 comments
Closed

update config patch files for 5.34 and 5.36? #56

shawnlaffan opened this issue Feb 26, 2023 · 40 comments

Comments

@shawnlaffan
Copy link
Contributor

The 5.32 and earlier builds override several of the configuration files under the perl/win32 dir before building perl. The files live under the share dir, for example https://github.com/StrawberryPerl/Perl-Dist-Strawberry/tree/master/share/perl-5.32

Some of these are to change build args such as NDBM and GDBM (although see StrawberryPerl/build-extlibs#13 for current build status), others are changing the installation dirs, dll extensions etc.

However, others change pointer sizes and the like.

There have been changes in the perl core since the 5.32 files were generated, so how much do the strawberry perl versions of these files need to be updated?

Diffs comparing the perl 5.36 versions with the strawberry perl 5.32 versions, excluding whitespace, are attached.

Many of the differences are typo fixes and some are just file reordering (HAS_MSG in Config.gc), but there are cases where new arguments in perl are not in the strawberry perl versions (e.g. HASATTRIBUTE_ALWAYS_INLINE in Config.gc).

Some of the missing parameters might not matter as they will be left undefined by default anyway. Right?

Others maybe should be defined? If so which?

config.gc.patch
config_H.gc.patch
FindExt.pm.patch

@shawnlaffan
Copy link
Contributor Author

If it turns out there are not many changes needed then maybe we can switch to using command line arguments?

It seems to work for @sisyphus in #39 (comment)

@genio
Copy link
Member

genio commented Feb 26, 2023

@xenu Do you have any thoughts here?

@mohawk2
Copy link

mohawk2 commented Feb 26, 2023

I prefer the idea of configuration stuff being as lightweight as possible: command-line args in scripts being preferred over patches, supplying a config file after that, etc. If nothing else, that makes it likelier to survive changes in Perl going forward. And any patches might suggest changes needed in core Perl in any case, which could be fed back in, and kept working by making Perl's own CI exercise it.

In a perfect world, the methods used to build at least the main Perl binaries/modules should be native Perl building, and Strawberry would only need to concern itself with "extra" stuff.

@hakonhagland
Copy link

maybe we can switch to using command line arguments?

@shawnlaffan Just want to mention that the same command line args (as used when building) must also be passed when testing (gmake test) and installing (gmake install) using this makefile, else strange things might happen, see:
Perl/perl5#20499 (comment) and Perl/perl5#20395 (comment)

@shawnlaffan
Copy link
Contributor Author

@hakonhagland - yes, that would make life more complex.

Another option is to edit the files in place rather than overwriting them completely. It would be simple enough to do with a subroutine passed a data structure of arg names with values, or undef to comment the line out.

@shawnlaffan
Copy link
Contributor Author

Here is the filtered list of changes to config_H.gc to show only the defines. This should make it easier to get a handle on what is being changed, in this case for perl 5.36.

The define ARCHNAME "MSWin32-x86-perlio" looks suspicious to me, for example, given this is a 64 bit build.

-#define HAS_LSTAT              /**/
-#define HAS_READLINK           /**/
+#define HAS_SETLOCALE  /**/
-#define HAS_SYMLINK    /**/
+#define I_DBM  /**/
+#define I_GDBM /**/
-#define BYTEORDER 0x12345678   /* large digits for MSB */
+#define BYTEORDER 0x1234       /* large digits for MSB */
-#define PTRSIZE 8              /**/
+#define PTRSIZE 4              /**/
-#define SSize_t long long      /* signed count of bytes */
+#define SSize_t int     /* signed count of bytes */
-#define OSVERS "10.0.19043.1237"               /**/
+#define OSVERS "6.1"           /**/
-#define LONG_DOUBLESIZE 16             /**/
+#define LONG_DOUBLESIZE 12             /**/
+#define HAS_MKSTEMP
-#define        HAS_SOCKADDR_STORAGE    /**/
+#define I_NDBM /**/
-#define HAS_ATOLL              /**/
-#define HAS_NON_INT_BITFIELDS  /**/
+#define HAS_BUILTIN_EXPECT     /* we have gcc-8.3 */
+#define HAS_BUILTIN_CHOOSE_EXPR        /* we have gcc-8.3 */
-#define HAS_MODFL_PROTO                /**/
-#define HAS_SETLOCALE  /**/
-#define HAS_STRTOLL            /**/
-#define HAS_STRTOULL           /**/
-#define LONGDBLINFBYTES 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xff, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00         /**/
-#define LONGDBLNANBYTES 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00         /**/
+#define LONGDBLINFBYTES 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xff, 0x7f, 0x00, 0x00         /**/
+#define LONGDBLNANBYTES 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xff, 0x00, 0x00         /**/
-#define        IVTYPE          long long               /**/
-#define        UVTYPE          unsigned long long              /**/
+#define        IVTYPE          long            /**/
+#define        UVTYPE          unsigned long           /**/
-#define        IVSIZE          8               /**/
-#define        UVSIZE          8               /**/
+#define        IVSIZE          4               /**/
+#define        UVSIZE          4               /**/
-#define        NV_PRESERVES_UV_BITS    53
-#define        NV_OVERFLOWS_INTEGERS_AT        (256.0*256.0*256.0*256.0*256.0*256.0*2.0*2.0*2.0*2.0*2.0)
+#define        NV_PRESERVES_UV
+#define        NV_PRESERVES_UV_BITS    32
+#define        NV_OVERFLOWS_INTEGERS_AT        256.0*256.0*256.0*256.0*256.0*256.0*2.0*2.0*2.0*2.0*2.0
-#define        IVdf            "I64d"          /**/
-#define        UVuf            "I64u"          /**/
-#define        UVof            "I64o"          /**/
-#define        UVxf            "I64x"          /**/
-#define        UVXf            "I64X"          /**/
+#define        IVdf            "ld"            /**/
+#define        UVuf            "lu"            /**/
+#define        UVof            "lo"            /**/
+#define        UVxf            "lx"            /**/
+#define        UVXf            "lX"            /**/
-#define ST_DEV_SIGN 1  /* st_dev sign */
-#define ST_DEV_SIZE 4  /* st_dev size */
-#define ST_INO_SIZE 8  /* st_ino size */
+#define ST_INO_SIZE 4  /* st_ino size */
-#define        USE_64_BIT_INT          /**/
-#define        USE_LARGE_FILES         /**/
-#define ARCHNAME "MSWin32-x64-perlio"          /**/
+#define ARCHNAME "MSWin32-x86-perlio"          /**/
-#define GETENV_PRESERVES_OTHER_THREAD  /**/
+#define                USE_THREADS             /* until src is revised*/
-#define Off_t long long                /* <offset> type */
-#define LSEEKSIZE 8            /* <offset> size */
-#define Off_t_size 8   /* <offset> size */
+#define Off_t long             /* <offset> type */
+#define LSEEKSIZE 4            /* <offset> size */
+#define Off_t_size 4   /* <offset> size */
-#define Size_t_size 8          /**/
+#define Size_t_size 4          /**/

@genio
Copy link
Member

genio commented Feb 26, 2023

For 5.34 (currently what we're working on with the Dockerfile in spbuild):
We're using gcc 11.2 from WinLibs: gcc-11.2.0-llvm-13.0.0-mingw-w64ucrt-9.0.0-r2

ARCHNAME looks off.

Since we're using 64-bit compilers on a 64-bit system, should we not leave all of the size definitions as-they-are?

ContainerAdministrator@93b8bbba23dc MINGW64 /c/spbuild
# cat foo.c
#include <stdio.h>
#include <sys/types.h>

int main(void) {
  off_t blah;
  size_t bloop;
  return 0;
}


ContainerAdministrator@93b8bbba23dc MINGW64 /c/spbuild
# gcc -E foo.c | grep size_t
__extension__ typedef unsigned long long size_t;
__extension__ typedef long long ssize_t;
typedef size_t rsize_t;

ContainerAdministrator@93b8bbba23dc MINGW64 /c/spbuild
# gcc -E foo.c | grep off_
# 1 "z:\\mingw64\\x86_64-w64-mingw32\\include\\_mingw_off_t.h" 1 3
  typedef long _off_t;
# 26 "z:\\mingw64\\x86_64-w64-mingw32\\include\\_mingw_off_t.h" 3
typedef off32_t off_t;
  static __attribute__ ((__unused__)) __inline__ __attribute__((__cdecl__)) int fseeko(FILE *_File, _off_t _Offset, int
_Origin) {
  static __attribute__ ((__unused__)) __inline__ __attribute__((__cdecl__)) _off_t ftello(FILE *_File) {
  off_t blah;

This part we should likely leave, but alter the comments

#define HAS_BUILTIN_EXPECT     /* we have gcc-8.3 */
#define HAS_BUILTIN_CHOOSE_EXPR        /* we have gcc-8.3 */

and the OSVERS as well?

PS C:\spbuild> [environment]::OSVersion.Version

Major  Minor  Build  Revision
-----  -----  -----  --------
10     0      17763  0

@shawnlaffan
Copy link
Contributor Author

I've been running 5.36 in my experiments on the assumption we can come back to 5.34 once that's done.

I should also note that I kept the build config simple and went with the gcc 8.3 toolchain. That saved editing the locations of all the libraries (I have work in progress to reduce hard coding when run under docker). It also resulted in a range of perl core test failures but those might just be due to the perl config used. I'll shift to gcc 11 once we have the perl config patches worked out.

@genio
Copy link
Member

genio commented Feb 26, 2023

My initial goal was to cut/release 5.34 with the gcc-11.2 setup and then go with gcc-12.2 for 5.36. That was also back in a time when I assumed this whole thing would be much easier. :)

@shawnlaffan
Copy link
Contributor Author

My current optimism is that the two builds will be pretty similar as they will use the same external libs and gcc toolchain.

If we can clean up the patches then we might even be able to refactor the build configs as all that will change is the perl version. Maybe. Possibly.

@sisyphus
Copy link

The define ARCHNAME "MSWin32-x86-perlio" looks suspicious to me, for example, given this is a 64 bit build.
With #define PTRSIZE 4, #define LONG_DOUBLESIZE 12, #define IVSIZE 4 amongst other specs, I'd say it's definitely changing from a 64 bit unthreaded perl to a 32 bit unthreaded perl.

If you're getting a 64-bit perl as a result, it's because those specs are being ignored/overwritten by gmake.
For my own builds, I certainly don't need to alter any of the settings specified in the win32 Config files that ship with the perl source, irrespective of the resultant perl's archname.
I'm a bit surprised that StrawberryPerl was being built like this - not least because I thought @kmx was a pretty strong advocate for using command line args.
But if it's easy to maintain, then I see nothing wrong with it.

If it turns out there are not many changes needed then maybe we can switch to using command line arguments?

As I've sort of just implied - I'm aware of no such changes that need to be made.
However, I think It's likely that there are some changes here-or-there in the win32 files Config that would, if made, enhance Strawberry Perl. (I have a patch to Config_H.gc and Config.gc that provides a minimal enhancement in that it corrects a few %Config values from undef to define. I don't usually apply it because my purposes are better served by sticking with the official perl source.)
It's theoretically possible that some/all of those amendments cannot be made to the perl source because they are not portable across the full range of systems and compilers that perl supports. But, in building Strawberry Perl, such portability constraints might not apply - given that a known specific mingw-w64 toolchain is being used to build StrawberryPerl.

And if Strawberry developers come across %Config settings that could be portably altered to provide enhancement, then please report them as perl5 issues.

Cheers,
Rob

@shawnlaffan
Copy link
Contributor Author

shawnlaffan commented Feb 27, 2023

So a starting point might be to leave most settings as-is in the config files but update these (based on my incomplete understanding of such things):

  • set HAS_LSTAT, HAS_READLINK and HAS_SYMLINK to undefined
  • retain the changes to IVdf, UVdf etc (but see below).
  • retain HAS_BUILTIN_EXPECT and HAS_BUILTIN_CHOOSE_EXPR

What of the other settings near to HAS_BUILTIN_EXPECT?

-#define HAS_ATOLL              /**/
-#define HAS_NON_INT_BITFIELDS  /**/
+#define HAS_BUILTIN_EXPECT     /* we have gcc-8.3 */
+#define HAS_BUILTIN_CHOOSE_EXPR        /* we have gcc-8.3 */
-#define HAS_MODFL_PROTO                /**/
-#define HAS_SETLOCALE  /**/
-#define HAS_STRTOLL            /**/
-#define HAS_STRTOULL

WRT printing formats, running this one liner for a 5.32 install gives these settings. Some are defined in the config file, others are not in the diffs. Should all "I64o" cases be changed to "lo", for example?

perl -MData::Printer -MConfig -E"say np %Config" | findstr /i format | findstr /v d_
    gidformat                               ""ld"",
    ivdformat                               ""I64d"",
    nveformat                               ""e"",
    nvEUformat                              ""E"",
    nvfformat                               ""f"",
    nvFUformat                              ""F"",
    nvgformat                               ""g"",
    nvGUformat                              ""G"",
    uidformat                               ""ld"",
    uvoformat                               ""I64o"",
    uvuformat                               ""I64u"",
    uvxformat                               ""I64x"",
    uvXUformat                              ""I64X"",

@shawnlaffan
Copy link
Contributor Author

shawnlaffan commented Feb 28, 2023

So I did a test run with the "uncleaned" GCC 11 toolchain, without any patching of the config files. It results in a large number of errors before failure. A sample is below but they are all essentially the same (let me know if the full set is needed). I assume I've missed something obvious or there are issues with not cleaning up the toolchain files (see #57).

For comparison, running with the GCC 8 toolchain from https://strawberryperl.com/package/kmx/64_gcctoolchain/ builds perl and is now running tests. The good news is that it passes several tests it failed when the configs were being patched (op/sort.t for one). op/magic.t has two UTF related failures and win32/runenv.t fails the . is not in @INC test (probably a config issue - I think it is set somewhere). I can give details when it is finished but figure it's better to get GCC 11 working?

GCC 11 errors:

gcc -c  -I.\include -I. -I.. -DWIN32 -DWIN64 -DPERLDLL -DPERL_CORE -O2 -D__USE_MINGW_ANSI_STDIO -fwrapv -fno-strict-alia
sing -DPERL_EXTERNAL_GLOB -DPERL_IS_MINIPERL -omini\perlio.o  ..\perlio.c
In file included from ..\perl.h:3455,
                 from ..\perlio.c:43:
..\perlio.c: In function 'PerlIOStdio_invalidate_fileno':
./win32.h:343:33: error: 'FILE' {aka 'struct _iobuf'} has no member named '_file'
  343 | #define PERLIO_FILE_file(f) ((f)->_file)
      |                                 ^~
./win32.h:343:33: note: in definition of macro 'PERLIO_FILE_file'
  343 | #define PERLIO_FILE_file(f) ((f)->_file)
      |                                 ^~
..\perlio.c: In function 'PerlIOStdio_unread':
./win32.h:339:33: error: 'FILE' {aka 'struct _iobuf'} has no member named '_ptr'
  339 | #define PERLIO_FILE_ptr(f)  ((f)->_ptr)
      |                                 ^~
./win32.h:339:33: note: in definition of macro 'PERLIO_FILE_ptr'
  339 | #define PERLIO_FILE_ptr(f)  ((f)->_ptr)
      |                                 ^~
..\iperlsys.h:308:41: note: in expansion of macro 'FILE_ptr'
  308 | #    define PerlSIO_get_ptr(f)          FILE_ptr(f)
      |                                         ^~~~~~~~
..\perlio.c:3397:35: note: in expansion of macro 'PerlSIO_get_ptr'
 3397 |         STDCHAR *eptr = (STDCHAR*)PerlSIO_get_ptr(s);
      |                                   ^~~~~~~~~~~~~~~
./win32.h:339:33: error: 'FILE' {aka 'struct _iobuf'} has no member named '_ptr'
  339 | #define PERLIO_FILE_ptr(f)  ((f)->_ptr)
      |                                 ^~
./win32.h:339:33: note: in definition of macro 'PERLIO_FILE_ptr'
  339 | #define PERLIO_FILE_ptr(f)  ((f)->_ptr)
      |                                 ^~
..\iperlsys.h:308:41: note: in expansion of macro 'FILE_ptr'
  308 | #    define PerlSIO_get_ptr(f)          FILE_ptr(f)
      |                                         ^~~~~~~~
..\perlio.c:3405:27: note: in expansion of macro 'PerlSIO_get_ptr'
 3405 |             if ((STDCHAR*)PerlSIO_get_ptr(s) != --eptr || (((U8) *eptr) != ch)) {
      |                           ^~~~~~~~~~~~~~~

@sisyphus
Copy link

sisyphus commented Feb 28, 2023

IIRC (unverified) these issues have been fixed in the perl-5.36.0 source, but not the perl-5.34.0 source.
If that's so, then other than patch the perl-5.34.0 source, you'll have to use an older version of gcc for perl-5.34.0. I could probably dig up the patches if you want to use 11.3.0 - I don't think they were extensive ... but my memory is shit.
(I used gcc-10.2.0 to build perl-5.34.0 without issue and gcc-11.3.0 to build 5.36.0. Currently using gcc-12.2.0 (with blead) since 5.36.0 was released. All are winlibs.com builds of gcc).

Update: Duh - I knew I had seen those errors before .... but then I attributed them to the wrong issue.
The possibility that you were using the UCRT winlibs builds completely slipped my mind,
I think you will still strike (other) issues using gcc-11 to build perl-5.34.0 from source, though I take it that you'll be using gcc-10 anyway.

Cheers,
Rob

@genio
Copy link
Member

genio commented Feb 28, 2023

I spoke with @xenu on IRC and it looks like we are going to have some issues because we're trying to use the UCRT version of the winlibs build. Perl isn't yet able to work there. We will need to try the MSVCRT build instead for now.

@shawnlaffan Can you try changing your checked out Dockerfile to use https://github.com/brechtsanders/winlibs_mingw/releases/download/10.4.0-10.0.0-msvcrt-r1/winlibs-x86_64-posix-seh-gcc-10.3.0-mingw-w64-9.0.0-r2.zip instead and test with that?

That'd take us down to gcc v10 as well.

@shawnlaffan
Copy link
Contributor Author

Will give that a go. I assume it will need a full rebuild of the extlibs?

@genio
Copy link
Member

genio commented Feb 28, 2023

Will give that a go. I assume it will need a full rebuild of the extlibs?

Yes, unfortunately, everything will have to be built with that new winlibs selection.

@shawnlaffan
Copy link
Contributor Author

shawnlaffan commented Feb 28, 2023

@genio
Copy link
Member

genio commented Feb 28, 2023

Sorry about that. The links on the actual WinLibs site are wrong.

@shawnlaffan
Copy link
Contributor Author

Sorry about that. The links on the actual WinLibs site are wrong.

No dramas. I went straight to github, although it's about seven pages in under the releases...

@shawnlaffan
Copy link
Contributor Author

The external libs compile pretty well under GCC 10. There is a test failure for netcdf I have yet to look into closely but I think (hope) that this is testing utilities we don't distribute anyway. The others are all known (libgdbm, libsodium and libssh2).

I think it makes sense to upload these to a github release on the extlibs repo, flagged as a pre-release. That will allow other people to get started with the builds. I'll also push the 5.36 scripts to a branch on this repo.

WRT the perl builds, we are hitting issues with IO.xs (see below). These are already fixed in the perl core but after 5.36 was released.
Perl/perl5#19663
Perl/perl5#18911

@sisyphus - Are there other such issues lurking?

Meanwhile I'll try adding the patch from 19663.

"C:\strawberry_build\build\perl_core\perl-5.36.0\miniperl.exe" "-I..\..\lib" -MExtUtils::Command -e mv -- IO.xsc IO.c
gcc -c   -DWIN32 -DWIN64 -D__USE_MINGW_ANSI_STDIO -DPERL_TEXTMODE_SCRIPTS -DMULTIPLICITY -DPERL_IMPLICIT_SYS -DUSE_PERLI
O -D__USE_MINGW_ANSI_STDIO -fwrapv -fno-strict-aliasing -mms-bitfields -O2   -DVERSION=\"1.50\" -DXS_VERSION=\"1.50\"  "
-I..\..\lib\CORE"   IO.c
In file included from IO.xs:17:
poll.h:14:12: fatal error: poll.h: No such file or directory
   14 | #  include <poll.h>
      |            ^~~~~~~~
compilation terminated.
gmake[1]: *** [makefile:349: IO.o] Error 1
gmake[1]: Leaving directory 'C:/strawberry_build/build/perl_core/perl-5.36.0/dist/IO'
gmake[1]: Entering directory 'C:/strawberry_build/build/perl_core/perl-5.36.0/dist/IO'
"C:\strawberry_build\build\perl_core\perl-5.36.0\miniperl.exe" "-I..\..\lib" -MExtUtils::Command::MM -e cp_nonempty -- I
O.bs ..\..\lib\auto\IO\IO.bs 644
gcc -c   -DWIN32 -DWIN64 -D__USE_MINGW_ANSI_STDIO -DPERL_TEXTMODE_SCRIPTS -DMULTIPLICITY -DPERL_IMPLICIT_SYS -DUSE_PERLI
O -D__USE_MINGW_ANSI_STDIO -fwrapv -fno-strict-aliasing -mms-bitfields -O2   -DVERSION=\"1.50\" -DXS_VERSION=\"1.50\"  "
-I..\..\lib\CORE"   IO.c
In file included from IO.xs:17:
poll.h:14:12: fatal error: poll.h: No such file or directory
   14 | #  include <poll.h>
      |            ^~~~~~~~
compilation terminated.
gmake[1]: *** [makefile:349: IO.o] Error 1

@shawnlaffan
Copy link
Contributor Author

After patching with Perl/perl5#19663 and also https://rt.cpan.org/Transaction/Display.html?id=2258362 the core build completes. Now I need to rerun with core tests on and see how far it gets.

@shawnlaffan
Copy link
Contributor Author

Two more notes:

The patch.exe that comes with strawberry perl 5.32 does not work when applying the patches (5.32 is being used to bootstrap the process and is currently at the front of the path). The winlibs version does, however, work.

I have yet to add the two defines flagged in #56 (comment)

+#define HAS_BUILTIN_EXPECT     /* we have gcc-8.3 */
+#define HAS_BUILTIN_CHOOSE_EXPR        /* we have gcc-8.3 */

@shawnlaffan
Copy link
Contributor Author

Current files are in the wip_536 branch: https://github.com/StrawberryPerl/Perl-Dist-Strawberry/tree/wip_536

@sisyphus
Copy link

sisyphus commented Mar 2, 2023

@sisyphus - Are there other such issues lurking?

(Sorry, my "memory" reckoned that the requisite perl patches had been applied to the perl source much earlier than they actually were.)
As mentioned in #19663 , you might also need to apply the patch provided at the end of https://rt.cpan.org/Public/Bug/Display.html?id=142390.

Beyond that, I can't think of any issues until you get to using gcc-12 compiler - where you might want to apply Perl/perl5@51634b4 to win32/GNUmakefile
I think that patch means that -Os optimization will also be applied to 32-bit builds - though it's only the 64-bit builds that need to avoid -O2 optimization.
Note that the GNUmakefile specifies the default optimization which can be overwritten in the "gmake" command line - so you could do it that way if you want to avoid patching the GNUmakefile.

Be aware that these recent compilers from winlibs set _WIN32_WINNT to 0x0a00 which implies that the system is Windows 10.
Give some thought to how you deal with that.
I know from experience that if, on Windows 7, _WIN32_WINNT is set to 0x0a00 then it doesn't go well if some XS file decides (based on that setting) that the system is in fact at least Windows 10, and then calls some Windows 10 function that doesn't exist on Windows 7.
On that windows 7 machine, I merely inserted -D_WIN32_WINNT=0x0601 into $Config{ccflags}, which overwrites _WIN32_WINNT back to a sane level for that system.
Maybe Strawberry is already well ahead of me on issues like that - though SP-5.32.1 does not specify a _WIN32_WINNT value in $Config{ccflags}, so I'm thinking it might just accept whatever value gcc supplies (like I used to do ;-)

Cheers,
Rob

@shawnlaffan
Copy link
Contributor Author

shawnlaffan commented Mar 2, 2023

Thanks Rob. I might open a separate issue to flag the GCC 12 changes for future reference.

Incidentally, the core tests passed except for these two. Maybe another define is needed? (Edit - that's a general question, not for @sisyphus specifically).

op/magic-27839.t ..................................................... ok
# Failed test 186 - ENV store downgrades utf8 in setenv at op/magic.t line 75
#      got 'foo=eh zero �\n'
# expected /(?^:^(?:foo=)?eh\ zero\ \<A0>$)/
# Failed test 187 - ENV store downgrades utf8 key in setenv at op/magic.t line 75
#      got 'eh zero �=widekey\r\neh zero �=widekey\n'
# expected /(?^:^(?:eh\ zero\ \<A0>=)?widekey$)/
op/magic.t ...........................................................
Failed 2/208 subtests
        (less 13 skipped subtests: 193 okay)
op/method.t .......................................................... ok

Edit 2: And this one, although it is to be expected since Socket.xs was patched.

# Failed test 22 - SHA for cpan/Socket/Socket.xs matches stashed SHA at porting/customized.t line 112
#      got "532f2c439968918460d8482783a47ce84ac3b0d3"
# expected "146541e7deb5593f0469740a6e38bfd0b42c0329"
porting/customized.t .................................................
Failed 1/44 subtests

And perhaps more importantly there is cpan/ExtUtils-MakeMaker/t/basic.t.

Invalid code page
# Looks like your test exited with 256 just after 188.
../cpan/ExtUtils-MakeMaker/t/basic.t .................................
Dubious, test returned 255 (wstat 65280, 0xff00)
All 188 subtests passed
        (less 105 skipped subtests: 83 okay)

@sisyphus
Copy link

sisyphus commented Mar 2, 2023

(Edit - that's a general question, not for @sisyphus specifically).

Yes, some expert intervention might be needed here.
The porting/customized.t failure can be ignored, or "fixed" by altering the stored hash of Socket.xs to 532f2c439968918460d8482783a47ce84ac3b0d3.
But the other 2 failures don't ring any bells at all with me.
What's the perl -V of this build ?

Cheers,
Rob

@shawnlaffan
Copy link
Contributor Author

perl -v below for its current location.

# perl/bin/perl -V
Summary of my perl5 (revision 5 version 36 subversion 0) configuration:

  Platform:
    osname=MSWin32
    osvers=10.0.17763.3406
    archname=MSWin32-x64-multi-thread
    uname=''
    config_args='undef'
    hint=recommended
    useposix=true
    d_sigaction=undef
    useithreads=define
    usemultiplicity=define
    use64bitint=define
    use64bitall=undef
    uselongdouble=undef
    usemymalloc=n
    default_inc_excludes_dot=define
  Compiler:
    cc='gcc'
    ccflags =' -DWIN32 -DWIN64 -D__USE_MINGW_ANSI_STDIO -DPERL_TEXTMODE_SCRIPTS -DMULTIPLICITY -DPERL_IMPLICIT_SYS -DUSE
_PERLIO -D__USE_MINGW_ANSI_STDIO -fwrapv -fno-strict-aliasing -mms-bitfields'
    optimize='-O2'
    cppflags='-DWIN32'
    ccversion=''
    gccversion='10.3.0'
    gccosandvers=''
    intsize=4
    longsize=4
    ptrsize=8
    doublesize=8
    byteorder=12345678
    doublekind=3
    d_longlong=define
    longlongsize=8
    d_longdbl=define
    longdblsize=16
    longdblkind=3
    ivtype='long long'
    ivsize=8
    nvtype='double'
    nvsize=8
    Off_t='long long'
    lseeksize=8
    alignbytes=8
    prototype=define
  Linker and Libraries:
    ld='g++'
    ldflags ='-s -L"C:\strawberry\perl\lib\CORE" -L"C:\strawberry\c\lib" -L"C:\strawberry\c\x86_64-w64-mingw32\lib" -L"C
:\strawberry\c\lib\gcc\x86_64-w64-mingw32\10.3.0"'
    libpth=C:\strawberry\c\lib C:\strawberry\c\x86_64-w64-mingw32\lib C:\strawberry\c\lib\gcc\x86_64-w64-mingw32\10.3.0
C:\strawberry\c\x86_64-w64-mingw32\lib C:\strawberry\c\lib\gcc\x86_64-w64-mingw32\10.3.0
    libs= -lmoldname -lkernel32 -luser32 -lgdi32 -lwinspool -lcomdlg32 -ladvapi32 -lshell32 -lole32 -loleaut32 -lnetapi3
2 -luuid -lws2_32 -lmpr -lwinmm -lversion -lodbc32 -lodbccp32 -lcomctl32
    perllibs= -lmoldname -lkernel32 -luser32 -lgdi32 -lwinspool -lcomdlg32 -ladvapi32 -lshell32 -lole32 -loleaut32 -lnet
api32 -luuid -lws2_32 -lmpr -lwinmm -lversion -lodbc32 -lodbccp32 -lcomctl32
    libc=
    so=dll
    useshrplib=true
    libperl=libperl536.a
    gnulibc_version=''
  Dynamic Linking:
    dlsrc=dl_win32.xs
    dlext=dll
    d_dlsymun=undef
    ccdlflags=' '
    cccdlflags=' '
    lddlflags='-shared -s -L"C:\strawberry\perl\lib\CORE" -L"C:\strawberry\c\lib" -L"C:\strawberry\c\x86_64-w64-mingw32\
lib" -L"C:\strawberry\c\lib\gcc\x86_64-w64-mingw32\10.3.0"'


Characteristics of this binary (from libperl):
  Compile-time options:
    HAS_TIMES
    HAVE_INTERP_INTERN
    MULTIPLICITY
    PERLIO_LAYERS
    PERL_COPY_ON_WRITE
    PERL_DONT_CREATE_GVSV
    PERL_IMPLICIT_SYS
    PERL_MALLOC_WRAP
    PERL_OP_PARENT
    PERL_PRESERVE_IVUV
    USE_64_BIT_INT
    USE_ITHREADS
    USE_LARGE_FILES
    USE_LOCALE
    USE_LOCALE_COLLATE
    USE_LOCALE_CTYPE
    USE_LOCALE_NUMERIC
    USE_LOCALE_TIME
    USE_PERLIO
    USE_PERL_ATOF
  Built under MSWin32
  Compiled at Mar  2 2023 16:43:03
  @INC:
    Z:/run20230302a/strawberry/perl/site/lib/MSWin32-x64-multi-thread
    Z:/run20230302a/strawberry/perl/site/lib
    Z:/run20230302a/strawberry/perl/lib

@sisyphus
Copy link

sisyphus commented Mar 2, 2023

Hmmm ... I've now built perl-5.36.0 on Windows 11 using winlibs 64-bit gcc-10.3.0.
(This is the first time I've used gcc-10.3.0 on Windows 11. The perl-5.36.0 that I already had on this Windows 11 box was built using gcc-11.3.0.)
I've replaced the dist/IO/poll.h and cpan/Socket/Socket.xs files that shipped with the 5.36.0 with the patched versions.
Here are the diffs on those 2 files:

--- poll.h_orig	2019-02-18 20:59:22.000000000 +1100
+++ poll.h	2022-09-18 15:21:18.217669100 +1000
@@ -10,7 +10,7 @@
 #ifndef POLL_H
 #  define POLL_H
 
-#if (defined(HAS_POLL) && defined(I_POLL)) || defined(POLLWRBAND)
+#if (defined(HAS_POLL) && defined(I_POLL)) || (defined(POLLWRBAND) && !defined(_WIN32))
 #  include <poll.h>
 #elif (defined(HAS_POLL) && defined(I_SYS_POLL))
 #  include <sys/poll.h>
@@ -22,11 +22,16 @@
 
 #define EMULATE_POLL_WITH_SELECT
 
+#ifdef _WIN32
+#  include <winsock2.h>
+#endif
+
 #ifdef poll
 # undef poll
 #endif
 #define poll Perl_my_poll
 
+#if WINVER < 0x0600
 typedef struct pollfd {
     int fd;
     short events;
@@ -48,6 +53,8 @@
 #define	POLLHUP		0x0010
 #define	POLLNVAL	0x0020
 
+#endif
+
 int poll (struct pollfd *, unsigned long, int);
 
 #ifndef HAS_POLL


--- Socket.xs_orig	2022-04-25 06:29:00.000000000 +1000
+++ Socket.XS	2022-09-18 15:21:18.186426500 +1000
@@ -98,6 +98,14 @@
 
 #endif
 
+/*
+ * The Windows implementations of inet_ntop and inet_pton are available
+ * whenever (and only when) InetNtopA is defined.
+ * Use those implementations whenever they are available.
+ * Else use the implementations provided below.
+*/
+#ifndef InetNtopA
+
 static int inet_pton(int af, const char *src, void *dst)
 {
   struct sockaddr_storage ss;
@@ -146,6 +154,8 @@
     return dst;
 }
 
+#endif /* InetNtopA not defined */
+
 #define HAS_INETPTON
 #define HAS_INETNTOP
 #endif

All other files are as per original perl-5.36.0 source.
I got a different result to you:

Test Summary Report
-------------------
re/reg_mesg.t                                                      (Wstat: 65280 (exited 255) Tests: 339 Failed: 0)
  Non-zero exit status: 255
  Parse errors: No plan found in TAP output
re/regexp_unicode_prop.t                                           (Wstat: 65280 (exited 255) Tests: 0 Failed: 0)
  Non-zero exit status: 255
  Parse errors: Bad plan.  You planned 1110 tests but ran 0.
re/regexp_unicode_prop_thr.t                                       (Wstat: 65280 (exited 255) Tests: 2 Failed: 0)
  Non-zero exit status: 255
  Parse errors: Bad plan.  You planned 1110 tests but ran 2.
porting/customized.t                                               (Wstat: 0 Tests: 44 Failed: 1)
  Failed test:  22
../ext/IPC-Open3/t/IPC-Open3.t                                     (Wstat: 0 Tests: 45 Failed: 0)
  TODO passed:   25
../lib/warnings.t                                                  (Wstat: 0 Tests: 932 Failed: 1)
  Failed test:  282
Files=2766, Tests=1146339, 1165 wallclock secs ( 6.28 usr +  0.20 sys =  6.48 CPU)
Result: FAIL
make: *** [GNUmakefile:1810: test] Error 2

I installed that perl anyway - just in case that might prove useful somewhere down the track, and ran make distclean.
Then, I switched to gcc-11.3.0 and rebuilt perl using the exact same source that gcc-10.3.0 had struggled with. ( I changed CCHOME and INST_TOP appropriately for the 11.3.0 build.)
That worked beautifully:

Test Summary Report
-------------------
porting/customized.t                                               (Wstat: 0 Tests: 44 Failed: 1)
  Failed test:  22
../ext/IPC-Open3/t/IPC-Open3.t                                     (Wstat: 0 Tests: 45 Failed: 0)
  TODO passed:   25
Files=2766, Tests=1151496, 1079 wallclock secs ( 6.41 usr +  0.30 sys =  6.70 CPU)
Result: FAIL
make: *** [GNUmakefile:1810: test] Error 1

There's apparently some issue with gcc-10.3.0 that's not afflicting 11.3.0.
I don't know what that issue is.
Maybe it's just the different runtime version - version 9.0 (10.3.0) vs version 10.0 (11.3.0).
Are you able to update your gcc to (winlibs) version 11.3.0 and see if that also fixes things for you ?

Cheers,
Rob

@shawnlaffan
Copy link
Contributor Author

@sisyphus - Just to be sure, did you use the winlibs versions ? If so, which specific links?

It could also be a difference in the build env. FWIW, my builds are running in a cmd shell on a mingw bash shell on a powershell in a windows 10 docker image on a windows 10 box.

@sisyphus
Copy link

sisyphus commented Mar 2, 2023

@sisyphus - Just to be sure, did you use the winlibs versions ? If so, which specific links?

Yes:
https://github.com/brechtsanders/winlibs_mingw/releases/download/10.3.0-12.0.0-9.0.0-r2/winlibs-x86_64-posix-seh-gcc-10.3.0-llvm-12.0.0-mingw-w64-9.0.0-r2.7z
and
https://github.com/brechtsanders/winlibs_mingw/releases/download/11.3.0-14.0.1-10.0.0-msvcrt-r2/winlibs-x86_64-posix-seh-gcc-11.3.0-llvm-14.0.1-mingw-w64msvcrt-10.0.0-r2.7z

The winlibs website currently lists a later version (release 3) of 11.3.0, containing llvm-14.0.3.

It could also be a difference in the build env.

Yes - but on my Windows 11 machine, in exactly the same environment, 10.3.0 is failing to handle the same perl source that 11.3.0 handles just fine.
That doesn't bother me. I'm quite happy to stick with my 11.3.0 builds of 5.36.0, but it does imply that (as regards building perl) there are issues with 10.3.0 on Windows 11 (and probably also on Windows 10) that 11.3.0 does not experience.

Incidentally, last night on Windows 7, I built perl-5.36.0 straight out of the box (no patches) using that same gcc-10.3.0.
A lot of these problems arise only when you move to Windows 10/11 - though I've not tested on Windows 8 (which I don't have).
@shawnlaffan -TBC,- I'm not suggesting you move to Windows 7.

I'll just mention that, as regards the upcoming 5.38.0 release:
At this stage of the devel cycle (blead is currently at perl-5.37.10) I am using gcc-12.2.0 and NO PATCHES (yay !!).

Actually, I do build with one (unnecessary) patch that puts the mingw-runtime version of the toolset that built perl into the currently empty $Config{gnulibc_version}.
Then perl -V will provide that info ... and, furthermore, I can see whether perl has overridden that value by looking at ccflags in the very same output.
I reckon that sort of thing could be handy in cpantester reports, or bug reports. Unfortunately, I think that p5p doesn't like that mis-appropriation of "gnulibc_version", and creating a new Config key for inclusion in "perl -V" output is more trouble for me than it's worth.

Cheers,
Rob

@shawnlaffan
Copy link
Contributor Author

@genio
Copy link
Member

genio commented Mar 3, 2023

When I started the task of getting the build environment together using the Dockerfile, gcc11 was the current version available on WinLibs. The latest available was my only selection criteria (also, I hoped the UCRT version would work well); there wasn't any other reasoning behind that selection.

If gcc 10, 11, or 12 works, then I'm all for whichever one makes our lives easier.

@shawnlaffan
Copy link
Contributor Author

Thanks. Will keep building with GCC 10 for now, largely because I have all the extlibs done (with known caveats).

I updated the config.gc values as below (just showing additions) so the libs from cpan go to the right vendor dir, and now we see additional fails in the main build.

op/inccode-tie.t .....................................................
Dubious, test returned 9 (wstat 2304, 0x900)
Failed 15/71 subtests
op/inccode.t .........................................................
Dubious, test returned 9 (wstat 2304, 0x900)
Failed 15/71 subtests

op/sort.t ............................................................
Dubious, test returned 40 (wstat 10240, 0x2800)
Failed 49/203 subtests

myuname and osver are obviously still out of date, but should d_mkstemp be defined?

Do the [gno]dbm settings affect any of these tests? I would assume not.

+archlib='~INST_TOP~\lib'
+archlibexp='~INST_TOP~\lib'
+bin='~INST_TOP~\bin'
+binexp='~INST_TOP~\bin'
+d_builtin_choose_expr='define'
+d_builtin_expect='define'
+d_mkstemp='define'
+d_ndbm='define'
+d_vendorarch='define'
+d_vendorbin='define'
+d_vendorlib='define'
+d_vendorscript='define'
+dlext='xs.dll'
+i_db='define'
+i_dbm='define'
+i_gdbm='define'
+i_ndbm='define'
+installarchlib='~INST_TOP~\lib'
+installbin='~INST_TOP~\bin'
+installhtmldir=''
+installhtmlhelpdir=''
+installman1dir=''
+installman3dir=''
+installprefix='~INST_TOP~'
+installprefixexp='~INST_TOP~'
+installprivlib='~INST_TOP~\lib'
+installscript='~INST_TOP~\bin'
+installsitearch='~INST_TOP~\site\lib'
+installsitebin='~INST_TOP~\site\bin'
+installsitelib='~INST_TOP~\site\lib'
+installsitescript='~INST_TOP~\site\bin'
+installvendorarch='~INST_TOP~\vendor\lib'
+installvendorbin='~INST_TOP~\bin'
+installvendorlib='~INST_TOP~\vendor\lib'
+installvendorscript='~INST_TOP~\bin'
+man1dir=''
+man1direxp=''
+man3dir=''
+man3direxp=''
+myuname='Win32 strawberry-perl 5.32.0.1 #1 Sun Aug  2 17:07:44 2020 i386'
+osvers='6.1'
+perlpath='~INST_TOP~\bin\perl.exe'
+privlib='~INST_TOP~\lib'
+privlibexp='~INST_TOP~\lib'
+scriptdir='~INST_TOP~\bin'
+scriptdirexp='~INST_TOP~\bin'
+sitearch='~INST_TOP~\site\lib'
+sitearchexp='~INST_TOP~\site\lib'
+sitebin='~INST_TOP~\site\bin'
+sitebinexp='~INST_TOP~\site\bin'
+sitelib='~INST_TOP~\site\lib'
+sitelibexp='~INST_TOP~\site\lib'
+siteprefix='~INST_TOP~\site'
+siteprefixexp='~INST_TOP~\site'
+sitescript='~INST_TOP~\site\bin'
+sitescriptexp='~INST_TOP~\site\bin'
+usevendorprefix='define'
+usrinc='C:\strawberry\c\include'
+vendorarch='~INST_TOP~\vendor\lib'
+vendorarchexp='~INST_TOP~\vendor\lib'
+vendorbin='~INST_TOP~\bin'
+vendorbinexp='~INST_TOP~\bin'
+vendorlib='~INST_TOP~\vendor\lib'
+vendorlibexp='~INST_TOP~\vendor\lib'
+vendorprefix='~INST_TOP~\vendor'
+vendorprefixexp='~INST_TOP~\vendor'
+vendorscript='~INST_TOP~\bin'
+vendorscriptexp='~INST_TOP~\bin'

@shawnlaffan
Copy link
Contributor Author

shawnlaffan commented Mar 4, 2023

And just a data point. The MSYS2 project seems to have a working perl 5.32 using UCRT. See for example this patch.

They have a few other patches, some of which might be useful for Strawberry Perl.
https://github.com/msys2/MINGW-packages/tree/master/mingw-w64-perl

One of their patches is similar to what @sisyphus noted in an earlier comment and which I think is now also in blead? (If so is it a candidate for 5.36.1 or does it not fit the backport policy?)

(Edited for grammar)

@sisyphus
Copy link

sisyphus commented Mar 5, 2023

.... is it a candidate for 5.36.1 or does it not fit the backport policy?

Steve Hay is currently preparing for the 5.36.1 release.
A couple of days ago he posted a link (https://github.com/Perl/perl5/blob/maint-votes/votes-5.36.xml) to the "voting file".
It specifies a list of likely candidates - and I don't see this issue mentioned there.
I suggest you take it up directly with Steve (steve.m.hay@googlemail.com), and do it sooner rather than later if you want to catch that boat.

It feels to me that such a backport should be allowable as a "portability" fix, but I'm not sure that I understand the rules all that well.
Anyway, Steve is the man to approach, and if the request comes from Strawberry Perl (instead of me), it will carry more weight.

AIUI, you'd be wanting the patches to dist/IO/poll.h as well as the ones given in @Biswa96's patch at https://github.com/msys2/MINGW-packages/blob/master/mingw-w64-perl/007-use-winsock-socket-functions.patch.

Applying @Biswa96's patches are (I think) as simple as syncing the current cpan Socket source into the perl-5.36.1 source.
And the dist/IO/poll.h patch is a fairly simple one.

Cheers,
Rob

PS
I would have already raised this with Steve earlier, except that I was thinking that this had already been addressed in the perl-5.36.0 source :-(

@shawnlaffan
Copy link
Contributor Author

shawnlaffan commented Mar 5, 2023

Thanks Rob.

The build is currently applying both those patches, assuming they are the same as in Perl/perl5#19663 and Perl/perl5#18911 So, even if the changes don't make it in to 5.36.1, Strawberry Perl will include them.

Edit: ...although Perl/perl5#18911 is still open so incomplete? If it is then it is unlikely to be up for backport.

@sisyphus
Copy link

sisyphus commented Mar 5, 2023

.... although Perl/perl5#18911 is still open so incomplete?

I believe it was still open due to oversight ;-)
I've just now closed it as completed.

Cheers,
Rob

@shawnlaffan
Copy link
Contributor Author

shawnlaffan commented Mar 11, 2023

Just returning to the original aim of this issue, I have added code on the wip_536 branch to use hashes of values to update the config.gc and config_H.gc files.

The approach is a bit clunky as it hijacks the target name with a keyword so the destination is the hash of changes, so the source and destination are reversed in such cases. An alternate approach would be to also support an array of arrays so then the hash can be first.

f8f3b97
4699841
78adc57
0062273

(The branch will need a bit of cleanup before any PR)

Edit - Also, while the implementation is clunky, this approach is much simpler and more future proof than working with patch files.

@shawnlaffan
Copy link
Contributor Author

The implementation works. Any modifications can be done under their own issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants