-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Support building from a MinGW-w64-based compiler #15077
Merged
straight-shoota
merged 4 commits into
crystal-lang:master
from
HertzDevil:feature/mingw-w64-compiler
Oct 19, 2024
Merged
Support building from a MinGW-w64-based compiler #15077
straight-shoota
merged 4 commits into
crystal-lang:master
from
HertzDevil:feature/mingw-w64-compiler
Oct 19, 2024
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
straight-shoota
approved these changes
Oct 18, 2024
straight-shoota
pushed a commit
that referenced
this pull request
Oct 23, 2024
Cross-compiles a MinGW-w64-based Crystal compiler from Ubuntu, then links it on MSYS2's UCRT64 environment. Resolves part of #6170. The artifact includes the compiler, all dependent DLLs, and the source code only. It is not a complete installation since it is missing e.g. the documentation and the licenses, but it is sufficient for bootstrapping further native compiler builds within MSYS2. The resulting binary is portable within MSYS2 and can be executed from anywhere inside an MSYS2 shell, although compilation requires `mingw-w64-ucrt-x86_64-cc`, probably `mingw-w64-ucrt-x86_64-pkgconf`, plus the respective development libraries listed in #15077. The DLLs bundled under `bin/` are needed to even start Crystal since they are dynamically linked at load time; they are not strictly needed if Crystal is always run only within MSYS2, but that is the job of an actual `PKGBUILD` file.
CTC97
pushed a commit
to CTC97/crystal
that referenced
this pull request
Nov 9, 2024
) Cross-compiles a MinGW-w64-based Crystal compiler from Ubuntu, then links it on MSYS2's UCRT64 environment. Resolves part of crystal-lang#6170. The artifact includes the compiler, all dependent DLLs, and the source code only. It is not a complete installation since it is missing e.g. the documentation and the licenses, but it is sufficient for bootstrapping further native compiler builds within MSYS2. The resulting binary is portable within MSYS2 and can be executed from anywhere inside an MSYS2 shell, although compilation requires `mingw-w64-ucrt-x86_64-cc`, probably `mingw-w64-ucrt-x86_64-pkgconf`, plus the respective development libraries listed in crystal-lang#15077. The DLLs bundled under `bin/` are needed to even start Crystal since they are dynamically linked at load time; they are not strictly needed if Crystal is always run only within MSYS2, but that is the job of an actual `PKGBUILD` file.
1 task
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
kind:feature
platform:windows-gnu
Windows support based on the MinGW-w64 toolchain + MSYS2
topic:compiler:cli
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is a continuation of #15070 that allows a compiler built with MinGW-w64 to itself build programs correctly. Resolves part of #6170.
-rdynamic
since that only makes sense for ELF executables.x86_64-windows-gnu
, including normal compilations from such a Crystal compiler, will not copy dependent DLLs to the output directory. Crystal itself and programs built under MSYS2 will just work as long as the proper environment is used. You are on your own here, althoughldd
exists on MSYS2 so that you don't need the MSVC build tools for this.wmain
overmain
as the C entry point is-municode
. (The system entry point is presumably_start
now.)legacy_stdio_definitions.obj
doesn't exist on MinGW-w64, so we disable it outside MSVC.To build a MinGW-w64 compiler:
Now you can run or build a considerable number of files from here, such as
./crystal.exe samples/2048.cr
and./crystal.exe spec spec/std/regex_spec.cr
. Notable omissions are OpenSSL and LLVM, as fixing their version detection macros is a bit complicated.The interpreter is not supported. Most likely,
Crystal::Loader
would have a GCC-style.parse
, but the rest of the functionality would be identical to the MSVCLoadLibraryExW
-based loader.Also, some invocations like./crystal.exe spec spec/std/json
will fail since the whole command line string is too long. Similar to MSVC, GCC also handles response files starting with@
, so this can be implemented later; a workaround is to use--single-module
.For reference, here are all the useful MSYS2 packages and their corresponding pkg-config names: