[clang] 44de2bb - [CIR][cmake] Add support for cmake variable CLANG_ENABLE_CIR
via cfe-commits
cfe-commits at lists.llvm.org
Thu Apr 11 13:56:34 PDT 2024
Author: Nathan Lanza
Date: 2024-04-11T16:56:31-04:00
New Revision: 44de2bb6949f0ca62a2e16506fe3d91be14e6d23
URL: https://github.com/llvm/llvm-project/commit/44de2bb6949f0ca62a2e16506fe3d91be14e6d23
DIFF: https://github.com/llvm/llvm-project/commit/44de2bb6949f0ca62a2e16506fe3d91be14e6d23.diff
LOG: [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: https://github.com/llvm/llvm-project/pull/86078
Added:
clang/include/clang/CIR/CMakeLists.txt
clang/lib/CIR/CMakeLists.txt
Modified:
clang/CMakeLists.txt
clang/include/clang/CMakeLists.txt
clang/include/clang/Config/config.h.cmake
clang/lib/CMakeLists.txt
clang/test/CMakeLists.txt
clang/test/lit.site.cfg.py.in
Removed:
################################################################################
diff --git a/clang/CMakeLists.txt b/clang/CMakeLists.txt
index 284b2af24ddaa0..f092766fa19f07 100644
--- a/clang/CMakeLists.txt
+++ b/clang/CMakeLists.txt
@@ -165,6 +165,13 @@ if(CLANG_ENABLE_LIBXML2)
endif()
endif()
+if(CLANG_ENABLE_CIR)
+ if (NOT "${LLVM_ENABLE_PROJECTS}" MATCHES "MLIR|mlir")
+ message(FATAL_ERROR
+ "Cannot build ClangIR without MLIR in LLVM_ENABLE_PROJECTS")
+ endif()
+endif()
+
include(CheckIncludeFile)
check_include_file(sys/resource.h CLANG_HAVE_RLIMITS)
diff --git a/clang/include/clang/CIR/CMakeLists.txt b/clang/include/clang/CIR/CMakeLists.txt
new file mode 100644
index 00000000000000..e69de29bb2d1d6
diff --git a/clang/include/clang/CMakeLists.txt b/clang/include/clang/CMakeLists.txt
index 0dc9ea5ed8ac8a..47ac70cd21690f 100644
--- a/clang/include/clang/CMakeLists.txt
+++ b/clang/include/clang/CMakeLists.txt
@@ -1,5 +1,8 @@
add_subdirectory(AST)
add_subdirectory(Basic)
+if(CLANG_ENABLE_CIR)
+ add_subdirectory(CIR)
+endif()
add_subdirectory(Driver)
add_subdirectory(Parse)
add_subdirectory(Sema)
diff --git a/clang/include/clang/Config/config.h.cmake b/clang/include/clang/Config/config.h.cmake
index 4015ac8040861c..27ed69e21562bf 100644
--- a/clang/include/clang/Config/config.h.cmake
+++ b/clang/include/clang/Config/config.h.cmake
@@ -83,4 +83,7 @@
/* Spawn a new process clang.exe for the CC1 tool invocation, when necessary */
#cmakedefine01 CLANG_SPAWN_CC1
+/* Whether CIR is built into Clang */
+#cmakedefine01 CLANG_ENABLE_CIR
+
#endif
diff --git a/clang/lib/CIR/CMakeLists.txt b/clang/lib/CIR/CMakeLists.txt
new file mode 100644
index 00000000000000..e69de29bb2d1d6
diff --git a/clang/lib/CMakeLists.txt b/clang/lib/CMakeLists.txt
index 0cac86451f39e4..14ba55360fe050 100644
--- a/clang/lib/CMakeLists.txt
+++ b/clang/lib/CMakeLists.txt
@@ -31,3 +31,7 @@ if(CLANG_INCLUDE_TESTS)
endif()
add_subdirectory(Interpreter)
add_subdirectory(Support)
+
+if(CLANG_ENABLE_CIR)
+ add_subdirectory(CIR)
+endif()
diff --git a/clang/test/CMakeLists.txt b/clang/test/CMakeLists.txt
index fcfca354f4a75f..df34a5707da33e 100644
--- a/clang/test/CMakeLists.txt
+++ b/clang/test/CMakeLists.txt
@@ -9,6 +9,7 @@ llvm_canonicalize_cmake_booleans(
CLANG_ENABLE_STATIC_ANALYZER
CLANG_PLUGIN_SUPPORT
CLANG_SPAWN_CC1
+ CLANG_ENABLE_CIR
ENABLE_BACKTRACES
LLVM_ENABLE_ZLIB
LLVM_ENABLE_ZSTD
diff --git a/clang/test/lit.site.cfg.py.in b/clang/test/lit.site.cfg.py.in
index ef75770a2c3c9a..6641811c588395 100644
--- a/clang/test/lit.site.cfg.py.in
+++ b/clang/test/lit.site.cfg.py.in
@@ -27,6 +27,7 @@ config.clang_default_pie_on_linux = @CLANG_DEFAULT_PIE_ON_LINUX@
config.clang_default_cxx_stdlib = "@CLANG_DEFAULT_CXX_STDLIB@"
config.clang_staticanalyzer = @CLANG_ENABLE_STATIC_ANALYZER@
config.clang_staticanalyzer_z3 = @LLVM_WITH_Z3@
+config.clang_enable_cir = @CLANG_ENABLE_CIR@
config.clang_examples = @CLANG_BUILD_EXAMPLES@
config.enable_shared = @ENABLE_SHARED@
config.enable_backtrace = @ENABLE_BACKTRACES@
More information about the cfe-commits
mailing list