-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Bazel 7 no longer compiles with mingw and instead uses visual studio #20492
Comments
Is there anyone I should be assigning to this issue? Still have the same issue, and seems pretty urgent given it breaks building on windows OS. (cc @iancha1992 or other) |
I've also encountered this issue. |
This is probably due to the flip of You could also try to adapt to use the second approach described in https://bazel.build/configure/windows#clang to Line 49 in 8e8ddab
|
@fmeum That worked, I'll give the second approach linked a try as well. Much appreciated, thank you! |
Bazel 8 has removed the With Bazel 8 I tried:
and got:
Looking inside I tried specifying the highlighted toolchain with
... but when I tried with the
... I got a different sequence of events:
Seems like the I even tried adding
... but got this:
No idea how to proceed from here. 😕 |
Eventually I gave up and edited three files ( diff --git a/BUILD.bazel b/BUILD.bazel
index 0306468e..ca9b77d1 100644
--- a/BUILD.bazel
+++ b/BUILD.bazel
@@ -234,3 +234,12 @@ cc_test(
srcs = ["googletest/samples/sample10_unittest.cc"],
deps = [":gtest"],
)
+
+platform(
+ name = "my_platform",
+ constraint_values = [
+ "@platforms//cpu:x86_64",
+ "@platforms//os:windows",
+ "@rules_cc//cc/private/toolchain:mingw",
+ ],
+)
diff --git a/MODULE.bazel b/MODULE.bazel
index e213d43e..39782319 100644
--- a/MODULE.bazel
+++ b/MODULE.bazel
@@ -47,6 +47,10 @@ bazel_dep(
name = "platforms",
version = "0.0.10",
)
+bazel_dep(
+ name = "rules_cc",
+ version = "0.0.16",
+)
bazel_dep(
name = "re2",
version = "2024-07-02",
diff --git a/WORKSPACE b/WORKSPACE
index 63f76813..489bbb3b 100644
--- a/WORKSPACE
+++ b/WORKSPACE
@@ -60,3 +60,10 @@ http_archive(
],
sha256 = "218efe8ee736d26a3572663b374a253c012b716d8af0c07e842e82f238a0a7ee",
)
+
+http_archive(
+ name = "rules_cc",
+ urls = ["https://github.com/bazelbuild/rules_cc/releases/download/0.0.16/rules_cc-0.0.16.tar.gz"],
+ sha256 = "bbf1ae2f83305b7053b11e4467d317a7ba3517a12cef608543c1b1c5bf48a4df",
+ strip_prefix = "rules_cc-0.0.16",
+) and then it worked:
Seems like there is no way to avoid editing |
See bazelbuild/bazel#20492. "Toolchain resolution" can no longer be disabled in Bazel 8, so we are forced to edit 3 files in the GoogleTest repo to build it with MSYS2's mingw64 GCC.
Description of the bug:
in v6.4.0 I had bazel configured so that it would use mingw-gcc , my .bazelrc was as follows:
Everything compiled and worked correctly to this point. Now upgrading to bazel 7.0.0 , I get this error:
As you can see its now trying to use visual studio despite specifying
--compiler=mingw-gcc
This is on windows 10, and I have some of the following relevant ENV set:
As well as mingw being available in the PATH. Again, this DOES work in v6.4.0, it stops working in v7.0.0
Thanks for any help
Which category does this issue belong to?
C++/Objective-C Rules
What's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.
Attempt to use mingw with above flags / ENV vars in the new bazel 7.0.0
Which operating system are you running Bazel on?
Windows 10
What is the output of
bazel info release
?release 7.0.0
If
bazel info release
returnsdevelopment version
or(@non-git)
, tell us how you built Bazel.No response
What's the output of
git remote get-url origin; git rev-parse master; git rev-parse HEAD
?Is this a regression? If yes, please try to identify the Bazel commit where the bug was introduced.
No response
Have you found anything relevant by searching the web?
No
Any other information, logs, or outputs that you want to share?
No response
The text was updated successfully, but these errors were encountered: