Skip to content
Tcl Source Code View Ticket
Login

View Ticket

windows: msys: gcc version 10.1.0 32-bit build fails due to zlib incompatibility

Closed / Invalid62e693e66887d3739ab8059aa1e1abfe69d78403Created 7 years agoUpdated 7 years ago
Descriptionplain2020-05-29 17:50:37
Platform: windows / msys
Compiler: gcc 10.1.0 / 32-bit

Building 8.6.10 with windows/msys/gcc 10.1.0/32-bit segfaults due to some
imcompatibility with the compat/zlib/win32/zdll.lib and .../zlib1.dll file.

I built zlib (make -f win32/Makefile.gcc), copied libz.dll.a and zlib1.dll 
to win32/ and adjusted the Tcl Makefile to link against libz.dll.a for win32.

a) If the shipped files in compat/zlib/win32 are used, tclsh86.exe segfaults
   (at cfg[0].value = zlibVersion(); ).
b) If a new zlib1.dll is created using the gcc 10.1.0 compiler, the 
   zlib1.dll file is not recognized as valid (on a system without msys2).

I cannot find a method to link that works.
bll Ticket [62e693e668]: 3 changes [History diff]2020-05-29 21:24:22
bll Ticket [62e693e668]: 3 changes [History diff]2020-05-29 23:07:58
bllplain2020-05-30 15:26:31
a) Build compat/zlib using gcc 10.1.0:
   make -f win32/Makefile.gcc LDFLAGS=-static-libgcc

b) Copy the files:
   cp libz.dll.a zlib1.dll win32

c) Change 'configure' to link with libz.dll.a for win32:

$ diff configure-orig configure
4414c4414
<     ZLIB_LIBS=\${ZLIB_DIR_NATIVE}/win32/zdll.lib
---
>     ZLIB_LIBS=\${ZLIB_DIR_NATIVE}/win32/libz.dll.a

d) Fix Makefile.in to copy the correct zlib1.dll:

$ diff Makefile.in-orig Makefile.in
516,521d515
<       @if test "@ZLIB_LIBS@set" != "${ZLIB_DIR_NATIVE}/win32/zdll.libset" ; then \
<               $(COPY) $(ZLIB_DIR)/win64/${ZLIB_DLL_FILE} ${ZLIB_DLL_FILE}; \
<       else \
<               $(COPY) $(ZLIB_DIR)/win32/${ZLIB_DLL_FILE} ${ZLIB_DLL_FILE}; \
<       fi;
<
522a517
>     $(COPY) `dirname @ZLIB_LIBS@`/${ZLIB_DLL_FILE} ${ZLIB_DLL_FILE}


I tried creating a new zdll.lib and linking with it, but that did not work.

I did not test keeping the original zlib1.dll and linking with the new
libz.dll.a.
bllplain2020-05-30 15:27:32
That should probably be:

$(COPY) `dirname "@ZLIB_LIBS@"`/${ZLIB_DLL_FILE} ${ZLIB_DLL_FILE}

with quotes.
jan.nijtmanswiki2020-05-31 15:42:17

Did you consider the possibility that this is a bug in your toolchain somewhere. Do you - by any chance - have binutils version 2.34 (which is the latest upstream version). Well, this one contains a fatal bug, which prevents it to build Tcl at all for win32. See:

https://www.mail-archive.com/[email protected]/msg32696.html

The description of this bug:

PR 25447 * coffgen.c (_bfd_coff_close_and_cleanup): Do not clear the keep syms and keep strings flags as these may have been set in order to prevent a bogus call to free.

You could try to downgrade binutils to an earlier version and see if this helps. This bug is already fixed upstream, but no new binutils release is done yet which contains it.

For now, I'll mark this bug as 'Invalid', because I think it's not a bug in Tcl but somewhere else (most likely in binutils). If you have proof that I'm wrong, or a way Tcl could provide a workaround, feel free to re-open this ticket.

Hope this helps.

bllplain2020-05-31 16:00:53
My 32-bit toolchain worked fine until I upgraded msys2.

It could be most anything at this point.

I did provide a work-around for the zlib .dll.

I'm not having a not-build-at-all problem, the build is working now once
I resolved the .dll issue.   I am having a problem with Tk images not working
(crashes) now.

Unfortunately, msys2 has no downgrade path.
jan.nijtmanswiki2020-05-31 16:22:52

> My 32-bit toolchain worked fine until I upgraded msys2.

Did you report this tot the msys2 people? I did report it to cygwin: https://www.mail-archive.com/[email protected]/msg164105.html That's how I noted the problem. Downgrading binutils (which is easy on Cygwin) helped, so I just wait until they pick it up, providing a binutils version which works again. Until then, I'm keeping binutils downgraded to 2.13.1, that's one known to work.

bllplain2020-05-31 17:00:11
Reported.  I have no idea how responsive they are.  We shall see.
bll Closed ticket [62e693e668]. [History diff]2020-06-01 18:51:08
sebreswiki2020-06-02 14:33:45

I don't use msys2/packman (to upgrade a toolchain), I use own mingw-w64 selector (path and/or mount) instead, that allows to target different gcc (mingw) versions.

I can successful built 32-bit 8.6 using gcc 10.1.0 (MinGW-W64 i686-posix-dwarf, built by Brecht Sanders), downloaded from https://github.com/brechtsanders/winlibs_mingw/releases/tag/10.1.0-10.0.0-7.0.0-r3 (see "winlibs.com").

No extra zlib built has been required here, no issue by build (../configure && make tcltest). Test of zlib succeeds too:

    ./tcltest.sh -file zlib*.test
    ...
    zlib.test
    all.tcl:        Total   65      Passed  64      Skipped 1       Failed  0

bllplain2020-06-02 16:50:05
Interesting that that works, as it looks that he is also using binutils 2.34.
sebreswiki2020-06-02 17:13:10

Perhaps it has been built after some patches are applied (it is already 3rd release of 10.1 - tagged as 10.1.0-10.0.0-7.0.0-r3).

Anyway it looks indeed like it were 2.34:

$ ld --version
GNU ld (Binutils for MinGW-W64 i686, built by Brecht Sanders) 2.34

bllplain2020-06-02 17:31:03
I will try building with his build within a day or two.
bllplain2020-06-02 18:24:14
His build looks good.   I did not get the immediate segfault upon installation.
I will build all my tools and test my application and see how things look.
bllplain2020-06-02 18:34:18
I spoke too soon.

It doesn't segfault, but it doesn't run either (exits immediately).
The difference is that I build with -static-libgcc.

I believe the bug that is causing issues has problems with loading dynamic 
libraries when built with -static-libgcc.
bllplain2020-06-02 19:20:57
But thanks for giving me a pointer as to where I can download older versions
of the mingw gcc compiler.  I am building my application with an older version
of gcc now.
bllplain2020-06-03 13:55:02
msys binutils got updated with the two patches that jan pointed out.
I finished building my application with 9.2.0.
I'll test 10.1.0 some other day when I'm not tired of windows development.
Log in (anonymous is fine) to add a comment.