[clang] [llvm] [clang][Modules] Fixing Build Breaks When -DLLVM_ENABLE_MODULES=ON (PR #119473)
Qiongsi Wu via llvm-commits
llvm-commits at lists.llvm.org
Wed Dec 11 15:03:08 PST 2024
https://github.com/qiongsiwu updated https://github.com/llvm/llvm-project/pull/119473
>From 06ae1ba1222f09e35ed428bcd6da91438b15e016 Mon Sep 17 00:00:00 2001
From: Qiongsi Wu <qiongsi_wu at apple.com>
Date: Tue, 10 Dec 2024 15:42:46 -0800
Subject: [PATCH 1/3] Fixing issues causing build break when
-DLLVM_ENABLE_MODULES=ON
---
clang/include/clang/Support/Compiler.h | 2 --
clang/include/module.modulemap | 5 ++++-
llvm/include/llvm/DebugInfo/DWARF/DWARFTypePrinter.h | 1 +
llvm/include/llvm/IR/NVVMIntrinsicFlags.h | 2 ++
llvm/include/llvm/Support/Memory.h | 1 +
llvm/include/llvm/TargetParser/AArch64TargetParser.h | 1 +
llvm/include/module.modulemap | 1 +
llvm/tools/llvm-jitlink/llvm-jitlink-executor/CMakeLists.txt | 1 +
llvm/unittests/tools/llvm-profgen/CMakeLists.txt | 1 +
9 files changed, 12 insertions(+), 3 deletions(-)
diff --git a/clang/include/clang/Support/Compiler.h b/clang/include/clang/Support/Compiler.h
index 13582b899dc2a6..0cba1ad7331682 100644
--- a/clang/include/clang/Support/Compiler.h
+++ b/clang/include/clang/Support/Compiler.h
@@ -14,8 +14,6 @@
#ifndef CLANG_SUPPORT_COMPILER_H
#define CLANG_SUPPORT_COMPILER_H
-#include "llvm/Support/Compiler.h"
-
/// CLANG_ABI is the main export/visibility macro to mark something as
/// explicitly exported when clang is built as a shared library with everything
/// else that is unannotated having hidden visibility.
diff --git a/clang/include/module.modulemap b/clang/include/module.modulemap
index b399f0beee59a1..e9218c715147b0 100644
--- a/clang/include/module.modulemap
+++ b/clang/include/module.modulemap
@@ -115,7 +115,7 @@ module Clang_Diagnostics {
module Driver { header "clang/Driver/DriverDiagnostic.h" export * }
module Frontend { header "clang/Frontend/FrontendDiagnostic.h" export * }
module Lex { header "clang/Lex/LexDiagnostic.h" export * }
- module Parse { header "clang/Parse/ParseDiagnostic.h" export * }
+ module Parse { header "clang/Basic/DiagnosticParse.h" export * }
module Serialization { header "clang/Serialization/SerializationDiagnostic.h" export * }
module Refactoring { header "clang/Tooling/Refactoring/RefactoringDiagnostic.h" export * }
}
@@ -186,6 +186,9 @@ module Clang_StaticAnalyzer_Frontend {
module Clang_Testing {
requires cplusplus
umbrella "clang/Testing"
+
+ textual header "clang/Testing/TestLanguage.def"
+
module * { export * }
}
diff --git a/llvm/include/llvm/DebugInfo/DWARF/DWARFTypePrinter.h b/llvm/include/llvm/DebugInfo/DWARF/DWARFTypePrinter.h
index 3c936b93865045..bd25f6c30ebf1f 100644
--- a/llvm/include/llvm/DebugInfo/DWARF/DWARFTypePrinter.h
+++ b/llvm/include/llvm/DebugInfo/DWARF/DWARFTypePrinter.h
@@ -9,6 +9,7 @@
#ifndef LLVM_DEBUGINFO_DWARF_DWARFTYPEPRINTER_H
#define LLVM_DEBUGINFO_DWARF_DWARFTYPEPRINTER_H
+#include "llvm/ADT/StringExtras.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/BinaryFormat/Dwarf.h"
#include "llvm/Support/Error.h"
diff --git a/llvm/include/llvm/IR/NVVMIntrinsicFlags.h b/llvm/include/llvm/IR/NVVMIntrinsicFlags.h
index 43dde42bbbd620..dfb6e857b3a6ad 100644
--- a/llvm/include/llvm/IR/NVVMIntrinsicFlags.h
+++ b/llvm/include/llvm/IR/NVVMIntrinsicFlags.h
@@ -15,6 +15,8 @@
#ifndef LLVM_IR_NVVMINTRINSICFLAGS_H
#define LLVM_IR_NVVMINTRINSICFLAGS_H
+#include <stdint.h>
+
namespace llvm {
namespace nvvm {
diff --git a/llvm/include/llvm/Support/Memory.h b/llvm/include/llvm/Support/Memory.h
index c02a3cc14dc7de..a587f2a8542b2e 100644
--- a/llvm/include/llvm/Support/Memory.h
+++ b/llvm/include/llvm/Support/Memory.h
@@ -15,6 +15,7 @@
#include "llvm/Support/DataTypes.h"
#include <system_error>
+#include <utility>
namespace llvm {
diff --git a/llvm/include/llvm/TargetParser/AArch64TargetParser.h b/llvm/include/llvm/TargetParser/AArch64TargetParser.h
index 1311329821828f..11836e87d1b208 100644
--- a/llvm/include/llvm/TargetParser/AArch64TargetParser.h
+++ b/llvm/include/llvm/TargetParser/AArch64TargetParser.h
@@ -16,6 +16,7 @@
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/Bitset.h"
+#include "llvm/ADT/StringExtras.h"
#include "llvm/ADT/StringMap.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/VersionTuple.h"
diff --git a/llvm/include/module.modulemap b/llvm/include/module.modulemap
index b00da6d7cd28c7..ac7bd257cbb422 100644
--- a/llvm/include/module.modulemap
+++ b/llvm/include/module.modulemap
@@ -346,6 +346,7 @@ extern module LLVM_Extern_Utils_DataTypes "module.extern.modulemap"
// TargetParser module before building the TargetParser module itself.
module TargetParserGen {
module AArch64TargetParserDef {
+ textual header "llvm/TargetParser/AArch64CPUFeatures.inc"
header "llvm/TargetParser/AArch64TargetParser.h"
extern module LLVM_Extern_TargetParser_Gen "module.extern.modulemap"
export *
diff --git a/llvm/tools/llvm-jitlink/llvm-jitlink-executor/CMakeLists.txt b/llvm/tools/llvm-jitlink/llvm-jitlink-executor/CMakeLists.txt
index f2daa294eec072..0692f4351ad67f 100644
--- a/llvm/tools/llvm-jitlink/llvm-jitlink-executor/CMakeLists.txt
+++ b/llvm/tools/llvm-jitlink/llvm-jitlink-executor/CMakeLists.txt
@@ -2,6 +2,7 @@ set(LLVM_LINK_COMPONENTS
OrcShared
OrcTargetProcess
Support
+ Core
)
add_llvm_utility(llvm-jitlink-executor
diff --git a/llvm/unittests/tools/llvm-profgen/CMakeLists.txt b/llvm/unittests/tools/llvm-profgen/CMakeLists.txt
index 5a658cf7084678..51de95311a6c91 100644
--- a/llvm/unittests/tools/llvm-profgen/CMakeLists.txt
+++ b/llvm/unittests/tools/llvm-profgen/CMakeLists.txt
@@ -1,5 +1,6 @@
set(LLVM_LINK_COMPONENTS
Support
+ Core
)
add_llvm_unittest(LLVMProfgenTests
>From 9f758eece7bf27999837eaa337c7577d7b8ebac2 Mon Sep 17 00:00:00 2001
From: Qiongsi Wu <qiongsi_wu at apple.com>
Date: Wed, 11 Dec 2024 10:56:40 -0800
Subject: [PATCH 2/3] Revise to handle Attrs.inc better.
---
clang/include/clang/AST/Attr.h | 1 +
clang/include/clang/Support/Compiler.h | 2 ++
clang/include/module.modulemap | 2 ++
clang/utils/TableGen/ClangAttrEmitter.cpp | 1 -
4 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/clang/include/clang/AST/Attr.h b/clang/include/clang/AST/Attr.h
index 725498e132fc28..3365ebe4d9012b 100644
--- a/clang/include/clang/AST/Attr.h
+++ b/clang/include/clang/AST/Attr.h
@@ -24,6 +24,7 @@
#include "clang/Basic/OpenMPKinds.h"
#include "clang/Basic/Sanitizers.h"
#include "clang/Basic/SourceLocation.h"
+#include "clang/Support/Compiler.h"
#include "llvm/Frontend/HLSL/HLSLResource.h"
#include "llvm/Support/CodeGen.h"
#include "llvm/Support/ErrorHandling.h"
diff --git a/clang/include/clang/Support/Compiler.h b/clang/include/clang/Support/Compiler.h
index 0cba1ad7331682..13582b899dc2a6 100644
--- a/clang/include/clang/Support/Compiler.h
+++ b/clang/include/clang/Support/Compiler.h
@@ -14,6 +14,8 @@
#ifndef CLANG_SUPPORT_COMPILER_H
#define CLANG_SUPPORT_COMPILER_H
+#include "llvm/Support/Compiler.h"
+
/// CLANG_ABI is the main export/visibility macro to mark something as
/// explicitly exported when clang is built as a shared library with everything
/// else that is unannotated having hidden visibility.
diff --git a/clang/include/module.modulemap b/clang/include/module.modulemap
index e9218c715147b0..5bb9f6b7a91f67 100644
--- a/clang/include/module.modulemap
+++ b/clang/include/module.modulemap
@@ -183,6 +183,8 @@ module Clang_StaticAnalyzer_Frontend {
module * { export * }
}
+module Clang_Support { requires cplusplus umbrella "clang/Support" module * { export * } }
+
module Clang_Testing {
requires cplusplus
umbrella "clang/Testing"
diff --git a/clang/utils/TableGen/ClangAttrEmitter.cpp b/clang/utils/TableGen/ClangAttrEmitter.cpp
index 630beaef983bc6..cc6a8eaebd44ec 100644
--- a/clang/utils/TableGen/ClangAttrEmitter.cpp
+++ b/clang/utils/TableGen/ClangAttrEmitter.cpp
@@ -3183,7 +3183,6 @@ void clang::EmitClangAttrClass(const RecordKeeper &Records, raw_ostream &OS) {
OS << "#ifndef LLVM_CLANG_ATTR_CLASSES_INC\n";
OS << "#define LLVM_CLANG_ATTR_CLASSES_INC\n";
- OS << "#include \"clang/Support/Compiler.h\"\n\n";
emitAttributes(Records, OS, true);
>From a4748b577af03e9cfdb323e5df84925ccd446347 Mon Sep 17 00:00:00 2001
From: Qiongsi Wu <qiongsi_wu at apple.com>
Date: Wed, 11 Dec 2024 15:02:44 -0800
Subject: [PATCH 3/3] Avoid introducing unused symbols to llvm-jitlink-executor
and llvm-profgen when building with modules.
---
llvm/include/llvm/SandboxIR/Type.h | 7 ++-----
llvm/include/module.modulemap | 9 +++++++++
llvm/lib/SandboxIR/Type.cpp | 9 +++++++++
.../llvm-jitlink/llvm-jitlink-executor/CMakeLists.txt | 1 -
llvm/unittests/tools/llvm-profgen/CMakeLists.txt | 1 -
5 files changed, 20 insertions(+), 7 deletions(-)
diff --git a/llvm/include/llvm/SandboxIR/Type.h b/llvm/include/llvm/SandboxIR/Type.h
index 9d1db11edb05ae..3218b991b31a20 100644
--- a/llvm/include/llvm/SandboxIR/Type.h
+++ b/llvm/include/llvm/SandboxIR/Type.h
@@ -283,11 +283,8 @@ class Type {
}
#ifndef NDEBUG
- void dumpOS(raw_ostream &OS) { LLVMTy->print(OS); }
- LLVM_DUMP_METHOD void dump() {
- dumpOS(dbgs());
- dbgs() << "\n";
- }
+ void dumpOS(raw_ostream &OS);
+ LLVM_DUMP_METHOD void dump();
#endif // NDEBUG
};
diff --git a/llvm/include/module.modulemap b/llvm/include/module.modulemap
index ac7bd257cbb422..6beb0e03e222d5 100644
--- a/llvm/include/module.modulemap
+++ b/llvm/include/module.modulemap
@@ -427,3 +427,12 @@ module LLVM_WindowsManifest {
umbrella "llvm/WindowsManifest"
module * { export * }
}
+
+module LLVM_SandboxIR {
+ requires cplusplus
+
+ umbrella "llvm/SandboxIR"
+ module * { export * }
+
+ textual header "llvm/SandboxIR/Values.def"
+}
diff --git a/llvm/lib/SandboxIR/Type.cpp b/llvm/lib/SandboxIR/Type.cpp
index 7bb788ecf25a64..9ecff5f0165a9d 100644
--- a/llvm/lib/SandboxIR/Type.cpp
+++ b/llvm/lib/SandboxIR/Type.cpp
@@ -36,6 +36,15 @@ Type *Type::getDoubleTy(Context &Ctx) {
Type *Type::getFloatTy(Context &Ctx) {
return Ctx.getType(llvm::Type::getFloatTy(Ctx.LLVMCtx));
}
+
+#ifndef NDEBUG
+void Type::dumpOS(raw_ostream &OS) { LLVMTy->print(OS); }
+void Type::dump() {
+ dumpOS(dbgs());
+ dbgs() << "\n";
+}
+#endif
+
PointerType *PointerType::get(Type *ElementType, unsigned AddressSpace) {
return cast<PointerType>(ElementType->getContext().getType(
llvm::PointerType::get(ElementType->LLVMTy, AddressSpace)));
diff --git a/llvm/tools/llvm-jitlink/llvm-jitlink-executor/CMakeLists.txt b/llvm/tools/llvm-jitlink/llvm-jitlink-executor/CMakeLists.txt
index 0692f4351ad67f..f2daa294eec072 100644
--- a/llvm/tools/llvm-jitlink/llvm-jitlink-executor/CMakeLists.txt
+++ b/llvm/tools/llvm-jitlink/llvm-jitlink-executor/CMakeLists.txt
@@ -2,7 +2,6 @@ set(LLVM_LINK_COMPONENTS
OrcShared
OrcTargetProcess
Support
- Core
)
add_llvm_utility(llvm-jitlink-executor
diff --git a/llvm/unittests/tools/llvm-profgen/CMakeLists.txt b/llvm/unittests/tools/llvm-profgen/CMakeLists.txt
index 51de95311a6c91..5a658cf7084678 100644
--- a/llvm/unittests/tools/llvm-profgen/CMakeLists.txt
+++ b/llvm/unittests/tools/llvm-profgen/CMakeLists.txt
@@ -1,6 +1,5 @@
set(LLVM_LINK_COMPONENTS
Support
- Core
)
add_llvm_unittest(LLVMProfgenTests
More information about the llvm-commits
mailing list