diff --git a/llvm/docs/CommandGuide/dsymutil.rst b/llvm/docs/CommandGuide/dsymutil.rst --- a/llvm/docs/CommandGuide/dsymutil.rst +++ b/llvm/docs/CommandGuide/dsymutil.rst @@ -21,7 +21,7 @@ .. option:: --accelerator= Specify the desired type of accelerator table. Valid options are 'Apple', - 'Dwarf' and 'Default'. + 'Dwarf', 'Default' and 'None'. .. option:: --arch diff --git a/llvm/include/llvm/DWARFLinker/DWARFLinker.h b/llvm/include/llvm/DWARFLinker/DWARFLinker.h --- a/llvm/include/llvm/DWARFLinker/DWARFLinker.h +++ b/llvm/include/llvm/DWARFLinker/DWARFLinker.h @@ -29,7 +29,8 @@ enum class DwarfLinkerClient { Dsymutil, LLD, General }; /// The kind of accelerator tables we should emit. -enum class AccelTableKind { +enum class DwarfLinkerAccelTableKind : uint8_t { + None, Apple, ///< .apple_names, .apple_namespaces, .apple_types, .apple_objc. Dwarf, ///< DWARF v5 .debug_names. Default, ///< Dwarf for DWARF5 or later, Apple otherwise. @@ -293,7 +294,7 @@ void setNumThreads(unsigned NumThreads) { Options.Threads = NumThreads; } /// Set kind of accelerator tables to be generated. - void setAccelTableKind(AccelTableKind Kind) { + void setAccelTableKind(DwarfLinkerAccelTableKind Kind) { Options.TheAccelTableKind = Kind; } @@ -804,7 +805,8 @@ unsigned Threads = 1; /// The accelerator table kind - AccelTableKind TheAccelTableKind = AccelTableKind::Default; + DwarfLinkerAccelTableKind TheAccelTableKind = + DwarfLinkerAccelTableKind::Default; /// Prepend path for the clang modules. std::string PrependPath; diff --git a/llvm/lib/DWARFLinker/DWARFLinker.cpp b/llvm/lib/DWARFLinker/DWARFLinker.cpp --- a/llvm/lib/DWARFLinker/DWARFLinker.cpp +++ b/llvm/lib/DWARFLinker/DWARFLinker.cpp @@ -1787,16 +1787,19 @@ void DWARFLinker::emitAcceleratorEntriesForUnit(CompileUnit &Unit) { switch (Options.TheAccelTableKind) { - case AccelTableKind::Apple: + case DwarfLinkerAccelTableKind::None: + // Nothing to do. + break; + case DwarfLinkerAccelTableKind::Apple: emitAppleAcceleratorEntriesForUnit(Unit); break; - case AccelTableKind::Dwarf: + case DwarfLinkerAccelTableKind::Dwarf: emitDwarfAcceleratorEntriesForUnit(Unit); break; - case AccelTableKind::Pub: + case DwarfLinkerAccelTableKind::Pub: emitPubAcceleratorEntriesForUnit(Unit); break; - case AccelTableKind::Default: + case DwarfLinkerAccelTableKind::Default: llvm_unreachable("The default must be updated to a concrete value."); break; } @@ -2215,7 +2218,7 @@ } void DWARFLinker::updateAccelKind(DWARFContext &Dwarf) { - if (Options.TheAccelTableKind != AccelTableKind::Default) + if (Options.TheAccelTableKind != DwarfLinkerAccelTableKind::Default) return; auto &DwarfObj = Dwarf.getDWARFObj(); @@ -2341,11 +2344,11 @@ // would affect the decision. However, as they're built with the same // compiler and flags, it is safe to assume that they will follow the // decision made here. - if (Options.TheAccelTableKind == AccelTableKind::Default) { + if (Options.TheAccelTableKind == DwarfLinkerAccelTableKind::Default) { if (AtLeastOneDwarfAccelTable && !AtLeastOneAppleAccelTable) - Options.TheAccelTableKind = AccelTableKind::Dwarf; + Options.TheAccelTableKind = DwarfLinkerAccelTableKind::Dwarf; else - Options.TheAccelTableKind = AccelTableKind::Apple; + Options.TheAccelTableKind = DwarfLinkerAccelTableKind::Apple; } for (LinkContext &OptContext : ObjectContexts) { @@ -2524,19 +2527,22 @@ TheDwarfEmitter->emitAbbrevs(Abbreviations, MaxDwarfVersion); TheDwarfEmitter->emitStrings(OffsetsStringPool); switch (Options.TheAccelTableKind) { - case AccelTableKind::Apple: + case DwarfLinkerAccelTableKind::None: + // Nothing to do. + break; + case DwarfLinkerAccelTableKind::Apple: TheDwarfEmitter->emitAppleNames(AppleNames); TheDwarfEmitter->emitAppleNamespaces(AppleNamespaces); TheDwarfEmitter->emitAppleTypes(AppleTypes); TheDwarfEmitter->emitAppleObjc(AppleObjc); break; - case AccelTableKind::Dwarf: + case DwarfLinkerAccelTableKind::Dwarf: TheDwarfEmitter->emitDebugNames(DebugNames); break; - case AccelTableKind::Pub: + case DwarfLinkerAccelTableKind::Pub: // Already emitted by emitPubAcceleratorEntriesForUnit. break; - case AccelTableKind::Default: + case DwarfLinkerAccelTableKind::Default: llvm_unreachable("Default should have already been resolved."); break; } diff --git a/llvm/test/tools/dsymutil/X86/accelerator.test b/llvm/test/tools/dsymutil/X86/accelerator.test --- a/llvm/test/tools/dsymutil/X86/accelerator.test +++ b/llvm/test/tools/dsymutil/X86/accelerator.test @@ -1,20 +1,26 @@ RUN: dsymutil -accelerator=Dwarf -oso-prepend-path=%p/.. %p/../Inputs/basic.macho.x86_64 -o %t.dwarf.dSYM RUN: dsymutil -accelerator=Apple -oso-prepend-path=%p/.. %p/../Inputs/basic.macho.x86_64 -o %t.apple.dSYM +RUN: dsymutil -accelerator=None -oso-prepend-path=%p/.. %p/../Inputs/basic.macho.x86_64 -o %t.none.dSYM RUN: llvm-dwarfdump -verify %t.dwarf.dSYM RUN: llvm-dwarfdump -verify %t.apple.dSYM +RUN: llvm-dwarfdump -verify %t.none.dSYM RUN: llvm-dwarfdump -debug-names %t.dwarf.dSYM | FileCheck %s -check-prefixes=NAMES,DWARF RUN: llvm-dwarfdump -apple-names -apple-namespaces -apple-types %t.apple.dSYM | FileCheck %s -check-prefixes=NAMES,APPLE +RUN: llvm-dwarfdump -a %t.none.dSYM | FileCheck %s -check-prefixes=NONE RUN: dsymutil -update -accelerator=Dwarf %t.apple.dSYM RUN: dsymutil -update -accelerator=Apple %t.dwarf.dSYM +RUN: dsymutil -update -accelerator=None %t.none.dSYM RUN: llvm-dwarfdump -verify %t.dwarf.dSYM RUN: llvm-dwarfdump -verify %t.apple.dSYM +RUN: llvm-dwarfdump -verify %t.none.dSYM RUN: llvm-dwarfdump -debug-names %t.apple.dSYM | FileCheck %s -check-prefixes=NAMES,DWARF RUN: llvm-dwarfdump -apple-names -apple-namespaces -apple-types %t.dwarf.dSYM | FileCheck %s -check-prefixes=NAMES,APPLE +RUN: llvm-dwarfdump -a %t.none.dSYM | FileCheck %s -check-prefixes=NONE DWARF: .debug_names contents: DWARF: Compilation Unit offsets [ @@ -36,3 +42,13 @@ NAMES-DAG: "val" NAMES-DAG: "main" NAMES-DAG: "char" + +NONE-NOT: .debug_names +NONE-NOT: .apple_names +NONE-NOT: .apple_types +NONE-NOT: .apple_namespaces +NONE-NOT: .apple_objc +NONE-NOT: .debug_pubnames +NONE-NOT: .debug_types +NONE-NOT: .debug_gnu_pubnames +NONE-NOT: .debug_gnu_types diff --git a/llvm/tools/dsymutil/LinkUtils.h b/llvm/tools/dsymutil/LinkUtils.h --- a/llvm/tools/dsymutil/LinkUtils.h +++ b/llvm/tools/dsymutil/LinkUtils.h @@ -56,7 +56,7 @@ OutputFileType FileType = OutputFileType::Object; /// The accelerator table kind - AccelTableKind TheAccelTableKind; + DwarfLinkerAccelTableKind TheAccelTableKind; /// -oso-prepend-path std::string PrependPath; diff --git a/llvm/tools/dsymutil/Options.td b/llvm/tools/dsymutil/Options.td --- a/llvm/tools/dsymutil/Options.td +++ b/llvm/tools/dsymutil/Options.td @@ -143,7 +143,7 @@ def accelerator: Separate<["--", "-"], "accelerator">, MetaVarName<"">, - HelpText<"Specify the desired type of accelerator table. Valid options are 'Apple' (.apple_names, .apple_namespaces, .apple_types, .apple_objc), 'Dwarf' (.debug_names), 'Pub' (.debug_pubnames, .debug_pubtypes) and 'Default'">, + HelpText<"Specify the desired type of accelerator table. Valid options are 'Apple' (.apple_names, .apple_namespaces, .apple_types, .apple_objc), 'Dwarf' (.debug_names), 'Pub' (.debug_pubnames, .debug_pubtypes), 'Default' and 'None'">, Group; def: Joined<["--", "-"], "accelerator=">, Alias; diff --git a/llvm/tools/dsymutil/dsymutil.cpp b/llvm/tools/dsymutil/dsymutil.cpp --- a/llvm/tools/dsymutil/dsymutil.cpp +++ b/llvm/tools/dsymutil/dsymutil.cpp @@ -206,23 +206,26 @@ return Error::success(); } -static Expected getAccelTableKind(opt::InputArgList &Args) { +static Expected +getAccelTableKind(opt::InputArgList &Args) { if (opt::Arg *Accelerator = Args.getLastArg(OPT_accelerator)) { StringRef S = Accelerator->getValue(); if (S == "Apple") - return AccelTableKind::Apple; + return DwarfLinkerAccelTableKind::Apple; if (S == "Dwarf") - return AccelTableKind::Dwarf; + return DwarfLinkerAccelTableKind::Dwarf; if (S == "Pub") - return AccelTableKind::Pub; + return DwarfLinkerAccelTableKind::Pub; if (S == "Default") - return AccelTableKind::Default; - return make_error( - "invalid accelerator type specified: '" + S + - "'. Support values are 'Apple', 'Dwarf', 'Pub' and 'Default'.", - inconvertibleErrorCode()); + return DwarfLinkerAccelTableKind::Default; + if (S == "None") + return DwarfLinkerAccelTableKind::None; + return make_error("invalid accelerator type specified: '" + S + + "'. Supported values are 'Apple', " + "'Dwarf', 'Pub', 'Default' and 'None'.", + inconvertibleErrorCode()); } - return AccelTableKind::Default; + return DwarfLinkerAccelTableKind::Default; } static Expected getVerifyKind(opt::InputArgList &Args) { @@ -240,7 +243,7 @@ return DWARFVerify::None; return make_error( "invalid verify type specified: '" + S + - "'. Support values are 'input', 'output', 'all' and 'none'.", + "'. Supported values are 'input', 'output', 'all' and 'none'.", inconvertibleErrorCode()); } return DWARFVerify::None; @@ -282,7 +285,7 @@ if (Args.hasArg(OPT_gen_reproducer)) Options.ReproMode = ReproducerMode::Generate; - if (Expected AccelKind = getAccelTableKind(Args)) { + if (Expected AccelKind = getAccelTableKind(Args)) { Options.LinkOpts.TheAccelTableKind = *AccelKind; } else { return AccelKind.takeError();