File tree Expand file tree Collapse file tree 3 files changed +30
-2
lines changed Expand file tree Collapse file tree 3 files changed +30
-2
lines changed Original file line number Diff line number Diff line change @@ -166,6 +166,10 @@ set(AMD_COMGR_PRIVATE_COMPILE_DEFINITIONS ${LLVM_DEFINITIONS})
166
166
set (AMD_COMGR_PUBLIC_LINKER_OPTIONS )
167
167
set (AMD_COMGR_PRIVATE_LINKER_OPTIONS )
168
168
169
+ if (${COMGR_DISABLE_SPIRV} )
170
+ list (APPEND AMD_COMGR_PRIVATE_COMPILE_OPTIONS "-DCOMGR_DISABLE_SPIRV" )
171
+ endif ()
172
+
169
173
list (APPEND AMD_COMGR_PRIVATE_COMPILE_OPTIONS "-DAMD_COMGR_GIT_COMMIT=${AMD_COMGR_GIT_COMMIT} " )
170
174
list (APPEND AMD_COMGR_PRIVATE_COMPILE_OPTIONS "-DAMD_COMGR_GIT_BRANCH=${AMD_COMGR_GIT_BRANCH} " )
171
175
message ("----COMGR_GIT_COMMIT: ${AMD_COMGR_GIT_COMMIT} " )
@@ -383,8 +387,18 @@ set(LLD_LIBS
383
387
lldELF
384
388
lldCommon )
385
389
390
+ if (${COMGR_DISABLE_SPIRV} )
391
+ message ("-- Comgr SPIRV Disabled" )
392
+ set (SPIRV_DYNAMIC_LIB "" )
393
+ set (SPIRV_STATIC_LIB "" )
394
+ else ()
395
+ message ("-- Comgr SPIRV Enabled" )
396
+ set (SPIRV_DYNAMIC_LIB "LLVMSPIRVAMDLib" )
397
+ set (SPIRV_STATIC_LIB "SPIRVAMDLib" )
398
+ endif ()
399
+
386
400
if (LLVM_LINK_LLVM_DYLIB )
387
- set (LLVM_LIBS LLVM )
401
+ set (LLVM_LIBS LLVM ${SPIRV_DYNAMIC_LIB} )
388
402
else ()
389
403
llvm_map_components_to_libnames (LLVM_LIBS
390
404
${LLVM_TARGETS_TO_BUILD}
@@ -405,7 +419,7 @@ else()
405
419
Support
406
420
Symbolize
407
421
TargetParser
408
- SPIRVAMDLib
422
+ ${SPIRV_STATIC_LIB}
409
423
)
410
424
endif ()
411
425
Original file line number Diff line number Diff line change @@ -80,6 +80,10 @@ may be enabled during development via `-DADDRESS_SANITIZER=On` during the Comgr
80
80
Comgr can be built as a static library by passing
81
81
` -DCOMGR_BUILD_SHARED_LIBS=OFF ` during the Comgr ` cmake ` step.
82
82
83
+ Comgr SPIRV-related APIs can be disabled by passing
84
+ ` -DCOMGR_DISABLE_SPIRV=1 ` during the Comgr ` cmake ` step. This removes any
85
+ dependency on LLVM SPIRV libraries or the llvm-spirv tool.
86
+
83
87
Depending on the Code Object Manager
84
88
------------------------------------
85
89
Original file line number Diff line number Diff line change 81
81
#include " llvm/Support/WithColor.h"
82
82
#include " llvm/TargetParser/Host.h"
83
83
84
+ #ifndef COMGR_DISABLE_SPIRV
84
85
#include " LLVMSPIRVLib/LLVMSPIRVLib.h"
86
+ #endif
87
+
85
88
#include " time-stat/ts-interface.h"
86
89
87
90
#include < csignal>
@@ -1852,6 +1855,12 @@ amd_comgr_status_t AMDGPUCompiler::linkToExecutable() {
1852
1855
}
1853
1856
1854
1857
amd_comgr_status_t AMDGPUCompiler::translateSpirvToBitcode () {
1858
+ #ifdef COMGR_DISABLE_SPIRV
1859
+ LogS << " Calling AMDGPUCompiler::translateSpirvToBitcode() not supported "
1860
+ << " Comgr is built with -DCOMGR_DISABLE_SPIRV. Re-build LLVM and Comgr "
1861
+ << " with LLVM-SPIRV-Translator support to continue.\n " ;
1862
+ return AMD_COMGR_STATUS_ERROR;
1863
+ #else
1855
1864
if (auto Status = createTmpDirs ()) {
1856
1865
return Status;
1857
1866
}
@@ -1906,6 +1915,7 @@ amd_comgr_status_t AMDGPUCompiler::translateSpirvToBitcode() {
1906
1915
}
1907
1916
1908
1917
return AMD_COMGR_STATUS_SUCCESS;
1918
+ #endif
1909
1919
}
1910
1920
1911
1921
AMDGPUCompiler::AMDGPUCompiler (DataAction *ActionInfo, DataSet *InSet,
You can’t perform that action at this time.
0 commit comments