1fanwang opened a new pull request, #50998: URL: https://github.com/apache/arrow/pull/50998
### Rationale for this change Building Arrow C++ against the macOS 12.3 SDK fails: ``` error: no member named 'log2p1' in namespace 'std' ``` Apple clang shipped `std::log2p1`, the pre-standard name for `std::bit_width`, in older SDKs. Arrow keeps a workaround that calls it when `__cpp_lib_bitops` is undefined, but that is the wrong feature-test macro. It covers popcount, rotl and friends, while bit_width and has_single_bit are covered by `__cpp_lib_int_pow2`. Probing both SDKs shows why that matters: | SDK | bitops | int_pow2 | bit_width | log2p1 | |---|---|---|---|---| | 11.3 | undefined | undefined | absent | present | | 12.3 | undefined | 202002 | present | absent | `__cpp_lib_bitops` is undefined on both, so on 12.3 the guard selects the one name that is missing. Before this change Arrow cannot be built on that SDK; after it, it builds. Closes #49841. ### What changes are included in this PR? Switch the discriminator to `__cpp_lib_int_pow2` at the five sites using this workaround, keeping the `__apple_build_version__` condition and every fallback branch unchanged. One of the five guards has_single_bit rather than bit_width. It still compiled on 12.3 because its fallback is a manual power-of-two check, but the macro is wrong there for the same reason, so it is corrected too. ### Are these changes tested? Each affected translation unit was compiled against both SDKs, before and after. ```console $ curl -fsSL -o s.tar.xz https://github.com/alexey-lysiuk/macos-sdk/releases/download/12.3/MacOSX12.3.tar.xz $ mkdir /tmp/s && tar -xJf s.tar.xz -C /tmp/s && cd cpp/src $ CC="clang++ -std=gnu++20 -isysroot /tmp/s/MacOSX12.3.sdk -I . -fsyntax-only" $ F=parquet/encoder.cc $ git switch main && $CC $F ./arrow/util/bit_util.h:149:15: error: no member named 'log2p1' in namespace 'std' 2 errors generated. $ git switch - && $CC $F && echo compiled successfully compiled successfully ``` All five compile on both SDKs after the change. Compiling on 11.3 is itself proof the log2p1 branch is still selected there, since bit_width does not exist in that SDK. The covering test target builds and passes on this machine's current SDK: ``` [ PASSED ] 204 tests. ``` ### Are there any user-facing changes? No API change. Arrow C++ now builds against macOS SDK 12.3 and later. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
