Skip to content

Commit 6cece96

Browse files
sarnexsys-ce-bb
authored andcommitted
Fix build when linking against SPIRVLib with SPIR-V backend support enabled (#3274)
When building with SPIR-V backend support, naturally we need to link against the SPIR-V backend. Currently this is done as part of the tool (`llvm-spirv`)'s CMake dependencies, instead of `SPIRVLib` which is the actual CMake target that requires the SPIR-V backend (`SPIRVTranslateModule` call inside `SPIRVWriter.cpp`). This causes a linker error if someone depends on `SPIRVLib` directly and doesn't depend on `llvm-spirv`. Move the dependency from the tool to the lib. Signed-off-by: Sarnie, Nick <[email protected]> Original commit: KhronosGroup/SPIRV-LLVM-Translator@10c7569b3c4cb45
1 parent 76b9f31 commit 6cece96

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

llvm-spirv/lib/SPIRV/CMakeLists.txt

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,9 @@ set(SRC_LIST
4040
libSPIRV/SPIRVValue.cpp
4141
libSPIRV/SPIRVError.cpp
4242
libSPIRV/SPIRVFnVar.cpp
43-
)
44-
add_llvm_library(LLVMSPIRVLib
45-
${SRC_LIST}
46-
LINK_COMPONENTS
43+
)
44+
45+
set(SPIRVLIB_LINK_COMPONENTS
4746
Analysis
4847
BitWriter
4948
CodeGen
@@ -55,6 +54,16 @@ add_llvm_library(LLVMSPIRVLib
5554
Support
5655
TargetParser
5756
TransformUtils
57+
)
58+
59+
if(SPIRV_BACKEND_FOUND)
60+
list(APPEND SPIRVLIB_LINK_COMPONENTS "SPIRVCodeGen")
61+
endif()
62+
63+
add_llvm_library(LLVMSPIRVLib
64+
${SRC_LIST}
65+
LINK_COMPONENTS
66+
${SPIRVLIB_LINK_COMPONENTS}
5867
DEPENDS
5968
intrinsics_gen
6069
)

llvm-spirv/tools/llvm-spirv/CMakeLists.txt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,6 @@ set(LLVM_LINK_COMPONENTS
1010
TransformUtils
1111
)
1212

13-
if(SPIRV_BACKEND_FOUND)
14-
list(APPEND LLVM_LINK_COMPONENTS "SPIRVCodeGen")
15-
endif()
16-
1713
# llvm_setup_rpath messes with the rpath making llvm-spirv not
1814
# executable from the build directory in out-of-tree builds
1915
set(add_llvm_tool_options)

0 commit comments

Comments
 (0)