Build issues using Visual Studio (latest)
Hi,
Since this revision:
Revision: c02c0e318b22b1e456601ec392d80e679ef6bc1e Author: Highway [email protected] Date: 28/04/2025 09:37:13 Message: Work around an LLVM inliner crash in HWY_DYNAMIC_DISPATCH(...)
LLVM may attempt to inline incompatible intrinsics (and crash) when this macro is used. As a workaround, we add a zero-instruction inline asm blob.
PiperOrigin-RevId: 752193594
Modified: hwy/highway.h
hwy can no longer be build using Visual Studio.
The problem lies with the adjusted code in highway.h:
// We call hwy::PreventElision(...) to work around a compiler crash where the // LLVM inliner crashes due to inlining incompatible intrinsics. #define HWY_DYNAMIC_DISPATCH(FUNC_NAME) ({ \ auto p = *(HWY_DYNAMIC_POINTER(FUNC_NAME)); \ hwy::PreventElision(p); \ p; \ })
This is not understood by VS.
Gemini suggests to change it to:
namespace hwy_internal { template <typename FuncPtrType> inline FuncPtrType DynamicDispatchWrapper(FuncPtrType ptr) { PreventElision(ptr); return ptr; } } // namespace hwy_internal #define HWY_DYNAMIC_DISPATCH(FUNC_NAME) \ hwy_internal::DynamicDispatchWrapper(*(HWY_DYNAMIC_POINTER(FUNC_NAME)))
For my own use, I changed the code back to the previous line:
#define HWY_DYNAMIC_DISPATCH(FUNC_NAME) (*(HWY_DYNAMIC_POINTER(FUNC_NAME)))
but it would be nice if this incompatibility could be fixed.
Thanks and greetings, Auke Nauta
Hi, thanks for pointing this out. Out of curiosity, what's the build error, and on which VS?
FYI we will likely roll this back soon.
Hi,The error happens in "per_target.cc" for example, line 57:HWY_DLLEXPORT int64_t DispatchedTarget() { return HWY_DYNAMIC_DISPATCH(GetTarget)(); // syntax error: missing ';' before '{'}I am using Visual Studio Community 2020, preview 6.0 (just released) on Windows 11.Greetings,AukeJan Wassenberg wrote:jan-wassenberg left a comment (google/highway#2568) Hi, thanks for pointing this out. Out of curiosity, what's the build error, and on which VS? FYI we will likely roll this back soon. —Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you authored the thread.Message ID: @.***>
@jan-wassenberg and @anauta00 I am able to get Google Highway to compile successfully with Visual C++ 2022 (with both cl 19.43.34810 and clang-cl 19.1.1) with the fix in pull request #2571.
I am also now able to get Google Highway to compile successfully with Visual C++ 2019 if the fixes in pull requests #2571 and #2572 are both applied.
I believe this is now fixed :)