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})
166166set (AMD_COMGR_PUBLIC_LINKER_OPTIONS)
167167set (AMD_COMGR_PRIVATE_LINKER_OPTIONS)
168168
169+ if (${COMGR_DISABLE_SPIRV} )
170+ list (APPEND AMD_COMGR_PRIVATE_COMPILE_OPTIONS "-DCOMGR_DISABLE_SPIRV" )
171+ endif ()
172+
169173list (APPEND AMD_COMGR_PRIVATE_COMPILE_OPTIONS "-DAMD_COMGR_GIT_COMMIT=${AMD_COMGR_GIT_COMMIT} " )
170174list (APPEND AMD_COMGR_PRIVATE_COMPILE_OPTIONS "-DAMD_COMGR_GIT_BRANCH=${AMD_COMGR_GIT_BRANCH} " )
171175message ("----COMGR_GIT_COMMIT: ${AMD_COMGR_GIT_COMMIT} " )
@@ -383,8 +387,18 @@ set(LLD_LIBS
383387 lldELF
384388 lldCommon)
385389
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+
386400if (LLVM_LINK_LLVM_DYLIB)
387- set (LLVM_LIBS LLVM)
401+ set (LLVM_LIBS LLVM ${SPIRV_DYNAMIC_LIB} )
388402else ()
389403 llvm_map_components_to_libnames(LLVM_LIBS
390404 ${LLVM_TARGETS_TO_BUILD}
@@ -405,7 +419,7 @@ else()
405419 Support
406420 Symbolize
407421 TargetParser
408- SPIRVAMDLib
422+ ${SPIRV_STATIC_LIB}
409423 )
410424endif ()
411425
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
8080Comgr can be built as a static library by passing
8181` -DCOMGR_BUILD_SHARED_LIBS=OFF ` during the Comgr ` cmake ` step.
8282
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+
8387Depending on the Code Object Manager
8488------------------------------------
8589
Original file line number Diff line number Diff line change 8181#include " llvm/Support/WithColor.h"
8282#include " llvm/TargetParser/Host.h"
8383
84+ #ifndef COMGR_DISABLE_SPIRV
8485#include " LLVMSPIRVLib/LLVMSPIRVLib.h"
86+ #endif
87+
8588#include " time-stat/ts-interface.h"
8689
8790#include < csignal>
@@ -1852,6 +1855,12 @@ amd_comgr_status_t AMDGPUCompiler::linkToExecutable() {
18521855}
18531856
18541857amd_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
18551864 if (auto Status = createTmpDirs ()) {
18561865 return Status;
18571866 }
@@ -1906,6 +1915,7 @@ amd_comgr_status_t AMDGPUCompiler::translateSpirvToBitcode() {
19061915 }
19071916
19081917 return AMD_COMGR_STATUS_SUCCESS;
1918+ #endif
19091919}
19101920
19111921AMDGPUCompiler::AMDGPUCompiler (DataAction *ActionInfo, DataSet *InSet,
You can’t perform that action at this time.
0 commit comments