[all-commits] [llvm/llvm-project] 421085: [Offload] Change unregister library to use `atexit...

Joseph Huber via All-commits all-commits at lists.llvm.org
Wed Mar 27 12:09:59 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 421085fd740d937559db068c0a1b354b033aca63
      https://github.com/llvm/llvm-project/commit/421085fd740d937559db068c0a1b354b033aca63
  Author: Joseph Huber <huberjn at outlook.com>
  Date:   2024-03-27 (Wed, 27 Mar 2024)

  Changed paths:
    M clang/test/Driver/linker-wrapper-image.c
    M llvm/lib/Frontend/Offloading/OffloadWrapper.cpp

  Log Message:
  -----------
  [Offload] Change unregister library to use `atexit` instead of destructor (#86830)

Summary:
The 'new driver' sets up the lifetime of a registered liftime using
global constructors and destructors. Currently, this is put at priority
1 which isn't strictly conformant as it will conflict with system
utilities. We now use 101 as this is the loweest suggested for
non-system constructors and will still run before user constructors.

Secondly, there were issues with the CUDA runtime when destructed with a
global destructor. Because the global ones are in any order and
potentially run before other things we were hitting an edge case where
the OpenMP runtime was uninitialized *after* `_dl_fini` was called. This
would result in us erroring when we call into a destroyed `libcuda.so`
instance. using `atexit` is what CUDA / HIP use and it prevents this
from happening. Most everything uses `atexit` except system utilities
and because of the constructor priority it will be unregistered *after*
everything else but not after `_fl_fini`.



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list