Skip to content

5.41.13 thru EU::MM 7.72 breaks all i386 Win32 XS .dll during linking if they add any extra "-lsome_c_lib"es #23331

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

Open
bulk88 opened this issue May 26, 2025 · 14 comments

Comments

@bulk88
Copy link
Contributor

bulk88 commented May 26, 2025

Module: EU::MM in blead

Description

This bug blocks Perl 5.42.0. I don't have time to rewrite all this ATM.

<bulk88> Revision: 179356156963a4b43629d91b6c8abc3030e76739 Author: Chris
'BinGOs' Williams <[email protected]> Date: 3/14/2025 7:39:15 AM
Message: Update ExtUtils-MakeMaker to CPAN version 7.72
<bulk88> i386 WinGCCPerl's XS .dll files are ABI uncompileable if ```
WriteMakefile(LIBS => '-lwinspool -lgui32 -lprinter32 -lmouse32'); ``` is
executed
<bulk88> I need to sleep but that "improvement" telling Mingw GCC to scan
the headers of any .dll file in %PATH% and totally ignoring all .a disk
files, is incompatible with i386's __stdcall name mangling
<bulk88> Win64 has 1.001 calling conventions aka ABIs, Win32 i386 had 4-6
ABIs/calling conventions, all in 1 address space
<bulk88> mohawk_ic try a i386 blead perl GCC compile
<bulk88> Yes I know Strawberry's dev team doesn't have institutional
knowledge how to compile an i386 Strawberry Perl anymore
* bulk88 will note Strawberry Perl is 1000x more difficult to compile than
P5Ps tarball, the first is compiling Debian from src, the 2nd is just 1
tarball
<bulk88>
C:/Strawberry/c/bin/../lib/gcc/i686-w64-mingw32/8.3.0/../../../../i686-w64-mingw
<bulk88> 32/bin/ld.exe: Win32.o:Win32.c:(.text+0x9e8): undefined reference
to `_imp__Stri
<bulk88> ngFromCLSID@8'
<bulk88> nothing will ever fix this message except a .def file and a .a
file on Win32
<bulk88> MS renames the C Abstract Linker Symbols's ASCII names before
inserting them into their export table
<bulk88> unless your a i386 machine code decompiler/regexp-er, or have
prior knowledge, you can't automatically figure out from just looking at
ascii disk file names of __stdcall functions, if they are __stdcall or
__cdecl insider C Abstract linker
<bulk88> special casing, MS .dll
<bulk88> 'es only, and perhaps people like me who found the secret cmd
line arg to unmangle the ascii names of functions for the export table
only
<bulk88> because nobody will ever remember to write fnptr =
dl_sym(lib_ptr, "_MultiByteToWideChar@28");

problem code inside cpan/ExtUtils-MakeMaker/lib/ExtUtils/Liblist/Kid.pm

