ELF: Make link() to take an output stream to which error messages are written.
http://reviews.llvm.org/D16668 llvm-svn: 259597
This commit is contained in:
parent
cbe392629b
commit
b6940115a8
|
@ -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;
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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:
|
||||
|
|
Loading…
Reference in New Issue