summaryrefslogtreecommitdiff
path: root/lld/Common
diff options
context:
space:
mode:
authorAlexandre Ganea <alexandre.ganea@legionlabs.com>2022-02-08 17:36:14 -0500
committerAlexandre Ganea <alexandre.ganea@legionlabs.com>2022-02-08 19:12:15 -0500
commit1e661e583d8406d5fce5269e803b287987332831 (patch)
treefa78ce596c51255317b9cc4b1f878a43d1cbda2a /lld/Common
parent9b81d2fae8c05ea611578137101e46a7b61fbaed (diff)
downloadllvm-1e661e583d8406d5fce5269e803b287987332831.tar.gz
[MLIR] Temporary workaround for calling the LLD ELF driver as-a-lib
This fixes the situation described in https://github.com/llvm/llvm-project/issues/53475 with a repro exposed by https://github.com/ROCmSoftwarePlatform/D108850-lld-bug-reproduction This is purposely just a workaround to unblock users. This could be transplanted to the release/14.x branch if need be. A proper fix will later be provided in https://reviews.llvm.org/D119049. Differential Revision: https://reviews.llvm.org/D119277
Diffstat (limited to 'lld/Common')
-rw-r--r--lld/Common/CommonLinkerContext.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/lld/Common/CommonLinkerContext.cpp b/lld/Common/CommonLinkerContext.cpp
index 50ccbb37c796..90f0f942a38c 100644
--- a/lld/Common/CommonLinkerContext.cpp
+++ b/lld/Common/CommonLinkerContext.cpp
@@ -7,6 +7,7 @@
//===----------------------------------------------------------------------===//
#include "lld/Common/CommonLinkerContext.h"
+#include "lld/Common/Driver.h"
#include "lld/Common/ErrorHandler.h"
#include "lld/Common/Memory.h"
@@ -43,3 +44,11 @@ void CommonLinkerContext::destroy() {
return;
delete lctx;
}
+
+// Temporary API that forces global state cleanup between explicit calls to
+// drivers. See discussion in https://reviews.llvm.org/D119049.
+void lld::cleanup() {
+ // Delete the global context and clear the global context pointer, so that it
+ // cannot be accessed anymore.
+ CommonLinkerContext::destroy();
+}