@@ -460,8 +446,8 @@ sub _win32_try_attach_extension {
 }
 
 sub _win32_lib_extensions {
-    my @extensions;
-    push @extensions, $Config{'lib_ext'} if $Config{'lib_ext'};
+    my @extensions = grep $_, @Config{qw(lib_ext)};
+    push @extensions, map ".$_", grep $_, @Config{qw(dlext so)};
     push @extensions, '.dll.a' if grep { m!^\.a$! } @extensions;
     push @extensions, '.lib' unless grep { m!^\.lib$! } @extensions;
     return \@extensions;

console failure

gmake[1]: Entering directory 'C:/sources/perl5/cpan/Time-Piece'
"C:\sources\perl5\miniperl.exe" "-I..\..\lib" -MExtUtils::Command::MM -e cp_none
mpty -- Piece.bs ..\..\lib\auto\Time\Piece\Piece.bs 644
g++ Piece.def -o ..\..\lib\auto\Time\Piece\Piece.dll -shared -s -L"c:\perl\lib\C
ORE" -L"C:\MinGW\lib" -L"C:\MinGW\i686-w64-mingw32\lib" -L"C:\MinGW\lib\gcc\i686
-w64-mingw32\8.3.0" Piece.o   "..\..\lib\CORE\libperl541.a" -lmoldname -lkernel3
2 -luser32 -lgdi32 -lwinspool -lcomdlg32 -ladvapi32 -lshell32 -lole32 -loleaut32
 -lnetapi32 -luuid -lws2_32 -lmpr -lwinmm -lversion -lodbc32 -lodbccp32 -lcomctl
32 -Wl,--enable-auto-image-base
"C:\sources\perl5\miniperl.exe" "-I..\..\lib" -MExtUtils::Command -e chmod -- 75
5 ..\..\lib\auto\Time\Piece\Piece.dll
gmake[1]: Leaving directory 'C:/sources/perl5/cpan/Time-Piece'
gmake[1]: Entering directory 'C:/sources/perl5/cpan/Unicode-Collate'
"C:\sources\perl5\miniperl.exe" "-I..\..\lib" -MExtUtils::Command::MM -e cp_none
mpty -- Collate.bs ..\..\lib\auto\Unicode\Collate\Collate.bs 644
g++ Collate.def -o ..\..\lib\auto\Unicode\Collate\Collate.dll -shared -s -L"c:\p
erl\lib\CORE" -L"C:\MinGW\lib" -L"C:\MinGW\i686-w64-mingw32\lib" -L"C:\MinGW\lib
\gcc\i686-w64-mingw32\8.3.0" Collate.o   "..\..\lib\CORE\libperl541.a" -lmoldnam
e -lkernel32 -luser32 -lgdi32 -lwinspool -lcomdlg32 -ladvapi32 -lshell32 -lole32
 -loleaut32 -lnetapi32 -luuid -lws2_32 -lmpr -lwinmm -lversion -lodbc32 -lodbccp
32 -lcomctl32 -Wl,--enable-auto-image-base
"C:\sources\perl5\miniperl.exe" "-I..\..\lib" -MExtUtils::Command -e chmod -- 75
5 ..\..\lib\auto\Unicode\Collate\Collate.dll
gmake[1]: Leaving directory 'C:/sources/perl5/cpan/Unicode-Collate'
gmake[1]: Entering directory 'C:/sources/perl5/cpan/Win32'
Makefile out-of-date with respect to Makefile.PL
Cleaning current config before rebuilding Makefile...
gmake -f Makefile.old clean > NUL
"C:\sources\perl5\miniperl.exe" "-I..\..\lib" Makefile.PL "INSTALLDIRS=perl" "IN
STALLMAN1DIR=none" "INSTALLMAN3DIR=none" "PERL_CORE=1" "PERL=C:\sources\perl5\mi
niperl.exe"
Warning (mostly harmless): No library found for
Warning (mostly harmless): No library found for -lmoldname
Warning (mostly harmless): No library found for -lwinspool
Warning (mostly harmless): No library found for -luuid
Generating a gmake-style Makefile
Writing Makefile for Win32
==> Your Makefile has been rebuilt. <==
==> Please rerun the gmake command.  <==
"C:\sources\perl5\miniperl.exe" "-I..\..\lib"  -e "exit 1" --
gmake[1]: *** [Makefile:924: Makefile] Error 1
gmake[1]: Leaving directory 'C:/sources/perl5/cpan/Win32'
gmake[1]: Entering directory 'C:/sources/perl5/cpan/Win32'
Running Mkbootstrap for Win32 ()
"C:\sources\perl5\miniperl.exe" "-I..\..\lib" -MExtUtils::Command -e chmod -- 64
4 "Win32.bs"
"C:\sources\perl5\miniperl.exe" "-I..\..\lib" -MExtUtils::Command::MM -e cp_none
mpty -- Win32.bs ..\..\lib\auto\Win32\Win32.bs 644
"C:\sources\perl5\miniperl.exe" "-I..\..\lib" "..\..\lib\ExtUtils/xsubpp"  -type
map C:\sources\perl5\lib\ExtUtils\typemap  Win32.xs > Win32.xsc
"C:\sources\perl5\miniperl.exe" "-I..\..\lib" -MExtUtils::Command -e mv -- Win32
.xsc Win32.c
gcc -c   -std=c99 -DWIN32 -DPERL_TEXTMODE_SCRIPTS -DMULTIPLICITY -DPERL_IMPLICIT
_SYS -DUSE_PERLIO -D__USE_MINGW_ANSI_STDIO -fwrapv -fno-strict-aliasing -mms-bit
fields -Os   -DVERSION=\"0.59_02\" -DXS_VERSION=\"0.59_02\"  "-I..\..\lib\CORE"
  Win32.c
"C:\sources\perl5\miniperl.exe" "-I..\..\lib" -MExtUtils::Mksymlists \
     -e "Mksymlists('NAME'=>\"Win32\", 'DLBASE' => 'Win32', 'DL_FUNCS' => {  },
'FUNCLIST' => [], 'IMPORTS' => {  }, 'DL_VARS' => []);"
g++ Win32.def -o ..\..\lib\auto\Win32\Win32.dll -shared -s -L"c:\perl\lib\CORE"
-L"C:\MinGW\lib" -L"C:\MinGW\i686-w64-mingw32\lib" -L"C:\MinGW\lib\gcc\i686-w64-
mingw32\8.3.0" Win32.o   "..\..\lib\CORE\libperl541.a" "C:\Windows\system32\ole3
2.dll" "C:\Windows\system32\version.dll" "C:\Windows\system32\netapi32.dll" "C:\
Windows\system32\userenv.dll" "C:\Windows\system32\winhttp.dll" "C:\Windows\syst
em32\kernel32.dll" "C:\Windows\system32\user32.dll" "C:\Windows\system32\gdi32.d
ll" "C:\Windows\system32\comdlg32.dll" "C:\Windows\system32\advapi32.dll" "C:\Wi
ndows\system32\shell32.dll" "C:\Windows\system32\ole32.dll" "C:\Windows\system32
\oleaut32.dll" "C:\Windows\system32\netapi32.dll" "C:\Windows\system32\ws2_32.dl
l" "C:\Windows\system32\mpr.dll" "C:\Windows\system32\winmm.dll" "C:\Windows\sys
tem32\version.dll" "C:\Windows\system32\odbc32.dll" "C:\Windows\system32\odbccp3
2.dll" "C:\Windows\system32\comctl32.dll" -Wl,--enable-auto-image-base
C:/Strawberry/c/bin/../lib/gcc/i686-w64-mingw32/8.3.0/../../../../i686-w64-mingw
32/bin/ld.exe: warning: resolving _NetWkstaGetInfo@12 by linking to _NetWkstaGet
Info
Use --enable-stdcall-fixup to disable these warnings
Use --disable-stdcall-fixup to disable these fixups
C:/Strawberry/c/bin/../lib/gcc/i686-w64-mingw32/8.3.0/../../../../i686-w64-mingw
32/bin/ld.exe: warning: resolving _NetApiBufferFree@4 by linking to _NetApiBuffe
rFree
C:/Strawberry/c/bin/../lib/gcc/i686-w64-mingw32/8.3.0/../../../../i686-w64-mingw
32/bin/ld.exe: warning: resolving _GetFileVersionInfoSizeA@8 by linking to _GetF
ileVersionInfoSizeA
C:/Strawberry/c/bin/../lib/gcc/i686-w64-mingw32/8.3.0/../../../../i686-w64-mingw
32/bin/ld.exe: warning: resolving _GetFileVersionInfoA@16 by linking to _GetFile
VersionInfoA
C:/Strawberry/c/bin/../lib/gcc/i686-w64-mingw32/8.3.0/../../../../i686-w64-mingw
32/bin/ld.exe: warning: resolving _VerQueryValueA@16 by linking to _VerQueryValu
eA
C:/Strawberry/c/bin/../lib/gcc/i686-w64-mingw32/8.3.0/../../../../i686-w64-mingw
32/bin/ld.exe: warning: resolving _CreateEnvironmentBlock@12 by linking to _Crea
teEnvironmentBlock
C:/Strawberry/c/bin/../lib/gcc/i686-w64-mingw32/8.3.0/../../../../i686-w64-mingw
32/bin/ld.exe: warning: resolving _DestroyEnvironmentBlock@4 by linking to _Dest
royEnvironmentBlock
C:/Strawberry/c/bin/../lib/gcc/i686-w64-mingw32/8.3.0/../../../../i686-w64-mingw
32/bin/ld.exe: Win32.o:Win32.c:(.text+0x9bf): undefined reference to `_imp__CoCr
eateGuid@4'
C:/Strawberry/c/bin/../lib/gcc/i686-w64-mingw32/8.3.0/../../../../i686-w64-mingw
32/bin/ld.exe: Win32.o:Win32.c:(.text+0x9e8): undefined reference to `_imp__Stri
ngFromCLSID@8'
C:/Strawberry/c/bin/../lib/gcc/i686-w64-mingw32/8.3.0/../../../../i686-w64-mingw
32/bin/ld.exe: Win32.o:Win32.c:(.text+0xa4b): undefined reference to `_imp__CoTa
skMemFree@4'
collect2.exe: error: ld returned 1 exit status
gmake[1]: *** [Makefile:477: ..\..\lib\auto\Win32\Win32.dll] Error 1
gmake[1]: Leaving directory 'C:/sources/perl5/cpan/Win32'
Unsuccessful make(cpan/Win32): code=512 at ..\make_ext.pl line 584.
gmake: *** [GNUmakefile:1562: Extensions] Error 2

C:\sources\perl5\win32>

Steps to Reproduce

Try building a i386 WinMingwGCCPerl with 5.41.13

Expected behavior

I have a new i386 WinGCCPerl on my disk.

Perl configuration

N/A
@haarg
Copy link
Contributor

haarg commented May 26, 2025

Perl-Toolchain-Gang/ExtUtils-MakeMaker@2c61b35 is the relevant change in EUMM.

@jkeenan
Copy link
Contributor

jkeenan commented May 26, 2025

@bulk88, I recommend you write a succinct version of this bug report and post it here.

@bulk88
Copy link
Contributor Author

bulk88 commented May 26, 2025

@bulk88, I recommend you write a succinct version of this bug report and post it here.

This is a revert needed in core issue at this point. Its not a wait for EUMM TC group, to go through the original minor flaw/minor defect and go through the broken "improvement" commit and work out a fix for the broken improvement, that probably involves discussing and modifying high river Public PP CPAN APIs.

Is support for i386/32 bit CPUs going to be officially dropped in 5.42.0 stable?

@sisyphus
Copy link
Contributor

I've just built 32-bit Windows build of current blead (at commit 79d4169), using gcc-15.1.0 (from https://winlibs.com) and can't find any issue.
Here is perl -V:

D:\>perl -V
Summary of my perl5 (revision 5 version 41 subversion 13) configuration:
  Derived from:
  Platform:
    osname=MSWin32
    osvers=10.0.26100.4061
    archname=MSWin32-x86-multi-thread
    uname=''
    config_args='undef'
    hint=recommended
    useposix=true
    d_sigaction=undef
    useithreads=define
    usemultiplicity=define
    use64bitint=undef
    use64bitall=undef
    uselongdouble=undef
    usemymalloc=n
    default_inc_excludes_dot=define
  Compiler:
    cc='gcc'
    ccflags =' -DWIN32 -fdiagnostics-color=never -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='15.1.0'
    gccosandvers=''
    intsize=4
    longsize=4
    ptrsize=4
    doublesize=8
    byteorder=1234
    doublekind=3
    d_longlong=define
    longlongsize=8
    d_longdbl=define
    longdblsize=12
    longdblkind=3
    ivtype='long'
    ivsize=4
    nvtype='double'
    nvsize=8
    Off_t='long long'
    lseeksize=8
    alignbytes=8
    prototype=define
  Linker and Libraries:
    ld='g++'
    ldflags ='-s -L"D:\perl-5.41.125-1510-ucrt-mcf\lib\MSWin32-x86-multi-thread\CORE" -L"C:\winlibs-ucrt-1510\mingw32\lib" -L"C:\winlibs-ucrt-1510\mingw32\i686-w64-mingw32\lib" -L"C:\winlibs-ucrt-1510\mingw32\lib\gcc\i686-w64-mingw32\15.1.0"'
    libpth=C:\winlibs-ucrt-1510\mingw32\lib C:\winlibs-ucrt-1510\mingw32\i686-w64-mingw32\lib C:\winlibs-ucrt-1510\mingw32\lib\gcc\i686-w64-mingw32\15.1.0 D:\_32\msys_1510\1.0\local\lib
    libs= -lmoldname -lkernel32 -luser32 -lgdi32 -lwinspool -lcomdlg32 -ladvapi32 -lshell32 -lole32 -loleaut32 -lnetapi32 -luuid -lws2_32 -lmpr -lwinmm -lversion -lodbc32 -lodbccp32 -lcomctl32
    perllibs= -lmoldname -lkernel32 -luser32 -lgdi32 -lwinspool -lcomdlg32 -ladvapi32 -lshell32 -lole32 -loleaut32 -lnetapi32 -luuid -lws2_32 -lmpr -lwinmm -lversion -lodbc32 -lodbccp32 -lcomctl32
    libc=-lucrt
    so=dll
    useshrplib=true
    libperl=libperl541.a
    gnulibc_version=''
  Dynamic Linking:
    dlsrc=dl_win32.xs
    dlext=dll
    d_dlsymun=undef
    ccdlflags=' '
    cccdlflags=' '
    lddlflags='-shared -s -L"D:\perl-5.41.125-1510-ucrt-mcf\lib\MSWin32-x86-multi-thread\CORE" -L"C:\winlibs-ucrt-1510\mingw32\lib" -L"C:\winlibs-ucrt-1510\mingw32\i686-w64-mingw32\lib" -L"C:\winlibs-ucrt-1510\mingw32\lib\gcc\i686-w64-mingw32\15.1.0"'


Characteristics of this binary (from libperl):
  Compile-time options:
    HAS_LONG_DOUBLE
    HAS_TIMES
    HAVE_INTERP_INTERN
    MULTIPLICITY
    PERLIO_LAYERS
    PERL_COPY_ON_WRITE
    PERL_DONT_CREATE_GVSV
    PERL_HASH_FUNC_ZAPHOD32
    PERL_HASH_USE_SBOX32
    PERL_IMPLICIT_SYS
    PERL_MALLOC_WRAP
    PERL_OP_PARENT
    PERL_PRESERVE_IVUV
    PERL_USE_SAFE_PUTENV
    USE_ITHREADS
    USE_LARGE_FILES
    USE_LOCALE
    USE_LOCALE_COLLATE
    USE_LOCALE_CTYPE
    USE_LOCALE_NUMERIC
    USE_LOCALE_TIME
    USE_PERLIO
    USE_PERL_ATOF
    USE_THREAD_SAFE_LOCALE
  Locally applied patches:
    uncommitted-changes
  Built under MSWin32
  Compiled at May 27 2025 11:17:35
  @INC:
    D:/perl-5.41.125-1510-ucrt-mcf/site/lib/MSWin32-x86-multi-thread
    D:/perl-5.41.125-1510-ucrt-mcf/site/lib
    D:/perl-5.41.125-1510-ucrt-mcf/lib/MSWin32-x86-multi-thread
    D:/perl-5.41.125-1510-ucrt-mcf/lib

Note that I build my perl with the -std=c99 switch removed from ccflags.
In case it matters, I also build perl with this patch applied to ExtUtils-MakeMaker/MM_Win32.pm:

$ diff  -u MM_Win32.pm_orig MM_Win32.pm
--- MM_Win32.pm_orig    2025-05-27 10:57:45.128196800 +1000
+++ MM_Win32.pm 2025-05-27 11:09:31.297057700 +1000
@@ -142,9 +142,18 @@
     $self->{NOOP}     ||= 'rem';
     $self->{DEV_NULL} ||= '> NUL';

-    $self->{FIXIN}    ||= $self->{PERL_CORE} ?
-      "\$(PERLRUN) -I$self->{PERL_SRC}\\cpan\\ExtUtils-PL2Bat\\lib $self->{PERL_SRC}\\win32\\bin\\pl2bat.pl" :
-      'pl2bat.bat';
+    if (!$self->{FIXIN}) {
+        if ($self->{PERL_CORE}) {
+            my $psrc = $self->{PERL_SRC};  #  shorten next line
+            $self->{FIXIN} = "\$(PERLRUN) -I${psrc}\\cpan\\ExtUtils-PL2Bat\\lib ${psrc}\\win32\\bin\\pl2bat.pl";
+        }
+        else {
+            my @path = split $Config{path_sep}, $ENV{PATH};
+            my @found = grep {-e qq{$_\\pl2bat.bat}} @path;
+            $self->{FIXIN} = @found ? qq{"$found[0]\\pl2bat.bat"} : "pl2bat.bat";
+        }
+    }
+

     $self->SUPER::init_tools;

How do I get to experience the problem that you are seeing ?

@bulk88
Copy link
Contributor Author

bulk88 commented May 27, 2025

I've just built 32-bit Windows build of current blead (at commit 79d4169), using gcc-15.1.0 (from https://winlibs.com) and can't find any issue. Here is perl -V:

IDK how Winlibs.com configs/bundles their GCC, and is it of mingw.org or mingw64 family, winlibs.com claims to be a mingw64, which I consider the good fork.

I use whatever GCC binaries/headers that came with various different Strawberry Perls I installed. All Strawberrys come with GCCs compiled from source by Strawberry project ppl. Except early on when they distributed a GCC binary from H**L called mingw.org 3.4.5

For the above errors, I am using This is perl 5, version 32, subversion 1 (v5.32.1) built for MSWin32-x86-multi-thread-64int and

C:\sources\perl5\win32>gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=C:/Strawberry/c/bin/../libexec/gcc/i686-w64-mingw32/8.3.0/lt
o-wrapper.exe
Target: i686-w64-mingw32
Configured with: ../../../src/gcc-8.3.0/configure --host=i686-w64-mingw32 --buil
d=i686-w64-mingw32 --target=i686-w64-mingw32 --prefix=/mingw32 --enable-shared -
-enable-static --disable-multilib --enable-languages=c,c++,fortran,lto --enable-
expand ``` libstdcxx-time=yes --enable-threads=posix --enable-libgomp --enable-libatomic -- enable-lto --enable-graphite --enable-checking=release --enable-fully-dynamic-st ring --enable-version-specific-runtime-libs --enable-libstdcxx-filesystem-ts=yes --disable-sjlj-exceptions --with-dwarf2 --disable-libstdcxx-pch --disable-libst dcxx-debug --disable-bootstrap --disable-rpath --disable-win32-registry --disabl e-nls --disable-werror --disable-symvers --with-gnu-as --with-gnu-ld --with-arch =i686 --with-tune=generic --with-libiconv --with-system-zlib --with-gmp=/opt/bui ld/prerequisites/i686-w64-mingw32-static --with-mpfr=/opt/build/prerequisites/i6 86-w64-mingw32-static --with-mpc=/opt/build/prerequisites/i686-w64-mingw32-stati c --with-isl=/opt/build/prerequisites/i686-w64-mingw32-static --with-pkgversion= 'i686-posix-dwarf, Built by strawberryperl.com project' --with-bugurl=https://so urceforge.net/projects/mingw-w64 CFLAGS='-O2 -pipe -fno-ident -I/opt/build/i686- 830-posix-dwarf-rt_v6/mingw32/opt/include -I/opt/build/prerequisites/i686-zlib-s tatic/include -I/opt/build/prerequisites/i686-w64-mingw32-static/include' CXXFLA GS='-O2 -pipe -fno-ident -I/opt/build/i686-830-posix-dwarf-rt_v6/mingw32/opt/inc lude -I/opt/build/prerequisites/i686-zlib-static/include -I/opt/build/prerequisi tes/i686-w64-mingw32-static/include' CPPFLAGS=' -I/opt/build/i686-830-posix-dwar f-rt_v6/mingw32/opt/include -I/opt/build/prerequisites/i686-zlib-static/include -I/opt/build/prerequisites/i686-w64-mingw32-static/include' LDFLAGS='-pipe -fno- ```
ident -L/opt/build/i686-830-posix-dwarf-rt_v6/mingw32/opt/lib -L/opt/build/prere
quisites/i686-zlib-static/lib -L/opt/build/prerequisites/i686-w64-mingw32-static
/lib -Wl,--large-address-aware' LD_FOR_TARGET=/opt/build/i686-830-posix-dwarf-rt
_v6/mingw32/bin/ld.exe
Thread model: posix
gcc version 8.3.0 (i686-posix-dwarf, Built by strawberryperl.com project)

