Fix static lib crash by setting top init_priority

Set top init_priority on affecting global variables so that
they will be created firstly and destroyed lastly.

Change-Id: Ied59fbecab66ba8195c4a7a02b6bef9fa2fad3af
Этот коммит содержится в:
Tao Sang
2020-07-04 23:15:03 -04:00
коммит произвёл Tao Sang
родитель 2c551e44cc
Коммит f7bf882981
4 изменённых файлов: 12 добавлений и 8 удалений
+6 -4
Просмотреть файл
@@ -88,10 +88,12 @@ OptionDescriptor OptDescTable[] = {
Any prefix option (-f/-fno, -m/-mno) has no long name, and must have
a value separator if it requires a value.
*/
std::map <std::string, int> OptionNameMap[2];
std::map <std::string, int> NoneSeparatorOptionMap[2];
std::map <std::string, int> FOptionMap; // prefix -f/-fno- options
std::map <std::string, int> MOptionMap; // prefix -m/-mno- options
std::map <std::string, int> OptionNameMap[2] ROCCLR_INIT_PRIORITY(101);
std::map <std::string, int> NoneSeparatorOptionMap[2] ROCCLR_INIT_PRIORITY(101);
// prefix -f/-fno- options
std::map <std::string, int> FOptionMap ROCCLR_INIT_PRIORITY(101);
// prefix -m/-mno- options
std::map <std::string, int> MOptionMap ROCCLR_INIT_PRIORITY(101);
bool setOptionVariable (
OptionDescriptor* oDesc,
+2 -2
Просмотреть файл
@@ -85,8 +85,8 @@ Context* Device::glb_ctx_ = nullptr;
Monitor Device::p2p_stage_ops_("P2P Staging Lock", true);
Memory* Device::p2p_stage_ = nullptr;
amd::Monitor MemObjMap::AllocatedLock_("Guards SVM allocation list");
std::map<uintptr_t, amd::Memory*> MemObjMap::MemObjMap_;
Monitor MemObjMap::AllocatedLock_ ROCCLR_INIT_PRIORITY(101) ("Guards MemObjMap allocation list");
std::map<uintptr_t, amd::Memory*> MemObjMap::MemObjMap_ ROCCLR_INIT_PRIORITY(101);
size_t MemObjMap::size() {
amd::ScopedLock lock(AllocatedLock_);
+2
Просмотреть файл
@@ -71,9 +71,11 @@ typedef __int32 ssize_t;
#if _MSC_VER < 1900
#define snprintf sprintf_s
#endif
#define ROCCLR_INIT_PRIORITY(priority)
#else /*!_WIN32*/
#define SIZE_T_FMT "%zu"
#define PTR_FMT "%p"
#define ROCCLR_INIT_PRIORITY(priority) __attribute__ ((init_priority (priority)))
#endif /*!_WIN32*/
typedef uint32_t cl_mem_fence_flags;
+2 -2
Просмотреть файл
@@ -1430,8 +1430,8 @@ void Image::Format::formatColor(const void* colorRGBA, void* colorFormat) const
}
}
std::map<uintptr_t, uintptr_t> SvmBuffer::Allocated_;
Monitor SvmBuffer::AllocatedLock_("Guards SVM allocation list");
Monitor SvmBuffer::AllocatedLock_ ROCCLR_INIT_PRIORITY(101) ("Guards SVM allocation list");
std::map<uintptr_t, uintptr_t> SvmBuffer::Allocated_ ROCCLR_INIT_PRIORITY(101);
void SvmBuffer::Add(uintptr_t k, uintptr_t v) {
ScopedLock lock(AllocatedLock_);