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

How to build LLVMSPIRVLib as a shared library on Windows? #2595

Open
ZzEeKkAa opened this issue Jun 6, 2024 · 2 comments
Open

How to build LLVMSPIRVLib as a shared library on Windows? #2595

ZzEeKkAa opened this issue Jun 6, 2024 · 2 comments

Comments

@ZzEeKkAa
Copy link
Contributor

ZzEeKkAa commented Jun 6, 2024

Hello there!

I've tried to build library on windows, but it seems like there is no option to build it as shared library on windows:

LLVM does not support shared libraries on windows:
https://www.llvm.org/docs/CMake.html#llvm-related-variables
And the way library is written is add_llvm_library
https://github.com/KhronosGroup/SPIRV-LLVM-Translator/blob/main/lib/SPIRV/CMakeLists.txt#L43

If I try to build it with -DLLVM_BUILD_LLVM_DYLIB=ON, I get :

[43/43] Linking CXX executable tools\llvm-spirv\llvm-spirv.exe
FAILED: tools/llvm-spirv/llvm-spirv.exe
C:\windows\system32\cmd.exe /C "cd . && C:\Users\yevhenii\.miniforge3\conda-bld\debug_1717564664836\_build_env\Library\bin\cmake.exe -E vs_link_exe --intdir=tools\llvm-spirv\CMakeFiles\llvm-spirv.dir --rc=C:\PROGRA~2\WI3CF2~1\10\bin\100226~1.0\x64\rc.exe --mt=C:\PROGRA~2\WI3CF2~1\10\bin\100226~1.0\x64\mt.exe --manifests  -- C:\PROGRA~2\MICROS~4\2022\BUILDT~1\VC\Tools\MSVC\1429~1.301\bin\HostX64\x64\link.exe /nologo @CMakeFiles\llvm-spirv.rsp  /out:tools\llvm-spirv\llvm-spirv.exe /implib:tools\llvm-spirv\llvm-spirv.lib /pdb:tools\llvm-spirv\llvm-spirv.pdb /version:0.0 /machine:x64 /STACK:10000000 /INCREMENTAL:NO /subsystem:console && cd ."
LINK: command "C:\PROGRA~2\MICROS~4\2022\BUILDT~1\VC\Tools\MSVC\1429~1.301\bin\HostX64\x64\link.exe /nologo @CMakeFiles\llvm-spirv.rsp /out:tools\llvm-spirv\llvm-spirv.exe /implib:tools\llvm-spirv\llvm-spirv.lib /pdb:tools\llvm-spirv\llvm-spirv.pdb /version:0.0 /machine:x64 /STACK:10000000 /INCREMENTAL:NO /subsystem:console /MANIFEST:EMBED,ID=1" failed (exit code 1181) with the following output:
LINK : fatal error LNK1181: cannot open input file 'lib\SPIRV\LLVMSPIRVLib.lib'
ninja: build stopped: subcommand failed.

So cmake builds library as .dll, but whenever it comes to building llvm-spirv binary it is looking for static library.

Please note, that on linux it works as expected: It creates shared library and links binary to it.

So do you have any ideas how to bypass it?

@MrSidims
Copy link
Contributor

There was a patch #1543 that later was reverted, see the latest comments in the PR. If you try it on windows - would it help?

@ZzEeKkAa
Copy link
Contributor Author

@MrSidims as far as I can understand - it does the oposit - blocks shared library build and build static library, when trying to build shared one with LLVM_LINK_LLVM_DYLIB. Moreover LLVM_LINK_LLVM_DYLIB is not supported on Windows:

LLVM_BUILD_LLVM_DYLIB:BOOL
If enabled, the target for building the libLLVM shared library is added. This library contains all of LLVM’s components in a single shared library. Defaults to OFF. This cannot be used in conjunction with BUILD_SHARED_LIBS. Tools will only be linked to the libLLVM shared library if LLVM_LINK_LLVM_DYLIB is also ON. The components in the library can be customised by setting LLVM_DYLIB_COMPONENTS to a list of the desired components. This option is not available on Windows.

https://www.llvm.org/docs/CMake.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants