diff options
| author | Mike Aizatsky <maizatskyi@cloudflare.com> | 2026-11-20 10:19:04 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-11-20 10:19:04 -0800 |
| commit | d10fc880af2a5899d83a34afddea195b2ce8525c (patch) | |
| tree | 0b33898b7489a80d13c1fe5c79b20d214e01a826 | |
| parent | 7d3db3760068ec6a5214a0c3509da398e71dc668 (diff) | |
| download | capnproto-master.tar.gz capnproto-master.zip | |
fix head windows builds (#2937)HEADlocal/capnprotomaster
* fix msvc-latest build
* update bazel-windows build
| -rw-r--r-- | .github/workflows/quick-test.yml | 10 | ||||
| -rw-r--r-- | c++/src/kj/tuple-test.c++ | 6 | ||||
| -rw-r--r-- | c++/src/kj/tuple.h | 10 |
3 files changed, 21 insertions, 5 deletions
diff --git a/.github/workflows/quick-test.yml b/.github/workflows/quick-test.yml index c3a44b4f..6b527a90 100644 --- a/.github/workflows/quick-test.yml +++ b/.github/workflows/quick-test.yml @@ -194,6 +194,16 @@ jobs: arch: -A x64 steps: - uses: actions/checkout@v7 + - name: Use Visual Studio's bundled LLVM + # The standalone LLVM preinstalled in C:\Program Files\LLVM can lag behind the minimum Clang + # version required by the MSVC STL, so point Bazel's clang-cl toolchain at the LLVM that + # ships with Visual Studio instead. + run: | + $vs = & "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe" -latest -products * -property installationPath + $llvm = "$vs\VC\Tools\Llvm\x64" + if (-not (Test-Path "$llvm\bin\clang-cl.exe")) { throw "clang-cl not found in $llvm" } + & "$llvm\bin\clang-cl.exe" --version + echo "BAZEL_LLVM=$llvm" >> $env:GITHUB_ENV - name: test run: | cd c++ && bazel test --config=ci //... diff --git a/c++/src/kj/tuple-test.c++ b/c++/src/kj/tuple-test.c++ index 979149bd..eeb956fe 100644 --- a/c++/src/kj/tuple-test.c++ +++ b/c++/src/kj/tuple-test.c++ @@ -384,8 +384,7 @@ KJ_TEST("Tuple reference conversion to a derived type uses the conversion operat KJ_EXPECT(&get<0>(constFromExplicitRefs) == &explicitTarget); } -#ifdef __has_builtin -#if __has_builtin(__reference_constructs_from_temporary) +#if KJ_HAS_REFERENCE_CONSTRUCTS_FROM_TEMPORARY KJ_TEST("Tuple conversions do not bind reference elements to temporaries") { // Converting a long to an int creates a temporary, which would die at the end of the // conversion and leave the const reference element dangling. @@ -406,8 +405,7 @@ KJ_TEST("Tuple conversions do not bind reference elements to temporaries") { struct Derived: Base {}; static_assert(!_::ConstructibleFrom<Tuple<const Derived&, int>, Tuple<Base, int>&>); } -#endif -#endif +#endif // KJ_HAS_REFERENCE_CONSTRUCTS_FROM_TEMPORARY KJ_TEST("Tuple reference conversions borrow existing elements") { // Reference elements that bind to the source's own elements remain convertible. diff --git a/c++/src/kj/tuple.h b/c++/src/kj/tuple.h index 77da07bf..f32a4340 100644 --- a/c++/src/kj/tuple.h +++ b/c++/src/kj/tuple.h @@ -115,7 +115,15 @@ struct TupleElement { constexpr inline TupleElement(U&& value): value(pointerSafeSource<T>(kj::fwd<U>(value))) {} }; +#if !defined(_MSC_VER) || defined(__clang__) +// MSVC rejects __reference_constructs_from_temporary as an argument to __has_builtin (C1017), so +// the check must not be evaluated there. #if __has_builtin(__reference_constructs_from_temporary) +#define KJ_HAS_REFERENCE_CONSTRUCTS_FROM_TEMPORARY 1 +#endif +#endif + +#if KJ_HAS_REFERENCE_CONSTRUCTS_FROM_TEMPORARY template <typename T, typename U> concept BindsTemporary = __reference_constructs_from_temporary(T, U&&); #else @@ -123,7 +131,7 @@ template <typename T, typename U> concept BindsTemporary = false; #endif // Concept: T is a reference that, initialized from U&&, would bind to a temporary. Compilers -// without the builtin do not detect this case. +// without the builtin (including MSVC) do not detect this case. template <typename T, typename U> concept TupleElementConstructibleFrom = PointerSafeConstructibleFrom<T, U> && |
