[libc-commits] [libc] [libc] Use `<assert.h>` in overlay mode for LIBC_ASSERT (PR #99875)

Joseph Huber via libc-commits libc-commits at lists.llvm.org
Mon Jul 22 06:51:11 PDT 2024


https://github.com/jhuber6 created https://github.com/llvm/llvm-project/pull/99875

Summary:
This uses `internal::exit` which is not built in overlay mode, leading
to linker errors. Fix this to just use `assert.h`.


>From a5bb845a33ca2f101c8cd71c7aaf1aa5728c1d89 Mon Sep 17 00:00:00 2001
From: Joseph Huber <huberjn at outlook.com>
Date: Mon, 22 Jul 2024 08:49:43 -0500
Subject: [PATCH] [libc] Use `<assert.h>` in overlay mode for LIBC_ASSERT

Summary:
This uses `internal::exit` which is not built in overlay mode, leading
to linker errors. Fix this to just use `assert.h`.
---
 libc/src/__support/libc_assert.h | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/libc/src/__support/libc_assert.h b/libc/src/__support/libc_assert.h
index e3235199780c2..72a59f9c0e578 100644
--- a/libc/src/__support/libc_assert.h
+++ b/libc/src/__support/libc_assert.h
@@ -10,7 +10,7 @@
 #define LLVM_LIBC_SRC___SUPPORT_LIBC_ASSERT_H
 
 #include "src/__support/macros/config.h"
-#ifdef LIBC_COPT_USE_C_ASSERT
+#if defined(LIBC_COPT_USE_C_ASSERT) || !defined(LIBC_FULL_BUILD)
 
 // The build is configured to just use the public <assert.h> API
 // for libc's internal assertions.
@@ -69,6 +69,8 @@ LIBC_INLINE void report_assertion_failure(const char *assertion,
 #define __LIBC_MACRO_TO_STR_INDIR(y) __LIBC_MACRO_TO_STR(y)
 #define __LIBC_LINE_STR__ __LIBC_MACRO_TO_STR_INDIR(__LINE__)
 
+#ifdef 
+
 #define LIBC_ASSERT(COND)                                                      \
   do {                                                                         \
     if (!(COND)) {                                                             \



More information about the libc-commits mailing list