Open pgoodman opened 3 years ago
I think the problem is that GCC doesn't support __builtin_rotateright{8,16,32,64}
. It isn't mentioned in the GCC docs AFAICT. Check out the godbolt links below
I hacked build.sh by putting CC=clang-11 CXX=clang++-11
in front of the cmake command and that did the trick.
From another project we worked around this issue with the following functions:
/// Rotate `val` to the right `rot` positions.
inline static uint64_t RotateRight64(uint64_t val, unsigned rot) {
// NOTE: if we ever move to C++20, there are builtin rotation functions in the
// standard library, which we should use instead.
#ifdef __has_builtin
# if !__has_builtin(__builtin_rotateright64)
# define HYDE_NEEDS_ROR64 1
# else
# define HYDE_NEEDS_ROR64 0
# endif
#elif !defined(__clang__)
# define HYDE_NEEDS_ROR64 1
#endif
#if HYDE_NEEDS_ROR64
if (!rot)
return val;
return (val >> rot) | (val << (64u - (rot % 64u)));
#else
return __builtin_rotateright64(val, rot);
#endif
#undef HYDE_NEEDS_ROR64
}
/// Rotate `val` to the right `rot` positions.
inline static uint32_t RotateRight32(uint32_t val, unsigned rot) {
// NOTE: if we ever move to C++20, there are builtin rotation functions in the
// standard library, which we should use instead.
#ifdef __has_builtin
# if !__has_builtin(__builtin_rotateright32)
# define HYDE_NEEDS_ROR32 1
# else
# define HYDE_NEEDS_ROR32 0
# endif
#elif !defined(__clang__)
# define HYDE_NEEDS_ROR32 1
#endif
#if HYDE_NEEDS_ROR32
if (!rot)
return val;
return (val >> rot) | (val << (32u - (rot % 32u)));
#else
return __builtin_rotateright32(val, rot);
#endif
#undef HYDE_NEEDS_ROR32
}
We should just work these into the Arch/Runtime/Operators.h
We would presumable want to make sure that __builtin_rotateright*
behaves the same way across architectures when given a zero rotation amount. If I remember correctly, John Regehr found some issues in our semantics related to this issue in the past.
Example GCC command line:
GCC version: