[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 14:05:06 PDT 2024
https://github.com/michaelrj-google updated https://github.com/llvm/llvm-project/pull/98537
>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 1/2] [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(
>From 2c1f298d6f3b9a28dcfb98cbf33758ea2d783887 Mon Sep 17 00:00:00 2001
From: Michael Jones <michaelrj at google.com>
Date: Thu, 11 Jul 2024 14:03:54 -0700
Subject: [PATCH 2/2] uncomment list adding
---
libc/src/stdlib/CMakeLists.txt | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/libc/src/stdlib/CMakeLists.txt b/libc/src/stdlib/CMakeLists.txt
index 2c13b7e4acdc9..7b7e55db391fa 100644
--- a/libc/src/stdlib/CMakeLists.txt
+++ b/libc/src/stdlib/CMakeLists.txt
@@ -502,9 +502,9 @@ list(APPEND exit_deps
._Exit
)
if (NOT LIBC_TARGET_OS_IS_BAREMETAL)
- # list(APPEND exit_deps
- # .atexit
- # )
+ list(APPEND exit_deps
+ .atexit
+ )
endif()
add_entrypoint_object(
More information about the libc-commits
mailing list