-
Notifications
You must be signed in to change notification settings - Fork 797
Add support for toolchain compilation with LLVM_LINK_LLVM_DYLIB option #6413
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
Changes from all commits
e2fd946
2c604d5
47ff267
560a38a
6296046
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,14 +1,31 @@ | ||
| set(LLVM_LINK_COMPONENTS | ||
| BinaryFormat | ||
| Core | ||
| Support | ||
| SPIRVLib | ||
| ) | ||
| BinaryFormat | ||
| Core | ||
| Support | ||
| SPIRVLib | ||
| ) | ||
|
|
||
| if(LLVM_LINK_LLVM_DYLIB) | ||
| list (REMOVE_ITEM LLVM_LINK_COMPONENTS SPIRVLib) | ||
| endif() | ||
|
|
||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please, remove duplication. if (LLVM_LINK_LLVM_DYLIB)
list (REMOVE_ITEM LLVM_LINK_COMPONENTS SPIRVLib)
endif()Another option: create a list w/o On the other hand, I expect
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The main issue is that llvm library depends on GenXIntrinsics and GenXIntrinsics depends on llvm which causes cmake to fail when shared library build option is used. The whole idea here is to break circular dependency cycle for shared library build by removing libraries from explicit linking list
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I expect GenXIntrinsics library to be linked statically to llvm.so library as all other libraries. Can we do that?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. GenXIntrinsics is built as static and therefore linked statically. The issue is that in current configuration there is a circular dependency between the libraries and while it is not a problem when building static llvm library, cmake throws an error when shared library llvm.so is built. Here is the error it produces:
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why did you remove
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I believe your suggestion is implemented : i.e. GenXIntrinsics is explicitly declared static if you try to build dynamic libraries and therefore it is linked statically with everything. The problem is that turning it into static is not enough to break the circular dependency as cmake is more sensitive to circular dependencies when dynamic libraries are built. That is why the dependency of GenXIntrinsics on llvm.so is replaced with dependencies on smaller libraries. We can discuss it in Teams if you believe it will be more productive.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I don't get what it means.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When you build static libraries you are allowed to have circular dependencies. You are not allowed to have circular dependencies when you build dynamic libraries. That is why we don't see the issue during regular builds.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
GenX intrinsics come from an external repo during the build, unlike others, and they are built with the cmake files provided in that repo.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think sources are fetched during CMake configuration, so the build process can be same.
Thant's sounds like the real cause of CMake customizations on our side. I'm okay to keep changes in our repository for a while, but I suggest we open an issue to discuss with GenX instrinsics owners the way this repository is integrated with other LLVM projects. My main concern is that current approach with customizing CMake files for all projects linking with LLVM targets is not scalable. In my opinion, we can shoot for similar integration, where customization of one (or limited number) LLVM library is required, but rest of the projects should use standard CMake functions to integrate LLVM libraries. |
||
| include_directories( | ||
| ${LLVM_EXTERNAL_LLVM_SPIRV_SOURCE_DIR}/include | ||
| ) | ||
|
|
||
| add_llvm_tool(spirv-to-ir-wrapper | ||
| spirv-to-ir-wrapper.cpp | ||
| if(LLVM_LINK_LLVM_DYLIB) | ||
| add_llvm_tool(spirv-to-ir-wrapper | ||
| spirv-to-ir-wrapper.cpp | ||
| DEPENDS | ||
| LLVMSPIRVLib | ||
| ) | ||
| else() | ||
| add_llvm_tool(spirv-to-ir-wrapper | ||
| spirv-to-ir-wrapper.cpp | ||
| ) | ||
| endif() | ||
|
|
||
| target_link_libraries(spirv-to-ir-wrapper | ||
| PRIVATE | ||
| LLVMSPIRVLib | ||
| ) | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@fineg74, please, commit LLVM-SPIRV-Translator changes to https://github.com/KhronosGroup/SPIRV-LLVM-Translator/ repository. We regularly pull changes from Khronos repository here.
I thought that llvm-spirv tool build is fixed by KhronosGroup/SPIRV-LLVM-Translator#458. Has it been broken again?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Created a PR there.
I believe KhronosGroup/SPIRV-LLVM-Translator#458 solved different problem. The problem this PR solves is a circular dependency that is created when shared libraries are built for toolchain build (building with static libraries do not has this problem as circular dependencies are allowed there).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems KhronosGroup/SPIRV-LLVM-Translator#1543 is the PR mentioned and it should land first.
@fineg74, please add detailed rationale in PR description there. Not sure if testing fails due to infrastructure temporary problems, you can restart if it was. I guess failed testing and no description are the reasons patch stuck for a while.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
KhronosGroup/SPIRV-LLVM-Translator#1543 is merged, so I expect no changes in llvm-spirv/* files.
I agree with Pavel that description should be improved. It's not clear why we need to change customize cmake files here. I expected
add_llvm_libraryto handle linking with all intrinsics. I assume we are building all libraries from sources, so compilation and linking with intrinsics_gen should be no different than any other intrinsics like X86 or NVPTX intrinsics, which do not require this changes. Could you elaborate in the description the difference with regular intrinsics, which makes us customize cmake files for these tools, please?