The ctype mask for newlib/picolibc is fully saturated, so __regex_word
has to overlap with one of the values. This commit uses the same workaround
as bionic did (uint16_t for char_class_type inside regex_traits). It
should be possible to have libc++ provide the default rune table instead,
but that will require a new mechanism to detect newlib inside __config
since the header defining the newlib/picolibc macros has not been included
yet inside __config. This also avoids duplicating the ctype table for
newlib, reducing the global data size.
Details
- Reviewers
michaelplatings philnik ldionne - Group Reviewers
Restricted Project - Commits
- rG455986489750: [libc++] Fix __regex_word value when using newlib/picolibc
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
I think this could be considered an ABI break. I don't see an alternative and given that the static assert has been failing for some time maybe no-one cares. But just in case, would it be worth noting in the release notes?
This is definitely an ABI break, but I'm not sure we care for newlib about that. We don't officially support it and most people that are using newlib + libc++ are probably in an environment where ABI stability isn't much of a concern. It's mostly used in embedded environments, right? It's probably a good idea to add a note to the ABI Affecting Changes section though.
I agree this is technically an ABI break, but I believe there can't be any affected code since the static_assert would have failed previously when including <regex> for a libc++ build with locale support? And even if it is, I would assume this should not matter for newlib where you generally don't have a system libc++.so that is being linked against.
Happy to add a release note though.
The static_assert was only added in LLVM 14, so there could be users that simply haven't upgraded yet. Anyways, I think this patch LGTM with a release note. @jfb @jroelofs it looks like you worked a bit on newlib + libc++ support. Do you have any opinion here? #libc_vendors is anybody using newlib with libc++? If yes, what's your opinion?
The newlib + libc++ work I did for a previous employer (CodeSourcery/MentorGraphics/Siemens) was aimed at building a clang toolchain that could support building for baremetal arm. An ABI break for that environment would not be the end of the world, especially considering those environments cannot afford the code size from locale support. AFAIK, @abidh is still maintaining that work, and would be able to give a definitive answer.
AFAIR, the newlib work @jfb did was for (P)NaCl, which has been deprecated in favor of Wasm [1].
1: https://developer.chrome.com/docs/native-client/nacl-and-pnacl/
My last work on this stuff was before that assert was added so never faced this problem. But I agree with above comment. We could live with such ABI breakage.
Thanks for checking. I guess this is fine from an ABI standpoint, however I do have a problem with us making Newlib-related changes at all since it's not supported. @arichardson How did you come across this issue?
I've got an RFC up to make a step towards testing newlib: https://discourse.llvm.org/t/rfc-testing-of-newlib-picolibc/66509
I was trying to build some C++ code for an embedded target and as part of that tried to build libc++ because I saw there was existing newlib code inside libc++. It had bitrotted a bit due to missing CI, but wasn't too difficult to get working. Looking forward to the CI proposed by @michaelplatings :)
Oh, I had missed this. Thanks.
This LGTM but as I explained on the RFC, we need to add a BuildKite runner, not a BuildBot runner. Libc++ doesn't deal with BuildBot at all anymore. If you do the work, you might as well do it such that it fits nicely with libc++'s CI from the start. Reach out to me on Discord for details.
It's still an ABI break, we just don't expect people to care.