[libc-commits] [libc] [libc] Fix atexit not getting linked on linux (PR #98537)
Michael Jones via libc-commits
libc-commits at lists.llvm.org
Thu Jul 11 13:23:07 PDT 2024
https://github.com/michaelrj-google created https://github.com/llvm/llvm-project/pull/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.
>From c464f29e44332ae498006f5fac284fe1a91e4c41 Mon Sep 17 00:00:00 2001
From: Michael Jones <michaelrj at google.com>
Date: Thu, 11 Jul 2024 13:21:45 -0700
Subject: [PATCH] [libc] Fix atexit not getting linked on linux
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.
---
libc/src/stdlib/CMakeLists.txt | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
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(
More information about the libc-commits
mailing list