Skip to content

[stable/21.x] Fix windows build failures with MSVC #11128

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

Merged
merged 2 commits into from
Aug 5, 2025

Conversation

AnthonyLatsis
Copy link

@AnthonyLatsis AnthonyLatsis commented Aug 5, 2025

Cherry-picks #11092. The second commit here is not so much a cherry-pick as a correction upon #11120 in favor of next, to avoid future conflicts. (I didn’t notice this had already been fixed on next.)

This fixes the windows build with MSVC.

(cherry picked from commit 4d97270)
llvm::has_single_bit and llvm::countr_zero both require that the
argument type is unsigned but the default underlying type for enums
is int, which causes build errors with MSVC.

This fixes the windows build with MSVC.

```
FAILED: tools/clang/lib/Driver/CMakeFiles/obj.clangDriver.dir/BoundsSafetyArgs.cpp.obj
C:\PROGRA~1\MICROS~1\2022\COMMUN~1\VC\Tools\MSVC\1444~1.352\bin\Hostx64\x64\cl.exe  /nologo /TP -DCLANG_BUILD_STATIC -DEXPERIMENTAL_KEY_INSTRUCTIONS -DGTEST_HAS_RTTI=0 -DUNICODE -D_CRT_NONSTDC_NO_DEPRECATE -D_CRT_NONSTDC_NO_WARNINGS -D_CRT_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS -D_HAS_EXCEPTIONS=0 -D_SCL_SECURE_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS -D_UNICODE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -D__SHORT_FILE__=\"BoundsSafetyArgs.cpp\" -IC:\Users\hiroshi\cas\llvm-project\build\tools\clang\lib\Driver -IC:\Users\hiroshi\cas\llvm-project\clang\lib\Driver -IC:\Users\hiroshi\cas\llvm-project\clang\include -IC:\Users\hiroshi\cas\llvm-project\build\tools\clang\include -IC:\Users\hiroshi\cas\llvm-project\build\include -IC:\Users\hiroshi\cas\llvm-project\llvm\include /DWIN32 /D_WINDOWS   /Zc:inline /Zc:preprocessor /Zc:__cplusplus /Oi /bigobj /permissive- /W4 -wd4141 -wd4146 -wd4244 -wd4267 -wd4291 -wd4351 -wd4456 -wd4457 -wd4458 -wd4459 -wd4503 -wd4624 -wd4722 -wd4100 -wd4127 -wd4512 -wd4505 -wd4610 -wd4510 -wd4702 -wd4245 -wd4706 -wd4310 -wd4701 -wd4703 -wd4389 -wd4611 -wd4805 -wd4204 -wd4577 -wd4091 -wd4592 -wd4319 -wd4709 -wd5105 -wd4324 -wd4251 -wd4275 -w14062 -we4238 /Gw /O2 /Ob2 /DNDEBUG -std:c++17 -MD  /EHs-c- /GR- /showIncludes /Fotools\clang\lib\Driver\CMakeFiles\obj.clangDriver.dir\BoundsSafetyArgs.cpp.obj /Fdtools\clang\lib\Driver\CMakeFiles\obj.clangDriver.dir\ /FS -c C:\Users\hiroshi\cas\llvm-project\clang\lib\Driver\BoundsSafetyArgs.cpp
C:\Users\hiroshi\cas\llvm-project\clang\lib\Driver\BoundsSafetyArgs.cpp(196): error C2672: 'llvm::has_single_bit': no matching overloaded function found
C:\Users\hiroshi\cas\llvm-project\llvm\include\llvm/ADT/bit.h(147): note: could be 'bool llvm::has_single_bit(T) noexcept'
C:\Users\hiroshi\cas\llvm-project\clang\lib\Driver\BoundsSafetyArgs.cpp(196): note: 'bool llvm::has_single_bit(T) noexcept': could not deduce template argument for '<unnamed-symbol>'
C:\Users\hiroshi\cas\llvm-project\llvm\include\llvm/ADT/bit.h(146): note: 'std::enable_if_t<false,void>' : Failed to specialize alias template
```
```
FAILED: tools/clang/lib/Driver/CMakeFiles/obj.clangDriver.dir/BoundsSafetyArgs.cpp.obj
C:\PROGRA~1\MICROS~1\2022\COMMUN~1\VC\Tools\MSVC\1444~1.352\bin\Hostx64\x64\cl.exe  /nologo /TP -DCLANG_BUILD_STATIC -DEXPERIMENTAL_KEY_INSTRUCTIONS -DGTEST_HAS_RTTI=0 -DUNICODE -D_CRT_NONSTDC_NO_DEPRECATE -D_CRT_NONSTDC_NO_WARNINGS -D_CRT_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS -D_HAS_EXCEPTIONS=0 -D_SCL_SECURE_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS -D_UNICODE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -D__SHORT_FILE__=\"BoundsSafetyArgs.cpp\" -IC:\Users\hiroshi\cas\llvm-project\build\tools\clang\lib\Driver -IC:\Users\hiroshi\cas\llvm-project\clang\lib\Driver -IC:\Users\hiroshi\cas\llvm-project\clang\include -IC:\Users\hiroshi\cas\llvm-project\build\tools\clang\include -IC:\Users\hiroshi\cas\llvm-project\build\include -IC:\Users\hiroshi\cas\llvm-project\llvm\include /DWIN32 /D_WINDOWS   /Zc:inline /Zc:preprocessor /Zc:__cplusplus /Oi /bigobj /permissive- /W4 -wd4141 -wd4146 -wd4244 -wd4267 -wd4291 -wd4351 -wd4456 -wd4457 -wd4458 -wd4459 -wd4503 -wd4624 -wd4722 -wd4100 -wd4127 -wd4512 -wd4505 -wd4610 -wd4510 -wd4702 -wd4245 -wd4706 -wd4310 -wd4701 -wd4703 -wd4389 -wd4611 -wd4805 -wd4204 -wd4577 -wd4091 -wd4592 -wd4319 -wd4709 -wd5105 -wd4324 -wd4251 -wd4275 -w14062 -we4238 /Gw /O2 /Ob2 /DNDEBUG -std:c++17 -MD  /EHs-c- /GR- /showIncludes /Fotools\clang\lib\Driver\CMakeFiles\obj.clangDriver.dir\BoundsSafetyArgs.cpp.obj /Fdtools\clang\lib\Driver\CMakeFiles\obj.clangDriver.dir\ /FS -c C:\Users\hiroshi\cas\llvm-project\clang\lib\Driver\BoundsSafetyArgs.cpp
C:\Users\hiroshi\cas\llvm-project\llvm\include\llvm/ADT/bit.h(158): error C2338: static_assert failed: 'Only unsigned integral types are allowed.'
C:\Users\hiroshi\cas\llvm-project\llvm\include\llvm/ADT/bit.h(158): note: the template instantiation context (the oldest one first) is
```

(cherry picked from commit 7524778)
@AnthonyLatsis AnthonyLatsis requested a review from bnbarham August 5, 2025 22:57
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

Successfully merging this pull request may close these issues.

3 participants