How do I get to experience the problem that you are seeing ?

Use the i386 GCC that came with i386 Straw 5.32.

"C:\sources\perl5\miniperl.exe" "-I..\..\lib" -MExtUtils::Command -e chmod -- 75
5 ..\..\lib\auto\Unicode\Collate\Collate.dll
gmake[1]: Leaving directory 'C:/sources/perl5/cpan/Unicode-Collate'
Warning (mostly harmless): No library found for
Warning (mostly harmless): No library found for -lmoldname
Warning (mostly harmless): No library found for -lwinspool
Warning (mostly harmless): No library found for -luuid
Generating a gmake-style Makefile
Writing Makefile for Win32
gmake[1]: Entering directory 'C:/sources/perl5/cpan/Win32'
Running Mkbootstrap for Win32 ()
"C:\sources\perl5\miniperl.exe" "-I..\..\lib" -MExtUtils::Command -e chmod -- 64
4 "Win32.bs"
"C:\sources\perl5\miniperl.exe" "-I..\..\lib" -MExtUtils::Command::MM -e cp_none
mpty -- Win32.bs ..\..\lib\auto\Win32\Win32.bs 644
"C:\sources\perl5\miniperl.exe" "-I..\..\lib" "C:\sources\perl5\dist\ExtUtils-Pa
rseXS\lib\ExtUtils/xsubpp"  -typemap C:\sources\perl5\lib\ExtUtils\typemap  Win3
2.xs > Win32.xsc
"C:\sources\perl5\miniperl.exe" "-I..\..\lib" -MExtUtils::Command -e mv -- Win32
.xsc Win32.c
gcc -c   -std=c99 -DWIN32 -DPERL_TEXTMODE_SCRIPTS -DMULTIPLICITY -DPERL_IMPLICIT
_SYS -DUSE_PERLIO -D__USE_MINGW_ANSI_STDIO -fwrapv -fno-strict-aliasing -mms-bit
fields -Os   -DVERSION=\"0.59_01\" -DXS_VERSION=\"0.59_01\"  "-I..\..\lib\CORE"
  Win32.c
"C:\sources\perl5\miniperl.exe" "-I..\..\lib" -MExtUtils::Mksymlists \
     -e "Mksymlists('NAME'=>\"Win32\", 'DLBASE' => 'Win32', 'DL_FUNCS' => {  },
