<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Nov 5, 2014 at 7:03 PM, Nick Kledzik <span dir="ltr"><<a href="mailto:kledzik@apple.com" target="_blank">kledzik@apple.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: kledzik<br>
Date: Wed Nov  5 21:03:42 2014<br>
New Revision: 221432<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=221432&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=221432&view=rev</a><br>
Log:<br>
[mach-o] Add support for -S option<br>
<br>
The darwin linker does not process dwarf debug info.  Instead it produces a<br>
"debug map" in the output file which points back to the original .o files for<br>
anything that wants debug info (e.g. debugger).<br>
<br>
The -S option means "don't add a debug map".  lld for mach-o currently does<br>
not generate the debug map, so there is nothing to do when this option is used.<br>
But we need to process the option to get existing projects building.<br>
<br>
Modified:<br>
    lld/trunk/include/lld/ReaderWriter/MachOLinkingContext.h<br>
    lld/trunk/lib/Driver/DarwinLdDriver.cpp<br>
    lld/trunk/lib/Driver/DarwinLdOptions.td<br>
    lld/trunk/lib/ReaderWriter/MachO/MachOLinkingContext.cpp<br>
<br>
Modified: lld/trunk/include/lld/ReaderWriter/MachOLinkingContext.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/ReaderWriter/MachOLinkingContext.h?rev=221432&r1=221431&r2=221432&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/ReaderWriter/MachOLinkingContext.h?rev=221432&r1=221431&r2=221432&view=diff</a><br>
==============================================================================<br>
--- lld/trunk/include/lld/ReaderWriter/MachOLinkingContext.h (original)<br>
+++ lld/trunk/include/lld/ReaderWriter/MachOLinkingContext.h Wed Nov  5 21:03:42 2014<br>
@@ -57,6 +57,11 @@ public:<br>
     blackList   // -unexported_symbol[s_list], no listed symbol exported.<br>
   };<br>
<br>
+  enum class DebugInfoMode {<br>
+    addDebugMap,    // Default<br>
+    noDebugMap      // -S option<br>
+  };<br>
+<br>
   /// Initializes the context to sane default values given the specified output<br>
   /// file type, arch, os, and minimum os version.  This should be called before<br>
   /// other setXXX() methods.<br>
@@ -93,6 +98,11 @@ public:<br>
   bool exportRestrictMode() const { return _exportMode != ExportMode::globals; }<br>
   bool exportSymbolNamed(StringRef sym) const;<br>
<br>
+  DebugInfoMode debugInfoMode() const { return _debugInfoMode; }<br>
+  void setDebugInfoMode(DebugInfoMode mode) {<br>
+    _debugInfoMode = mode;<br>
+  }<br>
+<br>
   bool keepPrivateExterns() const { return _keepPrivateExterns; }<br>
   void setKeepPrivateExterns(bool v) { _keepPrivateExterns = v; }<br>
   bool demangleSymbols() const { return _demangle; }<br>
@@ -322,6 +332,7 @@ private:<br>
   mutable std::vector<std::unique_ptr<class MachOFileNode>> _indirectDylibs;<br>
   ExportMode _exportMode;<br>
   llvm::StringSet<> _exportedSymbols;<br>
+  DebugInfoMode _debugInfoMode;<br>
   std::unique_ptr<llvm::raw_fd_ostream> _dependencyInfo;<br>
 };<br>
<br>
<br>
Modified: lld/trunk/lib/Driver/DarwinLdDriver.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Driver/DarwinLdDriver.cpp?rev=221432&r1=221431&r2=221432&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Driver/DarwinLdDriver.cpp?rev=221432&r1=221431&r2=221432&view=diff</a><br>
==============================================================================<br>
--- lld/trunk/lib/Driver/DarwinLdDriver.cpp (original)<br>
+++ lld/trunk/lib/Driver/DarwinLdDriver.cpp Wed Nov  5 21:03:42 2014<br>
@@ -640,6 +640,11 @@ bool DarwinLdDriver::parse(int argc, con<br>
     }<br>
   }<br>
<br>
+  // Handle debug info handling options: -S<br>
+  if (parsedArgs->hasArg(OPT_S)) {<br>
+    ctx.setDebugInfoMode(MachOLinkingContext::DebugInfoMode::noDebugMap);<br>
+  }<br></blockquote><div><br></div><div>Not sure if lld does this differently, but it's sort of an unwritten convention in LLVM & Clang that {} are omitted from single-line (or sometimes single-statement) blocks.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+<br>
   // Handle input files<br>
   for (auto &arg : *parsedArgs) {<br>
     bool upward;<br>
<br>
Modified: lld/trunk/lib/Driver/DarwinLdOptions.td<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Driver/DarwinLdOptions.td?rev=221432&r1=221431&r2=221432&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Driver/DarwinLdOptions.td?rev=221432&r1=221431&r2=221432&view=diff</a><br>
==============================================================================<br>
--- lld/trunk/lib/Driver/DarwinLdOptions.td (original)<br>
+++ lld/trunk/lib/Driver/DarwinLdOptions.td Wed Nov  5 21:03:42 2014<br>
@@ -160,6 +160,8 @@ def demangle : Flag<["-"], "demangle">,<br>
 def dependency_info : Separate<["-"], "dependency_info">,<br>
      MetaVarName<"<file>">,<br>
      HelpText<"Write binary list of files used during link">;<br>
+def S : Flag<["-"], "S">,<br>
+     HelpText<"Remove debug information (STABS or DWARF) from the output file">;<br>
<br>
 def t : Flag<["-"], "t">,<br>
      HelpText<"Print the names of the input files as ld processes them">;<br>
<br>
Modified: lld/trunk/lib/ReaderWriter/MachO/MachOLinkingContext.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/MachO/MachOLinkingContext.cpp?rev=221432&r1=221431&r2=221432&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/MachO/MachOLinkingContext.cpp?rev=221432&r1=221431&r2=221432&view=diff</a><br>
==============================================================================<br>
--- lld/trunk/lib/ReaderWriter/MachO/MachOLinkingContext.cpp (original)<br>
+++ lld/trunk/lib/ReaderWriter/MachO/MachOLinkingContext.cpp Wed Nov  5 21:03:42 2014<br>
@@ -145,7 +145,8 @@ MachOLinkingContext::MachOLinkingContext<br>
       _compatibilityVersion(0), _currentVersion(0), _deadStrippableDylib(false),<br>
       _printAtoms(false), _testingFileUsage(false), _keepPrivateExterns(false),<br>
       _demangle(false), _archHandler(nullptr),<br>
-      _exportMode(ExportMode::globals) {}<br>
+      _exportMode(ExportMode::globals),<br>
+      _debugInfoMode(DebugInfoMode::addDebugMap) {}<br>
<br>
 MachOLinkingContext::~MachOLinkingContext() {}<br>
<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
</blockquote></div><br></div></div>