diff options
author | serge-sans-paille <sguelton@redhat.com> | 2020-10-19 13:19:52 +0200 |
---|---|---|
committer | serge-sans-paille <sguelton@redhat.com> | 2020-11-03 11:01:29 +0100 |
commit | cfc32267e27f77211ee5eb6e30c52ab2c7740e6e (patch) | |
tree | 54ae7faabdeb831bf136f040b7efe659aac6ccf0 /lld/include | |
parent | 90131e3ecb753c38cc99e060aa69ca1766d96432 (diff) | |
download | llvm-cfc32267e27f77211ee5eb6e30c52ab2c7740e6e.tar.gz |
Provide a hook to customize missing library error handling
Make it possible for lld users to provide a custom script that would help to
find missing libraries. A possible scenario could be:
% clang /tmp/a.c -fuse-ld=lld -loauth -Wl,--error-handling-script=/tmp/addLibrary.py
unable to find library -loauth
looking for relevant packages to provides that library
liboauth-0.9.7-4.el7.i686
liboauth-devel-0.9.7-4.el7.i686
liboauth-0.9.7-4.el7.x86_64
liboauth-devel-0.9.7-4.el7.x86_64
pix-1.6.1-3.el7.x86_64
Where addLibrary would be called with the missing library name as first argument
(in that case addLibrary.py oauth)
Differential Revision: https://reviews.llvm.org/D87758
Diffstat (limited to 'lld/include')
-rw-r--r-- | lld/include/lld/Common/ErrorHandler.h | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/lld/include/lld/Common/ErrorHandler.h b/lld/include/lld/Common/ErrorHandler.h index 79a5940823bd..64f363014400 100644 --- a/lld/include/lld/Common/ErrorHandler.h +++ b/lld/include/lld/Common/ErrorHandler.h @@ -89,11 +89,14 @@ extern llvm::raw_ostream *stderrOS; llvm::raw_ostream &outs(); llvm::raw_ostream &errs(); +enum class ErrorTag { LibNotFound }; + class ErrorHandler { public: uint64_t errorCount = 0; uint64_t errorLimit = 20; StringRef errorLimitExceededMsg = "too many errors emitted, stopping now"; + StringRef errorHandlingScript; StringRef logName = "lld"; bool exitEarly = true; bool fatalWarnings = false; @@ -103,6 +106,7 @@ public: std::function<void()> cleanupCallback; void error(const Twine &msg); + void error(const Twine &msg, ErrorTag tag, ArrayRef<StringRef> args); LLVM_ATTRIBUTE_NORETURN void fatal(const Twine &msg); void log(const Twine &msg); void message(const Twine &msg); @@ -126,6 +130,9 @@ private: ErrorHandler &errorHandler(); inline void error(const Twine &msg) { errorHandler().error(msg); } +inline void error(const Twine &msg, ErrorTag tag, ArrayRef<StringRef> args) { + errorHandler().error(msg, tag, args); +} inline LLVM_ATTRIBUTE_NORETURN void fatal(const Twine &msg) { errorHandler().fatal(msg); } |