Skip to content

[LLVM] Manually prefix ManagedStatic static vars #38488

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions deps/llvm.mk
Original file line number Diff line number Diff line change
Expand Up @@ -520,6 +520,7 @@ endif # LLVM_VER 11.0

# Add a JL prefix to the version map. DO NOT REMOVE
ifneq ($(LLVM_VER), svn)
$(eval $(call LLVM_PATCH,llvm-jl-prefix-static-variables))
$(eval $(call LLVM_PATCH,llvm7-symver-jlprefix))
endif

Expand Down
82 changes: 82 additions & 0 deletions deps/patches/llvm-jl-prefix-static-variables.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
From ea445dcaab3d5d50a7042a49366e25f704a585f4 Mon Sep 17 00:00:00 2001
From: Valentin Churavy <[email protected]>
Date: Wed, 18 Nov 2020 12:49:56 -0500
Subject: [PATCH] manually prefix global variables

---
llvm/lib/Support/ManagedStatic.cpp | 28 ++++++++++++++--------------
1 file changed, 14 insertions(+), 14 deletions(-)

diff --git llvm/lib/Support/ManagedStatic.cpp llvm/lib/Support/ManagedStatic.cpp
index 053493f72fb..881301c827a 100644
--- llvm/lib/Support/ManagedStatic.cpp
+++ llvm/lib/Support/ManagedStatic.cpp
@@ -17,17 +17,17 @@
#include <mutex>
using namespace llvm;

-static const ManagedStaticBase *StaticList = nullptr;
-static std::recursive_mutex *ManagedStaticMutex = nullptr;
-static llvm::once_flag mutex_init_flag;
+static const ManagedStaticBase *JL_StaticList = nullptr;
+static std::recursive_mutex *JL_ManagedStaticMutex = nullptr;
+static llvm::once_flag JL_mutex_init_flag;

static void initializeMutex() {
- ManagedStaticMutex = new std::recursive_mutex();
+ JL_ManagedStaticMutex = new std::recursive_mutex();
}

static std::recursive_mutex *getManagedStaticMutex() {
- llvm::call_once(mutex_init_flag, initializeMutex);
- return ManagedStaticMutex;
+ llvm::call_once(JL_mutex_init_flag, initializeMutex);
+ return JL_ManagedStaticMutex;
}

void ManagedStaticBase::RegisterManagedStatic(void *(*Creator)(),
@@ -43,8 +43,8 @@ void ManagedStaticBase::RegisterManagedStatic(void *(*Creator)(),
DeleterFn = Deleter;

// Add to list of managed statics.
- Next = StaticList;
- StaticList = this;
+ Next = JL_StaticList;
+ JL_StaticList = this;
}
} else {
assert(!Ptr && !DeleterFn && !Next &&
@@ -53,17 +53,17 @@ void ManagedStaticBase::RegisterManagedStatic(void *(*Creator)(),
DeleterFn = Deleter;

// Add to list of managed statics.
- Next = StaticList;
- StaticList = this;
+ Next = JL_StaticList;
+ JL_StaticList = this;
}
}

void ManagedStaticBase::destroy() const {
assert(DeleterFn && "ManagedStatic not initialized correctly!");
- assert(StaticList == this &&
+ assert(JL_StaticList == this &&
"Not destroyed in reverse order of construction?");
// Unlink from list.
- StaticList = Next;
+ JL_StaticList = Next;
Next = nullptr;

// Destroy memory.
@@ -78,6 +78,6 @@ void ManagedStaticBase::destroy() const {
void llvm::llvm_shutdown() {
std::lock_guard<std::recursive_mutex> Lock(*getManagedStaticMutex());

- while (StaticList)
- StaticList->destroy();
+ while (JL_StaticList)
+ JL_StaticList->destroy();
}
--
2.29.2