[libc-commits] [libc] [libc] Avoid host header collisions in full builds (-nostdinc) (PR #187025)
via libc-commits
libc-commits at lists.llvm.org
Tue Mar 17 08:07:23 PDT 2026
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-libc
Author: Jeff Bailey (kaladron)
<details>
<summary>Changes</summary>
When building the full library with -nostdinc, directly including <stdint.h> may pull in host or compiler-provided headers that collide with LLVM-libc's local macro definitions. Switch to using our internal stdint-macros.h when LIBC_FULL_BUILD is enabled.
Additionally, declare aligned_alloc with noexcept in C++ to match common C library declarations and avoid fatal type specification mismatches during sysroot builds.
---
Full diff: https://github.com/llvm/llvm-project/pull/187025.diff
2 Files Affected:
- (modified) libc/hdr/func/aligned_alloc.h (+4)
- (modified) libc/hdr/stdint_proxy.h (+4)
``````````diff
diff --git a/libc/hdr/func/aligned_alloc.h b/libc/hdr/func/aligned_alloc.h
index b3436dfee1f23..3c197f4671a76 100644
--- a/libc/hdr/func/aligned_alloc.h
+++ b/libc/hdr/func/aligned_alloc.h
@@ -11,7 +11,11 @@
#ifdef LIBC_FULL_BUILD
#include "hdr/types/size_t.h"
+#ifdef __cplusplus
+extern "C" void *aligned_alloc(size_t, size_t) noexcept;
+#else
extern "C" void *aligned_alloc(size_t, size_t);
+#endif
#else // Overlay mode
diff --git a/libc/hdr/stdint_proxy.h b/libc/hdr/stdint_proxy.h
index 8e815679a4e24..d5c600d5a28bf 100644
--- a/libc/hdr/stdint_proxy.h
+++ b/libc/hdr/stdint_proxy.h
@@ -13,6 +13,10 @@
// that is `libc.include.stdint` is added to the dependency of all targets
// that use <stdint.h> header.
+#ifdef LIBC_FULL_BUILD
+#include "include/llvm-libc-macros/stdint-macros.h"
+#else
#include <stdint.h>
+#endif
#endif // LLVM_LIBC_HDR_STDINT_PROXY_H
``````````
</details>
https://github.com/llvm/llvm-project/pull/187025
More information about the libc-commits
mailing list