Skip to content

Build issues using Visual Studio (latest) #2568

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
anauta00 opened this issue May 7, 2025 · 3 comments
Open

Build issues using Visual Studio (latest) #2568

anauta00 opened this issue May 7, 2025 · 3 comments

Comments

@anauta00
Copy link

anauta00 commented May 7, 2025

Hi,

Since this revision:

Revision: c02c0e3
Author: Highway no-reply@google.com
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

@jan-wassenberg
Copy link
Member

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.

@anauta00
Copy link
Author

anauta00 commented May 7, 2025 via email

@johnplatts
Copy link
Contributor

johnplatts commented May 9, 2025

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants