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

Windows: Use local configuration for LLVM when linking dynamically #14101

Merged

Conversation

HertzDevil
Copy link
Contributor

Similar to how openssl_VERSION is already used on Windows, LLVM will now locate the first file called llvm_VERSION from CRYSTAL_LIBRARY_PATH, reading its contents to configure LLVM, rather than running %LLVM_CONFIG%. This file should consist of 3 lines:

  • the output of llvm-config --version, using the same llvm-config.exe that built LLVM-C.dll
  • the output of llvm-config --targets-built
  • the output of llvm-config --system-libs (we assume --libs --ldflags do nothing more than locating LLVM-C.lib in the original LLVM installation)

On my LLVM 18-dev build, the file looks like this:

18.0.0git
X86
psapi.lib shell32.lib ole32.lib uuid.lib advapi32.lib

Then to make dynamic linking work, copy lib/LLVM-C.lib from LLVM to the Crystal installation's lib/llvm-dynamic.lib, as well as bin/LLVM-C.dll to the Crystal compiler's directory. This means we will be able to distribute LLVM as a dynamic-only library on Windows, without having to also distribute llvm-config.exe at all, since the above configuration is essentially synchronized to the DLL provided by Crystal.

This PR does not touch our Windows CI, that will be the next step.

@HertzDevil HertzDevil changed the title Windows: Do not use %LLVM_CONFIG% when linking dynamically Windows: Use local configuration for LLVM when linking dynamically Dec 15, 2023
src/llvm/lib_llvm.cr Outdated Show resolved Hide resolved
src/llvm/lib_llvm.cr Outdated Show resolved Hide resolved
src/llvm/lib_llvm.cr Outdated Show resolved Hide resolved
@straight-shoota straight-shoota added this to the 1.11.0 milestone Dec 18, 2023
@straight-shoota straight-shoota merged commit e0f665e into crystal-lang:master Dec 19, 2023
55 checks passed
@HertzDevil HertzDevil deleted the feature/windows-llvm-config-dll branch December 19, 2023 11:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

3 participants