Revert "Revert "Make the DWARF version emitted by the Swift compiler configurable.""

This commit is contained in:
Adrian Prantl
2023-10-26 12:29:18 -07:00
committed by GitHub
parent 7afa4cfdc6
commit 5d978b44ca
19 changed files with 104 additions and 69 deletions

View File

@@ -16,27 +16,27 @@
//
//===----------------------------------------------------------------------===//
#include "swift/ABI/ObjectFile.h"
#include "swift/AST/ASTDemangler.h"
#include "swift/AST/PrintOptions.h"
#include "swift/ASTSectionImporter/ASTSectionImporter.h"
#include "swift/Basic/LLVMInitialize.h"
#include "swift/Frontend/Frontend.h"
#include "swift/Serialization/SerializedModuleLoader.h"
#include "swift/Serialization/Validation.h"
#include "swift/Basic/Dwarf.h"
#include "llvm/Object/ELFObjectFile.h"
#include "swift/Basic/LLVMInitialize.h"
#include "llvm/Object/COFF.h"
#include "llvm/Object/ELFObjectFile.h"
#include "llvm/Object/MachO.h"
#include "llvm/Object/ObjectFile.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/ManagedStatic.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/Path.h"
#include "llvm/Support/PrettyStackTrace.h"
#include "llvm/Support/Signals.h"
#include "llvm/Support/TargetSelect.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/Support/ManagedStatic.h"
#include <fstream>
#include <sstream>
@@ -209,15 +209,19 @@ collectASTModules(llvm::cl::list<std::string> &InputNames,
continue;
}
llvm::StringRef Name = *NameOrErr;
if ((MachO && Name == swift::MachOASTSectionName) ||
(ELF && Name == swift::ELFASTSectionName) ||
(COFF && Name == swift::COFFASTSectionName)) {
if ((MachO && Name == swift::SwiftObjectFileFormatMachO().getSectionName(
swift::ReflectionSectionKind::swiftast)) ||
(ELF && Name == swift::SwiftObjectFileFormatELF().getSectionName(
swift::ReflectionSectionKind::swiftast)) ||
(COFF && Name == swift::SwiftObjectFileFormatCOFF().getSectionName(
swift::ReflectionSectionKind::swiftast))) {
uint64_t Size = Section.getSize();
llvm::Expected<llvm::StringRef> ContentsReference = Section.getContents();
llvm::Expected<llvm::StringRef> ContentsReference =
Section.getContents();
if (!ContentsReference) {
llvm::errs() << "error: " << name << " "
<< errorToErrorCode(OF.takeError()).message() << "\n";
<< errorToErrorCode(OF.takeError()).message() << "\n";
return false;
}
char *Module = Alloc.Allocate<char>(Size);