'FUNCLIST' => [], 'IMPORTS' => {  }, 'DL_VARS' => []);"
g++ Win32.def -o ..\..\lib\auto\Win32\Win32.dll -shared -s -L"c:\perl\lib\CORE"
-L"C:\MinGW\lib" -L"C:\MinGW\i686-w64-mingw32\lib" -L"C:\MinGW\lib\gcc\i686-w64-
mingw32\8.3.0" Win32.o   "..\..\lib\CORE\libperl541.a" "C:\Windows\system32\user
env.dll" "C:\Windows\system32\winhttp.dll" "C:\Windows\system32\kernel32.dll" "C
:\Windows\system32\user32.dll" "C:\Windows\system32\gdi32.dll" "C:\Windows\syste
m32\comdlg32.dll" "C:\Windows\system32\advapi32.dll" "C:\Windows\system32\shell3
2.dll" "C:\Windows\system32\ole32.dll" "C:\Windows\system32\oleaut32.dll" "C:\Wi
ndows\system32\netapi32.dll" "C:\Windows\system32\ws2_32.dll" "C:\Windows\system
32\mpr.dll" "C:\Windows\system32\winmm.dll" "C:\Windows\system32\version.dll" "C
:\Windows\system32\odbc32.dll" "C:\Windows\system32\odbccp32.dll" "C:\Windows\sy
stem32\comctl32.dll" -Wl,--enable-auto-image-base
C:/Strawberry/c/bin/../lib/gcc/i686-w64-mingw32/8.3.0/../../../../i686-w64-mingw
32/bin/ld.exe: warning: resolving _NetWkstaGetInfo@12 by linking to _NetWkstaGet
Info
Use --enable-stdcall-fixup to disable these warnings
Use --disable-stdcall-fixup to disable these fixups
C:/Strawberry/c/bin/../lib/gcc/i686-w64-mingw32/8.3.0/../../../../i686-w64-mingw
32/bin/ld.exe: warning: resolving _NetApiBufferFree@4 by linking to _NetApiBuffe
rFree
C:/Strawberry/c/bin/../lib/gcc/i686-w64-mingw32/8.3.0/../../../../i686-w64-mingw
32/bin/ld.exe: warning: resolving _GetFileVersionInfoSizeA@8 by linking to _GetF
ileVersionInfoSizeA
C:/Strawberry/c/bin/../lib/gcc/i686-w64-mingw32/8.3.0/../../../../i686-w64-mingw
32/bin/ld.exe: warning: resolving _GetFileVersionInfoA@16 by linking to _GetFile
VersionInfoA
C:/Strawberry/c/bin/../lib/gcc/i686-w64-mingw32/8.3.0/../../../../i686-w64-mingw
32/bin/ld.exe: warning: resolving _VerQueryValueA@16 by linking to _VerQueryValu
eA
C:/Strawberry/c/bin/../lib/gcc/i686-w64-mingw32/8.3.0/../../../../i686-w64-mingw
32/bin/ld.exe: warning: resolving _WinHttpCrackUrl@16 by linking to _WinHttpCrac
kUrl

CUT

