Skip to content

Commit 44de2bb

Browse files
authoredApr 11, 2024··
[CIR][cmake] Add support for cmake variable CLANG_ENABLE_CIR
Introduce a cmake variable that guards the inclusion of ClangIR into the build of clang. Guard that we aren't trying to build without MLIR. Add two subdirectories that, as of now, don't do anything. Reviewers: bcardosolopes, erichkeane, petrhosek, Ericson2314 Reviewed By: bcardosolopes Pull Request: #86078
1 parent 1f5d130 commit 44de2bb

File tree

8 files changed

+19
-0
lines changed

8 files changed

+19
-0
lines changed
 

‎clang/CMakeLists.txt

+7
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,13 @@ if(CLANG_ENABLE_LIBXML2)
165165
endif()
166166
endif()
167167

168+
if(CLANG_ENABLE_CIR)
169+
if (NOT "${LLVM_ENABLE_PROJECTS}" MATCHES "MLIR|mlir")
170+
message(FATAL_ERROR
171+
"Cannot build ClangIR without MLIR in LLVM_ENABLE_PROJECTS")
172+
endif()
173+
endif()
174+
168175
include(CheckIncludeFile)
169176
check_include_file(sys/resource.h CLANG_HAVE_RLIMITS)
170177

‎clang/include/clang/CIR/CMakeLists.txt

Whitespace-only changes.

‎clang/include/clang/CMakeLists.txt

+3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
add_subdirectory(AST)
22
add_subdirectory(Basic)
3+
if(CLANG_ENABLE_CIR)
4+
add_subdirectory(CIR)
5+
endif()
36
add_subdirectory(Driver)
47
add_subdirectory(Parse)
58
add_subdirectory(Sema)

‎clang/include/clang/Config/config.h.cmake

+3
Original file line numberDiff line numberDiff line change
@@ -83,4 +83,7 @@
8383
/* Spawn a new process clang.exe for the CC1 tool invocation, when necessary */
8484
#cmakedefine01 CLANG_SPAWN_CC1
8585

86+
/* Whether CIR is built into Clang */
87+
#cmakedefine01 CLANG_ENABLE_CIR
88+
8689
#endif

‎clang/lib/CIR/CMakeLists.txt

Whitespace-only changes.

‎clang/lib/CMakeLists.txt

+4
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,7 @@ if(CLANG_INCLUDE_TESTS)
3131
endif()
3232
add_subdirectory(Interpreter)
3333
add_subdirectory(Support)
34+
35+
if(CLANG_ENABLE_CIR)
36+
add_subdirectory(CIR)
37+
endif()

‎clang/test/CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ llvm_canonicalize_cmake_booleans(
99
CLANG_ENABLE_STATIC_ANALYZER
1010
CLANG_PLUGIN_SUPPORT
1111
CLANG_SPAWN_CC1
12+
CLANG_ENABLE_CIR
1213
ENABLE_BACKTRACES
1314
LLVM_ENABLE_ZLIB
1415
LLVM_ENABLE_ZSTD

‎clang/test/lit.site.cfg.py.in

+1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ config.clang_default_pie_on_linux = @CLANG_DEFAULT_PIE_ON_LINUX@
2727
config.clang_default_cxx_stdlib = "@CLANG_DEFAULT_CXX_STDLIB@"
2828
config.clang_staticanalyzer = @CLANG_ENABLE_STATIC_ANALYZER@
2929
config.clang_staticanalyzer_z3 = @LLVM_WITH_Z3@
30+
config.clang_enable_cir = @CLANG_ENABLE_CIR@
3031
config.clang_examples = @CLANG_BUILD_EXAMPLES@
3132
config.enable_shared = @ENABLE_SHARED@
3233
config.enable_backtrace = @ENABLE_BACKTRACES@

0 commit comments

Comments
 (0)
Please sign in to comment.