[llvm-commits] [lld] r169717 - in /lld/trunk: include/lld/Driver/LinkerOptions.h lib/Driver/CoreOptions.td lib/Driver/Drivers.cpp lib/Driver/LDOptions.td tools/lld/lld.cpp
Michael J. Spencer
bigcheesegs at gmail.com
Sun Dec 9 15:56:26 PST 2012
Author: mspencer
Date: Sun Dec 9 17:56:26 2012
New Revision: 169717
URL: http://llvm.org/viewvc/llvm-project?rev=169717&view=rev
Log:
[Driver] Add -### support for printing out the core command line.
Modified:
lld/trunk/include/lld/Driver/LinkerOptions.h
lld/trunk/lib/Driver/CoreOptions.td
lld/trunk/lib/Driver/Drivers.cpp
lld/trunk/lib/Driver/LDOptions.td
lld/trunk/tools/lld/lld.cpp
Modified: lld/trunk/include/lld/Driver/LinkerOptions.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/Driver/LinkerOptions.h?rev=169717&r1=169716&r2=169717&view=diff
==============================================================================
--- lld/trunk/include/lld/Driver/LinkerOptions.h (original)
+++ lld/trunk/include/lld/Driver/LinkerOptions.h Sun Dec 9 17:56:26 2012
@@ -110,13 +110,16 @@
, _target(std::move(other._target))
, _outputPath(std::move(other._outputPath))
, _entrySymbol(std::move(other._entrySymbol))
- , _relocatable(other._relocatable) {}
+ , _relocatable(other._relocatable)
+ , _outputCommands(other._outputCommands) {}
std::vector<LinkerInput> _input;
std::string _target;
std::string _outputPath;
std::string _entrySymbol;
unsigned _relocatable : 1;
+ /// \brief -###
+ unsigned _outputCommands : 1;
private:
LinkerOptions(const LinkerOptions&) LLVM_DELETED_FUNCTION;
Modified: lld/trunk/lib/Driver/CoreOptions.td
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Driver/CoreOptions.td?rev=169717&r1=169716&r2=169717&view=diff
==============================================================================
--- lld/trunk/lib/Driver/CoreOptions.td (original)
+++ lld/trunk/lib/Driver/CoreOptions.td Sun Dec 9 17:56:26 2012
@@ -5,3 +5,5 @@
def output : Joined<["-"], "output=">;
def entry : Joined<["-"], "entry=">;
def relocatable : Flag<["-"], "relocatable">;
+
+def OCTOTHORPE_OCTOTHORPE_OCTOTHORPE : Flag<["-"], "###">;
Modified: lld/trunk/lib/Driver/Drivers.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Driver/Drivers.cpp?rev=169717&r1=169716&r2=169717&view=diff
==============================================================================
--- lld/trunk/lib/Driver/Drivers.cpp (original)
+++ lld/trunk/lib/Driver/Drivers.cpp Sun Dec 9 17:56:26 2012
@@ -130,6 +130,11 @@
if (llvm::opt::Arg *A = _inputArgs->getLastArg(ld::OPT_relocatable))
newArgs->AddFlagArg(A, _core.getOption(core::OPT_relocatable));
+ if (llvm::opt::Arg *A =
+ _inputArgs->getLastArg(ld::OPT_OCTOTHORPE_OCTOTHORPE_OCTOTHORPE))
+ newArgs->AddFlagArg(A, _core.getOption(
+ core::OPT_OCTOTHORPE_OCTOTHORPE_OCTOTHORPE));
+
// Copy input args.
for (llvm::opt::arg_iterator it = _inputArgs->filtered_begin(ld::OPT_INPUT),
ie = _inputArgs->filtered_end();
@@ -173,6 +178,7 @@
ret._outputPath = args.getLastArgValue(core::OPT_output);
ret._entrySymbol = args.getLastArgValue(core::OPT_entry);
ret._relocatable = args.hasArg(core::OPT_relocatable);
+ ret._outputCommands = args.hasArg(core::OPT_OCTOTHORPE_OCTOTHORPE_OCTOTHORPE);
return std::move(ret);
}
Modified: lld/trunk/lib/Driver/LDOptions.td
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Driver/LDOptions.td?rev=169717&r1=169716&r2=169717&view=diff
==============================================================================
--- lld/trunk/lib/Driver/LDOptions.td (original)
+++ lld/trunk/lib/Driver/LDOptions.td Sun Dec 9 17:56:26 2012
@@ -11,3 +11,5 @@
def relocatable : Flag<["--"], "relocatable">;
def relocatable_r : Flag<["-"], "r">, Alias<relocatable>;
+
+def OCTOTHORPE_OCTOTHORPE_OCTOTHORPE : Flag<["-"], "###">;
Modified: lld/trunk/tools/lld/lld.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/tools/lld/lld.cpp?rev=169717&r1=169716&r2=169717&view=diff
==============================================================================
--- lld/trunk/tools/lld/lld.cpp (original)
+++ lld/trunk/tools/lld/lld.cpp Sun Dec 9 17:56:26 2012
@@ -129,12 +129,24 @@
if (!coreArgs)
return 1;
- for (auto arg : *coreArgs) {
- llvm::outs() << arg->getAsString(*coreArgs) << " ";
+ for (const auto &arg : *coreArgs) {
+ if (arg->getOption().getKind() == llvm::opt::Option::UnknownClass) {
+ llvm::errs() << "Unknown option: " << arg->getAsString(*coreArgs) << "\n";
+ }
}
- llvm::outs() << "\n";
LinkerOptions lo(generateOptions(*coreArgs));
+
+ if (lo._outputCommands) {
+ for (auto arg : *coreArgs) {
+ llvm::outs() << arg->getAsString(*coreArgs) << " ";
+ }
+ llvm::outs() << "\n";
+
+ // Don't do the link if we are just outputting commands.
+ return 0;
+ }
+
LinkerInvocation invocation(lo);
invocation();
More information about the llvm-commits
mailing list