enc.cc,msvc: add clang_rt.builtins for __builtin_cpu_* - #185
Open
jzern wants to merge 1 commit into
Open
Conversation
Fixes link errors related to `__builtin_cpu_init` and `__builtin_cpu_supports` when using `clang-cl.exe` or `clang.exe` to target the Windows ABI. Issue webmproject#163
Contributor
Author
|
Detection in CMake looked something like: But this only covered |
jzern
marked this pull request as ready for review
September 2, 2026 20:47
hasinoff
reviewed
Sep 2, 2026
| #else | ||
| #pragma comment(lib, "clang_rt.builtins-i386.lib") | ||
| #endif | ||
| #endif |
Contributor
There was a problem hiding this comment.
Ideally non-clang Windows would return false - this will fail to compile on MSVC, I think.
Contributor
Author
There was a problem hiding this comment.
MSVC (cl.exe) will not have __i386__ or __x86_64__ defined.
Contributor
Author
There was a problem hiding this comment.
MSVC (
cl.exe) will not have__i386__or__x86_64__defined.
It fails to link due to the deficient SSE2 check, mentioned in #163 (comment).
Contributor
Author
There was a problem hiding this comment.
This works in the 3 configurations I tested with Visual Studio 2026:
-G Visual Studio 18 2026 -T ClangCl(clang-cl.exe)-G Visual Studio 18 2026(cl.exe, hits the#else)-G Ninja Multi-Config(clang.exe)
So, later some work can be done to add cl.exe support using the __cpuid(ex) and _xgetbv intrinsics like we do in libwebp.
skal65535
approved these changes
Sep 3, 2026
| #else | ||
| #pragma comment(lib, "clang_rt.builtins-i386.lib") | ||
| #endif | ||
| #endif |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes link errors related to
__builtin_cpu_initand__builtin_cpu_supportswhen usingclang-cl.exeorclang.exetotarget the Windows ABI.
Issue #163