[libcxx-commits] [libcxx] [libc++] Check for _newlib_version.h instead of picolibc.h (PR #152766)

via libcxx-commits libcxx-commits at lists.llvm.org
Fri Aug 8 10:23:13 PDT 2025


https://github.com/inglorion created https://github.com/llvm/llvm-project/pull/152766

Fixes #152763.

https://github.com/llvm/llvm-project/pull/131921 added some code to pull in a definition of _NEWLIB_VERSION if it exists. It does this by checking __has_include(<picolibc.h>) and including it if so. However, this does not work for systems that have newlib rather than picolibc. This change instead checks for and includes _newlib_version.h, which should work for both newlib and picolibc.

>From b68f3afb9dea56e5059d4c644f2d27d343538628 Mon Sep 17 00:00:00 2001
From: Bob Haarman <llvm at inglorion.net>
Date: Fri, 8 Aug 2025 17:19:21 +0000
Subject: [PATCH] [libc++] Check for _newlib_version.h instead of picolibc.h

Fixes #152763.

https://github.com/llvm/llvm-project/pull/131921 added some code to
pull in a definition of _NEWLIB_VERSION if it exists. It does this
by checking __has_include(<picolibc.h>) and including it if so.
However, this does not work for systems that have newlib rather
than picolibc. This change instead checks for and includes
_newlib_version.h, which should work for both newlib and picolibc.
---
 libcxx/include/__configuration/platform.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libcxx/include/__configuration/platform.h b/libcxx/include/__configuration/platform.h
index f3c199dee172b..c14089b5fc074 100644
--- a/libcxx/include/__configuration/platform.h
+++ b/libcxx/include/__configuration/platform.h
@@ -45,8 +45,8 @@
 // This is required in order for _NEWLIB_VERSION to be defined in places where we use it.
 // TODO: We shouldn't be including arbitrarily-named headers from libc++ since this can break valid
 //       user code. Move code paths that need _NEWLIB_VERSION to another customization mechanism.
-#if __has_include(<picolibc.h>)
-#  include <picolibc.h>
+#if __has_include(<_newlib_version.h>)
+#  include <_newlib_version.h>
 #endif
 
 #ifndef __BYTE_ORDER__



More information about the libcxx-commits mailing list