[libcxx-commits] [libcxx] [libc++] Guard additional headers with _LIBCPP_HAS_LOCALIZATION (PR #131921)
Louis Dionne via libcxx-commits
libcxx-commits at lists.llvm.org
Wed Mar 26 12:32:16 PDT 2025
ldionne wrote:
I have this patch, but I actually struggle to see how that would fix anything since all of the failing tests show an explicit `-include <picolibc.h>` on the compiler command-line. So they're already including `<picolibc.h>` first thing in the compilation:
```diff
diff --git a/libcxx/include/__configuration/platform.h b/libcxx/include/__configuration/platform.h
index 8d0f8f63f521..e2f8353cf7d5 100644
--- a/libcxx/include/__configuration/platform.h
+++ b/libcxx/include/__configuration/platform.h
@@ -42,6 +42,13 @@
# endif
#endif
+// 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 defined(__linux__) && __has_include(<picolibc.h>)
+# include <picolibc.h>
+#endif
+
#ifndef __BYTE_ORDER__
# error \
"Your compiler doesn't seem to define __BYTE_ORDER__, which is required by libc++ to know the endianness of your target platform"
diff --git a/libcxx/test/configs/armv7m-picolibc-libc++.cfg.in b/libcxx/test/configs/armv7m-picolibc-libc++.cfg.in
index 7aedfde89916..9bff5021494e 100644
--- a/libcxx/test/configs/armv7m-picolibc-libc++.cfg.in
+++ b/libcxx/test/configs/armv7m-picolibc-libc++.cfg.in
@@ -11,10 +11,6 @@ config.substitutions.append(('%{compile_flags}',
# "large atomic operation may incur significant performance penalty; the
# access size (4 bytes) exceeds the max lock-free size (0 bytes)"
' -Wno-atomic-alignment'
-
- # Various libc++ headers check for the definition of _NEWLIB_VERSION
- # which for picolibc is defined in picolibc.h.
- ' -include picolibc.h'
))
config.substitutions.append(('%{link_flags}',
'-nostdlib -nostdlib++ -L %{lib-dir} -lc++ -lc++abi'
```
Plus, as I said earlier, I don't think that patch is really the right thing to do.
https://github.com/llvm/llvm-project/pull/131921
More information about the libcxx-commits
mailing list