[libc-commits] [libc] [libc] Avoid the atexit and exit_handler dependency for exit (PR #98121)

Petr Hosek via libc-commits libc-commits at lists.llvm.org
Tue Jul 9 00:29:29 PDT 2024


https://github.com/petrhosek created https://github.com/llvm/llvm-project/pull/98121

These are not required and without these dependencies, we would wound up with an unresolved reference to __cxa_finalize, which can be provided by the vendor making this compatible with baremetal.

>From b508f490de82988ab1045a2146cdbd1a88fe92cd Mon Sep 17 00:00:00 2001
From: Petr Hosek <phosek at google.com>
Date: Tue, 9 Jul 2024 00:20:01 -0700
Subject: [PATCH] [libc] Avoid the atexit and exit_handler dependency for exit

These are not required and without these dependencies, we would wound up
with an unresolved reference to __cxa_finalize, which can be provided by
the vendor making this compatible with baremetal.
---
 libc/config/baremetal/arm/entrypoints.txt   | 1 +
 libc/config/baremetal/riscv/entrypoints.txt | 1 +
 libc/src/stdlib/CMakeLists.txt              | 2 --
 3 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/libc/config/baremetal/arm/entrypoints.txt b/libc/config/baremetal/arm/entrypoints.txt
index 7705e971aed3e..b4ad1027cacd4 100644
--- a/libc/config/baremetal/arm/entrypoints.txt
+++ b/libc/config/baremetal/arm/entrypoints.txt
@@ -176,6 +176,7 @@ set(TARGET_LIBC_ENTRYPOINTS
     libc.src.stdlib.bsearch
     libc.src.stdlib.calloc
     libc.src.stdlib.div
+    libc.src.stdlib.exit
     libc.src.stdlib.free
     libc.src.stdlib.freelist_malloc
     libc.src.stdlib.labs
diff --git a/libc/config/baremetal/riscv/entrypoints.txt b/libc/config/baremetal/riscv/entrypoints.txt
index 4d020fd8a1758..94d93522dd325 100644
--- a/libc/config/baremetal/riscv/entrypoints.txt
+++ b/libc/config/baremetal/riscv/entrypoints.txt
@@ -172,6 +172,7 @@ set(TARGET_LIBC_ENTRYPOINTS
     libc.src.stdlib.bsearch
     libc.src.stdlib.calloc
     libc.src.stdlib.div
+    libc.src.stdlib.exit
     libc.src.stdlib.free
     libc.src.stdlib.freelist_malloc
     libc.src.stdlib.labs
diff --git a/libc/src/stdlib/CMakeLists.txt b/libc/src/stdlib/CMakeLists.txt
index 677bf358c82c4..5595664e90a56 100644
--- a/libc/src/stdlib/CMakeLists.txt
+++ b/libc/src/stdlib/CMakeLists.txt
@@ -505,9 +505,7 @@ add_entrypoint_object(
     exit.h
   DEPENDS
     ._Exit
-    .atexit
     libc.src.__support.OSUtil.osutil
-    .exit_handler
 )
 
 add_entrypoint_object(



More information about the libc-commits mailing list