-
Notifications
You must be signed in to change notification settings - Fork 13.6k
[CIR][cmake] Add support for cmake variable CLANG_ENABLE_CIR #86078
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[CIR][cmake] Add support for cmake variable CLANG_ENABLE_CIR #86078
Conversation
Created using spr 1.3.5
Created using spr 1.3.5 [skip ci]
@llvm/pr-subscribers-clang Author: Nathan Lanza (lanza) ChangesIntroduce a cmake variable that guards the inclusion of ClangIR into the Full diff: https://github.com/llvm/llvm-project/pull/86078.diff 7 Files Affected:
diff --git a/clang/CMakeLists.txt b/clang/CMakeLists.txt
index 47fc2e4886cfc2..0e2e9dbf7b2528 100644
--- a/clang/CMakeLists.txt
+++ b/clang/CMakeLists.txt
@@ -164,6 +164,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
|
Created using spr 1.3.5
Created using spr 1.3.5 [skip ci]
Created using spr 1.3.5 [skip ci]
Created using spr 1.3.5 [skip ci]
Created using spr 1.3.5
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The changes seem reasonable to me, but I've added the CMake code owners for final approval.
Created using spr 1.3.5 [skip ci]
Created using spr 1.3.5 [skip ci]
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.