Skip to content

Commit d1a2e01

Browse files
maarquitos14sys-ce-bb
authored andcommitted
Add cmake option to enable --spirv-tools-dis feature (#2925)
Original commit: KhronosGroup/SPIRV-LLVM-Translator@b8b1b96bd7419c1
1 parent f27011d commit d1a2e01

File tree

6 files changed

+11
-4
lines changed

6 files changed

+11
-4
lines changed

llvm-spirv/CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,9 @@ if (NOT SPIRV_TOOLS_FOUND)
144144
endif()
145145
endif()
146146

147-
if (NOT SPIRV_TOOLS_FOUND)
147+
option(LLVM_SPIRV_ENABLE_LIBSPIRV_DIS "Enable --spirv-tools-dis support.")
148+
149+
if (NOT SPIRV_TOOLS_FOUND AND LLVM_SPIRV_ENABLE_LIBSPIRV_DIS)
148150
message(STATUS "SPIRV-Tools not found; project will be built without "
149151
"--spirv-tools-dis support.")
150152
endif()

llvm-spirv/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ Building clang from sources takes time and resources and it can be avoided:
9797
### Build with SPIRV-Tools
9898

9999
The translator can use [SPIRV-Tools](https://github.com/KhronosGroup/SPIRV-Tools) to generate assembly with widely adopted syntax.
100+
This feature can be enabled by passing `-DLLVM_SPIRV_ENABLE_LIBSPIRV_DIS=ON` option.
100101
If SPIRV-Tools have been installed prior to the build it will be detected and
101102
used automatically. However it is also possible to enable use of SPIRV-Tools
102103
from a custom location using the following instructions:

llvm-spirv/test/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ if(SPIRV_TOOLS_FOUND AND NOT SPIRV-Tools-tools_FOUND)
3131
endif()
3232

3333
set(SPIRV_TOOLS_BINDIR "${SPIRV_TOOLS_PREFIX}/bin")
34+
if (LLVM_SPIRV_ENABLE_LIBSPIRV_DIS)
35+
set(SPIRV_ENABLE_LIBSPIRV_DIS ON)
36+
endif()
3437
elseif(SPIRV-Tools-tools_FOUND)
3538
# we found SPIRV-Tools via cmake targets
3639

llvm-spirv/test/lit.cfg.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
# excludes: A list of directories and fles to exclude from the testsuite.
2222
config.excludes = ['CMakeLists.txt']
2323

24-
if config.spirv_tools_found:
24+
if config.libspirv_dis:
2525
config.available_features.add('libspirv_dis')
2626

2727
if not config.spirv_skip_debug_info_tests:

llvm-spirv/test/lit.site.cfg.py.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ config.host_arch = "@HOST_ARCH@"
1919
config.python_executable = "@PYTHON_EXECUTABLE@"
2020
config.test_run_dir = "@CMAKE_CURRENT_BINARY_DIR@"
2121
config.spirv_tools_found = "@SPIRV_TOOLS_FOUND@"
22+
config.libspirv_dis = "@SPIRV_ENABLE_LIBSPIRV_DIS@"
2223
config.spirv_tools_have_spirv_as = @SPIRV_TOOLS_SPIRV_AS_FOUND@
2324
config.spirv_tools_have_spirv_dis = @SPIRV_TOOLS_SPIRV_DIS_FOUND@
2425
config.spirv_tools_have_spirv_link = @SPIRV_TOOLS_SPIRV_LINK_FOUND@

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ target_include_directories(llvm-spirv
3232
${LLVM_SPIRV_INCLUDE_DIRS}
3333
)
3434

35-
if(SPIRV_TOOLS_FOUND)
35+
if(SPIRV_TOOLS_FOUND AND LLVM_SPIRV_ENABLE_LIBSPIRV_DIS)
3636
target_compile_definitions(llvm-spirv PRIVATE LLVM_SPIRV_HAVE_SPIRV_TOOLS=1)
3737
target_include_directories(llvm-spirv PRIVATE ${SPIRV_TOOLS_INCLUDE_DIRS})
3838
target_link_libraries(llvm-spirv PRIVATE ${SPIRV_TOOLS_LDFLAGS})
39-
endif(SPIRV_TOOLS_FOUND)
39+
endif()

0 commit comments

Comments
 (0)