summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael J. Spencer <bigcheesegs@gmail.com>2012-12-09 23:56:26 +0000
committerMichael J. Spencer <bigcheesegs@gmail.com>2012-12-09 23:56:26 +0000
commit382576055010e26a2811cb7748e109b20e8c5456 (patch)
tree30698751d0b08ad9b3fd492824a74253b97ce415
parent48ed57271029a173694d5c343e15b75cc2d45500 (diff)
downloadbcm5719-llvm-382576055010e26a2811cb7748e109b20e8c5456.tar.gz
bcm5719-llvm-382576055010e26a2811cb7748e109b20e8c5456.zip
[Driver] Add -### support for printing out the core command line.
llvm-svn: 169717
-rw-r--r--lld/include/lld/Driver/LinkerOptions.h5
-rw-r--r--lld/lib/Driver/CoreOptions.td2
-rw-r--r--lld/lib/Driver/Drivers.cpp6
-rw-r--r--lld/lib/Driver/LDOptions.td2
-rw-r--r--lld/tools/lld/lld.cpp18
5 files changed, 29 insertions, 4 deletions
diff --git a/lld/include/lld/Driver/LinkerOptions.h b/lld/include/lld/Driver/LinkerOptions.h
index 801c401c176..494d403ee2c 100644
--- a/lld/include/lld/Driver/LinkerOptions.h
+++ b/lld/include/lld/Driver/LinkerOptions.h
@@ -110,13 +110,16 @@ struct LinkerOptions {
, _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;
diff --git a/lld/lib/Driver/CoreOptions.td b/lld/lib/Driver/CoreOptions.td
index b1c8acd40e9..97808a2053a 100644
--- a/lld/lib/Driver/CoreOptions.td
+++ b/lld/lib/Driver/CoreOptions.td
@@ -5,3 +5,5 @@ def target : Separate<["-"], "target">, HelpText<"Target triple to link for">;
def output : Joined<["-"], "output=">;
def entry : Joined<["-"], "entry=">;
def relocatable : Flag<["-"], "relocatable">;
+
+def OCTOTHORPE_OCTOTHORPE_OCTOTHORPE : Flag<["-"], "###">;
diff --git a/lld/lib/Driver/Drivers.cpp b/lld/lib/Driver/Drivers.cpp
index e829ec8f972..8ff4abedebf 100644
--- a/lld/lib/Driver/Drivers.cpp
+++ b/lld/lib/Driver/Drivers.cpp
@@ -130,6 +130,11 @@ public:
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 @@ LinkerOptions lld::generateOptions(const llvm::opt::ArgList &args) {
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);
}
diff --git a/lld/lib/Driver/LDOptions.td b/lld/lib/Driver/LDOptions.td
index 87a50262ccc..f6c0053dfef 100644
--- a/lld/lib/Driver/LDOptions.td
+++ b/lld/lib/Driver/LDOptions.td
@@ -11,3 +11,5 @@ def output_e : Separate<["-"], "o">, Alias<output>;
def relocatable : Flag<["--"], "relocatable">;
def relocatable_r : Flag<["-"], "r">, Alias<relocatable>;
+
+def OCTOTHORPE_OCTOTHORPE_OCTOTHORPE : Flag<["-"], "###">;
diff --git a/lld/tools/lld/lld.cpp b/lld/tools/lld/lld.cpp
index c4670b77469..78b2547b5df 100644
--- a/lld/tools/lld/lld.cpp
+++ b/lld/tools/lld/lld.cpp
@@ -129,12 +129,24 @@ int main(int argc, char **argv) {
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();
OpenPOWER on IntegriCloud