Skip to content

Commit cc99ff1

Browse files
[CMake] LLVM NVPTX target only if 'cuda' is enabled
CUDA in Cling is an optional feature that we know doesn't properly work from inside ROOT (with modules).
1 parent e48378e commit cc99ff1

File tree

3 files changed

+4
-5
lines changed

3 files changed

+4
-5
lines changed

interpreter/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ else()
9292
set(ROOT_CLING_TARGET "all")
9393
endif()
9494

95-
if(NOT "${ROOT_CLING_TARGET}" STREQUAL "all")
95+
if(cuda AND NOT "${ROOT_CLING_TARGET}" STREQUAL "all")
9696
string(APPEND ROOT_CLING_TARGET ";NVPTX")
9797
endif()
9898

interpreter/cling/CMakeLists.txt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,10 +118,6 @@ else()
118118
endif()
119119
endif()
120120

121-
if( NOT "NVPTX" IN_LIST LLVM_TARGETS_TO_BUILD)
122-
message(FATAL_ERROR "NVPTX backend is not activated\n"
123-
"Please enable it via -DLLVM_TARGETS_TO_BUILD=\"host;NVPTX\"")
124-
endif()
125121

126122
set(CLING_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
127123
set(CLING_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})

interpreter/cling/lib/Interpreter/IncrementalCUDADeviceCompiler.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include "clang/Frontend/CompilerInstance.h"
1717
#include "clang/Lex/HeaderSearchOptions.h"
1818

19+
#include "llvm/Config/llvm-config.h" // for LLVM_HAS_NVPTX_TARGET
1920
#include "llvm/Support/Process.h"
2021
#include "llvm/Support/Program.h"
2122
#include "llvm/Support/raw_ostream.h"
@@ -93,13 +94,15 @@ namespace cling {
9394
return;
9495
}
9596

97+
#if LLVM_HAS_NVPTX_TARGET
9698
// initialize NVPTX backend
9799
LLVMInitializeNVPTXTargetInfo();
98100
LLVMInitializeNVPTXTarget();
99101
LLVMInitializeNVPTXTargetMC();
100102
LLVMInitializeNVPTXAsmPrinter();
101103

102104
m_Init = true;
105+
#endif // LLVM_HAS_NVPTX_TARGET
103106
}
104107

105108
void IncrementalCUDADeviceCompiler::setCuArgs(

0 commit comments

Comments
 (0)