Skip to content

[libc] Use <assert.h> in overlay mode for LIBC_ASSERT #99875

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 22, 2024

Conversation

jhuber6
Copy link
Contributor

@jhuber6 jhuber6 commented Jul 22, 2024

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

@llvmbot llvmbot added the libc label Jul 22, 2024
@llvmbot
Copy link
Member

llvmbot commented Jul 22, 2024

@llvm/pr-subscribers-libc

Author: Joseph Huber (jhuber6)

Changes

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


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

1 Files Affected:

  • (modified) libc/src/__support/libc_assert.h (+3-1)
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)) {                                                             \

Copy link
Contributor

@lntue lntue left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Look like you will need to update some missing include headers with this change:

In file included from /usr/local/google/home/lntue/experiment/llvm-project/libc/src/__support/threads/linux/mutex.h:17:
/usr/local/google/home/lntue/experiment/llvm-project/libc/src/__support/threads/linux/raw_mutex.h:108:9: error: use of undeclared identifier 'LIBC_LIKELY'
    if (LIBC_LIKELY(try_lock()))

@jhuber6
Copy link
Contributor Author

jhuber6 commented Jul 22, 2024

No clue why that's not present after this change.

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

jhuber6 commented Jul 22, 2024

Should be fixed, something was picking it up accidentally.

Copy link
Contributor

@lntue lntue left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That fixes it. Thanks!

@jhuber6 jhuber6 merged commit 65825cd into llvm:main Jul 22, 2024
4 of 5 checks passed
yuxuanchen1997 pushed a commit that referenced this pull request Jul 25, 2024
Summary:
This uses `internal::exit` which is not built in overlay mode, leading
to linker errors. Fix this to just use `assert.h`.

Test Plan: 

Reviewers: 

Subscribers: 

Tasks: 

Tags: 


Differential Revision: https://phabricator.intern.facebook.com/D60251138
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants