[LIBOMPTARGET]Fix PR44933: fix crash because of the too early deinitialization of...
authorAlexey Bataev <a.bataev@hotmail.com>
Wed, 19 Feb 2020 14:41:50 +0000 (09:41 -0500)
committerAlexey Bataev <a.bataev@hotmail.com>
Tue, 25 Feb 2020 20:54:37 +0000 (15:54 -0500)
commit63cef621f954eb87c494021725f4eeac89132d16
treec0cf67a9f0c871bc583820e05abd69dd9ba14caa
parentc5ce6d8b561a5b2790a56803df24f800df7a76a8
[LIBOMPTARGET]Fix PR44933: fix crash because of the too early deinitialization of libomptarget.

Summary:
Instead of using global variables with unpredicted time of
deinitialization, use dynamically allocated variables with functions
explicitly marked as global constructor/destructor and priority. This
allows to prevent the crash because of the incorrect order of dynamic
libraries deinitialization.

Reviewers: grokos, hfinkel

Subscribers: caomhin, kkwli0, openmp-commits

Tags: #openmp

Differential Revision: https://reviews.llvm.org/D74837
openmp/libomptarget/src/api.cpp
openmp/libomptarget/src/device.cpp
openmp/libomptarget/src/interface.cpp
openmp/libomptarget/src/omptarget.cpp
openmp/libomptarget/src/rtl.cpp
openmp/libomptarget/src/rtl.h
openmp/libomptarget/test/offloading/dynamic_module_load.c [new file with mode: 0644]