diff options
| author | Andrew Kelley <superjoe30@gmail.com> | 2018-01-17 17:29:21 -0500 |
|---|---|---|
| committer | Andrew Kelley <superjoe30@gmail.com> | 2018-01-17 17:29:21 -0500 |
| commit | 4aed7ea6f89a091aede10ccf0fb45b3ce12c710d (patch) | |
| tree | 1e29f13ad17bfc841c33f6ac3d0ccb092404f409 /deps/lld/ELF/DriverUtils.cpp | |
| parent | 48cd808185f54e935714539d101585a9a0a41673 (diff) | |
| download | zig-4aed7ea6f89a091aede10ccf0fb45b3ce12c710d.tar.gz zig-4aed7ea6f89a091aede10ccf0fb45b3ce12c710d.zip | |
update embedded LLD to 6.0.0rc1
Diffstat (limited to 'deps/lld/ELF/DriverUtils.cpp')
| -rw-r--r-- | deps/lld/ELF/DriverUtils.cpp | 68 |
1 files changed, 39 insertions, 29 deletions
diff --git a/deps/lld/ELF/DriverUtils.cpp b/deps/lld/ELF/DriverUtils.cpp index 5adb09176a..2f7c922885 100644 --- a/deps/lld/ELF/DriverUtils.cpp +++ b/deps/lld/ELF/DriverUtils.cpp @@ -14,10 +14,10 @@ //===----------------------------------------------------------------------===// #include "Driver.h" -#include "Error.h" -#include "Memory.h" -#include "lld/Config/Version.h" -#include "lld/Core/Reproduce.h" +#include "lld/Common/ErrorHandler.h" +#include "lld/Common/Memory.h" +#include "lld/Common/Reproduce.h" +#include "lld/Common/Version.h" #include "llvm/ADT/Optional.h" #include "llvm/ADT/STLExtras.h" #include "llvm/ADT/Triple.h" @@ -51,25 +51,26 @@ static const opt::OptTable::Info OptInfo[] = { ELFOptTable::ELFOptTable() : OptTable(OptInfo) {} -// Parse -color-diagnostics={auto,always,never} or -no-color-diagnostics. -static bool getColorDiagnostics(opt::InputArgList &Args) { +// Set color diagnostics according to -color-diagnostics={auto,always,never} +// or -no-color-diagnostics flags. +static void handleColorDiagnostics(opt::InputArgList &Args) { auto *Arg = Args.getLastArg(OPT_color_diagnostics, OPT_color_diagnostics_eq, OPT_no_color_diagnostics); if (!Arg) - return ErrorOS->has_colors(); - if (Arg->getOption().getID() == OPT_color_diagnostics) - return true; - if (Arg->getOption().getID() == OPT_no_color_diagnostics) - return false; - - StringRef S = Arg->getValue(); - if (S == "auto") - return ErrorOS->has_colors(); - if (S == "always") - return true; - if (S != "never") - error("unknown option: -color-diagnostics=" + S); - return false; + return; + else if (Arg->getOption().getID() == OPT_color_diagnostics) + errorHandler().ColorDiagnostics = true; + else if (Arg->getOption().getID() == OPT_no_color_diagnostics) + errorHandler().ColorDiagnostics = false; + else { + StringRef S = Arg->getValue(); + if (S == "always") + errorHandler().ColorDiagnostics = true; + else if (S == "never") + errorHandler().ColorDiagnostics = false; + else if (S != "auto") + error("unknown option: -color-diagnostics=" + S); + } } static cl::TokenizerCallback getQuotingStyle(opt::InputArgList &Args) { @@ -103,9 +104,7 @@ opt::InputArgList ELFOptTable::parse(ArrayRef<const char *> Argv) { cl::ExpandResponseFiles(Saver, getQuotingStyle(Args), Vec); Args = this->ParseArgs(Vec, MissingIndex, MissingCount); - // Interpret -color-diagnostics early so that error messages - // for unknown flags are colored. - Config->ColorDiagnostics = getColorDiagnostics(Args); + handleColorDiagnostics(Args); if (MissingCount) error(Twine(Args.getArgString(MissingIndex)) + ": missing argument"); @@ -115,8 +114,8 @@ opt::InputArgList ELFOptTable::parse(ArrayRef<const char *> Argv) { } void elf::printHelp(const char *Argv0) { - ELFOptTable Table; - Table.PrintHelp(outs(), Argv0, "lld", false); + ELFOptTable().PrintHelp(outs(), Argv0, "lld", false /*ShowHidden*/, + true /*ShowAllAliases*/); outs() << "\n"; // Scripts generated by Libtool versions up to at least 2.4.6 (the most @@ -138,10 +137,11 @@ void elf::printHelp(const char *Argv0) { std::string elf::createResponseFile(const opt::InputArgList &Args) { SmallString<0> Data; raw_svector_ostream OS(Data); + OS << "--chroot .\n"; // Copy the command line to the output while rewriting paths. for (auto *Arg : Args) { - switch (Arg->getOption().getID()) { + switch (Arg->getOption().getUnaliasedOption().getID()) { case OPT_reproduce: break; case OPT_INPUT: @@ -154,17 +154,18 @@ std::string elf::createResponseFile(const opt::InputArgList &Args) { // Strip directories to prevent the issue. OS << "-o " << quote(sys::path::filename(Arg->getValue())) << "\n"; break; - case OPT_L: case OPT_dynamic_list: + case OPT_library_path: case OPT_rpath: - case OPT_alias_script_T: case OPT_script: + case OPT_symbol_ordering_file: + case OPT_sysroot: case OPT_version_script: OS << Arg->getSpelling() << " " << quote(rewritePath(Arg->getValue())) << "\n"; break; default: - OS << toString(Arg) << "\n"; + OS << toString(*Arg) << "\n"; } } return Data.str(); @@ -206,3 +207,12 @@ Optional<std::string> elf::searchLibrary(StringRef Name) { } return None; } + +// If a linker script doesn't exist in the current directory, we also look for +// the script in the '-L' search paths. This matches the behaviour of both '-T' +// and linker script INPUT() directives in ld.bfd. +Optional<std::string> elf::searchLinkerScript(StringRef Name) { + if (fs::exists(Name)) + return Name.str(); + return findFromSearchPaths(Name); +} |
