Problem
The file src/s2/util/endian/endian.h in s2geometry v0.13.1 uses:
absl::byteswap() (lines 28-29)
absl::endian::native and absl::endian::little (lines 57, 114-118)
These APIs were only added in abseil LTS 2025.01.27. When building with older abseil versions (which many package managers and CI systems still provide), compilation fails with:
error: 'byteswap' is not a member of 'absl'
error: 'absl::endian' has not been declared
Environment
- s2geometry version: v0.13.1
- abseil version: older than LTS 2025.01.27 (e.g., versions provided by vcpkg in DuckDB extension CI)
- Build system: CMake with vcpkg
Reproduction
Build s2geometry v0.13.1 with an abseil version older than LTS 2025.01.27.
Suggested Fix
Add fallback implementations for older abseil versions using compiler intrinsics (__builtin_bswap16/32/64 for GCC/Clang) and compile-time endianness detection via __BYTE_ORDER__ macros.
This would maintain backwards compatibility with older abseil versions while still working with newer ones.
Related
This issue was discovered while upgrading s2geometry in the duckdb-geography extension.