-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Cannot build cc_test()
targets on macOS
#20513
Comments
Can you post the log/error that Bazel gives you? |
The compiler invocation may be of interest:
Note that the But on macOS |
A quick fix here is the The problem is rules_cc is still registering its own out of date toolchain when done through the WORKSPACE https://github.com/bazelbuild/rules_cc/blob/51b77439a109b8c8f75ad70a130293291ed8b851/cc/repositories.bzl#L9-L10 but with bzlmod it's using the one in bazel https://github.com/bazelbuild/rules_cc/blob/51b77439a109b8c8f75ad70a130293291ed8b851/MODULE.bazel#L9-L10 Likely should just remove the |
this fixes though bazelbuild/rules_cc#215 |
I tried this change: diff --git a/WORKSPACE.bazel b/WORKSPACE.bazel
index 681b370..4dac4a4 100644
--- a/WORKSPACE.bazel
+++ b/WORKSPACE.bazel
@@ -35,15 +35,6 @@ maybe(
sha256 = "34c41bfb59cdaea29ac2df5a2fa79e5add609c71bb303b2ebb10985f93fa20e7",
)
-load(
- "@rules_cc//cc:repositories.bzl",
- "rules_cc_dependencies",
- "rules_cc_toolchains")
-
-rules_cc_dependencies()
-
-rules_cc_toolchains()
-
load(
"@build_bazel_rules_apple//apple:repositories.bzl",
"apple_rules_dependencies",
@@ -58,3 +49,11 @@ load(
apple_support_dependencies()
+load(
+ "@rules_cc//cc:repositories.bzl",
+ "rules_cc_dependencies",
+ "rules_cc_toolchains")
+
+rules_cc_dependencies()
+
+rules_cc_toolchains() And got:
I tried this too: diff --git a/WORKSPACE.bazel b/WORKSPACE.bazel
index 681b370..99723e5 100644
--- a/WORKSPACE.bazel
+++ b/WORKSPACE.bazel
@@ -42,8 +42,6 @@ load(
rules_cc_dependencies()
-rules_cc_toolchains()
-
load(
"@build_bazel_rules_apple//apple:repositories.bzl",
"apple_rules_dependencies",
@@ -58,3 +56,4 @@ load(
apple_support_dependencies()
+rules_cc_toolchains() Same results:
I tried that too: diff --git a/WORKSPACE.bazel b/WORKSPACE.bazel
index 681b370..f1e5616 100644
--- a/WORKSPACE.bazel
+++ b/WORKSPACE.bazel
@@ -42,8 +42,6 @@ load(
rules_cc_dependencies()
-rules_cc_toolchains()
-
load(
"@build_bazel_rules_apple//apple:repositories.bzl",
"apple_rules_dependencies", and this:
Same results. |
Currently a fresh project without anything in the WORKSPACE should work with the BUILD file from your repro case, since the default toolchain in bazel should still apply, are you not finding that to be the case? The first failure you posted makes sense if you don't have Xcode installed and only have the command line tools |
I am trying to get Bazel v7 to work in a much larger project, that needs a WORKSPACE file for a number of dependencies (Protobuf, gRPC, Abseil, etc.). If you are curious the project is: https://github.com/googleapis/google-cloud-cpp Frankly, our project does not really need
Is it necessary to install Xcode just to compile C++ programs? That seems sad, but I will gladly do it if that is what it takes. Is that documented anywhere in the Bazel v7 release notes? If it is, I probably missed it. |
It seems like it is not. Unfortunately one of our deps (gRPC) needs |
no it's not, I just assumed you had rules_apple intentionally. The issue is the first toolchain that is registered and matches wins in this case. You can either manually register the built in bazel toolchain first, use my rules_cc patch linked above, or set |
nit: it is intentional. If I don't have it, then I cannot even start a build with Bazel v7 which depends on gRPC. . I am not going to use it directly, and most likely I won't even use targets in gRPC that need it. But what I would call the loading phase (I am not sure that is the right name) of Bazel fails without it.
I think we can close this bug once bazelbuild/rules_cc#215 goes through. |
To summarize the issues here:
|
@veblush FYI the previous comment seems relevant for the Bazel v7 work on gRPC. |
Is it resolved? I met the exact same problem and it's really frustrating. |
Description of the bug:
Starting with Bazel v7 we cannot build
cc_test()
targets on macOS.Which category does this issue belong to?
No response
What's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.
Use the following repro:
repro.tar.gz
Which operating system are you running Bazel on?
uname -a
Darwin coryan-macbookpro.roam.internal 23.2.0 Darwin Kernel Version 23.2.0: Wed Nov 15 21:53:18 PST 2023; root:xnu-10002.61.3~2/RELEASE_ARM64_T6000 arm64
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
?No response
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?
There are older bugs with similar problems, e.g. #15069
Any other information, logs, or outputs that you want to share?
The text was updated successfully, but these errors were encountered: