[lld] r259395 - Revert r259143, it broke check-lld on Windows (see PR26388).
Nico Weber via llvm-commits
llvm-commits at lists.llvm.org
Mon Feb 1 12:03:53 PST 2016
Author: nico
Date: Mon Feb 1 14:03:53 2016
New Revision: 259395
URL: http://llvm.org/viewvc/llvm-project?rev=259395&view=rev
Log:
Revert r259143, it broke check-lld on Windows (see PR26388).
Removed:
lld/trunk/test/ELF/driver.test
Modified:
lld/trunk/ELF/Driver.cpp
lld/trunk/ELF/Driver.h
lld/trunk/ELF/DriverUtils.cpp
lld/trunk/ELF/Error.cpp
lld/trunk/ELF/Error.h
lld/trunk/ELF/LinkerScript.cpp
Modified: lld/trunk/ELF/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Driver.cpp?rev=259395&r1=259394&r2=259395&view=diff
==============================================================================
--- lld/trunk/ELF/Driver.cpp (original)
+++ lld/trunk/ELF/Driver.cpp Mon Feb 1 14:03:53 2016
@@ -55,10 +55,8 @@ static std::pair<ELFKind, uint16_t> pars
if (S == "aarch64linux")
return {ELF64LEKind, EM_AARCH64};
if (S == "i386pe" || S == "i386pep" || S == "thumb2pe")
- error("Windows targets are not supported on the ELF frontend: " + S);
- else
- error("Unknown emulation: " + S);
- return {ELFNoneKind, 0};
+ fatal("Windows targets are not supported on the ELF frontend: " + S);
+ fatal("Unknown emulation: " + S);
}
// Returns slices of MB by parsing MB as an archive file.
@@ -86,8 +84,7 @@ void LinkerDriver::addFile(StringRef Pat
if (Config->Verbose)
llvm::outs() << Path << "\n";
auto MBOrErr = MemoryBuffer::getFile(Path);
- if (error(MBOrErr, "cannot open " + Path))
- return;
+ fatal(MBOrErr, "cannot open " + Path);
std::unique_ptr<MemoryBuffer> &MB = *MBOrErr;
MemoryBufferRef MBRef = MB->getMemBufferRef();
OwningMBs.push_back(std::move(MB)); // take MB ownership
@@ -112,15 +109,6 @@ void LinkerDriver::addFile(StringRef Pat
}
}
-// Add a given library by searching it from input search paths.
-void LinkerDriver::addLibrary(StringRef Name) {
- std::string Path = searchLibrary(Name);
- if (Path.empty())
- error("Unable to find library -l" + Name);
- else
- addFile(Path);
-}
-
// Some command line options or some combinations of them are not allowed.
// This function checks for such errors.
static void checkOptions(opt::InputArgList &Args) {
@@ -128,15 +116,15 @@ static void checkOptions(opt::InputArgLi
// of executables or DSOs. We don't support that since the feature
// does not seem to provide more value than the static archiver.
if (Args.hasArg(OPT_relocatable))
- error("-r option is not supported. Use 'ar' command instead.");
+ fatal("-r option is not supported. Use 'ar' command instead.");
// The MIPS ABI as of 2016 does not support the GNU-style symbol lookup
// table which is a relatively new feature.
if (Config->EMachine == EM_MIPS && Config->GnuHash)
- error("The .gnu.hash section is not compatible with the MIPS target.");
+ fatal("The .gnu.hash section is not compatible with the MIPS target.");
if (Config->EMachine == EM_AMDGPU && !Config->Entry.empty())
- error("-e option is not valid for AMDGPU.");
+ fatal("-e option is not valid for AMDGPU.");
}
static StringRef
@@ -160,8 +148,6 @@ void LinkerDriver::main(ArrayRef<const c
readConfigs(Args);
createFiles(Args);
checkOptions(Args);
- if (HasError)
- return;
switch (Config->EKind) {
case ELF32LEKind:
@@ -177,7 +163,7 @@ void LinkerDriver::main(ArrayRef<const c
link<ELF64BE>(Args);
return;
default:
- error("-m or at least a .o file required");
+ fatal("-m or at least a .o file required");
}
}
@@ -233,7 +219,7 @@ void LinkerDriver::readConfigs(opt::Inpu
if (auto *Arg = Args.getLastArg(OPT_O)) {
StringRef Val = Arg->getValue();
if (Val.getAsInteger(10, Config->Optimize))
- error("Invalid optimization level");
+ fatal("Invalid optimization level");
}
if (auto *Arg = Args.getLastArg(OPT_hash_style)) {
@@ -244,7 +230,7 @@ void LinkerDriver::readConfigs(opt::Inpu
} else if (S == "both") {
Config->GnuHash = true;
} else if (S != "sysv")
- error("Unknown hash style: " + S);
+ fatal("Unknown hash style: " + S);
}
for (auto *Arg : Args.filtered(OPT_undefined))
@@ -255,7 +241,7 @@ void LinkerDriver::createFiles(opt::Inpu
for (auto *Arg : Args) {
switch (Arg->getOption().getID()) {
case OPT_l:
- addLibrary(Arg->getValue());
+ addFile(searchLibrary(Arg->getValue()));
break;
case OPT_INPUT:
case OPT_script:
@@ -282,8 +268,8 @@ void LinkerDriver::createFiles(opt::Inpu
}
}
- if (Files.empty() && !HasError)
- error("no input files.");
+ if (Files.empty())
+ fatal("no input files.");
}
template <class ELFT> void LinkerDriver::link(opt::InputArgList &Args) {
Modified: lld/trunk/ELF/Driver.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Driver.h?rev=259395&r1=259394&r2=259395&view=diff
==============================================================================
--- lld/trunk/ELF/Driver.h (original)
+++ lld/trunk/ELF/Driver.h Mon Feb 1 14:03:53 2016
@@ -27,7 +27,6 @@ class LinkerDriver {
public:
void main(ArrayRef<const char *> Args);
void addFile(StringRef Path);
- void addLibrary(StringRef Name);
private:
void readConfigs(llvm::opt::InputArgList &Args);
Modified: lld/trunk/ELF/DriverUtils.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/DriverUtils.cpp?rev=259395&r1=259394&r2=259395&view=diff
==============================================================================
--- lld/trunk/ELF/DriverUtils.cpp (original)
+++ lld/trunk/ELF/DriverUtils.cpp Mon Feb 1 14:03:53 2016
@@ -66,7 +66,7 @@ opt::InputArgList elf2::parseArgs(llvm::
// Parse options and then do error checking.
opt::InputArgList Args = Table.ParseArgs(Vec, MissingIndex, MissingCount);
if (MissingCount)
- error(Twine("missing arg value for \"") + Args.getArgString(MissingIndex) +
+ fatal(Twine("missing arg value for \"") + Args.getArgString(MissingIndex) +
"\", expected " + Twine(MissingCount) +
(MissingCount == 1 ? " argument.\n" : " arguments"));
@@ -74,7 +74,8 @@ opt::InputArgList elf2::parseArgs(llvm::
for (auto *Arg : Unknowns)
warning("warning: unknown argument: " + Arg->getSpelling());
if (Unknowns.begin() != Unknowns.end())
- error("unknown argument(s) found");
+ fatal("unknown argument(s) found");
+
return Args;
}
@@ -103,7 +104,7 @@ std::string elf2::searchLibrary(StringRe
if (!S.empty())
return S;
}
- return "";
+ fatal("Unable to find library -l" + Path);
}
// Makes a path by concatenating Dir and File.
Modified: lld/trunk/ELF/Error.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Error.cpp?rev=259395&r1=259394&r2=259395&view=diff
==============================================================================
--- lld/trunk/ELF/Error.cpp (original)
+++ lld/trunk/ELF/Error.cpp Mon Feb 1 14:03:53 2016
@@ -24,18 +24,14 @@ void error(const Twine &Msg) {
HasError = true;
}
-bool error(std::error_code EC, const Twine &Prefix) {
- if (!EC)
- return false;
- error(Prefix + ": " + EC.message());
- return true;
+void error(std::error_code EC, const Twine &Prefix) {
+ if (EC)
+ error(Prefix + ": " + EC.message());
}
-bool error(std::error_code EC) {
- if (!EC)
- return false;
- error(EC.message());
- return true;
+void error(std::error_code EC) {
+ if (EC)
+ error(EC.message());
}
void fatal(const Twine &Msg) {
Modified: lld/trunk/ELF/Error.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Error.h?rev=259395&r1=259394&r2=259395&view=diff
==============================================================================
--- lld/trunk/ELF/Error.h (original)
+++ lld/trunk/ELF/Error.h Mon Feb 1 14:03:53 2016
@@ -20,16 +20,13 @@ extern bool HasError;
void warning(const Twine &Msg);
void error(const Twine &Msg);
-bool error(std::error_code EC, const Twine &Prefix);
-bool error(std::error_code EC);
+void error(std::error_code EC, const Twine &Prefix);
+void error(std::error_code EC);
-template <typename T> bool error(const ErrorOr<T> &V, const Twine &Prefix) {
- return error(V.getError(), Prefix);
-}
-
-template <typename T> bool error(const ErrorOr<T> &V) {
- return error(V.getError());
+template <typename T> void error(const ErrorOr<T> &V, const Twine &Prefix) {
+ error(V.getError(), Prefix);
}
+template <typename T> void error(const ErrorOr<T> &V) { error(V.getError()); }
LLVM_ATTRIBUTE_NORETURN void fatal(const Twine &Msg);
void fatal(std::error_code EC, const Twine &Prefix);
@@ -38,7 +35,6 @@ void fatal(std::error_code EC);
template <typename T> void fatal(const ErrorOr<T> &V, const Twine &Prefix) {
fatal(V.getError(), Prefix);
}
-
template <typename T> void fatal(const ErrorOr<T> &V) { fatal(V.getError()); }
} // namespace elf2
Modified: lld/trunk/ELF/LinkerScript.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/LinkerScript.cpp?rev=259395&r1=259394&r2=259395&view=diff
==============================================================================
--- lld/trunk/ELF/LinkerScript.cpp (original)
+++ lld/trunk/ELF/LinkerScript.cpp Mon Feb 1 14:03:53 2016
@@ -178,7 +178,7 @@ void LinkerScript::addFile(StringRef S)
else
Driver->addFile(Saver.save(Config->Sysroot + "/" + S.substr(1)));
} else if (S.startswith("-l")) {
- Driver->addLibrary(S.substr(2));
+ Driver->addFile(searchLibrary(S.substr(2)));
} else if (sys::fs::exists(S)) {
Driver->addFile(S);
} else {
Removed: lld/trunk/test/ELF/driver.test
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/driver.test?rev=259394&view=auto
==============================================================================
--- lld/trunk/test/ELF/driver.test (original)
+++ lld/trunk/test/ELF/driver.test (removed)
@@ -1,9 +0,0 @@
-# RUN: not ld.lld -unknown1 -unknown2 -m foo /no/such/file -lnosuchlib \
-# RUN: 2>&1 | FileCheck %s
-
-# CHECK: warning: unknown argument: -unknown1
-# CHECK: warning: unknown argument: -unknown2
-# CHECK: unknown argument(s) found
-# CHECK: Unknown emulation: foo
-# CHECK: cannot open /no/such/file
-# CHECK: Unable to find library -lnosuchlib
More information about the llvm-commits
mailing list