tra added a comment.
In https://reviews.llvm.org/D49763#1174283, @joerg wrote:
> Can this ever end up in a shared library? If yes, please use the normal logic
> for creating a global destructor. atexit is not very friendly to dlopen...
Yes, it can end up in a shared library. What would be the normal logic in this
case?
We used to use regular global destructor, but has even worse issues. Alas,
NVIDIA provides no documentation to how compiler-generated glue is expected to
interact with CUDA runtime, so we need to guess what it wants.
NVCC-generated glue generates call to atexit(). If we use global destructors,
then by the time they are executed, nvidia's runtime has already been
deinitialized and our attempt to call it causes the crash.
Deregistering fatbin from atexit() works better, but apparently we still race
with the runtime. calling atexit() before we register the fatbin appears to
work for all combinations of {static/dynamic, kernel/runtime}.
https://reviews.llvm.org/D49763
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits