[clang] [llvm] Enable ClangIR Build By Default (PR #221291)
Erich Keane via cfe-commits
cfe-commits at lists.llvm.org
Thu Oct 8 11:46:44 PDT 2026
https://github.com/erichkeane updated https://github.com/llvm/llvm-project/pull/221291
>From e3116fa653a9dac54d2a58932130f2ec2d175c0c Mon Sep 17 00:00:00 2001
From: erichkeane <ekeane at nvidia.com>
Date: Fri, 4 Sep 2026 09:23:26 -0700
Subject: [PATCH 1/2] Enable ClangIR Build By Default-
This is subject to an RFC:
https://discourse.llvm.org/t/rfc-enable-clangir-build-by-default/91730
This patch enables building ClangIR (and thus MLIR) by default in clang
builds. The project has hit a maturity level where we believe this is
a good time to do it. See the RFC for details.
---
clang/CMakeLists.txt | 6 ++----
clang/docs/ReleaseNotes.md | 5 +++++
llvm/CMakeLists.txt | 11 +++++++++++
3 files changed, 18 insertions(+), 4 deletions(-)
diff --git a/clang/CMakeLists.txt b/clang/CMakeLists.txt
index fc71cf45dbb34c..3416e67eb79910 100644
--- a/clang/CMakeLists.txt
+++ b/clang/CMakeLists.txt
@@ -190,15 +190,13 @@ if(CLANG_ENABLE_LIBXML2)
endif()
endif()
+cmake_dependent_option(CLANG_ENABLE_CIR "Build ClangIR support into the compiler" ON "NOT CLANG_BUILT_STANDALONE" OFF)
+
if(CLANG_ENABLE_CIR)
if (CLANG_BUILT_STANDALONE)
message(FATAL_ERROR
"ClangIR is not yet supported in the standalone build.")
endif()
- if (NOT "${LLVM_ENABLE_PROJECTS}" MATCHES "MLIR|mlir")
- message(FATAL_ERROR
- "Cannot build ClangIR without MLIR in LLVM_ENABLE_PROJECTS")
- endif()
endif()
include(CheckIncludeFile)
diff --git a/clang/docs/ReleaseNotes.md b/clang/docs/ReleaseNotes.md
index ca5c63fbaa17d7..ce458ce2e0ecc7 100644
--- a/clang/docs/ReleaseNotes.md
+++ b/clang/docs/ReleaseNotes.md
@@ -837,6 +837,11 @@ The `alpha.cplusplus.UseAfterLifetimeEnd` checker was renamed to `alpha.core.Use
#### Improvements
+### Clang IR Improvements
+
+- Clang IR has now been enabled in builds by default, and should work with most workloads. However this is still an experimental flag and a work-in-progress.
+
+
## Additional Information
A wide variety of additional information is available on the [Clang web
diff --git a/llvm/CMakeLists.txt b/llvm/CMakeLists.txt
index 44299d51d784a1..7f0e8fc7a9915e 100644
--- a/llvm/CMakeLists.txt
+++ b/llvm/CMakeLists.txt
@@ -201,6 +201,17 @@ if ("flang" IN_LIST LLVM_ENABLE_PROJECTS)
endif ()
endif()
+# Clang defaults to CLANG_ENABLE_CIR now, so we need to auto-add MLIR unless it
+# was explicitly disabled.
+if ("clang" IN_LIST LLVM_ENABLE_PROJECTS)
+ if (NOT DEFINED CLANG_ENABLE_CIR OR CLANG_ENABLE_CIR)
+ if (NOT "mlir" IN_LIST LLVM_ENABLE_PROJECTS)
+ message(STATUS "Enabling MLIR as a dependency of ClangIR")
+ list(APPEND LLVM_ENABLE_PROJECTS "mlir")
+ endif()
+ endif()
+endif()
+
if ("lldb" IN_LIST LLVM_ENABLE_PROJECTS)
if (NOT "clang" IN_LIST LLVM_ENABLE_PROJECTS)
message(STATUS "Enabling clang as a dependency of lldb")
>From 33e5ee57b3112cd62890b36419c22156ec338247 Mon Sep 17 00:00:00 2001
From: erichkeane <ekeane at nvidia.com>
Date: Mon, 14 Sep 2026 10:21:37 -0700
Subject: [PATCH 2/2] Add to release-notes-template, plus clarify release notes
---
clang/docs/ReleaseNotes.md | 2 +-
clang/docs/ReleaseNotesTemplate.txt | 2 ++
2 files changed, 3 insertions(+), 1 deletion(-)
diff --git a/clang/docs/ReleaseNotes.md b/clang/docs/ReleaseNotes.md
index cbe99b9a22b603..21d3be7313dcde 100644
--- a/clang/docs/ReleaseNotes.md
+++ b/clang/docs/ReleaseNotes.md
@@ -908,7 +908,7 @@ The `alpha.cplusplus.UseAfterLifetimeEnd` checker was renamed to `alpha.core.Use
### Clang IR Improvements
-- Clang IR has now been enabled in builds by default, and should work with most workloads. However this is still an experimental flag and a work-in-progress.
+- Clang builds now build Clang IR support by default. Clang IR is expected to work with most Linux/X86-64 workloads. Normal builds are unchanged, however those who wish to test out the experimental `-fclangir` flag can now do so with a Clang build.
## Additional Information
diff --git a/clang/docs/ReleaseNotesTemplate.txt b/clang/docs/ReleaseNotesTemplate.txt
index df98f9adc03387..b7920ab029d0ea 100644
--- a/clang/docs/ReleaseNotesTemplate.txt
+++ b/clang/docs/ReleaseNotesTemplate.txt
@@ -193,6 +193,8 @@ latest release, please see the [Clang Web Site](https://clang.llvm.org) or the
#### Improvements
+### Clang IR Improvements
+
## Additional Information
A wide variety of additional information is available on the [Clang web
More information about the cfe-commits
mailing list