C:/Strawberry/c/bin/../lib/gcc/i686-w64-mingw32/8.3.0/../../../../i686-w64-mingw
32/bin/ld.exe: warning: resolving _WinHttpCloseHandle@4 by linking to _WinHttpCl
oseHandle
C:/Strawberry/c/bin/../lib/gcc/i686-w64-mingw32/8.3.0/../../../../i686-w64-mingw
32/bin/ld.exe: warning: resolving _CreateEnvironmentBlock@12 by linking to _Crea
teEnvironmentBlock
C:/Strawberry/c/bin/../lib/gcc/i686-w64-mingw32/8.3.0/../../../../i686-w64-mingw
32/bin/ld.exe: warning: resolving _DestroyEnvironmentBlock@4 by linking to _Dest
royEnvironmentBlock
C:/Strawberry/c/bin/../lib/gcc/i686-w64-mingw32/8.3.0/../../../../i686-w64-mingw
32/bin/ld.exe: Win32.o:Win32.c:(.text+0x78b): undefined reference to `_imp__CoCr
eateGuid@4'
C:/Strawberry/c/bin/../lib/gcc/i686-w64-mingw32/8.3.0/../../../../i686-w64-mingw
32/bin/ld.exe: Win32.o:Win32.c:(.text+0x7b4): undefined reference to `_imp__Stri
ngFromCLSID@8'
C:/Strawberry/c/bin/../lib/gcc/i686-w64-mingw32/8.3.0/../../../../i686-w64-mingw
32/bin/ld.exe: Win32.o:Win32.c:(.text+0x817): undefined reference to `_imp__CoTa
skMemFree@4'
collect2.exe: error: ld returned 1 exit status
gmake[1]: *** [Makefile:477: ..\..\lib\auto\Win32\Win32.dll] Error 1
gmake[1]: Leaving directory 'C:/sources/perl5/cpan/Win32'
gmake[1]: Entering directory 'C:/sources/perl5/cpan/Win32'
"C:\sources\perl5\miniperl.exe" "-I..\..\lib" -MExtUtils::Command::MM -e cp_none
mpty -- Win32.bs ..\..\lib\auto\Win32\Win32.bs 644
g++ Win32.def -o ..\..\lib\auto\Win32\Win32.dll -shared -s -L"c:\perl\lib\CORE"
-L"C:\MinGW\lib" -L"C:\MinGW\i686-w64-mingw32\lib" -L"C:\MinGW\lib\gcc\i686-w64-
mingw32\8.3.0" Win32.o   "..\..\lib\CORE\libperl541.a" "C:\Windows\system32\user
env.dll" "C:\Windows\system32\winhttp.dll" "C:\Windows\system32\kernel32.dll" "C
:\Windows\system32\user32.dll" "C:\Windows\system32\gdi32.dll" "C:\Windows\syste
m32\comdlg32.dll" "C:\Windows\system32\advapi32.dll" "C:\Windows\system32\shell3
2.dll" "C:\Windows\system32\ole32.dll" "C:\Windows\system32\oleaut32.dll" "C:\Wi
ndows\system32\netapi32.dll" "C:\Windows\system32\ws2_32.dll" "C:\Windows\system
32\mpr.dll" "C:\Windows\system32\winmm.dll" "C:\Windows\system32\version.dll" "C
:\Windows\system32\odbc32.dll" "C:\Windows\system32\odbccp32.dll" "C:\Windows\sy
stem32\comctl32.dll" -Wl,--enable-auto-image-base
C:/Strawberry/c/bin/../lib/gcc/i686-w64-mingw32/8.3.0/../../../../i686-w64-mingw
32/bin/ld.exe: warning: resolving _NetWkstaGetInfo@12 by linking to _NetWkstaGet
Info
Use --enable-stdcall-fixup to disable these warnings
Use --disable-stdcall-fixup to disable these fixups
C:/Strawberry/c/bin/../lib/gcc/i686-w64-mingw32/8.3.0/../../../../i686-w64-mingw
32/bin/ld.exe: warning: resolving _NetApiBufferFree@4 by linking to _NetApiBuffe
rFree

Do you see the "..\..\lib\CORE\libperl541.a" "C:\Windows\system32\user env.dll" "C:\Windows\system32\winhttp.dll" "C:\Windows\system32\kernel32.dll" "C :\Windows\system32\user32.dll" "C:\Windows\system32\gdi32.dll" when Win32.o is created on your side? With the abs paths to .dll'es instead of -lsomelib32 ?

@bulk88
Copy link
Contributor Author

bulk88 commented May 27, 2025

I 've never CC_HOME env var in the root makefile, my GCCs can find their /lib folder automatically.

changing Win32.pms makefile by hand, top is from current blead to bottom version fixes the link failure

# --- MakeMaker const_loadlibs section:

# Win32 might depend on some other libraries:
# See ExtUtils::Liblist for details
#
EXTRALIBS = "C:\Windows\system32\userenv.dll" "C:\Windows\system32\winhttp.dll" "C:\Windows\system32\kernel32.dll" "C:\Windows\system32\user32.dll" "C:\Windows\system32\gdi32.dll" "C:\Windows\system32\comdlg32.dll" "C:\Windows\system32\advapi32.dll" "C:\Windows\system32\shell32.dll" "C:\Windows\system32\ole32.dll" "C:\Windows\system32\oleaut32.dll" "C:\Windows\system32\netapi32.dll" "C:\Windows\system32\ws2_32.dll" "C:\Windows\system32\mpr.dll" "C:\Windows\system32\winmm.dll" "C:\Windows\system32\version.dll" "C:\Windows\system32\odbc32.dll" "C:\Windows\system32\odbccp32.dll" "C:\Windows\system32\comctl32.dll"
LDLOADLIBS = "C:\Windows\system32\userenv.dll" "C:\Windows\system32\winhttp.dll" "C:\Windows\system32\kernel32.dll" "C:\Windows\system32\user32.dll" "C:\Windows\system32\gdi32.dll" "C:\Windows\system32\comdlg32.dll" "C:\Windows\system32\advapi32.dll" "C:\Windows\system32\shell32.dll" "C:\Windows\system32\ole32.dll" "C:\Windows\system32\oleaut32.dll" "C:\Windows\system32\netapi32.dll" "C:\Windows\system32\ws2_32.dll" "C:\Windows\system32\mpr.dll" "C:\Windows\system32\winmm.dll" "C:\Windows\system32\version.dll" "C:\Windows\system32\odbc32.dll" "C:\Windows\system32\odbccp32.dll" "C:\Windows\system32\comctl32.dll"
BSLOADLIBS = 
# --- MakeMaker const_loadlibs section:

# Win32 might depend on some other libraries:
# See ExtUtils::Liblist for details
#
EXTRALIBS = -lmoldname -lkernel32 -luser32 -lgdi32 -lwinspool -lcomdlg32 -ladvapi32 -lshell32 -lole32 -loleaut32 -lnetapi32 -luuid -lws2_32 -lmpr -lwinmm -lversion -lodbc32 -lodbccp32 -lcomctl32 -lwinhttp -luserenv
LDLOADLIBS = -lmoldname -lkernel32 -luser32 -lgdi32 -lwinspool -lcomdlg32 -ladvapi32 -lshell32 -lole32 -loleaut32 -lnetapi32 -luuid -lws2_32 -lmpr -lwinmm -lversion -lodbc32 -lodbccp32 -lcomctl32 -lwinhttp -luserenv
BSLOADLIBS = 

@bulk88
Copy link
Contributor Author

bulk88 commented May 28, 2025

Perl-Toolchain-Gang/ExtUtils-MakeMaker#277

might be related but bug ticket was opened in 2018

@sisyphus
Copy link
Contributor

Use the i386 GCC that came with i386 Straw 5.32.

Building blead (at commit 79d4169) using that compiler, I start with:

D:\comp-830\blead\win32>gmake INST_TOP=D:\perl-5.41.13-830 CCTYPE=GCC CCHOME=C:\sp\_32\sp-5.32.1-64int\c USE_MINGW_ANSI_STDIO=define

That all proceeds without error for me - so I run the test suite:

D:\comp-830\blead\win32>gmake INST_TOP=D:\perl-5.41.13-830 CCTYPE=GCC CCHOME=C:\sp\_32\sp-5.32.1-64int\c USE_MINGW_ANSI_STDIO=define test

I get:

All tests successful.

Test Summary Report
-------------------
run/todo.t                                                         (Wstat: 0 Tests: 6 Failed: 0)
  TODO passed:   3-4
../ext/IPC-Open3/t/IPC-Open3.t                                     (Wstat: 0 Tests: 53 Failed: 0)
  TODO passed:   33
Files=2916, Tests=1240446, 1273 wallclock secs (47.67 usr +  3.66 sys = 51.33 CPU)
Result: PASS
Finished test run at Wed May 28 22:01:10 2025.

I'm still not seeing any issue.

Here is the perl -V output of this perl:

D:\comp-830\blead\win32>..\perl -I..\lib -V
Summary of my perl5 (revision 5 version 41 subversion 13) configuration:
  Derived from:
  Platform:
    osname=MSWin32
    osvers=10.0.26100.4061
    archname=MSWin32-x86-multi-thread
    uname=''
    config_args='undef'
    hint=recommended
    useposix=true
    d_sigaction=undef
    useithreads=define
    usemultiplicity=define
    use64bitint=undef
    use64bitall=undef
    uselongdouble=undef
    usemymalloc=n
    default_inc_excludes_dot=define
  Compiler:
    cc='gcc'
    ccflags ='-std=c99 -DWIN32  -DPERL_TEXTMODE_SCRIPTS -DMULTIPLICITY -DPERL_IMPLICIT_SYS -DUSE_PERLIO -D__USE_MINGW_ANSI_STDIO -fwrapv -fno-strict-aliasing -mms-bitfields'
    optimize='-Os'
    cppflags='-DWIN32'
    ccversion=''
    gccversion='8.3.0'
    gccosandvers=''
    intsize=4
    longsize=4
    ptrsize=4
    doublesize=8
    byteorder=1234
    doublekind=3
    d_longlong=define
    longlongsize=8
    d_longdbl=define
    longdblsize=12
    longdblkind=3
    ivtype='long'
    ivsize=4
    nvtype='double'
    nvsize=8
    Off_t='long long'
    lseeksize=8
    alignbytes=8
    prototype=define
  Linker and Libraries:
    ld='g++'
    ldflags ='-s -L"D:\perl-5.41.13-830\lib\CORE" -L"C:\sp\_32\sp-5.32.1-64int\c\lib" -L"C:\sp\_32\sp-5.32.1-64int\c\i686-w64-mingw32\lib" -L"C:\sp\_32\sp-5.32.1-64int\c\lib\gcc\i686-w64-mingw32\8.3.0"'
    libpth=C:\sp\_32\sp-5.32.1-64int\c\lib C:\sp\_32\sp-5.32.1-64int\c\i686-w64-mingw32\lib C:\sp\_32\sp-5.32.1-64int\c\lib\gcc\i686-w64-mingw32\8.3.0
    libs= -lmoldname -lkernel32 -luser32 -lgdi32 -lwinspool -lcomdlg32 -ladvapi32 -lshell32 -lole32 -loleaut32 -lnetapi32 -luuid -lws2_32 -lmpr -lwinmm -lversion -lodbc32 -lodbccp32 -lcomctl32
    perllibs= -lmoldname -lkernel32 -luser32 -lgdi32 -lwinspool -lcomdlg32 -ladvapi32 -lshell32 -lole32 -loleaut32 -lnetapi32 -luuid -lws2_32 -lmpr -lwinmm -lversion -lodbc32 -lodbccp32 -lcomctl32
    libc=-lmsvcrt
    so=dll
    useshrplib=true
    libperl=libperl541.a
    gnulibc_version=''
  Dynamic Linking:
    dlsrc=dl_win32.xs
    dlext=dll
    d_dlsymun=undef
    ccdlflags=' '
    cccdlflags=' '
    lddlflags='-shared -s -L"D:\perl-5.41.13-830\lib\CORE" -L"C:\sp\_32\sp-5.32.1-64int\c\lib" -L"C:\sp\_32\sp-5.32.1-64int\c\i686-w64-mingw32\lib" -L"C:\sp\_32\sp-5.32.1-64int\c\lib\gcc\i686-w64-mingw32\8.3.0"'


Characteristics of this binary (from libperl):
  Compile-time options:
    HAS_LONG_DOUBLE
    HAS_TIMES
    HAVE_INTERP_INTERN
    MULTIPLICITY
    PERLIO_LAYERS
    PERL_COPY_ON_WRITE
    PERL_DONT_CREATE_GVSV
    PERL_HASH_FUNC_ZAPHOD32
    PERL_HASH_USE_SBOX32
    PERL_IMPLICIT_SYS
    PERL_MALLOC_WRAP
    PERL_OP_PARENT
    PERL_PRESERVE_IVUV
    PERL_USE_SAFE_PUTENV
    USE_ITHREADS
    USE_LARGE_FILES
    USE_LOCALE
    USE_LOCALE_COLLATE
    USE_LOCALE_CTYPE
    USE_LOCALE_NUMERIC
    USE_LOCALE_TIME
    USE_PERLIO
    USE_PERL_ATOF
  Locally applied patches:
    uncommitted-changes
  Built under MSWin32
  Compiled at May 28 2025 21:31:23
  @INC:
    ..\lib
    D:/comp-830/blead/lib

According to gcc -v the compiler used was:
gcc version 8.3.0 (i686-posix-dwarf, Built by strawberryperl.com project)

@bulk88
Copy link
Contributor Author

bulk88 commented May 30, 2025

NST_TOP=D:\perl-5.41.13-830 CCTYPE=GCC CCHOME=C:\sp_32\sp-5.32.1-64int\c USE_MINGW_ANSI_STDIO=define

Use the i386 GCC that came with i386 Straw 5.32.

Building blead (at commit 79d4169) using that compiler, I start with:

D:\comp-830\blead\win32>gmake INST_TOP=D:\perl-5.41.13-830 CCTYPE=GCC CCHOME=C:\sp\_32\sp-5.32.1-64int\c USE_MINGW_ANSI_STDIO=define

That all proceeds without error for me - so I run the test suite:

D:\comp-830\blead\win32>gmake INST_TOP=D:\perl-5.41.13-830 CCTYPE=GCC CCHOME=C:\sp\_32\sp-5.32.1-64int\c USE_MINGW_ANSI_STDIO=define test

I get:

Type gmake -j1234 test, nothing else, pick whatever -j or no -j u want, just "test" on the command line, no makefile variables on the cmd line, GNUMkf's default is GCC always.

@sisyphus
Copy link
Contributor

no makefile variables on the cmd line

You want me to just accept all defaults ?
If I do that then CCHOME is either not set, or is set to (the non-existent) C:\MinGW.
That doesn't make much sense to me, but I've tried it anyway by building simply with gmake test.

Unsurprisingly the process croaked after a minute or so with:

'CCLIBDIR' contains the following non-existing paths:
        C:\MinGW\lib
        C:\MinGW\i686-w64-mingw32\lib
        C:\MinGW\lib\gcc\i686-w64-mingw32\8.3.0
Did you provide a correct value for the 'CCHOME' option?

(This check can be skipped by using the SKIP_CCHOME_CHECK=1 option)
gmake: *** [GNUmakefile:1192: ..\config.sh] Error 1

So, I try to rebuild from scratch with:

gmake SKIP_CCHOME_CHECK=1 test

But the build eventually fails with:

g++ Win32.def -o ....<snipped> .... -Wl,--enable-auto-image-base
C:/sp/_32/sp-5.32.1-64int/c/bin/../lib/gcc/i686-w64-mingw32/8.3.0/../../../../i686-w64-mingw32/bin/ld.exe: warning: resolving _NetWkstaGetInfo@12 by linking to _NetWkstaGetInfo
Use --enable-stdcall-fixup to disable these warnings
Use --disable-stdcall-fixup to disable these fixups
C:/sp/_32/sp-5.32.1-64int/c/bin/../lib/gcc/i686-w64-mingw32/8.3.0/../../../../i686-w64-mingw32/bin/ld.exe: warning: resolving _NetApiBufferFree@4 by linking to _NetApiBufferFree
C:/sp/_32/sp-5.32.1-64int/c/bin/../lib/gcc/i686-w64-mingw32/8.3.0/../../../../i686-w64-mingw32/bin/ld.exe: warning: resolving _GetFileVersionInfoSizeA@8 by linking to _GetFileVersionInfoSizeA
C:/sp/_32/sp-5.32.1-64int/c/bin/../lib/gcc/i686-w64-mingw32/8.3.0/../../../../i686-w64-mingw32/bin/ld.exe: warning: resolving _GetFileVersionInfoA@16 by linking to _GetFileVersionInfoA
C:/sp/_32/sp-5.32.1-64int/c/bin/../lib/gcc/i686-w64-mingw32/8.3.0/../../../../i686-w64-mingw32/bin/ld.exe: warning: resolving _VerQueryValueA@16 by linking to _VerQueryValueA
C:/sp/_32/sp-5.32.1-64int/c/bin/../lib/gcc/i686-w64-mingw32/8.3.0/../../../../i686-w64-mingw32/bin/ld.exe: warning: resolving _WinHttpCrackUrl@16 by linking to _WinHttpCrackUrl
C:/sp/_32/sp-5.32.1-64int/c/bin/../lib/gcc/i686-w64-mingw32/8.3.0/../../../../i686-w64-mingw32/bin/ld.exe: warning: resolving _WinHttpOpen@20 by linking to _WinHttpOpen
C:/sp/_32/sp-5.32.1-64int/c/bin/../lib/gcc/i686-w64-mingw32/8.3.0/../../../../i686-w64-mingw32/bin/ld.exe: warning: resolving _WinHttpConnect@16 by linking to _WinHttpConnect
C:/sp/_32/sp-5.32.1-64int/c/bin/../lib/gcc/i686-w64-mingw32/8.3.0/../../../../i686-w64-mingw32/bin/ld.exe: warning: resolving _WinHttpOpenRequest@28 by linking to _WinHttpOpenRequest
C:/sp/_32/sp-5.32.1-64int/c/bin/../lib/gcc/i686-w64-mingw32/8.3.0/../../../../i686-w64-mingw32/bin/ld.exe: warning: resolving _WinHttpSetOption@16 by linking to _WinHttpSetOption
C:/sp/_32/sp-5.32.1-64int/c/bin/../lib/gcc/i686-w64-mingw32/8.3.0/../../../../i686-w64-mingw32/bin/ld.exe: warning: resolving _WinHttpGetProxyForUrl@16 by linking to _WinHttpGetProxyForUrl
C:/sp/_32/sp-5.32.1-64int/c/bin/../lib/gcc/i686-w64-mingw32/8.3.0/../../../../i686-w64-mingw32/bin/ld.exe: warning: resolving _WinHttpSendRequest@28 by linking to _WinHttpSendRequest
C:/sp/_32/sp-5.32.1-64int/c/bin/../lib/gcc/i686-w64-mingw32/8.3.0/../../../../i686-w64-mingw32/bin/ld.exe: warning: resolving _WinHttpReceiveResponse@8 by linking to _WinHttpReceiveResponse
C:/sp/_32/sp-5.32.1-64int/c/bin/../lib/gcc/i686-w64-mingw32/8.3.0/../../../../i686-w64-mingw32/bin/ld.exe: warning: resolving _WinHttpQueryHeaders@24 by linking to _WinHttpQueryHeaders
C:/sp/_32/sp-5.32.1-64int/c/bin/../lib/gcc/i686-w64-mingw32/8.3.0/../../../../i686-w64-mingw32/bin/ld.exe: warning: resolving _WinHttpReadData@16 by linking to _WinHttpReadData
C:/sp/_32/sp-5.32.1-64int/c/bin/../lib/gcc/i686-w64-mingw32/8.3.0/../../../../i686-w64-mingw32/bin/ld.exe: warning: resolving _WinHttpCloseHandle@4 by linking to _WinHttpCloseHandle
C:/sp/_32/sp-5.32.1-64int/c/bin/../lib/gcc/i686-w64-mingw32/8.3.0/../../../../i686-w64-mingw32/bin/ld.exe: warning: resolving _CreateEnvironmentBlock@12 by linking to _CreateEnvironmentBlock
C:/sp/_32/sp-5.32.1-64int/c/bin/../lib/gcc/i686-w64-mingw32/8.3.0/../../../../i686-w64-mingw32/bin/ld.exe: warning: resolving _DestroyEnvironmentBlock@4 by linking to _DestroyEnvironmentBlock
C:/sp/_32/sp-5.32.1-64int/c/bin/../lib/gcc/i686-w64-mingw32/8.3.0/../../../../i686-w64-mingw32/bin/ld.exe: Win32.o:Win32.c:(.text+0x78b): undefined reference to `_imp__CoCreateGuid@4'
C:/sp/_32/sp-5.32.1-64int/c/bin/../lib/gcc/i686-w64-mingw32/8.3.0/../../../../i686-w64-mingw32/bin/ld.exe: Win32.o:Win32.c:(.text+0x7b4): undefined reference to `_imp__StringFromCLSID@8'
C:/sp/_32/sp-5.32.1-64int/c/bin/../lib/gcc/i686-w64-mingw32/8.3.0/../../../../i686-w64-mingw32/bin/ld.exe: Win32.o:Win32.c:(.text+0x817): undefined reference to `_imp__CoTaskMemFree@4'
collect2.exe: error: ld returned 1 exit status
gmake[1]: *** [Makefile:477: ..\..\lib\auto\Win32\Win32.dll] Error 1
gmake[1]: Leaving directory 'D:/comp-830/blead/cpan/Win32'
Unsuccessful make(cpan/Win32): code=512 at ..\make_ext.pl line 584.
gmake: *** [GNUmakefile:1562: Extensions] Error 2

