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

via libc-commits libc-commits at lists.llvm.org
Thu Jul 11 13:23:38 PDT 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-libc

Author: Michael Jones (michaelrj-google)

<details>
<summary>Changes</summary>

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.


---
Full diff: https://github.com/llvm/llvm-project/pull/98537.diff


1 Files Affected:

- (modified) libc/src/stdlib/CMakeLists.txt (+11-2) 


``````````diff
diff --git a/libc/src/stdlib/CMakeLists.txt b/libc/src/stdlib/CMakeLists.txt
index 5595664e90a56..2c13b7e4acdc9 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(

``````````

</details>


https://github.com/llvm/llvm-project/pull/98537


More information about the libc-commits mailing list