[llvm] [bazel] Select Windows GNU BLAKE3 assembly for clang-cl (PR #217695)

Corentin Kerisit via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 20 10:00:16 PDT 2026


https://github.com/cerisier created https://github.com/llvm/llvm-project/pull/217695

## Motivation

The LLVM Bazel overlay does not select a Windows-compatible BLAKE3 assembly source set for an x86_64 Windows target compiled with the `clang-cl` rules_cc compiler dialect.

The source choice is an object-format and assembler-syntax decision, not a request to disable BLAKE3 SIMD or to depend on an ambient Visual Studio installation. A hermetic clang-cl toolchain can assemble LLVM's GNU-syntax Windows sources directly into COFF and should not require `ml64.exe`.

## Invariant / contract

For x86_64 Windows, every supported compiler route must compile the BLAKE3 SIMD implementations using sources whose directives and symbol spelling match COFF:

- MinGW clang already selects the `windows_gnu.S` sources;
- MSVC CMake builds can select the MASM `windows_msvc.asm` sources when MASM is available;
- clang-cl without MASM needs the `windows_gnu.S` sources, which Clang's integrated assembler accepts for a Windows target.

Non-Windows x86_64 targets must continue selecting the Unix sources. ARM targets are outside this select and remain unchanged.

## Root cause

The Bazel overlay has an explicit x86_64 Windows + `clang` (MinGW) configuration, but no equivalent x86_64 Windows + `clang-cl` configuration. Consequently clang-cl falls through to the default Unix assembly selection. On supported-line downstream overlays that exclude Unix assembly on Windows, the same missing case instead leaves the four SIMD implementations out and the final link reports undefined `blake3_*` dispatch symbols.

The MASM files are not a portable fallback for this route: clang-cl's driver does not assemble `.asm` MASM input, while the Windows GNU-syntax files are designed for Clang/GNU-style assemblers and emit the required COFF symbols.

## Change

Add an exact `x86_64` + `windows` + rules_cc compiler `clang-cl` configuration and select the existing four `windows_gnu.S` BLAKE3 files for it.

The existing MinGW branch is untouched. The default Unix branch is untouched. No source semantics, feature dispatch, or CMake behavior changes.

## Tests

- `buildifier -mode=check utils/bazel/llvm-project-overlay/llvm/BUILD.bazel`
- `git diff --check`
- Compiled each selected `windows_gnu.S` file with LLVM clang-cl 22.1.8 targeting `x86_64-pc-windows-msvc`; all four outputs were AMD64 COFF objects and defined the expected SSE2, SSE4.1, AVX2, and AVX-512 BLAKE3 symbols.
- Confirmed the corresponding `windows_msvc.asm` inputs are not accepted by this clang-cl-only route, so selecting them would introduce an undeclared MASM requirement rather than fix the Bazel configuration.
- A downstream full x86_64 Windows LLVM build linked successfully with this source selection. The identical baseline reached the final link with undefined BLAKE3 SIMD dispatch symbols.


>From 3f7a36e522dd07df9b439e1c83444ec3149d2bfd Mon Sep 17 00:00:00 2001
From: Corentin Kerisit <corentin.kerisit at gmail.com>
Date: Fri, 21 Aug 2026 01:58:59 +0900
Subject: [PATCH] [bazel] Select Windows GNU BLAKE3 assembly for clang-cl

---
 utils/bazel/llvm-project-overlay/llvm/BUILD.bazel | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/utils/bazel/llvm-project-overlay/llvm/BUILD.bazel b/utils/bazel/llvm-project-overlay/llvm/BUILD.bazel
index 6299d772606bf..3f056fd042673 100644
--- a/utils/bazel/llvm-project-overlay/llvm/BUILD.bazel
+++ b/utils/bazel/llvm-project-overlay/llvm/BUILD.bazel
@@ -332,6 +332,15 @@ config_setting(
     flag_values = {"@rules_cc//cc/compiler:compiler": "clang"},
 )
 
+config_setting(
+    name = "is_x86_64_windows_clang_cl",
+    constraint_values = [
+        "@platforms//cpu:x86_64",
+        "@platforms//os:windows",
+    ],
+    flag_values = {"@rules_cc//cc/compiler:compiler": "clang-cl"},
+)
+
 BLAKE3_x86_64_ASM_SOURCE_PATTERNS = [
     "lib/Support/BLAKE3/blake3_avx2_x86-64_%s.S",
     "lib/Support/BLAKE3/blake3_avx512_x86-64_%s.S",
@@ -346,6 +355,10 @@ filegroup(
             pattern % "windows_gnu"
             for pattern in BLAKE3_x86_64_ASM_SOURCE_PATTERNS
         ],
+        ":is_x86_64_windows_clang_cl": [
+            pattern % "windows_gnu"
+            for pattern in BLAKE3_x86_64_ASM_SOURCE_PATTERNS
+        ],
         "//conditions:default": [
             pattern % "unix"
             for pattern in BLAKE3_x86_64_ASM_SOURCE_PATTERNS



More information about the llvm-commits mailing list