[clang] [llvm] [clang][Serialization] Stop including Frontend headers from Serialization (NFC) (PR #123140)
Jorge Gorbe Moya via llvm-commits
llvm-commits at lists.llvm.org
Wed Jan 15 15:23:30 PST 2025
https://github.com/slackito created https://github.com/llvm/llvm-project/pull/123140
The Frontend library depends on Serialization. This is an explicit dependency encoded in the CMake target. However, Serialization currently has an implicit dependency on Frontend, as it includes one of its headers. This is not reflected in the CMake build rules, but Bazel is stricter so, in order to avoid a dependency cycle, it hackily declares the Frontend headers as source files for Serialization.
Fortunately, the only Frontend header used by Serialization is clang/Frontend/FrontendDiagnostic.h, which is a legacy header that just includes clang/Basic/DiagnosticFrontend since d076608d58d1ec55016eb747a995511e3a3f72aa, back in 2018.
This commit changes Serialization to use the underlying header from Basic instead. Both Serialization and Frontend depend on Basic, so this breaks the dependency cycle.
>From 36e54bb2477ac3907f441ae8a620dd7df51aae7b Mon Sep 17 00:00:00 2001
From: Jorge Gorbe Moya <jgorbe at google.com>
Date: Wed, 15 Jan 2025 15:08:55 -0800
Subject: [PATCH] [clang][Serialization] Stop including Frontend headers from
Serialization (NFC)
The Frontend library depends on Serialization. This is an explicit
dependency encoded in the CMake target. However, Serialization currently
has an implicit dependency on Frontend, as it includes one of its
headers. This is not reflected in the CMake build rules, but Bazel is
stricter so, in order to avoid a dependency cycle, it hackily declares
the Frontend headers as source files for Serialization.
Fortunately, the only Frontend header used by Serialization is
clang/Frontend/FrontendDiagnostic.h, which has been just a legacy header
that includes clang/Basic/DiagnosticFrontend since
d076608d58d1ec55016eb747a995511e3a3f72aa, back in 2018.
This commit changes Serialization to use the underlying header from
Basic instead. Both Serialization and Frontend depend on Basic, so this
breaks the dependency cycle.
---
clang/lib/Serialization/GeneratePCH.cpp | 2 +-
utils/bazel/llvm-project-overlay/clang/BUILD.bazel | 5 -----
2 files changed, 1 insertion(+), 6 deletions(-)
diff --git a/clang/lib/Serialization/GeneratePCH.cpp b/clang/lib/Serialization/GeneratePCH.cpp
index a3189bb40b1912..12751beb8d7157 100644
--- a/clang/lib/Serialization/GeneratePCH.cpp
+++ b/clang/lib/Serialization/GeneratePCH.cpp
@@ -12,7 +12,7 @@
//===----------------------------------------------------------------------===//
#include "clang/AST/ASTContext.h"
-#include "clang/Frontend/FrontendDiagnostic.h"
+#include "clang/Basic/DiagnosticFrontend.h"
#include "clang/Lex/HeaderSearch.h"
#include "clang/Lex/HeaderSearchOptions.h"
#include "clang/Lex/Preprocessor.h"
diff --git a/utils/bazel/llvm-project-overlay/clang/BUILD.bazel b/utils/bazel/llvm-project-overlay/clang/BUILD.bazel
index a86c295b04cb10..97445d99dc3784 100644
--- a/utils/bazel/llvm-project-overlay/clang/BUILD.bazel
+++ b/utils/bazel/llvm-project-overlay/clang/BUILD.bazel
@@ -2148,7 +2148,6 @@ cc_library(
"include/clang/Serialization/AttrPCHRead.inc",
"include/clang/Serialization/AttrPCHWrite.inc",
] + glob([
- "include/clang/Frontend/*.h",
"lib/Serialization/*.cpp",
"lib/Serialization/*.h",
]),
@@ -2160,15 +2159,11 @@ cc_library(
"include/clang/Serialization/*.def",
]),
deps = [
- ":apinotes",
":ast",
":basic",
- ":driver",
":lex",
":sema",
":serialization_attr_gen",
- ":static_analyzer_core_options",
- ":support",
":type_nodes_gen",
"//llvm:BitReader",
"//llvm:BitWriter",
More information about the llvm-commits
mailing list