[libc-commits] [libc] 8901c1c - [libc] Fix atexit not getting linked on linux (#98537)

via libc-commits libc-commits at lists.llvm.org
Thu Jul 11 14:07:14 PDT 2024


Author: Michael Jones
Date: 2024-07-11T14:07:11-07:00
New Revision: 8901c1c2801018ec3efa042a3acc8bada7b790e3

URL: https://github.com/llvm/llvm-project/commit/8901c1c2801018ec3efa042a3acc8bada7b790e3
DIFF: https://github.com/llvm/llvm-project/commit/8901c1c2801018ec3efa042a3acc8bada7b790e3.diff

LOG: [libc] Fix atexit not getting linked on linux (#98537)

Atexit needs to be linked into exit on linux since atexit defines
__cxa_finalize. This should probably be fixed a different way but this
works for now.

Added: 
    

Modified: 
    libc/src/stdlib/CMakeLists.txt

Removed: 
    


################################################################################
diff  --git a/libc/src/stdlib/CMakeLists.txt b/libc/src/stdlib/CMakeLists.txt
index 5595664e90a56..7b7e55db391fa 100644
--- a/libc/src/stdlib/CMakeLists.txt
+++ b/libc/src/stdlib/CMakeLists.txt
@@ -497,6 +497,16 @@ add_entrypoint_object(
     .exit_handler
 )
 
+list(APPEND exit_deps
+  libc.src.__support.OSUtil.osutil
+  ._Exit
+)
+if (NOT LIBC_TARGET_OS_IS_BAREMETAL)
+  list(APPEND exit_deps
+    .atexit
+  )
+endif()
+
 add_entrypoint_object(
   exit
   SRCS
@@ -504,8 +514,7 @@ add_entrypoint_object(
   HDRS
     exit.h
   DEPENDS
-    ._Exit
-    libc.src.__support.OSUtil.osutil
+    ${exit_deps}
 )
 
 add_entrypoint_object(


        


More information about the libc-commits mailing list