[lld] r221432 - [mach-o] Add support for -S option
David Blaikie
dblaikie at gmail.com
Wed Nov 5 22:19:06 PST 2014
On Wed, Nov 5, 2014 at 7:03 PM, Nick Kledzik <kledzik at apple.com> wrote:
> Author: kledzik
> Date: Wed Nov 5 21:03:42 2014
> New Revision: 221432
>
> URL: http://llvm.org/viewvc/llvm-project?rev=221432&view=rev
> Log:
> [mach-o] Add support for -S option
>
> The darwin linker does not process dwarf debug info. Instead it produces a
> "debug map" in the output file which points back to the original .o files
> for
> anything that wants debug info (e.g. debugger).
>
> The -S option means "don't add a debug map". lld for mach-o currently does
> not generate the debug map, so there is nothing to do when this option is
> used.
> But we need to process the option to get existing projects building.
>
> Modified:
> lld/trunk/include/lld/ReaderWriter/MachOLinkingContext.h
> lld/trunk/lib/Driver/DarwinLdDriver.cpp
> lld/trunk/lib/Driver/DarwinLdOptions.td
> lld/trunk/lib/ReaderWriter/MachO/MachOLinkingContext.cpp
>
> Modified: lld/trunk/include/lld/ReaderWriter/MachOLinkingContext.h
> URL:
> http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/ReaderWriter/MachOLinkingContext.h?rev=221432&r1=221431&r2=221432&view=diff
>
> ==============================================================================
> --- lld/trunk/include/lld/ReaderWriter/MachOLinkingContext.h (original)
> +++ lld/trunk/include/lld/ReaderWriter/MachOLinkingContext.h Wed Nov 5
> 21:03:42 2014
> @@ -57,6 +57,11 @@ public:
> blackList // -unexported_symbol[s_list], no listed symbol exported.
> };
>
> + enum class DebugInfoMode {
> + addDebugMap, // Default
> + noDebugMap // -S option
> + };
> +
> /// Initializes the context to sane default values given the specified
> output
> /// file type, arch, os, and minimum os version. This should be called
> before
> /// other setXXX() methods.
> @@ -93,6 +98,11 @@ public:
> bool exportRestrictMode() const { return _exportMode !=
> ExportMode::globals; }
> bool exportSymbolNamed(StringRef sym) const;
>
> + DebugInfoMode debugInfoMode() const { return _debugInfoMode; }
> + void setDebugInfoMode(DebugInfoMode mode) {
> + _debugInfoMode = mode;
> + }
> +
> bool keepPrivateExterns() const { return _keepPrivateExterns; }
> void setKeepPrivateExterns(bool v) { _keepPrivateExterns = v; }
> bool demangleSymbols() const { return _demangle; }
> @@ -322,6 +332,7 @@ private:
> mutable std::vector<std::unique_ptr<class MachOFileNode>>
> _indirectDylibs;
> ExportMode _exportMode;
> llvm::StringSet<> _exportedSymbols;
> + DebugInfoMode _debugInfoMode;
> std::unique_ptr<llvm::raw_fd_ostream> _dependencyInfo;
> };
>
>
> Modified: lld/trunk/lib/Driver/DarwinLdDriver.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Driver/DarwinLdDriver.cpp?rev=221432&r1=221431&r2=221432&view=diff
>
> ==============================================================================
> --- lld/trunk/lib/Driver/DarwinLdDriver.cpp (original)
> +++ lld/trunk/lib/Driver/DarwinLdDriver.cpp Wed Nov 5 21:03:42 2014
> @@ -640,6 +640,11 @@ bool DarwinLdDriver::parse(int argc, con
> }
> }
>
> + // Handle debug info handling options: -S
> + if (parsedArgs->hasArg(OPT_S)) {
> + ctx.setDebugInfoMode(MachOLinkingContext::DebugInfoMode::noDebugMap);
> + }
>
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.
> +
> // Handle input files
> for (auto &arg : *parsedArgs) {
> bool upward;
>
> Modified: lld/trunk/lib/Driver/DarwinLdOptions.td
> URL:
> http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Driver/DarwinLdOptions.td?rev=221432&r1=221431&r2=221432&view=diff
>
> ==============================================================================
> --- lld/trunk/lib/Driver/DarwinLdOptions.td (original)
> +++ lld/trunk/lib/Driver/DarwinLdOptions.td Wed Nov 5 21:03:42 2014
> @@ -160,6 +160,8 @@ def demangle : Flag<["-"], "demangle">,
> def dependency_info : Separate<["-"], "dependency_info">,
> MetaVarName<"<file>">,
> HelpText<"Write binary list of files used during link">;
> +def S : Flag<["-"], "S">,
> + HelpText<"Remove debug information (STABS or DWARF) from the output
> file">;
>
> def t : Flag<["-"], "t">,
> HelpText<"Print the names of the input files as ld processes them">;
>
> Modified: lld/trunk/lib/ReaderWriter/MachO/MachOLinkingContext.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/MachO/MachOLinkingContext.cpp?rev=221432&r1=221431&r2=221432&view=diff
>
> ==============================================================================
> --- lld/trunk/lib/ReaderWriter/MachO/MachOLinkingContext.cpp (original)
> +++ lld/trunk/lib/ReaderWriter/MachO/MachOLinkingContext.cpp Wed Nov 5
> 21:03:42 2014
> @@ -145,7 +145,8 @@ MachOLinkingContext::MachOLinkingContext
> _compatibilityVersion(0), _currentVersion(0),
> _deadStrippableDylib(false),
> _printAtoms(false), _testingFileUsage(false),
> _keepPrivateExterns(false),
> _demangle(false), _archHandler(nullptr),
> - _exportMode(ExportMode::globals) {}
> + _exportMode(ExportMode::globals),
> + _debugInfoMode(DebugInfoMode::addDebugMap) {}
>
> MachOLinkingContext::~MachOLinkingContext() {}
>
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20141105/f029f3f4/attachment.html>
More information about the llvm-commits
mailing list