From db2e0e7b10ac0a9931d1e0a43820bb349c96fd25 Mon Sep 17 00:00:00 2001 From: Bob Haarman Date: Fri, 8 Aug 2025 17:19:21 +0000 Subject: [PATCH] [libc++] Check for _newlib_version.h in addition to 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() and including it if so. However, this does not work for systems that have newlib rather than picolibc. With this change, we check for either picolibc.h or _newlib_version.h, which works for both newlib and picolibc. --- libcxx/include/__configuration/platform.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libcxx/include/__configuration/platform.h b/libcxx/include/__configuration/platform.h index f3c199dee172b..25e2cf4d3edd2 100644 --- a/libcxx/include/__configuration/platform.h +++ b/libcxx/include/__configuration/platform.h @@ -45,7 +45,9 @@ // 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() +#if __has_include(<_newlib_version.h>) +# include <_newlib_version.h> +#elif __has_include() # include #endif