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

adds libmsvcrt from mingw-64 to the build directory #57451

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

ajinkya-k
Copy link
Contributor

@ajinkya-k ajinkya-k commented Feb 18, 2025

The Problem: Build fails on Windows when using Msys/MinGW

Build was failing on windows 11 with MINGW64 using these instructions with the following error (See #57397). This is perhaps because of C runtime version mismatches (see #56840).

Output ────── 450.762215 seconds
    LINK usr/lib/julia/sys.dll
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/14.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/14.2.0/../../../../lib/dllcrt2.o: in function `_CRT_INIT':
C:/M/B/src/mingw-w64/mingw-w64-crt/crt/crtdll.c:100:(.text+0x15d): undefined reference to `_initterm_e'
collect2.exe: error: ld returned 1 exit status
make[1]: *** [sysimage.mk:18: /c/Users/kajin/Documents/julia/usr/lib/julia/sys.dll] Error 1
make: *** [Makefile:120: julia-sysimg-release] Error 2

The fix

Copy the libmsvcrt.a provided by mingw in the right spot in the julia build directory.

this PR fixes it
based on this patch:

https://github.com/Zentrik/llvm_julia_tester/blob/d8bfc7590bbcb3a9bc5c9eedbfe11bf65eddd91c/julia-patches/ffba662dd275d1bdd5a5935f4d3cc372b5235d07

Fix #56840, fix #57397.

@ajinkya-k
Copy link
Contributor Author

This seems to have fixed the build. I am not sure if this is a temporary fix or works more generally. Could the maintainers take a look and suggest changes (if any)?

@giordano giordano added building Build system, or building Julia or its dependencies system:windows Affects only Windows labels Feb 18, 2025
@giordano
Copy link
Contributor

This seems to have fixed the build

Can you elaborate what was the issue in the first place?

@giordano giordano changed the title adds libmsvcrt from mingw-64 to the build directory, adds libmsvcrt from mingw-64 to the build directory Feb 18, 2025
@ajinkya-k ajinkya-k changed the title adds libmsvcrt from mingw-64 to the build directory adds libmsvcrt from mingw-64 to the build directory. may fix ##56840 and #57397 Feb 18, 2025
@ajinkya-k ajinkya-k changed the title adds libmsvcrt from mingw-64 to the build directory. may fix ##56840 and #57397 adds libmsvcrt from mingw-64 to the build directory. may fix #56840 and #57397 Feb 18, 2025
@ajinkya-k
Copy link
Contributor Author

Building from source was failing on windows using mingw64. This is due to a mismatch of the c runtime library being used to link against. The error is reported in #57397 and done relevant discussion in #56840

@giordano giordano changed the title adds libmsvcrt from mingw-64 to the build directory. may fix #56840 and #57397 adds libmsvcrt from mingw-64 to the build directory Feb 18, 2025
@ajinkya-k
Copy link
Contributor Author

@giordano I removed the hardcoded paths, and using MINGW_PREFIX environment variable instead.

@ajinkya-k
Copy link
Contributor Author

okay the newest change might have broken the mingw32 we might need the if statement after all.

@ajinkya-k
Copy link
Contributor Author

This does fix the build for 64bit but fails on mingw32 🥲

@ajinkya-k
Copy link
Contributor Author

@giordano Is using $(MINGW_PREFIX) in the makefiles okay?

@giordano
Copy link
Contributor

Don't ask me, I don't use Windows, I have no clue 🙂 at least it's an environment variable which can be overridden.

@ajinkya-k
Copy link
Contributor Author

Maybe @vtjnash might know?

@vtjnash
Copy link
Member

vtjnash commented Feb 19, 2025

We have the same line a couple lines higher, so this may just corrupt the build, depending on the compiler version in use. I am not sure the most reasonable fix here, since I've also run into those issues and use a similar patch to get around them

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

Successfully merging this pull request may close these issues.

CSL: Potential crt version mismatch building from source with mingw fails on windows
3 participants