[libc-commits] [libc] bed77a1 - [libc] Avoid host header collisions in full builds (-nostdinc) (#187025)

via libc-commits libc-commits at lists.llvm.org
Tue Mar 17 09:12:12 PDT 2026


Author: Jeff Bailey
Date: 2026-03-17T16:12:05Z
New Revision: bed77a1d9bf40c1ab0a55572df148e5a8c44e975

URL: https://github.com/llvm/llvm-project/commit/bed77a1d9bf40c1ab0a55572df148e5a8c44e975
DIFF: https://github.com/llvm/llvm-project/commit/bed77a1d9bf40c1ab0a55572df148e5a8c44e975.diff

LOG: [libc] Avoid host header collisions in full builds (-nostdinc) (#187025)

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.

Added: 
    

Modified: 
    libc/hdr/func/aligned_alloc.h
    libc/hdr/stdint_proxy.h

Removed: 
    


################################################################################
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


        


More information about the libc-commits mailing list