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

CSL: Potential crt version mismatch #56840

Open
inkydragon opened this issue Dec 15, 2024 · 1 comment
Open

CSL: Potential crt version mismatch #56840

inkydragon opened this issue Dec 15, 2024 · 1 comment
Labels
building Build system, or building Julia or its dependencies system:windows Affects only Windows

Comments

@inkydragon
Copy link
Member

Background

Trying to reproduce #55900.
I'm using gcc 14 in MSYS2 (mingw32), and build from source with master fe5ed17.

Then I got a undef error from ld: "undefined reference to `_initterm_e'"

Details
$ make -j16
echo '@"%~dp0/'"$(echo 'usr/bin/julia.exe')"'" %*' | tr / '\\' > /d/jl/julia/julia.bat
chmod a+x /d/jl/julia/julia.bat
    LINK usr/lib/julia/sys.dll
D:/env/msys64/mingw32/bin/../lib/gcc/i686-w64-mingw32/14.2.0/../../../../i686-w64-mingw32/bin/ld.exe: D:/env/msys64/mingw32/bin/../lib/gcc/i686-w64-mingw32/14.2.0/../../../../lib/dllcrt2.o: in function `CRT_INIT@12':
C:/M/B/src/mingw-w64/mingw-w64-crt/crt/crtdll.c:100:(.text+0x17a): undefined reference to `_initterm_e'
collect2.exe: error: ld returned 1 exit status
make[1]: *** [sysimage.mk:18: /d/jl/julia/usr/lib/julia/sys.dll] Error 1
make: *** [Makefile:120: julia-sysimg-release] Error 2

I know julia carries a specific version of crt.
Check the exported symbols:

$ nm -g /d/jl/julia/usr/lib/gcc/i686-w64-mingw32/13/libmsvcrt.a | grep initterm
00000000 I __imp___initterm
00000000 T __initterm

$ nm -g /mingw32/lib/libmsvcrt.a  | grep initterm
lib32_libmsvcrt_extra_a-_initterm_e.o:
00000000 D __imp___initterm_e
00000000 T __initterm_e
00000000 I __imp___initterm
00000000 T __initterm

$ gcc --version
gcc.exe (Rev2, Built by MSYS2 project) 14.2.0

$ ld --version
GNU ld (GNU Binutils) 2.43.1

This ld error is easily fixed by not using the libraries carried by CSL.
But it also brought a problem to my attention.

Problem

On Windows, we ship crt from GCC 13.

julia/deps/csl.mk

Lines 107 to 115 in 006f19c

ifeq ($(OS),WINNT)
install-csl:
mkdir -p $(build_private_libdir)/
cp -a $(build_libdir)/gcc/$(BB_TRIPLET)/13/libgcc_s.a $(build_private_libdir)/
cp -a $(build_libdir)/gcc/$(BB_TRIPLET)/13/libgcc.a $(build_private_libdir)/
cp -a $(build_libdir)/gcc/$(BB_TRIPLET)/13/libmsvcrt.a $(build_private_libdir)/
cp -a $(build_libdir)/gcc/$(BB_TRIPLET)/13/libssp.dll.a $(build_private_libdir)/
cp -a $(build_libdir)/gcc/$(BB_TRIPLET)/13/libssp.dll.a $(build_libdir)/
endif

And we are using GCC 14 to build julia x64 version:

Using GCC 12 to build julia x86 version:

I'm wondering if the old gcc + new crt libraries are causing some problems.
Or if this is related to the stack trace error in #55900.

@inkydragon inkydragon added building Build system, or building Julia or its dependencies system:windows Affects only Windows labels Dec 15, 2024
@Zentrik
Copy link
Member

Zentrik commented Dec 22, 2024

Just hit this I'm guessing this broke in between mingw-w64-x86_64-crt-git-12.0.0.r423.g8bcd5fc1a-1 and mingw-w64-x86_64-crt-git-12.0.0.r446.ga2d19218d-1

EDIT: Yep clearly some suspicious commits in mingw-w64/mingw-w64@8bcd5fc...a2d1921.
Seems unfortunate USE_BINARYBUILDER_CSL=0 didn't get automatically set here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
building Build system, or building Julia or its dependencies system:windows Affects only Windows
Projects
None yet
Development

No branches or pull requests

2 participants