[ORC] Export __cxa_atexit from the main JITDylib in LLJIT.
authorLang Hames <lhames@gmail.com>
Wed, 1 Apr 2020 22:28:28 +0000 (15:28 -0700)
committerLang Hames <lhames@gmail.com>
Thu, 2 Apr 2020 02:12:08 +0000 (19:12 -0700)
commit0071eaaf0892d7ef733578312abefdcf84311071
tree6805300dab02f8e42d7d6a97678e2425cb350fff
parent32672b877dc1e05bc4489f2f4598f5472bc60576
[ORC] Export __cxa_atexit from the main JITDylib in LLJIT.

Failure to export __cxa_atexit can lead to an attempt to import a definition
from the process itself (if __cxa_atexit is referenced from another JITDylib),
but the process definition will clash with the existing non-exported definition
to produce an unexpected DuplicateDefinitionError.

This patch fixes the immediate issue by exporting __cxa_atexit. It also fixes a
bug where atexit functions in other JITDylibs were not being run by adding a
copy of run_atexits_helper to every JITDylib.

A follow up patch will deal with the bug where definition generators are called
despite a non-exported definition being present.
llvm/lib/ExecutionEngine/Orc/LLJIT.cpp
llvm/test/ExecutionEngine/OrcLazy/global-ctors-and-dtors.ll