Store just argv[0] in Config.

Having the full argv there seems in conflict with the desire to parse
all command line options in the Driver.

llvm-svn: 324418
This commit is contained in:
Rafael Espindola 2018-02-06 22:37:05 +00:00
parent cb7959fd78
commit 64626b344b
4 changed files with 9 additions and 9 deletions

View File

@ -89,12 +89,12 @@ struct Configuration {
llvm::StringRef MapFile; llvm::StringRef MapFile;
llvm::StringRef OutputFile; llvm::StringRef OutputFile;
llvm::StringRef OptRemarksFilename; llvm::StringRef OptRemarksFilename;
llvm::StringRef ProgName;
llvm::StringRef SoName; llvm::StringRef SoName;
llvm::StringRef Sysroot; llvm::StringRef Sysroot;
llvm::StringRef ThinLTOCacheDir; llvm::StringRef ThinLTOCacheDir;
std::string Rpath; std::string Rpath;
std::vector<VersionDefinition> VersionDefinitions; std::vector<VersionDefinition> VersionDefinitions;
std::vector<llvm::StringRef> Argv;
std::vector<llvm::StringRef> AuxiliaryList; std::vector<llvm::StringRef> AuxiliaryList;
std::vector<llvm::StringRef> FilterList; std::vector<llvm::StringRef> FilterList;
std::vector<llvm::StringRef> SearchPaths; std::vector<llvm::StringRef> SearchPaths;

View File

@ -89,7 +89,7 @@ bool elf::link(ArrayRef<const char *> Args, bool CanExitEarly,
Driver = make<LinkerDriver>(); Driver = make<LinkerDriver>();
Script = make<LinkerScript>(); Script = make<LinkerScript>();
Symtab = make<SymbolTable>(); Symtab = make<SymbolTable>();
Config->Argv = {Args.begin(), Args.end()}; Config->ProgName = Args[0];
Driver->main(Args, CanExitEarly); Driver->main(Args, CanExitEarly);
@ -317,7 +317,7 @@ void LinkerDriver::main(ArrayRef<const char *> ArgsArr, bool CanExitEarly) {
// Handle -help // Handle -help
if (Args.hasArg(OPT_help)) { if (Args.hasArg(OPT_help)) {
printHelp(ArgsArr[0]); printHelp();
return; return;
} }
@ -690,7 +690,7 @@ void LinkerDriver::readConfigs(opt::InputArgList &Args) {
Config->ZWxneeded = hasZOption(Args, "wxneeded"); Config->ZWxneeded = hasZOption(Args, "wxneeded");
// Parse LTO plugin-related options for compatibility with gold. // Parse LTO plugin-related options for compatibility with gold.
std::vector<const char *> LTOOptions({Config->Argv[0].data()}); std::vector<const char *> LTOOptions({Config->ProgName.data()});
for (auto *Arg : Args.filtered(OPT_plugin_opt)) { for (auto *Arg : Args.filtered(OPT_plugin_opt)) {
StringRef S = Arg->getValue(); StringRef S = Arg->getValue();
if (S == "disable-verify") if (S == "disable-verify")

View File

@ -63,7 +63,7 @@ enum {
#undef OPTION #undef OPTION
}; };
void printHelp(const char *Argv0); void printHelp();
std::string createResponseFile(const llvm::opt::InputArgList &Args); std::string createResponseFile(const llvm::opt::InputArgList &Args);
llvm::Optional<std::string> findFromSearchPaths(StringRef Path); llvm::Optional<std::string> findFromSearchPaths(StringRef Path);

View File

@ -114,9 +114,9 @@ opt::InputArgList ELFOptTable::parse(ArrayRef<const char *> Argv) {
return Args; return Args;
} }
void elf::printHelp(const char *Argv0) { void elf::printHelp() {
ELFOptTable().PrintHelp(outs(), Argv0, "lld", false /*ShowHidden*/, ELFOptTable().PrintHelp(outs(), Config->ProgName.data(), "lld",
true /*ShowAllAliases*/); false /*ShowHidden*/, true /*ShowAllAliases*/);
outs() << "\n"; outs() << "\n";
// Scripts generated by Libtool versions up to at least 2.4.6 (the most // Scripts generated by Libtool versions up to at least 2.4.6 (the most
@ -125,7 +125,7 @@ void elf::printHelp(const char *Argv0) {
// assume that the linker doesn't support very basic features such as // assume that the linker doesn't support very basic features such as
// shared libraries. Therefore, we need to print out at least "elf". // shared libraries. Therefore, we need to print out at least "elf".
// Here, we print out all the targets that we support. // Here, we print out all the targets that we support.
outs() << Argv0 << ": supported targets: " outs() << Config->ProgName << ": supported targets: "
<< "elf32-i386 elf32-iamcu elf32-littlearm elf32-ntradbigmips " << "elf32-i386 elf32-iamcu elf32-littlearm elf32-ntradbigmips "
<< "elf32-ntradlittlemips elf32-powerpc elf32-tradbigmips " << "elf32-ntradlittlemips elf32-powerpc elf32-tradbigmips "
<< "elf32-tradlittlemips elf32-x86-64 " << "elf32-tradlittlemips elf32-x86-64 "