The __builtin_bswap{32,64}() builtins (introduced in commit e07a421d)
are missing from MSVC, which causes build errors when compiling LLDB on
Windows (tested with MSVC 19.34.31943.0). This patch replaces the
builtins with either MSVC's _byteswap_u{long,64}() or the original
builtins, or the bswap_{32,64}() functions from byteswap.h, depending
on which ones are available.
Details
Details
Diff Detail
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Comment Actions
Instead of not using __builtin_bswap{32,64} entirely, we should check if they're available.
You can use the clang feature-checking macro __has_builtin (and if it doesn't exist you can define it). So you could amend this patch like so:
#if !defined(__has_builtin) #define __has_builtin(x) 0 #endif #if __has_builtin(__builtin_bswap32) #define bswap_32(x) __builtin_bswap32(x) #elif _MSC_VER #define bswap_32(x) _byteswap_ulong(x) #else #include <byteswap.h> #endif
Comment Actions
Thanks for the fix!
Made me realise I should have looked harder for an llvm utility in the first place, and it turns out llvm::byteswap exists. So I've changed this to use that in https://github.com/llvm/llvm-project/commit/9984cfc86ed6d5c1558d8dd82d82448e50d704ad.
Comment Actions
By the way, did this come up on a bot? Just wondering if I ignored an email, apologies if so.
Comment Actions
The llvm::byteswap() fix is much nicer. Thanks for the change!
No, this build error didn't show up on a bot (at least as far as I can tell).