[llvm] Fix compilation errors in llvm/DebugInfo/PDB headers when using -fforce-emit-vtables (PR #65456)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 7 02:32:26 PDT 2023
https://github.com/vient updated https://github.com/llvm/llvm-project/pull/65456:
>From 5f36dd063099537d4b3832a6cd17da218d2e1b72 Mon Sep 17 00:00:00 2001
From: vient <lozko.roma at gmail.com>
Date: Wed, 6 Sep 2023 11:53:50 +0300
Subject: [PATCH 1/4] fix1
---
llvm/include/llvm/DebugInfo/PDB/PDBSymbolFunc.h | 1 +
1 file changed, 1 insertion(+)
diff --git a/llvm/include/llvm/DebugInfo/PDB/PDBSymbolFunc.h b/llvm/include/llvm/DebugInfo/PDB/PDBSymbolFunc.h
index bfc7f7689718284..3b61c0d28634346 100644
--- a/llvm/include/llvm/DebugInfo/PDB/PDBSymbolFunc.h
+++ b/llvm/include/llvm/DebugInfo/PDB/PDBSymbolFunc.h
@@ -10,6 +10,7 @@
#define LLVM_DEBUGINFO_PDB_PDBSYMBOLFUNC_H
#include "llvm/DebugInfo/PDB/IPDBRawSymbol.h"
+#include "llvm/DebugInfo/PDB/PDBSymbolTypeFunctionSig.h"
#include "PDBSymbol.h"
#include "PDBTypes.h"
>From 692dd8c1d653003a0d75874465c2aa059d7bebf2 Mon Sep 17 00:00:00 2001
From: vient <lozko.roma at gmail.com>
Date: Wed, 6 Sep 2023 11:55:46 +0300
Subject: [PATCH 2/4] Update UDTLayout.h
---
llvm/include/llvm/DebugInfo/PDB/UDTLayout.h | 1 +
1 file changed, 1 insertion(+)
diff --git a/llvm/include/llvm/DebugInfo/PDB/UDTLayout.h b/llvm/include/llvm/DebugInfo/PDB/UDTLayout.h
index 8631c412f114254..5babe9da81ea627 100644
--- a/llvm/include/llvm/DebugInfo/PDB/UDTLayout.h
+++ b/llvm/include/llvm/DebugInfo/PDB/UDTLayout.h
@@ -14,6 +14,7 @@
#include "llvm/ADT/StringRef.h"
#include "llvm/DebugInfo/PDB/PDBSymbol.h"
#include "llvm/DebugInfo/PDB/PDBSymbolData.h"
+#include "llvm/DebugInfo/PDB/PDBSymbolFunc.h"
#include "llvm/DebugInfo/PDB/PDBSymbolTypeBaseClass.h"
#include "llvm/DebugInfo/PDB/PDBSymbolTypeBuiltin.h"
#include "llvm/DebugInfo/PDB/PDBSymbolTypeUDT.h"
>From 142b9793c8befd6c872775730007c9471f6fab97 Mon Sep 17 00:00:00 2001
From: vient <lozko.roma at gmail.com>
Date: Thu, 7 Sep 2023 12:10:15 +0300
Subject: [PATCH 3/4] Fix build errors in lld mach-o
---
lld/MachO/InputFiles.h | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/lld/MachO/InputFiles.h b/lld/MachO/InputFiles.h
index 2e37e7ba5a00608..6c628d754860959 100644
--- a/lld/MachO/InputFiles.h
+++ b/lld/MachO/InputFiles.h
@@ -20,6 +20,7 @@
#include "llvm/ADT/SetVector.h"
#include "llvm/BinaryFormat/MachO.h"
#include "llvm/DebugInfo/DWARF/DWARFUnit.h"
+#include "llvm/LTO/LTO.h"
#include "llvm/Object/Archive.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/Threading.h"
@@ -28,9 +29,6 @@
#include <vector>
namespace llvm {
-namespace lto {
-class InputFile;
-} // namespace lto
namespace MachO {
class InterfaceFile;
} // namespace MachO
>From ad0240756053ae989abaf38d2133f46281ec61cb Mon Sep 17 00:00:00 2001
From: vient <lozko.roma at gmail.com>
Date: Thu, 7 Sep 2023 12:32:19 +0300
Subject: [PATCH 4/4] Fix lld MachO build
---
lld/MachO/EhFrame.cpp | 6 +++---
lld/MachO/ICF.cpp | 6 +++---
lld/MachO/InputSection.cpp | 4 ++--
lld/MachO/ObjC.cpp | 6 +++---
lld/MachO/Relocations.cpp | 4 ++--
lld/MachO/UnwindInfoSection.cpp | 4 ++--
6 files changed, 15 insertions(+), 15 deletions(-)
diff --git a/lld/MachO/EhFrame.cpp b/lld/MachO/EhFrame.cpp
index 55a85f316cdd70d..271cd629bec640f 100644
--- a/lld/MachO/EhFrame.cpp
+++ b/lld/MachO/EhFrame.cpp
@@ -109,15 +109,15 @@ template <bool Invert = false>
static void createSubtraction(PointerUnion<Symbol *, InputSection *> a,
PointerUnion<Symbol *, InputSection *> b,
uint64_t off, uint8_t length,
- SmallVectorImpl<Reloc> *newRelocs) {
+ SmallVectorImpl<macho::Reloc> *newRelocs) {
auto subtrahend = a;
auto minuend = b;
if (Invert)
std::swap(subtrahend, minuend);
assert(subtrahend.is<Symbol *>());
- Reloc subtrahendReloc(target->subtractorRelocType, /*pcrel=*/false, length,
+ macho::Reloc subtrahendReloc(target->subtractorRelocType, /*pcrel=*/false, length,
off, /*addend=*/0, subtrahend);
- Reloc minuendReloc(target->unsignedRelocType, /*pcrel=*/false, length, off,
+ macho::Reloc minuendReloc(target->unsignedRelocType, /*pcrel=*/false, length, off,
(Invert ? 1 : -1) * off, minuend);
newRelocs->push_back(subtrahendReloc);
newRelocs->push_back(minuendReloc);
diff --git a/lld/MachO/ICF.cpp b/lld/MachO/ICF.cpp
index 0278bf7c6751a21..5b452bef0253742 100644
--- a/lld/MachO/ICF.cpp
+++ b/lld/MachO/ICF.cpp
@@ -105,7 +105,7 @@ bool ICF::equalsConstant(const ConcatInputSection *ia,
return false;
if (ia->relocs.size() != ib->relocs.size())
return false;
- auto f = [](const Reloc &ra, const Reloc &rb) {
+ auto f = [](const macho::Reloc &ra, const macho::Reloc &rb) {
if (ra.type != rb.type)
return false;
if (ra.pcrel != rb.pcrel)
@@ -178,7 +178,7 @@ bool ICF::equalsVariable(const ConcatInputSection *ia,
if (verboseDiagnostics)
++equalsVariableCount;
assert(ia->relocs.size() == ib->relocs.size());
- auto f = [this](const Reloc &ra, const Reloc &rb) {
+ auto f = [this](const macho::Reloc &ra, const macho::Reloc &rb) {
// We already filtered out mismatching values/addends in equalsConstant.
if (ra.referent == rb.referent)
return true;
@@ -286,7 +286,7 @@ void ICF::run() {
for (icfPass = 0; icfPass < 2; ++icfPass) {
parallelForEach(icfInputs, [&](ConcatInputSection *isec) {
uint32_t hash = isec->icfEqClass[icfPass % 2];
- for (const Reloc &r : isec->relocs) {
+ for (const macho::Reloc &r : isec->relocs) {
if (auto *sym = r.referent.dyn_cast<Symbol *>()) {
if (auto *defined = dyn_cast<Defined>(sym)) {
if (defined->isec) {
diff --git a/lld/MachO/InputSection.cpp b/lld/MachO/InputSection.cpp
index 8f5affb1dc21d8a..a9e341f14132a84 100644
--- a/lld/MachO/InputSection.cpp
+++ b/lld/MachO/InputSection.cpp
@@ -32,7 +32,7 @@ using namespace lld::macho;
// can differ based on STL debug levels (e.g. iterator debugging on MSVC's STL),
// so account for that.
static_assert(sizeof(void *) != 8 ||
- sizeof(ConcatInputSection) == sizeof(std::vector<Reloc>) + 88,
+ sizeof(ConcatInputSection) == sizeof(std::vector<macho::Reloc>) + 88,
"Try to minimize ConcatInputSection's size, we create many "
"instances of it");
@@ -135,7 +135,7 @@ std::string InputSection::getSourceLocation(uint64_t off) const {
return {};
}
-const Reloc *InputSection::getRelocAt(uint32_t off) const {
+const macho::Reloc *InputSection::getRelocAt(uint32_t off) const {
auto it = llvm::find_if(
relocs, [=](const macho::Reloc &r) { return r.offset == off; });
if (it == relocs.end())
diff --git a/lld/MachO/ObjC.cpp b/lld/MachO/ObjC.cpp
index 7e8cec026d2f7c2..f97da6d9352c48b 100644
--- a/lld/MachO/ObjC.cpp
+++ b/lld/MachO/ObjC.cpp
@@ -177,7 +177,7 @@ ObjcCategoryChecker::ObjcCategoryChecker()
methodLayout(target->wordSize) {}
// \p r must point to an offset within a cstring section.
-static StringRef getReferentString(const Reloc &r) {
+static StringRef getReferentString(const macho::Reloc &r) {
if (auto *isec = r.referent.dyn_cast<InputSection *>())
return cast<CStringInputSection>(isec)->getStringRefAtOffset(r.addend);
auto *sym = cast<Defined>(r.referent.get<Symbol *>());
@@ -191,7 +191,7 @@ void ObjcCategoryChecker::parseMethods(const ConcatInputSection *methodsIsec,
MethodContainerKind mcKind,
MethodKind mKind) {
ObjcClass &klass = classMap[methodContainerSym];
- for (const Reloc &r : methodsIsec->relocs) {
+ for (const macho::Reloc &r : methodsIsec->relocs) {
if ((r.offset - listHeaderLayout.totalSize) % methodLayout.totalSize !=
methodLayout.nameOffset)
continue;
@@ -219,7 +219,7 @@ void ObjcCategoryChecker::parseMethods(const ConcatInputSection *methodsIsec,
// We have a duplicate; generate a warning message.
const auto &mc = methodMap.lookup(methodName);
- const Reloc *nameReloc = nullptr;
+ const macho::Reloc *nameReloc = nullptr;
if (mc.kind == MCK_Category) {
nameReloc = mc.isec->getRelocAt(catLayout.nameOffset);
} else {
diff --git a/lld/MachO/Relocations.cpp b/lld/MachO/Relocations.cpp
index 4e840c6912cc571..bf1fc588d54bf70 100644
--- a/lld/MachO/Relocations.cpp
+++ b/lld/MachO/Relocations.cpp
@@ -18,10 +18,10 @@ using namespace llvm;
using namespace lld;
using namespace lld::macho;
-static_assert(sizeof(void *) != 8 || sizeof(Reloc) == 24,
+static_assert(sizeof(void *) != 8 || sizeof(macho::Reloc) == 24,
"Try to minimize Reloc's size; we create many instances");
-InputSection *Reloc::getReferentInputSection() const {
+InputSection *macho::Reloc::getReferentInputSection() const {
if (const auto *sym = referent.dyn_cast<Symbol *>()) {
if (const auto *d = dyn_cast<Defined>(sym))
return d->isec;
diff --git a/lld/MachO/UnwindInfoSection.cpp b/lld/MachO/UnwindInfoSection.cpp
index 1466e7b4fb394f5..24db102899700cf 100644
--- a/lld/MachO/UnwindInfoSection.cpp
+++ b/lld/MachO/UnwindInfoSection.cpp
@@ -234,7 +234,7 @@ void UnwindInfoSectionImpl::prepareRelocations(ConcatInputSection *isec) {
// that are referenced from many places, at least some of them likely
// live, it wouldn't reduce number of got entries.
for (size_t i = 0; i < isec->relocs.size(); ++i) {
- Reloc &r = isec->relocs[i];
+ macho::Reloc &r = isec->relocs[i];
assert(target->hasAttr(r.type, RelocAttrBits::UNSIGNED));
// Since compact unwind sections aren't part of the inputSections vector,
// they don't get canonicalized by scanRelocations(), so we have to do the
@@ -375,7 +375,7 @@ void UnwindInfoSectionImpl::relocateCompactUnwind(
cu.functionLength =
support::endian::read32le(buf + cuLayout.functionLengthOffset);
cu.encoding = support::endian::read32le(buf + cuLayout.encodingOffset);
- for (const Reloc &r : d->unwindEntry->relocs) {
+ for (const macho::Reloc &r : d->unwindEntry->relocs) {
if (r.offset == cuLayout.personalityOffset)
cu.personality = r.referent.get<Symbol *>();
else if (r.offset == cuLayout.lsdaOffset)
More information about the llvm-commits
mailing list