summaryrefslogtreecommitdiffstats
path: root/lld
diff options
context:
space:
mode:
authorRui Ueyama <ruiu@google.com>2016-02-02 22:49:32 +0000
committerRui Ueyama <ruiu@google.com>2016-02-02 22:49:32 +0000
commitb6940115a874b2d23c9c282fcf4b2922183af467 (patch)
tree149a15fe384b3f9db9249b4e8dd36733fe9275a7 /lld
parentcbe392629b55999f2bd37e10048b0e00630a9d0d (diff)
downloadbcm5719-llvm-b6940115a874b2d23c9c282fcf4b2922183af467.tar.gz
bcm5719-llvm-b6940115a874b2d23c9c282fcf4b2922183af467.zip
ELF: Make link() to take an output stream to which error messages are written.
http://reviews.llvm.org/D16668 llvm-svn: 259597
Diffstat (limited to 'lld')
-rw-r--r--lld/ELF/Driver.cpp3
-rw-r--r--lld/ELF/Driver.h3
-rw-r--r--lld/ELF/Error.cpp3
-rw-r--r--lld/ELF/Error.h5
-rw-r--r--lld/include/lld/Driver/Driver.h2
-rw-r--r--lld/lib/Driver/UniversalDriver.cpp2
6 files changed, 13 insertions, 5 deletions
diff --git a/lld/ELF/Driver.cpp b/lld/ELF/Driver.cpp
index 83402065d36..a417204ed08 100644
--- a/lld/ELF/Driver.cpp
+++ b/lld/ELF/Driver.cpp
@@ -29,8 +29,9 @@ using namespace lld::elf2;
Configuration *elf2::Config;
LinkerDriver *elf2::Driver;
-bool elf2::link(ArrayRef<const char *> Args) {
+bool elf2::link(ArrayRef<const char *> Args, raw_ostream &Error) {
HasError = false;
+ ErrorOS = &Error;
Configuration C;
LinkerDriver D;
Config = &C;
diff --git a/lld/ELF/Driver.h b/lld/ELF/Driver.h
index adcf4571375..a8c6e9c4228 100644
--- a/lld/ELF/Driver.h
+++ b/lld/ELF/Driver.h
@@ -14,6 +14,7 @@
#include "lld/Core/LLVM.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Option/ArgList.h"
+#include "llvm/Support/raw_ostream.h"
namespace lld {
namespace elf2 {
@@ -21,7 +22,7 @@ namespace elf2 {
extern class LinkerDriver *Driver;
// Entry point of the ELF linker. Returns true on success.
-bool link(ArrayRef<const char *> Args);
+bool link(ArrayRef<const char *> Args, llvm::raw_ostream &Error = llvm::errs());
class LinkerDriver {
public:
diff --git a/lld/ELF/Error.cpp b/lld/ELF/Error.cpp
index e3add1b4068..4a5b8af191f 100644
--- a/lld/ELF/Error.cpp
+++ b/lld/ELF/Error.cpp
@@ -16,11 +16,12 @@ namespace lld {
namespace elf2 {
bool HasError;
+llvm::raw_ostream *ErrorOS;
void warning(const Twine &Msg) { llvm::errs() << Msg << "\n"; }
void error(const Twine &Msg) {
- llvm::errs() << Msg << "\n";
+ *ErrorOS << Msg << "\n";
HasError = true;
}
diff --git a/lld/ELF/Error.h b/lld/ELF/Error.h
index 546e1d348f2..55782b1f608 100644
--- a/lld/ELF/Error.h
+++ b/lld/ELF/Error.h
@@ -12,10 +12,15 @@
#include "lld/Core/LLVM.h"
+namespace llvm {
+class raw_ostream;
+}
+
namespace lld {
namespace elf2 {
extern bool HasError;
+extern llvm::raw_ostream *ErrorOS;
void warning(const Twine &Msg);
diff --git a/lld/include/lld/Driver/Driver.h b/lld/include/lld/Driver/Driver.h
index f860cb685dc..7b4a381c036 100644
--- a/lld/include/lld/Driver/Driver.h
+++ b/lld/include/lld/Driver/Driver.h
@@ -125,7 +125,7 @@ void link(llvm::ArrayRef<const char *> args);
}
namespace elf2 {
-bool link(llvm::ArrayRef<const char *> args);
+bool link(llvm::ArrayRef<const char *> args, raw_ostream &diag = llvm::errs());
}
/// Driver for lld unit tests
diff --git a/lld/lib/Driver/UniversalDriver.cpp b/lld/lib/Driver/UniversalDriver.cpp
index 6014845777d..8df336575b6 100644
--- a/lld/lib/Driver/UniversalDriver.cpp
+++ b/lld/lib/Driver/UniversalDriver.cpp
@@ -205,7 +205,7 @@ bool UniversalDriver::link(llvm::MutableArrayRef<const char *> args,
case Flavor::old_gnu_ld:
return GnuLdDriver::linkELF(args, diagnostics);
case Flavor::gnu_ld:
- return elf2::link(args);
+ return elf2::link(args, diagnostics);
case Flavor::darwin_ld:
return DarwinLdDriver::linkMachO(args, diagnostics);
case Flavor::win_link:
OpenPOWER on IntegriCloud