Skip to content

Conversation

@fmeum
Copy link
Contributor

@fmeum fmeum commented Nov 2, 2023

No description provided.

@fmeum fmeum marked this pull request as ready for review November 16, 2023 09:39
@fmeum fmeum requested review from a team and comius as code owners November 16, 2023 09:39
@fmeum
Copy link
Contributor Author

fmeum commented Nov 16, 2023

@hvadehra @cushon This is ready for review.

@comius comius requested review from hvadehra and removed request for comius November 16, 2023 12:00
@fmeum fmeum deleted the native-turbine branch November 16, 2023 16:13
@fmeum
Copy link
Contributor Author

fmeum commented Nov 16, 2023

@keertk Sorry for all the hoops this requires, but could you create another rules_java release with this change?

copybara-service bot pushed a commit that referenced this pull request Nov 16, 2023
Copybara Import from #154

BEGIN_PUBLIC
Update rules_java to 7.3.0 (#154)

#151 (comment)

Closes #154
END_PUBLIC

COPYBARA_INTEGRATE_REVIEW=#154 from bazelbuild:rules_java-7.3 ddcebff
PiperOrigin-RevId: 583054998
Change-Id: I7078c14eada52276fa6e1fc7c54963a7c1c88c56
@keertk
Copy link
Member

keertk commented Nov 16, 2023

@BoleynSu
Copy link

BoleynSu commented Dec 2, 2023

@fmeum this breaks rules_jvm_external with crashing here https://github.com/google/turbine/blob/33ed406f653ecfda611933103261a6ad3146dbd5/java/com/google/turbine/binder/CtSymClassBinder.java#L52. Could you take a look?

# a minimal repro
java_library(
    name = "l",
    srcs = ["t.java"],
    javacopts = [
        "--release",
        "8",
    ],
)

java_binary(
    name = "b",
    srcs = ["t.java"],
    main_class = "t.t",
    deps = [":l"],
)

@cushon
Copy link
Collaborator

cushon commented Dec 2, 2023

@BoleynSu see bazelbuild/stardoc#195

@fmeum
Copy link
Contributor Author

fmeum commented Dec 2, 2023

@BoleynSu rules_java 7.3.1 is out with the fix. Please give it a try.

@BoleynSu
Copy link

BoleynSu commented Dec 2, 2023 via email

@fmeum
Copy link
Contributor Author

fmeum commented Dec 2, 2023

@BoleynSu That does sound like a problem with updating rules_java. How are you doing that?

With the following setup:

# BUILD
java_library(
    name = "l",
    srcs = ["t.java"],
    javacopts = [
        "--release",
        "8",
    ],
)

java_binary(
    name = "b",
    srcs = ["t.java"],
    main_class = "t.t",
    deps = [":l"],
)

# t.java
package t;

public class t {}

# MODULE.bazel
bazel_dep(name = "rules_java", version = "7.3.0")

I get:

$ USE_BAZEL_VERSION=7.0.0rc5 bazel build //:b
...
Use --sandbox_debug to see verbose messages from the sandbox and retain the sandbox build root for debugging
java.lang.NullPointerException: attempted to use --release, but JAVA_HOME is not set
	at [email protected]/java.util.Objects.requireNonNull(Objects.java:259)
	at com.google.turbine.binder.CtSymClassBinder.bind(CtSymClassBinder.java:52)
	at com.google.turbine.main.Main.bootclasspath(Main.java:309)
	at com.google.turbine.main.Main.compile(Main.java:142)
	at com.google.turbine.main.Main.compile(Main.java:133)
	at com.google.turbine.main.Main.main(Main.java:89)
Target //:b failed to build

When I update the rules_java version to 7.3.1, the build passes.

@BoleynSu
Copy link

BoleynSu commented Dec 2, 2023 via email

@fmeum
Copy link
Contributor Author

fmeum commented Dec 2, 2023

Yes, Bazel 6.4.0 doesn't contain bazelbuild/bazel@4a29f08, which is needed to make the Java rules pass ct.sym to Turbine. I would recommend staying on rules_java 7.2.0 with Bazel 6.4.0.

@BoleynSu
Copy link

BoleynSu commented Dec 2, 2023

I see. I am skipping 7.3.x for now. BoleynSu-Org/monorepo@770b1fc
Hopefully, Bazel 7 can be used soon.

mbland added a commit to EngFlow-Academy/bzlmod-bootcamp that referenced this pull request Oct 28, 2025
Adding a newer `rules_python` to `rules_magic_deps` _before_
`rules_proto` fixes the missing `rules_python` file error from the
previous commit.

rules_python 0.37.2 is the last version that doesn't pull in its own
`protobuf`. `rules_python` 0.38.0 pulls in protobuf v27 unconditionally.
0.37.2 allows us to keep using rules_proto-5.3.0-21.7 for now.

Also, `rules_python` 0.40.0 and later require newer `rules_cc` versions
that may not play nice with `protobuf` v21.7. After we upgrade
`protobuf` to a more recent version, we can upgrade to more recent
`rules_python` version. For details:

- bazel-contrib/rules_scala#1660 (comment)

The build now produces the following failure:

```txt
ERROR: external/remote_java_tools_darwin_arm64/BUILD:
  no such target
  '@@remote_java_tools_darwin_arm64//:turbine_direct_graal':
  target 'turbine_direct_graal' not declared in package ''
  defined by external/remote_java_tools_darwin_arm64/BUILD

ERROR: external/rules_java_builtin/toolchains/BUILD:163:14:
  no such target
  '@@remote_java_tools_darwin_arm64//:turbine_direct_graal':
  target 'turbine_direct_graal' not declared in package ''
  defined by external/remote_java_tools_darwin_arm64/BUILD
  and referenced by
  '@@rules_java_builtin//toolchains:turbine_direct_graal_darwin_arm64'

ERROR: Analysis of target '//:default-values' failed; build aborted:
  Analysis failed
```

Another `rules_java_builtin` and user-declared `rules_java` conflict due
to the legacy `WORKSPACE` model:

- `rules_java` 7.3.0 introduced the `turbine_direct_graal` target into its
  `//toolchains` package via:

  bazelbuild/rules_java#151: Use Turbine native image as
  `header_compiler_direct`
  bazelbuild/rules_java@d5b3ecf

- As noted in "Bump to Bazel 7.6.2", the legacy `WORKSPACE` prefix
  creates `@rules_java_builtin`, which is actually `rules_java` 7.6.5.
  This version depends on `remote_java_tools` v13.6.1, whose repos
  contain `//:turbine_direct_graal`. Its `README.md` shows that it
  comes from bazelbuild/bazel@40ec2cd.

  https://github.com/bazelbuild/rules_java/blob/7.6.5/java/repositories.bzl#L25
  https://github.com/bazelbuild/java_tools/releases/download/java_13.6.1/java_tools_darwin_arm64-v13.6.1.zip
  https://github.com/bazelbuild/bazel/blob/40ec2cd1a15d73473945475552ad1d0cb6d77927/tools/jdk/BUILD.java_tools_prebuilt#L26-L32

- The legacy `bootcamp/WORKSPACE` file invokes `rules_java_dependencies`
  from `rules_java` 6.5.2, instantiating `remote_java_tools` v12.6,
  whose repos do _not_ contain `//:turbine_direct_graal`. It comes from
  bazelbuild/bazel@bd91cb1.

  https://github.com/bazelbuild/rules_java/blob/6.5.2/java/repositories.bzl#L31
  https://github.com/bazelbuild/java_tools/releases/download/java_v12.6/java_tools_darwin_arm64-v12.6.zip
  https://github.com/bazelbuild/bazel/blob/bd91cb131785a6693d45c7840a229d345e48d40b/tools/jdk/BUILD.java_tools_prebuilt

- The legacy `WORKSPACE` suffix invokes `rules_java_dependencies` from
  `rules_java` 7.6.5. Since it wraps the `http_archive` repo rules
  instantiating `remote_java_tools` repos with `maybe`, nothing happens,
  because the repos already exist.

- The legacy `WORKSPACE` suffix then invokes `rules_java_toolchains`
  from `rules_java` 7.6.5, which registers `//toolchains:all`.

- That version of the `//toolchains` package aliases
  `"turbine_direct_graal_%s" % OS` to
  `"@remote_java_tools_%s//:turbine_direct_graal" % OS`.

  https://github.com/bazelbuild/rules_java/blob/7.6.5/toolchains/BUILD#L163-L166

- Since the `"@remote_java_tools_%s" % OS` repo doesn't contain a
  `turbine_direct_graal` target, analysis of `//toolchains:all` breaks.

---

Another solution would've been to apply the following patch to remove
`rules_proto` as a dependency and rely only on `com_google_protobuf`.
However, we'll keep `rules_proto` to illustrate a different upgrade path
prior to depending on `com_google_protobuf` directly.

```diff
diff --git i/bootcamp/WORKSPACE w/bootcamp/WORKSPACE
index 3e7a614..0b13a55 100644
--- i/bootcamp/WORKSPACE
+++ w/bootcamp/WORKSPACE
@@ -24,15 +24,6 @@ load(
 rules_java_dependencies()
 rules_java_toolchains()

-load(
-    "@rules_proto//proto:repositories.bzl",
-    "rules_proto_dependencies",
-    "rules_proto_toolchains",
-)
-
-rules_proto_dependencies()
-rules_proto_toolchains()
-
 load("@com_frobozz_rules_magic//magic:config.bzl", "magic_config")

 magic_config(
diff --git i/rules_magic/magic/deps.bzl w/rules_magic/magic/deps.bzl
index 984e8ae..23b64af 100644
--- i/rules_magic/magic/deps.bzl
+++ w/rules_magic/magic/deps.bzl
@@ -15,11 +15,9 @@ def rules_magic_deps():

     maybe(
         http_archive,
-        name = "rules_proto",
-        sha256 = "dc3fb206a2cb3441b485eb1e423165b231235a1ea9b031b4433cf7bc1fa460dd",
-        strip_prefix = "rules_proto-5.3.0-21.7",
+        name = "com_google_protobuf",
         urls = [
-            "https://mirror.bazel.build/github.com/bazelbuild/rules_proto/archive/refs/tags/5.3.0-21.7.tar.gz",
-            "https://github.com/bazelbuild/rules_proto/archive/refs/tags/5.3.0-21.7.tar.gz",
+            "https://github.com/protocolbuffers/protobuf/releases/download/v21.7/protobuf-all-21.7.zip",
         ],
+        sha256 = "5493a21f5ed3fc502e66fec6b9449c06a551ced63002fa48903c40dfa8de7a4a",
     )
```
mbland added a commit to EngFlow-Academy/bzlmod-bootcamp that referenced this pull request Oct 31, 2025
Adding a newer `rules_python` to `rules_magic_deps` _before_
`rules_proto` fixes the missing `rules_python` file error from the
previous commit.

rules_python 0.37.2 is the last version that doesn't pull in its own
`protobuf`. `rules_python` 0.38.0 pulls in protobuf v27 unconditionally.
0.37.2 allows us to keep using rules_proto-5.3.0-21.7 for now.

Also, `rules_python` 0.40.0 and later require newer `rules_cc` versions
that may not play nice with `protobuf` v21.7. After we upgrade
`protobuf` to a more recent version, we can upgrade to more recent
`rules_python` version. For details:

- bazel-contrib/rules_scala#1660 (comment)

The build now produces the following failure:

```txt
ERROR: external/remote_java_tools_darwin_arm64/BUILD:
  no such target
  '@@remote_java_tools_darwin_arm64//:turbine_direct_graal':
  target 'turbine_direct_graal' not declared in package ''
  defined by external/remote_java_tools_darwin_arm64/BUILD

ERROR: external/rules_java_builtin/toolchains/BUILD:163:14:
  no such target
  '@@remote_java_tools_darwin_arm64//:turbine_direct_graal':
  target 'turbine_direct_graal' not declared in package ''
  defined by external/remote_java_tools_darwin_arm64/BUILD
  and referenced by
  '@@rules_java_builtin//toolchains:turbine_direct_graal_darwin_arm64'

ERROR: Analysis of target '//:default-values' failed; build aborted:
  Analysis failed
```

Another `rules_java_builtin` and user-declared `rules_java` conflict due
to the legacy `WORKSPACE` model:

- `rules_java` 7.3.0 introduced the `turbine_direct_graal` target into its
  `//toolchains` package via:

  bazelbuild/rules_java#151: Use Turbine native image as
  `header_compiler_direct`
  bazelbuild/rules_java@d5b3ecf

- As noted in "Bump to Bazel 7.6.2", the legacy `WORKSPACE` prefix
  creates `@rules_java_builtin`, which is actually `rules_java` 7.6.5.
  This version depends on `remote_java_tools` v13.6.1, whose repos
  contain `//:turbine_direct_graal`. Its `README.md` shows that it
  comes from bazelbuild/bazel@40ec2cd.

  https://github.com/bazelbuild/rules_java/blob/7.6.5/java/repositories.bzl#L25
  https://github.com/bazelbuild/java_tools/releases/download/java_13.6.1/java_tools_darwin_arm64-v13.6.1.zip
  https://github.com/bazelbuild/bazel/blob/40ec2cd1a15d73473945475552ad1d0cb6d77927/tools/jdk/BUILD.java_tools_prebuilt#L26-L32

- The legacy `bootcamp/WORKSPACE` file invokes `rules_java_dependencies`
  from `rules_java` 6.5.2, instantiating `remote_java_tools` v12.6,
  whose repos do _not_ contain `//:turbine_direct_graal`. It comes from
  bazelbuild/bazel@bd91cb1.

  https://github.com/bazelbuild/rules_java/blob/6.5.2/java/repositories.bzl#L31
  https://github.com/bazelbuild/java_tools/releases/download/java_v12.6/java_tools_darwin_arm64-v12.6.zip
  https://github.com/bazelbuild/bazel/blob/bd91cb131785a6693d45c7840a229d345e48d40b/tools/jdk/BUILD.java_tools_prebuilt

- The legacy `WORKSPACE` suffix invokes `rules_java_dependencies` from
  `rules_java` 7.6.5. Since it wraps the `http_archive` repo rules
  instantiating `remote_java_tools` repos with `maybe`, nothing happens,
  because the repos already exist.

- The legacy `WORKSPACE` suffix then invokes `rules_java_toolchains`
  from `rules_java` 7.6.5, which registers `//toolchains:all`.

- That version of the `//toolchains` package aliases
  `"turbine_direct_graal_%s" % OS` to
  `"@remote_java_tools_%s//:turbine_direct_graal" % OS`.

  https://github.com/bazelbuild/rules_java/blob/7.6.5/toolchains/BUILD#L163-L166

- Since the `"@remote_java_tools_%s" % OS` repo doesn't contain a
  `turbine_direct_graal` target, analysis of `//toolchains:all` breaks.

---

Another solution would've been to remove `rules_proto` as a dependency
and to rely directly upon `com_google_protobuf`. However, we'll keep
`rules_proto` for now to illustrate a different upgrade path prior to
depending on `com_google_protobuf` directly.
mbland added a commit to EngFlow-Academy/bzlmod-bootcamp that referenced this pull request Nov 5, 2025
Adding a newer `rules_python` to `rules_magic_deps` _before_
`rules_proto` fixes the missing `rules_python` file error from the
previous commit.

rules_python 0.37.2 is the last version that doesn't pull in its own
`protobuf`. `rules_python` 0.38.0 pulls in protobuf v27 unconditionally.
0.37.2 allows us to keep using rules_proto-5.3.0-21.7 for now.

Also, `rules_python` 0.40.0 and later require newer `rules_cc` versions
that may not play nice with `protobuf` v21.7. After we upgrade
`protobuf` to a more recent version, we can upgrade to more recent
`rules_python` version. For details:

- bazel-contrib/rules_scala#1660 (comment)

The build now produces the following failure:

```txt
ERROR: external/remote_java_tools_darwin_arm64/BUILD:
  no such target
  '@@remote_java_tools_darwin_arm64//:turbine_direct_graal':
  target 'turbine_direct_graal' not declared in package ''
  defined by external/remote_java_tools_darwin_arm64/BUILD

ERROR: external/rules_java_builtin/toolchains/BUILD:163:14:
  no such target
  '@@remote_java_tools_darwin_arm64//:turbine_direct_graal':
  target 'turbine_direct_graal' not declared in package ''
  defined by external/remote_java_tools_darwin_arm64/BUILD
  and referenced by
  '@@rules_java_builtin//toolchains:turbine_direct_graal_darwin_arm64'

ERROR: Analysis of target '//:default-values' failed; build aborted:
  Analysis failed
```

Another `rules_java_builtin` and user-declared `rules_java` conflict due
to the legacy `WORKSPACE` model:

- `rules_java` 7.3.0 introduced the `turbine_direct_graal` target into its
  `//toolchains` package via:

  bazelbuild/rules_java#151: Use Turbine native image as
  `header_compiler_direct`
  bazelbuild/rules_java@d5b3ecf

- As noted in "Bump to Bazel 7.7.0", the legacy `WORKSPACE` prefix
  creates `@rules_java_builtin`, which is actually `rules_java` 7.6.5.
  This version depends on `remote_java_tools` v13.6.1, whose repos
  contain `//:turbine_direct_graal`. Its `README.md` shows that it
  comes from bazelbuild/bazel@40ec2cd.

  https://github.com/bazelbuild/rules_java/blob/7.6.5/java/repositories.bzl#L25
  https://github.com/bazelbuild/java_tools/releases/download/java_13.6.1/java_tools_darwin_arm64-v13.6.1.zip
  https://github.com/bazelbuild/bazel/blob/40ec2cd1a15d73473945475552ad1d0cb6d77927/tools/jdk/BUILD.java_tools_prebuilt#L26-L32

- The legacy `bootcamp/WORKSPACE` file invokes `rules_java_dependencies`
  from `rules_java` 6.5.2, instantiating `remote_java_tools` v12.6,
  whose repos do _not_ contain `//:turbine_direct_graal`. It comes from
  bazelbuild/bazel@bd91cb1.

  https://github.com/bazelbuild/rules_java/blob/6.5.2/java/repositories.bzl#L31
  https://github.com/bazelbuild/java_tools/releases/download/java_v12.6/java_tools_darwin_arm64-v12.6.zip
  https://github.com/bazelbuild/bazel/blob/bd91cb131785a6693d45c7840a229d345e48d40b/tools/jdk/BUILD.java_tools_prebuilt

- The legacy `WORKSPACE` suffix invokes `rules_java_dependencies` from
  `rules_java` 7.6.5. Since it wraps the `http_archive` repo rules
  instantiating `remote_java_tools` repos with `maybe`, nothing happens,
  because the repos already exist.

- The legacy `WORKSPACE` suffix then invokes `rules_java_toolchains`
  from `rules_java` 7.6.5, which registers `//toolchains:all`.

- That version of the `//toolchains` package aliases
  `"turbine_direct_graal_%s" % OS` to
  `"@remote_java_tools_%s//:turbine_direct_graal" % OS`.

  https://github.com/bazelbuild/rules_java/blob/7.6.5/toolchains/BUILD#L163-L166

- Since the `"@remote_java_tools_%s" % OS` repo doesn't contain a
  `turbine_direct_graal` target, analysis of `//toolchains:all` breaks.

---

Another solution would've been to remove `rules_proto` as a dependency
and to rely directly upon `com_google_protobuf`. However, we'll keep
`rules_proto` for now to illustrate a different upgrade path prior to
depending on `com_google_protobuf` directly.
mbland added a commit to EngFlow-Academy/bzlmod-bootcamp that referenced this pull request Nov 7, 2025
Adding a newer `rules_python` to `rules_magic_deps` _before_
`rules_proto` fixes the missing `rules_python` file error from the
previous commit.

rules_python 0.37.2 is the last version that doesn't pull in its own
`protobuf`. `rules_python` 0.38.0 pulls in protobuf v27 unconditionally.
0.37.2 allows us to keep using rules_proto-5.3.0-21.7 for now.

Also, `rules_python` 0.40.0 and later require newer `rules_cc` versions
that may not play nice with `protobuf` v21.7. After we upgrade
`protobuf` to a more recent version, we can upgrade to more recent
`rules_python` version. For details:

- bazel-contrib/rules_scala#1660 (comment)

The build now produces the following failure:

```txt
ERROR: external/remote_java_tools_darwin_arm64/BUILD:
  no such target
  '@@remote_java_tools_darwin_arm64//:turbine_direct_graal':
  target 'turbine_direct_graal' not declared in package ''
  defined by external/remote_java_tools_darwin_arm64/BUILD

ERROR: external/rules_java_builtin/toolchains/BUILD:163:14:
  no such target
  '@@remote_java_tools_darwin_arm64//:turbine_direct_graal':
  target 'turbine_direct_graal' not declared in package ''
  defined by external/remote_java_tools_darwin_arm64/BUILD
  and referenced by
  '@@rules_java_builtin//toolchains:turbine_direct_graal_darwin_arm64'

ERROR: Analysis of target '//:default-values' failed; build aborted:
  Analysis failed
```

Another `rules_java_builtin` and user-declared `rules_java` conflict due
to the legacy `WORKSPACE` model:

- `rules_java` 7.3.0 introduced the `turbine_direct_graal` target into its
  `//toolchains` package via:

  bazelbuild/rules_java#151: Use Turbine native image as
  `header_compiler_direct`
  bazelbuild/rules_java@d5b3ecf

- As noted in "Bump to Bazel 7.7.0", the legacy `WORKSPACE` prefix
  creates `@rules_java_builtin`, which is actually `rules_java` 7.6.5.
  This version depends on `remote_java_tools` v13.6.1, whose repos
  contain `//:turbine_direct_graal`. Its `README.md` shows that it
  comes from bazelbuild/bazel@40ec2cd.

  https://github.com/bazelbuild/rules_java/blob/7.6.5/java/repositories.bzl#L25
  https://github.com/bazelbuild/java_tools/releases/download/java_13.6.1/java_tools_darwin_arm64-v13.6.1.zip
  https://github.com/bazelbuild/bazel/blob/40ec2cd1a15d73473945475552ad1d0cb6d77927/tools/jdk/BUILD.java_tools_prebuilt#L26-L32

- The legacy `bootcamp/WORKSPACE` file invokes `rules_java_dependencies`
  from `rules_java` 6.5.2, instantiating `remote_java_tools` v12.6,
  whose repos do _not_ contain `//:turbine_direct_graal`. It comes from
  bazelbuild/bazel@bd91cb1.

  https://github.com/bazelbuild/rules_java/blob/6.5.2/java/repositories.bzl#L31
  https://github.com/bazelbuild/java_tools/releases/download/java_v12.6/java_tools_darwin_arm64-v12.6.zip
  https://github.com/bazelbuild/bazel/blob/bd91cb131785a6693d45c7840a229d345e48d40b/tools/jdk/BUILD.java_tools_prebuilt

- The legacy `WORKSPACE` suffix invokes `rules_java_dependencies` from
  `rules_java` 7.6.5. Since it wraps the `http_archive` repo rules
  instantiating `remote_java_tools` repos with `maybe`, nothing happens,
  because the repos already exist.

- The legacy `WORKSPACE` suffix then invokes `rules_java_toolchains`
  from `rules_java` 7.6.5, which registers `//toolchains:all`.

- That version of the `//toolchains` package aliases
  `"turbine_direct_graal_%s" % OS` to
  `"@remote_java_tools_%s//:turbine_direct_graal" % OS`.

  https://github.com/bazelbuild/rules_java/blob/7.6.5/toolchains/BUILD#L163-L166

- Since the `"@remote_java_tools_%s" % OS` repo doesn't contain a
  `turbine_direct_graal` target, analysis of `//toolchains:all` breaks.

---

Another solution would've been to remove `rules_proto` as a dependency
and to rely directly upon `com_google_protobuf`. However, we'll keep
`rules_proto` for now to illustrate a different upgrade path prior to
depending on `com_google_protobuf` directly.
mbland added a commit to EngFlow-Academy/bzlmod-bootcamp that referenced this pull request Nov 7, 2025
Adding a newer `rules_python` to `rules_magic_deps` _before_
`rules_proto` fixes the missing `rules_python` file error from the
previous commit.

rules_python 0.37.2 is the last version that doesn't pull in its own
`protobuf`. `rules_python` 0.38.0 pulls in protobuf v27 unconditionally.
0.37.2 allows us to keep using rules_proto-5.3.0-21.7 for now.

Also, `rules_python` 0.40.0 and later require newer `rules_cc` versions
that may not play nice with `protobuf` v21.7. After we upgrade
`protobuf` to a more recent version, we can upgrade to more recent
`rules_python` version. For details:

- bazel-contrib/rules_scala#1660 (comment)

The build now produces the following failure:

```txt
ERROR: external/remote_java_tools_darwin_arm64/BUILD:
  no such target
  '@@remote_java_tools_darwin_arm64//:turbine_direct_graal':
  target 'turbine_direct_graal' not declared in package ''
  defined by external/remote_java_tools_darwin_arm64/BUILD

ERROR: external/rules_java_builtin/toolchains/BUILD:163:14:
  no such target
  '@@remote_java_tools_darwin_arm64//:turbine_direct_graal':
  target 'turbine_direct_graal' not declared in package ''
  defined by external/remote_java_tools_darwin_arm64/BUILD
  and referenced by
  '@@rules_java_builtin//toolchains:turbine_direct_graal_darwin_arm64'

ERROR: Analysis of target '//:default-values' failed; build aborted:
  Analysis failed
```

Another `rules_java_builtin` and user-declared `rules_java` conflict due
to the legacy `WORKSPACE` model:

- `rules_java` 7.3.0 introduced the `turbine_direct_graal` target into its
  `//toolchains` package via:

  bazelbuild/rules_java#151: Use Turbine native image as
  `header_compiler_direct`
  bazelbuild/rules_java@d5b3ecf

- As noted in "Bump to Bazel 7.7.0", the legacy `WORKSPACE` prefix
  creates `@rules_java_builtin`, which is actually `rules_java` 7.6.5.
  This version depends on `remote_java_tools` v13.6.1, whose repos
  contain `//:turbine_direct_graal`. Its `README.md` shows that it
  comes from bazelbuild/bazel@40ec2cd.

  https://github.com/bazelbuild/rules_java/blob/7.6.5/java/repositories.bzl#L25
  https://github.com/bazelbuild/java_tools/releases/download/java_13.6.1/java_tools_darwin_arm64-v13.6.1.zip
  https://github.com/bazelbuild/bazel/blob/40ec2cd1a15d73473945475552ad1d0cb6d77927/tools/jdk/BUILD.java_tools_prebuilt#L26-L32

- The legacy `bootcamp/WORKSPACE` file invokes `rules_java_dependencies`
  from `rules_java` 6.5.2, instantiating `remote_java_tools` v12.6,
  whose repos do _not_ contain `//:turbine_direct_graal`. It comes from
  bazelbuild/bazel@bd91cb1.

  https://github.com/bazelbuild/rules_java/blob/6.5.2/java/repositories.bzl#L31
  https://github.com/bazelbuild/java_tools/releases/download/java_v12.6/java_tools_darwin_arm64-v12.6.zip
  https://github.com/bazelbuild/bazel/blob/bd91cb131785a6693d45c7840a229d345e48d40b/tools/jdk/BUILD.java_tools_prebuilt

- The legacy `WORKSPACE` suffix invokes `rules_java_dependencies` from
  `rules_java` 7.6.5. Since it wraps the `http_archive` repo rules
  instantiating `remote_java_tools` repos with `maybe`, nothing happens,
  because the repos already exist.

- The legacy `WORKSPACE` suffix then invokes `rules_java_toolchains`
  from `rules_java` 7.6.5, which registers `//toolchains:all`.

- That version of the `//toolchains` package aliases
  `"turbine_direct_graal_%s" % OS` to
  `"@remote_java_tools_%s//:turbine_direct_graal" % OS`.

  https://github.com/bazelbuild/rules_java/blob/7.6.5/toolchains/BUILD#L163-L166

- Since the `"@remote_java_tools_%s" % OS` repo doesn't contain a
  `turbine_direct_graal` target, analysis of `//toolchains:all` breaks.

---

Another solution would've been to remove `rules_proto` as a dependency
and to rely directly upon `com_google_protobuf`. However, we'll keep
`rules_proto` for now to illustrate a different upgrade path prior to
depending on `com_google_protobuf` directly.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants