HomePhabricator

[ORC] Export __cxa_atexit from the main JITDylib in LLJIT.

Authored by lhames on Apr 1 2020, 3:28 PM.

Description

[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.