[llvm] [Bazel] Prefer forward slashes for MinGW builds (PR #218181)

Corentin Kerisit via llvm-commits llvm-commits at lists.llvm.org
Sat Aug 22 20:08:44 PDT 2026


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

CMake defaults LLVM_WINDOWS_PREFER_FORWARD_SLASH to ON for MinGW and OFF for MSVC, while the Bazel header hardcoded it to zero everywhere. Move the value into platform configuration, set it to one through the existing clang MinGW selector, and retain zero for MSVC, clang-cl, and non-Windows configurations. This restores the native LLVM MinGW path policy without changing other path styles.

>From 2c4490ea6be5a0cf614ae4885ced77daaf329e72 Mon Sep 17 00:00:00 2001
From: Corentin Kerisit <corentin.kerisit at gmail.com>
Date: Sun, 23 Aug 2026 01:35:12 +0900
Subject: [PATCH] [Bazel] Prefer forward slashes with MinGW

---
 utils/bazel/llvm-project-overlay/llvm/config.bzl           | 7 ++++++-
 .../llvm-project-overlay/llvm/include/llvm/Config/config.h | 2 +-
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/utils/bazel/llvm-project-overlay/llvm/config.bzl b/utils/bazel/llvm-project-overlay/llvm/config.bzl
index 49f70f95d2c79..5cd0ecb3a4621 100644
--- a/utils/bazel/llvm-project-overlay/llvm/config.bzl
+++ b/utils/bazel/llvm-project-overlay/llvm/config.bzl
@@ -131,8 +131,13 @@ builtin_thread_pointer = select({
     "//conditions:default": [],
 })
 
+windows_prefer_forward_slash = select({
+    Label("//llvm:is_windows_clang_mingw"): ["LLVM_WINDOWS_PREFER_FORWARD_SLASH=1"],
+    "//conditions:default": ["LLVM_WINDOWS_PREFER_FORWARD_SLASH=0"],
+})
+
 # TODO: We should split out host vs. target here.
-llvm_config_defines = os_defines + builtin_thread_pointer + select({
+llvm_config_defines = os_defines + builtin_thread_pointer + windows_prefer_forward_slash + select({
     Label("//llvm:is_aarch64_windows_clang_mingw"): native_arch_defines("AArch64", "aarch64-w64-windows-gnu"),
     Label("//llvm:is_aarch64_windows_clang_cl"): native_arch_defines("AArch64", "aarch64-pc-windows-msvc"),
     Label("//llvm:is_aarch64_windows_msvc"): native_arch_defines("AArch64", "aarch64-pc-windows-msvc"),
diff --git a/utils/bazel/llvm-project-overlay/llvm/include/llvm/Config/config.h b/utils/bazel/llvm-project-overlay/llvm/include/llvm/Config/config.h
index bb69f3c472998..fdfd6a8488d64 100644
--- a/utils/bazel/llvm-project-overlay/llvm/include/llvm/Config/config.h
+++ b/utils/bazel/llvm-project-overlay/llvm/include/llvm/Config/config.h
@@ -37,7 +37,7 @@
 
 /* Define to 1 to prefer forward slashes on Windows, and to 0 prefer
    backslashes. */
-#define LLVM_WINDOWS_PREFER_FORWARD_SLASH 0
+/* LLVM_WINDOWS_PREFER_FORWARD_SLASH defined in Bazel */
 
 /* Define to 1 if you have the `backtrace' function. */
 /* HAVE_BACKTRACE defined in Bazel */



More information about the llvm-commits mailing list