[Driver] Add -### support for printing out the core command line.

llvm-svn: 169717
This commit is contained in:
Michael J. Spencer 2012-12-09 23:56:26 +00:00
parent 48ed572710
commit 3825760550
5 changed files with 29 additions and 4 deletions

View File

@ -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;

View File

@ -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<["-"], "###">;

View File

@ -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);
}

View File

@ -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<["-"], "###">;

View File

@ -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();