I just don't understand the point of all this.

@sisyphus
Copy link
Contributor

sisyphus commented May 30, 2025

I've just noticed that current blead and perl-5.41.13 both have EU-MM-7.76, whereas the title of this issue refers to version 7.72.
(Maybe it's referring to 7.72 onwards ... not sure.)
@bulk88 , has version 7.76 changed anything regarding this issue ?

UPDATE:

Aaah ... at last I see the similarity between what I got and what @bulk88 got - including the full paths to the Windows dlls (that I had snipped out).

@bulk88
Copy link
Contributor Author

bulk88 commented May 31, 2025

Edit: I forgot to include SKIP_CCHOME_CHECK=1 in gmake SKIP_CCHOME_CHECK=1 test. I set SKIP_CCHOME_CHECK=1 as a global ENV var on my dev capable systems. 1st post continues below.

Yes @sisyphus you reproduced what I am seeing. Previously Mingw GCC built stable perls/older EU::MMs just complain in the console with approx "can't find library for -lsomething32" but there are no side effects or failures or bugs, and since its harmless and a NOOP basically I've never cared about that warning.

A very recent new feature in EU::MM that mohawk added, but I can't find a PR or any discussion about it. I only see the commits related to the new feature in EU::MM, is to allow Linux style runtime static linking from importer XS_one.dll to exporter XS_two.dll. Both are CPAN XS modules. This feature is a wishlist item, its not a critical fix for EU::MM. EU::MM and WinGCCPerl/Strawberry have been happy without the new feature for the last 15-20 years.

Now that EU::MM or one of its subclasses, wants to pretend that it is smarter than the g++.exe/ld.exe binary, and knows better how to find """libraries""" than the g++.exe/ld.exe binary itself, and in reality EU::MM fails to be smarter than the g++.exe/ld.exe binary and doesn't find the """libraries""" on the FS b/c it doesn't know the real algorithm the g++.exe/ld.exe binary uses to find .a files.

Or maybe, I didn't single step EU::MM to verify this. EU::MM never looks for .a files on the FS, just .dll files in %PATH% on the FS. Thats a huge defect in EU::MM if hypothesis # 2 is true. The PE specification's .exe/.dll files, are 95% unrelated, hexdump wise, to COFF files, or .o files. While in the ELF spec, a .so and a .o are 90% identical in a hexdump. If desired, ld.so, could treat both .so and .o files identically as input at process runtime, and it would be invisible to the end user.

Then EU::MM deletes all the -lsomething32 cmd line args, and tells ld.exe to use a WinGCC only feature, and to look at the PE symbol tables of real .dll files. The PE Symbol table and its symbols, definitely aren't a synonym or 1 to 1 analog for C Abstract Virtual Machine Symbols. One example, for this discussion, PE symbols always include the .dll file name in their string name, otherwise that PE "symbol" now has what Linux people call "internal linkage" || "static declaration" || "hidden visibility".

The code inside g++.exe/ld.exe binary to link against raw .dll files, without using a .a file is buggy, or has a large limitation on i386 only. It can't find __stdcall symbols and probably can't find inter-.dll exported data vars. Just _cdecl functions and nothing else.

MS un-mangles __stdcall symbol names when they compile all i386 MS in-house .dll files, so GetProcAddress() is easy to use. ld.exe thinks its finding i386 _cdecl functions scanning i386 kernel32.dll's and i386 user32.dll's PE export tables and tries injecting auto-created _cdecl function symbols into C Abstract VM linker state . Hilarity ensues.

In reality, Mingw Project uses a different algorithm than the one inside ld.exe to separate i386 _cdecl and i386 __stdcall function symbols, in an automatic 100% safe and correct way.

See https://github.com/mirror/mingw-w64/blob/master/mingw-w64-tools/gendef/src/gendef.c

Mingw Project uses a light weight i386 machine code decompiler to generate Mingw's/WinGCC's .a files and decide if the symbol is __stdcall or _cdecl calling convention. Check the source code above how its done. There is no other bug-free, 100% safe, no prior knowledge, way to do it, except finding and reading and parsing the ret/return CPU instruction of that function.

Totally unrealistic to use inside EU::MM/Perl core, but i386 Win32::API .pm can separate _cdecl functions from _stdcall functions at runtime. But the major limitation is, the C function must be executed first, and return control flow without a SEGV, before i386 Win32::API .pm can look at the position of the update C stack pointer upon return, and compare it to the a cached copy of the C stack pointer, before it executed the C function. If the 2 don't match, Win32::API .pm makes console warnings or croaks, I forgot which. i386 Win32::API's stack_sentinal feature controlled has a back-compat flag but IDK why anyone would want to silence an warning [error really] about C functions getting uninit-ed memory as input values to their incoming args.

The EU::MM new feature shouldn't ship in the next stable perl, since it needs rework and improvement. It only works on x64 WinGCCPerl since Win64 all CPUs permanently eliminated C89/C99 name mangling of C89/C99 function/data symbols for PE Import/Export Table purposes, as part of Win64 having 1 universal ABI per CPU arch. Not multiple ABIs and calling conventions like it did on Win32 on i386.

@sisyphus
Copy link
Contributor

My understanding of this stuff is quite weak.

I switched from building bleadperl to building perl-5.41.9 (EU-MM-7.70), again by doing gmake SKIP_CCHOME_CHECK=1 test.
The build still fails at the same point - but in a quite different way:

g++ Win32.def -o ..\..\lib\auto\Win32\Win32.dll -shared -s -L"c:\perl\lib\CORE" -L"C:\MinGW\lib" -L"C:\MinGW\i686-w64-mingw32\lib" -L"C:\MinGW\lib\gcc\i686-w64-mingw32\8.3.0" Win32.o   "..\..\lib\CORE\libperl541.a" -lmoldname -lkernel32 -luser32 -lgdi32 -lwinspool -lcomdlg32 -ladvapi32 -lshell32 -lole32 -loleaut32 -lnetapi32 -luuid -lws2_32 -lmpr -lwinmm -lversion -lodbc32 -lodbccp32 -lcomctl32 -Wl,--enable-auto-image-base
C:/sp/_32/sp-5.32.1-64int/c/bin/../lib/gcc/i686-w64-mingw32/8.3.0/../../../../i686-w64-mingw32/bin/ld.exe: Win32.o:Win32.c:(.text+0x37b8): undefined reference to `WinHttpCrackUrl@16'
 .... more undefined references ....
C:/sp/_32/sp-5.32.1-64int/c/bin/../lib/gcc/i686-w64-mingw32/8.3.0/../../../../i686-w64-mingw32/bin/ld.exe: Win32.o:Win32.c:(.text+0x413d): undefined reference to `DestroyEnvironmentBlock@4'
collect2.exe: error: ld returned 1 exit status
gmake[1]: *** [Makefile:472: ..\..\lib\auto\Win32\Win32.dll] Error 1
gmake[1]: Leaving directory 'D:/comp-830/perl-5.41.9/cpan/Win32'
gmake[1]: Entering directory 'D:/comp-830/perl-5.41.9/cpan/Win32'
"D:\comp-830\perl-5.41.9\miniperl.exe" "-I..\..\lib" -MExtUtils::Command::MM -e cp_nonempty -- Win32.bs ..\..\lib\auto\Win32\Win32.bs 644
g++ Win32.def -o ..\..\lib\auto\Win32\Win32.dll -shared -s -L"c:\perl\lib\CORE" -L"C:\MinGW\lib" -L"C:\MinGW\i686-w64-mingw32\lib" -L"C:\MinGW\lib\gcc\i686-w64-mingw32\8.3.0" Win32.o   "..\..\lib\CORE\libperl541.a" -lmoldname -lkernel32 -luser32 -lgdi32 -lwinspool -lcomdlg32 -ladvapi32 -lshell32 -lole32 -loleaut32 -lnetapi32 -luuid -lws2_32 -lmpr -lwinmm -lversion -lodbc32 -lodbccp32 -lcomctl32 -Wl,--enable-auto-image-base
C:/sp/_32/sp-5.32.1-64int/c/bin/../lib/gcc/i686-w64-mingw32/8.3.0/../../../../i686-w64-mingw32/bin/ld.exe: Win32.o:Win32.c:(.text+0x37b8): undefined reference to `WinHttpCrackUrl@16'
 .... more undefined references ....
C:/sp/_32/sp-5.32.1-64int/c/bin/../lib/gcc/i686-w64-mingw32/8.3.0/../../../../i686-w64-mingw32/bin/ld.exe: Win32.o:Win32.c:(.text+0x413d): undefined reference to `DestroyEnvironmentBlock@4'
collect2.exe: error: ld returned 1 exit status
gmake[1]: *** [Makefile:472: ..\..\lib\auto\Win32\Win32.dll] Error 1
gmake[1]: Leaving directory 'D:/comp-830/perl-5.41.9/cpan/Win32'
Unsuccessful make(cpan/Win32): code=512 at ..\make_ext.pl line 584.
gmake: *** [GNUmakefile:1561: Extensions] Error 2

On my machine, the C:\MinGW directory (that is mentioned a few times at the beginning of that quote) does not exist.
I cannot see that it would ever work if CCHOME is not set by the user - unless CCHOME actually is C:\MinGW.
However, I can see that something has changed since 5.41.9 was released.

Was there ever a time that you could successfully build perl without specifying CCHOME if "CCHOME" is not the default "C:\MinGW" ?

@bulk88
Copy link
Contributor Author

bulk88 commented May 31, 2025

Was there ever a time that you could successfully build perl without specifying CCHOME if "CCHOME" is not the default "C:\MinGW" ?

Yes I was able to. I just tried a fresh git checkout of 5.30.0 i386 against i386 Strawberry 5.32's GCC. I have no build or test problems with "CCHOME" eq "C:\MinGW" and "C:\MinGW" is a junk path on my system with i386 5.30.0.

Edit: You are now hitting code rot from Win32.pm added in 2022 with not fully-correct PRs (see perl-libwin32/win32#30 ) being merged and published, and example of buggyness that PR added in perl-libwin32/win32#38

Win32::HttpGetFile was a PR written after a "CVE panic" about cpan.pl using cleartext HTTP. probably through LWP, and then the brand new Win32::HttpGetFile() XSUB WAS NEVER USED IN PRODUCTION anywhere in Perl ecosystem. The claimed 0-day CVE in cpan.pl turned out to be TIA Certified CSO Cyber Security Expert puffery after alot of research by real full time Perl ppl.

See long list of unanswered PRs in https://github.com/perl-libwin32/win32/pulls

Edit 2: Win32.pm has certified by P5P code rot see https://github.com/Perl/perl5/blob/blead/t/porting/customized.dat#L19

g++ re.def -o ..\..\lib\auto\re\re.dll -mdll -s -L"c:\perl\lib\CORE" -L"C:\MinGW
\lib" re_exec.o re_comp.o re.o   "..\..\lib\CORE\libperl530.a" -lmoldname -lkern
el32 -luser32 -lgdi32 -lwinspool -lcomdlg32 -ladvapi32 -lshell32 -lole32 -loleau
t32 -lnetapi32 -luuid -lws2_32 -lmpr -lwinmm -lversion -lodbc32 -lodbccp32 -lcom
ctl32 -Wl,--enable-auto-image-base
C:\sources\perl53\miniperl.exe "-I..\..\lib" -MExtUtils::Command -e chmod -- 755
 ..\..\lib\auto\re\re.dll
gmake[1]: Leaving directory 'C:/sources/perl53/ext/re'
Generating a gmake-style Makefile
Writing Makefile for threads
gmake[1]: Entering directory 'C:/sources/perl53/dist/threads'
Running Mkbootstrap for threads ()
C:\sources\perl53\miniperl.exe "-I..\..\lib" -MExtUtils::Command -e chmod -- 644
 "threads.bs"
C:\sources\perl53\miniperl.exe "-I..\..\lib" -MExtUtils::Command::MM -e cp_nonem
pty -- threads.bs ..\..\lib\auto\threads\threads.bs 644
"..\..\miniperl.exe" "-I..\..\lib" "..\..\lib\ExtUtils/xsubpp"  -typemap C:\sour
ces\perl53\lib\ExtUtils\typemap  threads.xs > threads.xsc
C:\sources\perl53\miniperl.exe "-I..\..\lib" -MExtUtils::Command -e mv -- thread
s.xsc threads.c
gcc -c   -s -O2 -DWIN32 -DPERL_TEXTMODE_SCRIPTS -DPERL_IMPLICIT_CONTEXT -DPERL_I
MPLICIT_SYS -DUSE_PERLIO -fwrapv -fno-strict-aliasing -mms-bitfields -s -O2   -D
VERSION=\"2.22\" -DXS_VERSION=\"2.22\"  "-I..\..\lib\CORE"   threads.c
"..\..\miniperl.exe" "-I..\..\lib" -MExtUtils::Mksymlists \
     -e "Mksymlists('NAME'=>\"threads\", 'DLBASE' => 'threads', 'DL_FUNCS' => {
 }, 'FUNCLIST' => [], 'IMPORTS' => {  }, 'DL_VARS' => []);"
