-
Notifications
You must be signed in to change notification settings - Fork 16
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
5.0rc1: android_ndk_repository
is fetched eagerly
#92
Comments
@Wyverald This breaks envoy-mobile CI when upgrading to 5.0: https://github.com/envoyproxy/envoy-mobile/runs/4096640402?check_suite_focus=true#step:4:46 |
Do you have a minimum repro case? I tried the following: $ echo 'android_ndk_repository(name = "androidndk", api_level = 29)' > WORKSPACE
$ echo 'filegroup(name="haha")' > BUILD
$ USE_BAZEL_VERSION=5.0.0rc1 bazelisk build :haha And nothing failed. (I don't have the NDK installed or the env var set.) |
|
Thanks, it looks like it's somehow related to rules_swift. I'll take a look now |
Pretty sure this is due to bazelbuild/bazel@7398e33. This commit made the @katre any thoughts? I think this is somewhat WAI, although it's weird that |
And is there any way to conditionally run a repository rule? For example, with a |
Why do you have an There are two parts to a toolchain: the actual underlying toolchain (in the case of the Android NDK, that's a There is no direct dependency from the The easiest fix is to separate them into two different repositories: one that defines the However, I don't think this will address your problem: the |
Because we have various different CI jobs, and they only setup what is needed for the job. Our iOS jobs don't setup the JDK or Android SDK, because it's not needed for that build. Local developers that only develop on the iOS stuff don't need to setup the JDK or Android SDK. |
Bazel's CI system only adds the I'm very nervous about either conditional repository rules, or lazy loading of repository rules, although @Wyverald is the expert on that and can answer about whether it makes sense. |
While that might address the CI issue, it's a huge pain for local developers then. Another case for conditional/lazy loading repository rules: I want to only download SDKs for my execution platforms, which might change depending on if I'm using RBE. |
Like you said later, I don't think that would help -- IIUC, as soon as you have some toolchains in @katre any idea why
I'm similarly nervous. There was a long discussion about conditional external dependencies in the Bzlmod design doc, and the rabbit hole goes a mile down. In today's WORKSPACE there is technically a way to do conditional dependencies based on environment variables, but it's more of a hack than something we're comfortable supporting. Anyhow, even if we were to support conditional dependencies, it wouldn't make it into 5.0.
For what it's worth, this is possible today if you carefully separate the execution platform definition and the actual SDK binary into two separate repos. The execution platform definition repo is always fetched (because it has the |
That's good to hear. Someone should update |
When we first added this system, that's exactly how If you're seeing something different (and if Bazel is downloading all several dozen go SDKs, you'll notice), that should definitely be filed as a bug to investigate. |
The default behavior only downloads SDKs for the host platform. If I have an execution platform that is different, one way to do that is to set my host platform to that execution platform. The repository rule uses |
@Wyverald I'm not sure why the NDK shows an error and the SDK doesn't. At a guess, the NDK error is just that it's not fully configured: there's no path to the NDK, and no environment variable. If the SDK isn't reporting errors, then either there is a path or the environment variable is set (even if it's not set to anything useful). One way forward would be to add an attribute to |
@brentleyjones Hmm, that's a bit odd, but I haven't followed |
I don't have any setup for the Android SDK: no env variable and no setup. |
^ neither do I. |
I'll take this off the release blocker list for now, as there doesn't seem to be a short-term solution (unless @katre you think we could work out a way to make |
The time has now come for Envoy Mobile to update to Bazel 5 so we're likely going to comment out the This isn't too problematic for CI, but will lead to some other issues:
Many of the workaround ideas that were suggested in this thread would work for us. For example, @brentleyjones suggested a way to conditionally run a repository rule with a @katre's suggestion to add an attribute to |
I think there needs to be some solution to this, even if it's the one mentioned above just making the NDK not fail. I think many projects are setup in this way for android where maybe not all codepaths require it, but some do, for example grpc: Based on this PR grpc/grpc#28683 they already hit this during their upgrade attempt. |
This works around https://github.com/bazelbuild/bazel/issues/14260 This is based on tensorflow's implementation https://github.com/tensorflow/tensorflow/tree/34c03ed67692eb76cb3399cebca50ea8bcde064c/third_party/android Signed-off-by: Keith Smiley <[email protected]>
For reference here's a workaround that I think will work in the meantime envoyproxy/envoy-mobile#2039 |
This works around https://github.com/bazelbuild/bazel/issues/14260 This is based on tensorflow's implementation https://github.com/tensorflow/tensorflow/tree/34c03ed67692eb76cb3399cebca50ea8bcde064c/third_party/android Signed-off-by: Keith Smiley <[email protected]>
This works around https://github.com/bazelbuild/bazel/issues/14260 This is based on tensorflow's implementation https://github.com/tensorflow/tensorflow/tree/34c03ed67692eb76cb3399cebca50ea8bcde064c/third_party/android Signed-off-by: Keith Smiley <[email protected]>
* Update Envoy: envoyproxy/envoy@71248e5...bbcd487 * Remove various `remotejdk_11` configurations in .bazelrc which we now inherit from Envoy * Work around https://github.com/bazelbuild/bazel/issues/14260 androidndk fetching issue Signed-off-by: JP Simard <[email protected]> Co-authored-by: Keith Smiley <[email protected]>
I just tested the workarounds listed above (grpc/grpc#28683, envoyproxy/envoy-mobile#2039) and they work. What isn't obvious to a novice is that you can't call The way to defer this would be to pass |
We're replacing the native version of |
hmm actually since this is about registering toolchains, and you still register toolchains with the starlark version of android_ndk_repository, it might still have the same problem |
* Update Envoy: 71248e5...bbcd487 * Remove various `remotejdk_11` configurations in .bazelrc which we now inherit from Envoy * Work around https://github.com/bazelbuild/bazel/issues/14260 androidndk fetching issue Signed-off-by: JP Simard <[email protected]> Co-authored-by: Keith Smiley <[email protected]> Signed-off-by: JP Simard <[email protected]>
Sounds like this can be solved with #63, we should revisit that PR |
Description of the problem / feature request:
In bazel 5.0rc1
android_ndk_repository
is fetched even if nothing depends on it. In 4.2.1, this wasn't the case.Bugs: what's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.
Add
android_ndk_repository(name = "androidndk", api_level = 29)
toWORKSPACE
, don't have theANDROID_NDK_HOME
environment variable set. Build anything, and get this error:In 4.2.1 this error wouldn't happen.
What operating system are you running Bazel on?
macOS 11.6.1
What's the output of
bazel info release
?release 5.0.0rc1
Have you found anything relevant by searching the web?
No.
The text was updated successfully, but these errors were encountered: