Add `_LIBCPP_HAS_BITINT` to libcxx
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
https://github.com/llvm/llvm-project/pull/160679 This PR/commit uses `_BitInt` for the implementation of `size_t bitset<_Size>::count()` in `` when using a "Clang-based" compiler
I was compiling libcxx 22.1.1 (from `llvmorg-22.1.1`) with a fork of clang 19.1.0 that targets the eZ80. We have not implemented `_BitInt` for the eZ80 target, so I get a compiler error
```c++
/home/zerico/programming/toolchain/src/libcxx/include/bitset:884:53: error: _BitInt is not supported on this target
884 | return __builtin_popcountg(static_cast(__base::__first_));
| ^
```
My proposal is to add a `_LIBCPP_HAS_BITINT` or etc to `<__config>`/`__config_site.in`. I would imagine it is possible that other niche clang/llvm targets may not have `_BitInt` implemented.
Otherwise, it is trivial for someone to manually `#ifndef _MY_TARGET` to use the generic implementation of `size_t bitset<_Size>::count()` if their target does not support `_BitInt`
https://github.com/llvm/llvm-project/blob/6dabcef0b3ffa0beadd426e0fd56c61c45b5b396/libcxx/include/bitset#L878-L890
Contributor guide
Research direction
Read libcxx/include/bitset around lines 878-890, then inspect <__config> and __config_site.in for existing target capability checks. Trace how libcxx decides whether _BitInt is available, and verify that bitset::count() can compile for a Clang target without _BitInt while retaining the current implementation where it is supported.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 64/100