g++ threads.def -o ..\..\lib\auto\threads\threads.dll -mdll -s -L"c:\perl\lib\CO
RE" -L"C:\MinGW\lib" threads.o   "..\..\lib\CORE\libperl530.a" -lmoldname -lkern
el32 -luser32 -lgdi32 -lwinspool -lcomdlg32 -ladvapi32 -lshell32 -lole32 -loleau
t32 -lnetapi32 -luuid -lws2_32 -lmpr -lwinmm -lversion -lodbc32 -lodbccp32 -lcom
ctl32 -Wl,--enable-auto-image-base
C:\sources\perl53\miniperl.exe "-I..\..\lib" -MExtUtils::Command -e chmod -- 755
 ..\..\lib\auto\threads\threads.dll
gmake[1]: Leaving directory 'C:/sources/perl53/dist/threads'
Generating a gmake-style Makefile
Writing Makefile for threads::shared
gmake[1]: Entering directory 'C:/sources/perl53/dist/threads-shared'
Running Mkbootstrap for shared ()
C:\sources\perl53\miniperl.exe "-I..\..\lib" -MExtUtils::Command -e chmod -- 644
 "shared.bs"
C:\sources\perl53\miniperl.exe "-I..\..\lib" -MExtUtils::Command::MM -e cp_nonem
pty -- shared.bs ..\..\lib\auto\threads\shared\shared.bs 644
"..\..\miniperl.exe" "-I..\..\lib" "..\..\lib\ExtUtils/xsubpp"  -typemap C:\sour
ces\perl53\lib\ExtUtils\typemap  shared.xs > shared.xsc
C:\sources\perl53\miniperl.exe "-I..\..\lib" -MExtUtils::Command -e mv -- shared
.xsc shared.c
gcc -c   -s -O2 -DWIN32 -DPERL_TEXTMODE_SCRIPTS -DPERL_IMPLICIT_CONTEXT -DPERL_I
MPLICIT_SYS -DUSE_PERLIO -fwrapv -fno-strict-aliasing -mms-bitfields -s -O2   -D
VERSION=\"1.60\" -DXS_VERSION=\"1.60\"  "-I..\..\lib\CORE"   shared.c
"..\..\miniperl.exe" "-I..\..\lib" -MExtUtils::Mksymlists \
     -e "Mksymlists('NAME'=>\"threads::shared\", 'DLBASE' => 'shared', 'DL_FUNCS
