libpsl icon indicating copy to clipboard operation
libpsl copied to clipboard

Statically link libpsl build with mingw-w64 13 break interop with previous mingw-w64 versions

Open JackCarterSmith opened this issue 2 months ago • 7 comments

This issue follow the one from libcurl (https://github.com/curl/curl/issues/19516). I tried to build a test program with libcurl, which depend on libpsl, that I then tried to add statically. That failed with an undefined reference to 'stat64'. The libpsl.a have been build with MinGW-w64 13 and the test program with MinGW-w64 12.

First and foremost, I'm not an expert with how libpsl use the stat element. MinGW-w64 13 seem to break interop with previous MinGW versions which use stat() function.

Again, I don't know what should be the best way to handle/fix it.

JackCarterSmith avatar Nov 14 '25 13:11 JackCarterSmith

Thanks for the report. Currently trying to reproduce, but cross-building the dependency libunistring fails atm in a Debian testing docker container (see https://savannah.gnu.org/bugs/index.php?67704).

rockdaboot avatar Nov 15 '25 19:11 rockdaboot

Thanks for investigating. I forgot to precise I've used the pre-compiled libpsl.a from the windows 64-bits libcurl package. I take a quick look on the log from your container, I suspect the line CPPFLAGS="-I$INSTALLDIR/include" can induce error in cross-building due to the possible presence of native headers files in the $INSTALLDIR/include location. Hope that can help!

JackCarterSmith avatar Nov 15 '25 23:11 JackCarterSmith

I suspect the line CPPFLAGS="-I$INSTALLDIR/include" can induce error in cross-building

Just tried, same error without it.

There is this gnulib ML thread about it. I can not add much to the discussion, just following it.

rockdaboot avatar Nov 16 '25 15:11 rockdaboot

I did a cross-compilation with MinGW 13 on Debian testing, but can't reproduce the error yet

ii  mingw-w64-common                   13.0.0-1     all          Common files for Mingw-w64
ii  mingw-w64-x86-64-dev               13.0.0-1     all          Development files for MinGW-w64 targeting Win64
$ LDFLAGS="-L/usr/x86_64-w64-mingw32/lib" ./configure --host=x86_64-w64-mingw32 --disable-runtime RUNTEST='wine'
$ make
$ make check
...
make[4]: Entering directory '/home/tim/src/libpsl/tests'
PASS: test-is-public-builtin.exe
PASS: test-registrable-domain.exe
PASS: test-is-cookie-domain-acceptable.exe
PASS: test-is-public.exe
PASS: test-is-public-all.exe
...

rockdaboot avatar Nov 16 '25 16:11 rockdaboot

From what I've understand, is when the libpsl is build with MinGW 13 and the test program is build with MinGW 12 (with static libpsl.a) that the linking step of the test program crash (with undefined 'stat64' error). I suppose the tests programs from Debian testing container have been built against MinGW 13.

libcurl have replaced the statcall by the corresponding _stat/_stati64 OS direct function, to avoid using the mingw interface I suppose. https://github.com/curl/curl/issues/19516#issuecomment-3530336494

JackCarterSmith avatar Nov 16 '25 18:11 JackCarterSmith

I understand the coment as "with mingw 12 all works", but "with mingw 13 stat() is defined as stat64()". And stat64() can't be resolved (on Windows?). That issue has not been introduced by libpsl, but by mingw 13.

IMO, it needs to be fixed on the MinGW side. But hey, we possibly can work around it by directly using the Windows API. But first, I'd like to be able to reproduce the error. Otherwise I am acting blindly and wasting my and everybody else's time.

It would be very helpful if you (or someone else) provide a simple reproducer (or even better: a tested patch).

rockdaboot avatar Nov 16 '25 19:11 rockdaboot

Absolutely, it was indeed a change from version 12 to version 13 that broke compatibility. I was just specifying the build versions to help with the bug reproduction.

I'm trying to understand what does what in each project, I'm just starting to dig into the mingw/stat part... And from what I can see from the issues on the mingw-w64 project, there have been a few breaks in sys/stat.h. I'll probably open another ticket on that side and follow up.

At the same time, I will try to provide a patch that would use direct calls on Windows without breaking functionality on Linux. But I can't promise...

JackCarterSmith avatar Nov 16 '25 22:11 JackCarterSmith