[lld] r307590 - [lld/pdb] Add some basic linker module symbols.
Galina Kistanova via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 12 14:49:20 PDT 2017
Thank you Adrian!
Thanks
Galina
On Wed, Jul 12, 2017 at 10:33 AM, Adrian McCarthy <amccarth at google.com>
wrote:
> I can take care of this.
>
> On Tue, Jul 11, 2017 at 7:42 PM, Zachary Turner via llvm-commits <
> llvm-commits at lists.llvm.org> wrote:
>
>> I'm on vacation at the moment, and while I will be committing
>> sporadically, it will be at least a few days until I can get the fix for
>> this upstreamed. I believe you can fix it by deleting the last 4
>> characters on line 209 of the test. If that works, can you upstream it for
>> me to get the bots green?
>>
>> On Tue, Jul 11, 2017 at 7:28 PM Galina Kistanova <gkistanova at gmail.com>
>> wrote:
>>
>>> Hello Zachary,
>>>
>>> Some of your resent commits broke one of our builders:
>>> http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-
>>> scei-ps4-windows10pro-fast/builds/11043
>>>
>>> Failing Tests (1):
>>> lld :: COFF/pdb-diff.test
>>>
>>> Please have a look?
>>>
>>> Thanks
>>>
>>>
>>> Galina
>>>
>>> On Mon, Jul 10, 2017 at 2:01 PM, Zachary Turner via llvm-commits <
>>> llvm-commits at lists.llvm.org> wrote:
>>>
>>>> Author: zturner
>>>> Date: Mon Jul 10 14:01:37 2017
>>>> New Revision: 307590
>>>>
>>>> URL: http://llvm.org/viewvc/llvm-project?rev=307590&view=rev
>>>> Log:
>>>> [lld/pdb] Add some basic linker module symbols.
>>>>
>>>> Differential Revision: https://reviews.llvm.org/D35152
>>>>
>>>> Added:
>>>> lld/trunk/test/COFF/pdb-linker-module.test
>>>> Modified:
>>>> lld/trunk/COFF/Config.h
>>>> lld/trunk/COFF/Driver.cpp
>>>> lld/trunk/COFF/Error.cpp
>>>> lld/trunk/COFF/Error.h
>>>> lld/trunk/COFF/PDB.cpp
>>>> lld/trunk/COFF/PDB.h
>>>> lld/trunk/COFF/Writer.cpp
>>>> lld/trunk/ELF/Config.h
>>>> lld/trunk/ELF/Driver.cpp
>>>> lld/trunk/ELF/Error.cpp
>>>> lld/trunk/ELF/Error.h
>>>>
>>>> Modified: lld/trunk/COFF/Config.h
>>>> URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/Config.h?
>>>> rev=307590&r1=307589&r2=307590&view=diff
>>>> ============================================================
>>>> ==================
>>>> --- lld/trunk/COFF/Config.h (original)
>>>> +++ lld/trunk/COFF/Config.h Mon Jul 10 14:01:37 2017
>>>> @@ -92,6 +92,7 @@ struct Configuration {
>>>> bool WriteSymtab = true;
>>>> unsigned DebugTypes = static_cast<unsigned>(DebugType::None);
>>>> llvm::SmallString<128> PDBPath;
>>>> + std::vector<llvm::StringRef> Argv;
>>>>
>>>> // Symbols in this set are considered as live by the garbage
>>>> collector.
>>>> std::set<SymbolBody *> GCRoot;
>>>>
>>>> Modified: lld/trunk/COFF/Driver.cpp
>>>> URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/Driver.cp
>>>> p?rev=307590&r1=307589&r2=307590&view=diff
>>>> ============================================================
>>>> ==================
>>>> --- lld/trunk/COFF/Driver.cpp (original)
>>>> +++ lld/trunk/COFF/Driver.cpp Mon Jul 10 14:01:37 2017
>>>> @@ -55,8 +55,8 @@ std::vector<SpecificAllocBase *> Specifi
>>>> bool link(ArrayRef<const char *> Args, raw_ostream &Diag) {
>>>> ErrorCount = 0;
>>>> ErrorOS = &Diag;
>>>> - Argv0 = Args[0];
>>>> Config = make<Configuration>();
>>>> + Config->Argv = {Args.begin(), Args.end()};
>>>> Config->ColorDiagnostics =
>>>> (ErrorOS == &llvm::errs() && Process::StandardErrHasColors());
>>>> Driver = make<LinkerDriver>();
>>>>
>>>> Modified: lld/trunk/COFF/Error.cpp
>>>> URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/Error.cpp
>>>> ?rev=307590&r1=307589&r2=307590&view=diff
>>>> ============================================================
>>>> ==================
>>>> --- lld/trunk/COFF/Error.cpp (original)
>>>> +++ lld/trunk/COFF/Error.cpp Mon Jul 10 14:01:37 2017
>>>> @@ -29,7 +29,6 @@ namespace lld {
>>>> static std::mutex Mu;
>>>>
>>>> namespace coff {
>>>> -StringRef Argv0;
>>>> uint64_t ErrorCount;
>>>> raw_ostream *ErrorOS;
>>>>
>>>> @@ -45,7 +44,7 @@ static LLVM_ATTRIBUTE_NORETURN void exit
>>>> }
>>>>
>>>> static void print(StringRef S, raw_ostream::Colors C) {
>>>> - *ErrorOS << Argv0 + ": ";
>>>> + *ErrorOS << Config->Argv[0] << ": ";
>>>> if (Config->ColorDiagnostics) {
>>>> ErrorOS->changeColor(C, true);
>>>> *ErrorOS << S;
>>>> @@ -58,7 +57,7 @@ static void print(StringRef S, raw_ostre
>>>> void log(const Twine &Msg) {
>>>> if (Config->Verbose) {
>>>> std::lock_guard<std::mutex> Lock(Mu);
>>>> - outs() << Argv0 << ": " << Msg << "\n";
>>>> + outs() << Config->Argv[0] << ": " << Msg << "\n";
>>>> outs().flush();
>>>> }
>>>> }
>>>>
>>>> Modified: lld/trunk/COFF/Error.h
>>>> URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/Error.h?
>>>> rev=307590&r1=307589&r2=307590&view=diff
>>>> ============================================================
>>>> ==================
>>>> --- lld/trunk/COFF/Error.h (original)
>>>> +++ lld/trunk/COFF/Error.h Mon Jul 10 14:01:37 2017
>>>> @@ -18,7 +18,6 @@ namespace coff {
>>>>
>>>> extern uint64_t ErrorCount;
>>>> extern llvm::raw_ostream *ErrorOS;
>>>> -extern llvm::StringRef Argv0;
>>>>
>>>> void log(const Twine &Msg);
>>>> void message(const Twine &Msg);
>>>>
>>>> Modified: lld/trunk/COFF/PDB.cpp
>>>> URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/PDB.cpp?
>>>> rev=307590&r1=307589&r2=307590&view=diff
>>>> ============================================================
>>>> ==================
>>>> --- lld/trunk/COFF/PDB.cpp (original)
>>>> +++ lld/trunk/COFF/PDB.cpp Mon Jul 10 14:01:37 2017
>>>> @@ -18,19 +18,20 @@
>>>> #include "llvm/DebugInfo/CodeView/DebugSubsectionRecord.h"
>>>> #include "llvm/DebugInfo/CodeView/DebugSubsectionVisitor.h"
>>>> #include "llvm/DebugInfo/CodeView/LazyRandomTypeCollection.h"
>>>> +#include "llvm/DebugInfo/CodeView/SymbolSerializer.h"
>>>> #include "llvm/DebugInfo/CodeView/TypeDumpVisitor.h"
>>>> #include "llvm/DebugInfo/CodeView/TypeIndexDiscovery.h"
>>>> #include "llvm/DebugInfo/CodeView/TypeStreamMerger.h"
>>>> #include "llvm/DebugInfo/CodeView/TypeTableBuilder.h"
>>>> #include "llvm/DebugInfo/MSF/MSFBuilder.h"
>>>> #include "llvm/DebugInfo/MSF/MSFCommon.h"
>>>> +#include "llvm/DebugInfo/PDB/Native/DbiModuleDescriptorBuilder.h"
>>>> #include "llvm/DebugInfo/PDB/Native/DbiStream.h"
>>>> #include "llvm/DebugInfo/PDB/Native/DbiStreamBuilder.h"
>>>> #include "llvm/DebugInfo/PDB/Native/InfoStream.h"
>>>> #include "llvm/DebugInfo/PDB/Native/InfoStreamBuilder.h"
>>>> #include "llvm/DebugInfo/PDB/Native/PDBFile.h"
>>>> #include "llvm/DebugInfo/PDB/Native/PDBFileBuilder.h"
>>>> -#include "llvm/DebugInfo/PDB/Native/DbiModuleDescriptorBuilder.h"
>>>> #include "llvm/DebugInfo/PDB/Native/PDBStringTableBuilder.h"
>>>> #include "llvm/DebugInfo/PDB/Native/PDBTypeServerHandler.h"
>>>> #include "llvm/DebugInfo/PDB/Native/TpiStream.h"
>>>> @@ -396,9 +397,54 @@ static void addObjectsToPDB(BumpPtrAlloc
>>>> addTypeInfo(Builder.getIpiBuilder(), IDTable);
>>>> }
>>>>
>>>> +static void addLinkerModuleSymbols(StringRef Path,
>>>> + pdb::DbiModuleDescriptorBuilder
>>>> &Mod,
>>>> + BumpPtrAllocator &Allocator) {
>>>> + codeview::SymbolSerializer Serializer(Allocator,
>>>> CodeViewContainer::Pdb);
>>>> + codeview::ObjNameSym ONS(SymbolRecordKind::ObjNameSym);
>>>> + codeview::Compile3Sym CS(SymbolRecordKind::Compile3Sym);
>>>> + codeview::EnvBlockSym EBS(SymbolRecordKind::EnvBlockSym);
>>>> +
>>>> + ONS.Name = "* Linker *";
>>>> + ONS.Signature = 0;
>>>> +
>>>> + CS.Machine = Config->is64() ? CPUType::X64 : CPUType::Intel80386;
>>>> + CS.Flags = CompileSym3Flags::None;
>>>> + CS.VersionBackendBuild = 0;
>>>> + CS.VersionBackendMajor = 0;
>>>> + CS.VersionBackendMinor = 0;
>>>> + CS.VersionBackendQFE = 0;
>>>> + CS.VersionFrontendBuild = 0;
>>>> + CS.VersionFrontendMajor = 0;
>>>> + CS.VersionFrontendMinor = 0;
>>>> + CS.VersionFrontendQFE = 0;
>>>> + CS.Version = "LLVM Linker";
>>>> + CS.setLanguage(SourceLanguage::Link);
>>>> +
>>>> + ArrayRef<StringRef> Args = makeArrayRef(Config->Argv).drop_front();
>>>> + std::string ArgStr = llvm::join(Args, " ");
>>>> + EBS.Fields.push_back("cwd");
>>>> + SmallString<64> cwd;
>>>> + llvm::sys::fs::current_path(cwd);
>>>> + EBS.Fields.push_back(cwd);
>>>> + EBS.Fields.push_back("exe");
>>>> + std::string Exe =
>>>> + llvm::sys::fs::getMainExecutable(Config->Argv[0].data(),
>>>> nullptr);
>>>> + EBS.Fields.push_back(Exe);
>>>> + EBS.Fields.push_back("pdb");
>>>> + EBS.Fields.push_back(Path);
>>>> + EBS.Fields.push_back("cmd");
>>>> + EBS.Fields.push_back(ArgStr);
>>>> + Mod.addSymbol(codeview::SymbolSerializer::writeOneSymbol(
>>>> + ONS, Allocator, CodeViewContainer::Pdb));
>>>> + Mod.addSymbol(codeview::SymbolSerializer::writeOneSymbol(
>>>> + CS, Allocator, CodeViewContainer::Pdb));
>>>> + Mod.addSymbol(codeview::SymbolSerializer::writeOneSymbol(
>>>> + EBS, Allocator, CodeViewContainer::Pdb));
>>>> +}
>>>> +
>>>> // Creates a PDB file.
>>>> -void coff::createPDB(StringRef Path, SymbolTable *Symtab,
>>>> - ArrayRef<uint8_t> SectionTable,
>>>> +void coff::createPDB(SymbolTable *Symtab, ArrayRef<uint8_t>
>>>> SectionTable,
>>>> const llvm::codeview::DebugInfo *DI) {
>>>> BumpPtrAllocator Alloc;
>>>> pdb::PDBFileBuilder Builder(Alloc);
>>>> @@ -413,7 +459,8 @@ void coff::createPDB(StringRef Path, Sym
>>>> auto &InfoBuilder = Builder.getInfoBuilder();
>>>> InfoBuilder.setAge(DI ? DI->PDB70.Age : 0);
>>>>
>>>> - llvm::SmallString<128> NativePath(Path.begin(), Path.end());
>>>> + llvm::SmallString<128> NativePath(Config->PDBPath.begin(),
>>>> + Config->PDBPath.end());
>>>> llvm::sys::fs::make_absolute(NativePath);
>>>> llvm::sys::path::native(NativePath, llvm::sys::path::Style::window
>>>> s);
>>>>
>>>> @@ -449,11 +496,12 @@ void coff::createPDB(StringRef Path, Sym
>>>>
>>>> auto &LinkerModule = ExitOnErr(DbiBuilder.addModuleInfo("* Linker
>>>> *"));
>>>> LinkerModule.setPdbFilePathNI(PdbFilePathNI);
>>>> + addLinkerModuleSymbols(NativePath, LinkerModule, Alloc);
>>>>
>>>> // Add COFF section header stream.
>>>> ExitOnErr(
>>>> DbiBuilder.addDbgStream(pdb::DbgHeaderType::SectionHdr,
>>>> SectionTable));
>>>>
>>>> // Write to a file.
>>>> - ExitOnErr(Builder.commit(Path));
>>>> + ExitOnErr(Builder.commit(Config->PDBPath));
>>>> }
>>>>
>>>> Modified: lld/trunk/COFF/PDB.h
>>>> URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/PDB.h?rev
>>>> =307590&r1=307589&r2=307590&view=diff
>>>> ============================================================
>>>> ==================
>>>> --- lld/trunk/COFF/PDB.h (original)
>>>> +++ lld/trunk/COFF/PDB.h Mon Jul 10 14:01:37 2017
>>>> @@ -23,8 +23,7 @@ namespace lld {
>>>> namespace coff {
>>>> class SymbolTable;
>>>>
>>>> -void createPDB(llvm::StringRef Path, SymbolTable *Symtab,
>>>> - llvm::ArrayRef<uint8_t> SectionTable,
>>>> +void createPDB(SymbolTable *Symtab, llvm::ArrayRef<uint8_t>
>>>> SectionTable,
>>>> const llvm::codeview::DebugInfo *DI);
>>>> }
>>>> }
>>>>
>>>> Modified: lld/trunk/COFF/Writer.cpp
>>>> URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/Writer.cp
>>>> p?rev=307590&r1=307589&r2=307590&view=diff
>>>> ============================================================
>>>> ==================
>>>> --- lld/trunk/COFF/Writer.cpp (original)
>>>> +++ lld/trunk/COFF/Writer.cpp Mon Jul 10 14:01:37 2017
>>>> @@ -239,7 +239,7 @@ void Writer::run() {
>>>> const llvm::codeview::DebugInfo *DI = nullptr;
>>>> if (Config->DebugTypes & static_cast<unsigned>(coff::De
>>>> bugType::CV))
>>>> DI = BuildId->DI;
>>>> - createPDB(Config->PDBPath, Symtab, SectionTable, DI);
>>>> + createPDB(Symtab, SectionTable, DI);
>>>> }
>>>>
>>>> writeMapFile(OutputSections);
>>>>
>>>> Modified: lld/trunk/ELF/Config.h
>>>> URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Config.h?
>>>> rev=307590&r1=307589&r2=307590&view=diff
>>>> ============================================================
>>>> ==================
>>>> --- lld/trunk/ELF/Config.h (original)
>>>> +++ lld/trunk/ELF/Config.h Mon Jul 10 14:01:37 2017
>>>> @@ -97,6 +97,7 @@ struct Configuration {
>>>> llvm::StringRef ThinLTOCacheDir;
>>>> std::string Rpath;
>>>> std::vector<VersionDefinition> VersionDefinitions;
>>>> + std::vector<llvm::StringRef> Argv;
>>>> std::vector<llvm::StringRef> AuxiliaryList;
>>>> std::vector<llvm::StringRef> SearchPaths;
>>>> std::vector<llvm::StringRef> SymbolOrderingFile;
>>>>
>>>> Modified: lld/trunk/ELF/Driver.cpp
>>>> URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Driver.cpp
>>>> ?rev=307590&r1=307589&r2=307590&view=diff
>>>> ============================================================
>>>> ==================
>>>> --- lld/trunk/ELF/Driver.cpp (original)
>>>> +++ lld/trunk/ELF/Driver.cpp Mon Jul 10 14:01:37 2017
>>>> @@ -74,13 +74,13 @@ bool elf::link(ArrayRef<const char *> Ar
>>>> raw_ostream &Error) {
>>>> ErrorCount = 0;
>>>> ErrorOS = &Error;
>>>> - Argv0 = Args[0];
>>>> InputSections.clear();
>>>> Tar = nullptr;
>>>>
>>>> Config = make<Configuration>();
>>>> Driver = make<LinkerDriver>();
>>>> Script = make<LinkerScript>();
>>>> + Config->Argv = {Args.begin(), Args.end()};
>>>>
>>>> Driver->main(Args, CanExitEarly);
>>>> freeArena();
>>>>
>>>> Modified: lld/trunk/ELF/Error.cpp
>>>> URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Error.cpp?
>>>> rev=307590&r1=307589&r2=307590&view=diff
>>>> ============================================================
>>>> ==================
>>>> --- lld/trunk/ELF/Error.cpp (original)
>>>> +++ lld/trunk/ELF/Error.cpp Mon Jul 10 14:01:37 2017
>>>> @@ -27,7 +27,6 @@ using namespace lld::elf;
>>>>
>>>> uint64_t elf::ErrorCount;
>>>> raw_ostream *elf::ErrorOS;
>>>> -StringRef elf::Argv0;
>>>>
>>>> // The functions defined in this file can be called from multiple
>>>> threads,
>>>> // but outs() or errs() are not thread-safe. We protect them using a
>>>> mutex.
>>>> @@ -46,7 +45,7 @@ static void newline(const Twine &Msg) {
>>>> }
>>>>
>>>> static void print(StringRef S, raw_ostream::Colors C) {
>>>> - *ErrorOS << Argv0 + ": ";
>>>> + *ErrorOS << Config->Argv[0] << ": ";
>>>> if (Config->ColorDiagnostics) {
>>>> ErrorOS->changeColor(C, true);
>>>> *ErrorOS << S;
>>>> @@ -59,7 +58,7 @@ static void print(StringRef S, raw_ostre
>>>> void elf::log(const Twine &Msg) {
>>>> if (Config->Verbose) {
>>>> std::lock_guard<std::mutex> Lock(Mu);
>>>> - outs() << Argv0 << ": " << Msg << "\n";
>>>> + outs() << Config->Argv[0] << ": " << Msg << "\n";
>>>> outs().flush();
>>>> }
>>>> }
>>>>
>>>> Modified: lld/trunk/ELF/Error.h
>>>> URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Error.h?re
>>>> v=307590&r1=307589&r2=307590&view=diff
>>>> ============================================================
>>>> ==================
>>>> --- lld/trunk/ELF/Error.h (original)
>>>> +++ lld/trunk/ELF/Error.h Mon Jul 10 14:01:37 2017
>>>> @@ -37,7 +37,6 @@ namespace elf {
>>>>
>>>> extern uint64_t ErrorCount;
>>>> extern llvm::raw_ostream *ErrorOS;
>>>> -extern llvm::StringRef Argv0;
>>>>
>>>> void log(const Twine &Msg);
>>>> void message(const Twine &Msg);
>>>>
>>>> Added: lld/trunk/test/COFF/pdb-linker-module.test
>>>> URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/COFF/pdb-
>>>> linker-module.test?rev=307590&view=auto
>>>> ============================================================
>>>> ==================
>>>> --- lld/trunk/test/COFF/pdb-linker-module.test (added)
>>>> +++ lld/trunk/test/COFF/pdb-linker-module.test Mon Jul 10 14:01:37 2017
>>>> @@ -0,0 +1,18 @@
>>>> +RUN: lld-link /debug /pdb:%t.pdb /nodefaultlib /entry:main
>>>> %S/Inputs/pdb-diff.obj
>>>> +RUN: llvm-pdbutil dump -modules -symbols %t.pdb | FileCheck %s
>>>> +
>>>> +CHECK: Mod 0001 | `* Linker *`:
>>>> +CHECK-NEXT: 4 | S_OBJNAME [size = 20] sig=0, `* Linker *`
>>>> +CHECK-NEXT: 24 | S_COMPILE3 [size = 40]
>>>> +CHECK-NEXT: machine = intel 80386, Ver = LLVM Linker, language =
>>>> link
>>>> +CHECK-NEXT: frontend = 0.0.0.0, backend = 0.0.0.0
>>>> +CHECK-NEXT: flags = none
>>>> +CHECK-NEXT: 64 | S_ENVBLOCK
>>>> +CHECK-NEXT: - cwd
>>>> +CHECK-NEXT: -
>>>> +CHECK-NEXT: - exe
>>>> +CHECK-NEXT: - {{.*}}lld-link
>>>> +CHECK-NEXT: - pdb
>>>> +CHECK-NEXT: - {{.*}}pdb-linker-module{{.*}}pdb
>>>> +CHECK-NEXT: - cmd
>>>> +CHECK-NEXT: - /debug /pdb:{{.*}}pdb-linker-module{{.*}}pdb
>>>> /nodefaultlib /entry:main {{.*}}pdb-diff.obj
>>>>
>>>>
>>>> _______________________________________________
>>>> llvm-commits mailing list
>>>> llvm-commits at lists.llvm.org
>>>> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>>>>
>>>
>>>
>> _______________________________________________
>> llvm-commits mailing list
>> llvm-commits at lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170712/4d72853a/attachment.html>
More information about the llvm-commits
mailing list