aboutsummaryrefslogtreecommitdiff
path: root/lld/MinGW/Driver.cpp
diff options
context:
space:
mode:
authorAlexandre Ganea <alex_toresh@yahoo.fr>2023-06-19 07:32:34 -0400
committerAlexandre Ganea <alex_toresh@yahoo.fr>2023-06-19 07:35:11 -0400
commit6f2e92c10cebca51f9bc98b99fa3b5583ff396c4 (patch)
treeca95b464ea79937019f1a23928ade2f10679c49b /lld/MinGW/Driver.cpp
parent9ef73f2f58ecfce21bdeb27f68b224d9be97cfe6 (diff)
downloadllvm-6f2e92c10cebca51f9bc98b99fa3b5583ff396c4.zip
llvm-6f2e92c10cebca51f9bc98b99fa3b5583ff396c4.tar.gz
llvm-6f2e92c10cebca51f9bc98b99fa3b5583ff396c4.tar.bz2
Re-land [LLD] Allow usage of LLD as a library
This reverts commit aa495214b39d475bab24b468de7a7c676ce9e366. As discussed in https://github.com/llvm/llvm-project/issues/53475 this patch allows for using LLD-as-a-lib. It also lets clients link only the drivers that they want (see unit tests). This also adds the unit test infra as in the other LLVM projects. Among the test coverage, I've added the original issue from @krzysz00, see: https://github.com/ROCmSoftwarePlatform/D108850-lld-bug-reproduction Important note: this doesn't allow (yet) linking in parallel. This will come a bit later hopefully, in subsequent patches, for COFF at least. Differential revision: https://reviews.llvm.org/D119049
Diffstat (limited to 'lld/MinGW/Driver.cpp')
-rw-r--r--lld/MinGW/Driver.cpp14
1 files changed, 11 insertions, 3 deletions
diff --git a/lld/MinGW/Driver.cpp b/lld/MinGW/Driver.cpp
index c5a32c3..a5b83d2 100644
--- a/lld/MinGW/Driver.cpp
+++ b/lld/MinGW/Driver.cpp
@@ -157,11 +157,17 @@ searchLibrary(StringRef name, ArrayRef<StringRef> searchPaths, bool bStatic) {
return "";
}
+namespace lld {
+namespace coff {
+bool link(ArrayRef<const char *> argsArr, llvm::raw_ostream &stdoutOS,
+ llvm::raw_ostream &stderrOS, bool exitEarly, bool disableOutput);
+}
+
+namespace mingw {
// Convert Unix-ish command line arguments to Windows-ish ones and
// then call coff::link.
-bool mingw::link(ArrayRef<const char *> argsArr, llvm::raw_ostream &stdoutOS,
- llvm::raw_ostream &stderrOS, bool exitEarly,
- bool disableOutput) {
+bool link(ArrayRef<const char *> argsArr, llvm::raw_ostream &stdoutOS,
+ llvm::raw_ostream &stderrOS, bool exitEarly, bool disableOutput) {
auto *ctx = new CommonLinkerContext;
ctx->e.initialize(stdoutOS, stderrOS, exitEarly, disableOutput);
@@ -482,3 +488,5 @@ bool mingw::link(ArrayRef<const char *> argsArr, llvm::raw_ostream &stdoutOS,
return coff::link(vec, stdoutOS, stderrOS, exitEarly, disableOutput);
}
+} // namespace mingw
+} // namespace lld