Skip to content

[Build] MSVC 14.43 ARM64 introduces hard requirement for Clang 18+ #79852

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
Steelskin opened this issue Mar 7, 2025 · 3 comments
Open

[Build] MSVC 14.43 ARM64 introduces hard requirement for Clang 18+ #79852

Steelskin opened this issue Mar 7, 2025 · 3 comments

Comments

@Steelskin
Copy link
Contributor

MSVC 14.43 introduces a hard requirement for these 2 compiler intrinsics: _CountLeadingZeros() and _CountLeadingZeros64(_Val) on ARM64. These were implemented in Clang 18 in this PR. Unlike the "soft" requirement in yvals_core.h, there is no compiler define that we can use to work around this issue.

As a result, the Swift Windows ARM64 toolchain can not be built using the 6.0 toolchain as a bootstrap when using MSVC 14.43 or higher.

Possible solutions:

  • Switch to a 6.1 toolchain for bootstrapping.
  • Cherry-pick this PR to 6.0 and do a new release.

Here is the build failure log:

<module-includes>:29:10: note: in file included from <module-includes>:29:
27 | #include "array"
28 | #include "atomic"
29 | #include "bitset"
   |          `- note: in file included from <module-includes>:29:
30 | #include "charconv"
31 | #include "chrono"

C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.43.34808\include/bitset:10:10: note: in file included from C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.43.34808\include/bitset:10:
  8 | #include <yvals_core.h>
  9 | #if _STL_COMPILER_PREPROCESSOR
 10 | #include <__msvc_bit_utils.hpp>
    |          `- note: in file included from C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.43.34808\include/bitset:10:
 11 | #include <iosfwd>
 12 | #include <xstring>

C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.43.34808\include\__msvc_bit_utils.hpp:138:33: error: use of undeclared identifier '_CountLeadingZeros'
136 | 
137 |     if constexpr (_Digits <= 32) {
138 |         return static_cast<int>(_CountLeadingZeros(_Val)) - (_Unsigned_integer_digits<unsigned long> - _Digits);
    |                                 `- error: use of undeclared identifier '_CountLeadingZeros'
139 |     } else {
140 |         return static_cast<int>(_CountLeadingZeros64(_Val));

C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.43.34808\include\__msvc_int128.hpp:61:16: note: in instantiation of function template specialization 'std::_Checked_arm_arm64_countl_zero<unsigned int>' requested here
  59 | #elif defined(_M_ARM) || defined(_M_ARM64) || defined(_M_ARM64EC) || defined(_M_HYBRID_X86_ARM64)
  60 |     if (!_Is_constant_evaluated()) {
  61 |         return _Checked_arm_arm64_countl_zero(_Val);
     |                `- note: in instantiation of function template specialization 'std::_Checked_arm_arm64_countl_zero<unsigned int>' requested here
  62 |     }
  63 | #endif // defined(_M_ARM) || defined(_M_ARM64) || defined(_M_ARM64EC) || defined(_M_HYBRID_X86_ARM64)

<module-includes>:29:10: note: in file included from <module-includes>:29:
27 | #include "array"
28 | #include "atomic"
29 | #include "bitset"
   |          `- note: in file included from <module-includes>:29:
30 | #include "charconv"
31 | #include "chrono"

C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.43.34808\include/bitset:10:10: note: in file included from C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.43.34808\include/bitset:10:
  8 | #include <yvals_core.h>
  9 | #if _STL_COMPILER_PREPROCESSOR
 10 | #include <__msvc_bit_utils.hpp>
    |          `- note: in file included from C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.43.34808\include/bitset:10:
 11 | #include <iosfwd>
 12 | #include <xstring>

<unknown>:0: error: could not build C module 'std'
C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.43.34808\include\__msvc_bit_utils.hpp:140:33: error: use of undeclared identifier '_CountLeadingZeros64'
138 |         return static_cast<int>(_CountLeadingZeros(_Val)) - (_Unsigned_integer_digits<unsigned long> - _Digits);
139 |     } else {
140 |         return static_cast<int>(_CountLeadingZeros64(_Val));
    |                                 `- error: use of undeclared identifier '_CountLeadingZeros64'
141 |     }
142 | }

C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.43.34808\include\__msvc_int128.hpp:61:16: note: in instantiation of function template specialization 'std::_Checked_arm_arm64_countl_zero<unsigned long long>' requested here
  59 | #elif defined(_M_ARM) || defined(_M_ARM64) || defined(_M_ARM64EC) || defined(_M_HYBRID_X86_ARM64)
  60 |     if (!_Is_constant_evaluated()) {
  61 |         return _Checked_arm_arm64_countl_zero(_Val);
     |                `- note: in instantiation of function template specialization 'std::_Checked_arm_arm64_countl_zero<unsigned long long>' requested here
  62 |     }
  63 | #endif // defined(_M_ARM) || defined(_M_ARM64) || defined(_M_ARM64EC) || defined(_M_HYBRID_X86_ARM64)
@compnerd
Copy link
Member

compnerd commented Mar 8, 2025

CC: @shahmishal @etcwilde

@shahmishal
Copy link
Member

shahmishal commented Mar 8, 2025

stable/20240123 branch is based on llvm.org/release/18.x

we are using stable/20240123 for main and release/6.1 (specifically, we are using swift/release/6.1 however its based on stable/20240123)

@Steelskin
Copy link
Contributor Author

The problem arises with the bootstrap toolchain, which is currently set to 6.0.3 in build.ps1. This can no longer build the toolchain with MSVC 14.43 because the llvm version is too old.

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