' => {  }, 'FUNCLIST' => [], 'IMPORTS' => {  }, 'DL_VARS' => []);"
g++ shared.def -o ..\..\lib\auto\threads\shared\shared.dll -mdll -s -L"c:\perl\l
ib\CORE" -L"C:\MinGW\lib" shared.o   "..\..\lib\CORE\libperl530.a" -lmoldname -l
kernel32 -luser32 -lgdi32 -lwinspool -lcomdlg32 -ladvapi32 -lshell32 -lole32 -lo
leaut32 -lnetapi32 -luuid -lws2_32 -lmpr -lwinmm -lversion -lodbc32 -lodbccp32 -
lcomctl32 -Wl,--enable-auto-image-base
C:\sources\perl53\miniperl.exe "-I..\..\lib" -MExtUtils::Command -e chmod -- 755
 ..\..\lib\auto\threads\shared\shared.dll
gmake[1]: Leaving directory 'C:/sources/perl53/dist/threads-shared'
..\perl.exe -f ..\pod\buildtoc -q
..\pod\buildtoc: perl54110delta.pod exists but is unknown by buildtoc
..\pod\buildtoc: perl54110delta.pod exists but is unknown by MANIFEST
Use of uninitialized value $_ in substitution (s///) at ..\pod\buildtoc line 215
, <$fh> chunk 2.
Use of uninitialized value $_ in pattern match (m//) at ..\pod\buildtoc line 216
, <$fh> chunk 2.
Use of uninitialized value $_ in substitution (s///) at ..\pod\buildtoc line 219
, <$fh> chunk 2.
Use of uninitialized value $_ in substitution (s///) at ..\pod\buildtoc line 219
, <$fh> chunk 2.
xcopy /f /r /i /d /y ..\perl.exe ..\t\
C:\sources\perl53\perl.exe -> C:\sources\perl53\t\perl.exe
1 File(s) copied
xcopy /f /r /i /d /y ..\perl530.dll ..\t\
C:\sources\perl53\perl530.dll -> C:\sources\perl53\t\perl530.dll
1 File(s) copied
xcopy /f /r /i /d /y ..\perlglob.exe ..\t\
C:\sources\perl53\perlglob.exe -> C:\sources\perl53\t\perlglob.exe
1 File(s) copied
set PERL_STATIC_EXT=Win32CORE && \
    cd ..\t && perl.exe harness
base/cond.t ........................................................ ok
base/if.t .......................................................... ok
base/lex.t ......................................................... ok
base/num.t ......................................................... ok
base/pat.t ......................................................... ok
################ CCC UUU TTT
io/semctl.t ........................................................ skipped: no
 SysV semaphores on this platform
io/shm.t ........................................................... skipped: --
 IPC::SysV was not built
io/socket.t ........................................................ ok
io/socketpair.t .................................................... ok
io/tell.t .......................................................... ok
io/through.t ....................................................... ok
io/utf8.t .......................................................... ok
re/alpha_assertions.t .............................................. ok
re/anyof.t ......................................................... 533/1174 Te
rminating on signal SIGINT(2)
Terminating on signal SIGINT(2)
Terminate batch job (Y/N)?
^Cgmake: *** [GNUmakefile:1947: test] Error 2

C:\sources\perl53\win32>
C:\sources\perl53\win32>..\perl -V -I..\lib
Summary of my perl5 (revision 5 version 30 subversion 0) configuration:

  Platform:
    osname=MSWin32
    osvers=6.1.7601
    archname=MSWin32-x86-multi-thread
    uname=''
    config_args='undef'
    hint=recommended
    useposix=true
    d_sigaction=undef
    useithreads=define
    usemultiplicity=define
    use64bitint=undef
    use64bitall=undef
    uselongdouble=undef
    usemymalloc=n
    default_inc_excludes_dot=define
    bincompat5005=undef
  Compiler:
    cc='gcc'
    ccflags =' -s -O2 -DWIN32 -DPERL_TEXTMODE_SCRIPTS -DPERL_IMPLICIT_CONTEXT -D
PERL_IMPLICIT_SYS -DUSE_PERLIO -fwrapv -fno-strict-aliasing -mms-bitfields'
    optimize='-s -O2'
    cppflags='-DWIN32'
    ccversion=''
    gccversion='8.3.0'
    gccosandvers=''
    intsize=4
    longsize=4
    ptrsize=4
    doublesize=8
    byteorder=1234
    doublekind=3
    d_longlong=define
    longlongsize=8
    d_longdbl=define
    longdblsize=12
    longdblkind=3
    ivtype='long'
    ivsize=4
    nvtype='double'
    nvsize=8
    Off_t='long long'
    lseeksize=8
    alignbytes=8
    prototype=define
  Linker and Libraries:
    ld='g++'
    ldflags ='-s -L"c:\perl\lib\CORE" -L"C:\MinGW\lib"'
    libpth=C:\MinGW\lib
    libs= -lmoldname -lkernel32 -luser32 -lgdi32 -lwinspool -lcomdlg32 -ladvapi3
2 -lshell32 -lole32 -loleaut32 -lnetapi32 -luuid -lws2_32 -lmpr -lwinmm -lversio
n -lodbc32 -lodbccp32 -lcomctl32
    perllibs= -lmoldname -lkernel32 -luser32 -lgdi32 -lwinspool -lcomdlg32 -ladv
api32 -lshell32 -lole32 -loleaut32 -lnetapi32 -luuid -lws2_32 -lmpr -lwinmm -lve
rsion -lodbc32 -lodbccp32 -lcomctl32
    libc=
    so=dll
    useshrplib=true
    libperl=libperl530.a
    gnulibc_version=''
  Dynamic Linking:
    dlsrc=dl_win32.xs
    dlext=dll
    d_dlsymun=undef
    ccdlflags=' '
    cccdlflags=' '
    lddlflags='-mdll -s -L"c:\perl\lib\CORE" -L"C:\MinGW\lib"'


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_CONTEXT
    PERL_IMPLICIT_SYS
    PERL_MALLOC_WRAP
    PERL_OP_PARENT
    PERL_PRESERVE_IVUV
    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 May 31 2025 09:28:23
  %ENV:
    PERL_JSON_BACKEND="Cpanel::JSON::XS"
    PERL_YAML_BACKEND="YAML::XS"
  @INC:
    ..\lib
    C:/sources/perl53/lib

C:\sources\perl53\win32>

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

No branches or pull requests

4 participants