bazelbuild / stardoc

Stardoc: Starlark Documentation Generator
Apache License 2.0
108 stars 45 forks source link

fix: add missing proto_library load to support Bazel 8 #263

Open rickeylev opened 18 hours ago

rickeylev commented 18 hours ago

The load for proto_library is missing, which breaks when used with Bazel 8.

Fixes https://github.com/bazelbuild/stardoc/issues/261

rickeylev commented 17 hours ago

Well, bzlmod seems to be happy, but workspace seems to be unhappy.

external/com_google_protobuf/bazel/private/java_proto_support.bzl:9:6: 
cannot load '@@rules_java//java/private:proto_support.bzl':
no such file and referenced by '@@bazel_tools//tools/proto:java_toolchain'

Let's see if upgrading rules_java in workspace helps. bzlmod is using 7.12.2, so let's try that...ok, yeah that seems to have fixed that part

But now an issue in rules_cc referencing @protobuf

error loading package '@@rules_java//toolchains':
at .../external/rules_cc/cc/defs.bzl:16:6:
Unable to find package for @@protobuf//bazel:cc_proto_library.bzl:
The repository '@@protobuf' could not be resolved:
Repository '@@protobuf' is not defined.

Ivo mentioned that the name must be com_google_protobuf for workspace builds. Lets try upgrading rules_cc 0.1.0 ... ah nope:

external/remote_java_tools/BUILD", line 7, column 60, in <toplevel>
    load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library", "cc_proto_library")
Error: file '@rules_cc//cc:defs.bzl' does not contain symbol 'cc_proto_library'

This sounds vaguely familiar. Lets try rules_cc 0.0.17 ... ah nope:

ERROR: .../external/com_google_protobuf/src/google/protobuf/BUILD.bazel:219:14:
in proto_library rule @@com_google_protobuf//src/google/protobuf:descriptor_proto:
Traceback (most recent call last):
    File ".../external/com_google_protobuf/bazel/private/bazel_proto_library_rule.bzl", line 67, column 39, in _proto_library_impl
        import_prefix = _get_import_prefix(ctx)
    File ".../external/com_google_protobuf/bazel/private/bazel_proto_library_rule.bzl", line 39, column 17, in _get_import_prefix
        if not paths.is_normalized(import_prefix):
Error: 'struct' value has no field or method 'is_normalized'

Not sure if this is a step forward or backwards. Well, i think the issue there is paths.is_normalized came about in skylib 1.7, so lets try bazel_skylib 1.7.1 ... almost there ... success! well, pretty close, anyways. Bazel@head fails compiling absl, which is probably related to protobuf. Everything else is happy though.


When I try this PR with rules_python, it gets past the error. (Eventually fails when compiling absl, but that is probably a separate issue specific to protobuf; maybe adding a --copt i saw elsewhere would fix that; wouldn't be surprised if the compiling failure in stardoc and rules_python originate from the same cause).

meteorcloudy commented 7 hours ago

For the remaining failures, we might want to just upgrade the platforms tested here (ubuntu1804 has a very old gcc and is no longer supported): https://github.com/bazelbuild/stardoc/blob/91e429d9e2e959893c1ce2f81c35806b3a2daf8c/.bazelci/presubmit.yml#L4-L6

Probably should be:

- ubuntu2004
- ubuntu2204
- macos_arm64
meteorcloudy commented 7 hours ago

@comius Does it look correct that autoload didn't work for Stardoc?

tetromino commented 18 minutes ago

When I try to build this PR on my Mac, I get a failure (some sort of java version incompatibility caused by rules_jvm_external).

ERROR: /private/var/tmp/_bazel_arostovtsev/4db74ff3612d0bdc1259d9a6e5cd2136/external/protobuf+/java/core/BUILD.bazel:182:22: Building external/protobuf+/java/core/liblite_runtime_only.jar (93 source files) failed: (Exit 1): java failed: error executing Javac command (from target @@protobuf+//java/core:lite_runtime_only) external/rules_java++toolchains+remotejdk21_macos/bin/java '--add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED' '--add-exports=jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED' ... (remaining 19 arguments skipped)
error: cannot access module-info
  bad class file: /modules/java.base/module-info.class
    class file has wrong version 67.0, should be 65.0
    Please remove or make sure it appears in the correct subdirectory of the classpath.
error: [BazelJavaConfiguration] The Java 21 runtime used to run javac is not recent enough to compile for the Java 23 runtime in external/rules_java++toolchains+local_jdk. Either register a Java toolchain with a newer java_runtime or specify a lower --java_runtime_version.
Use --verbose_failures to see the command lines of failed build steps.
rickeylev commented 10 minutes ago

The Java 21 runtime used to run javac is not recent enough to compile for the Java 23 runtime in external/rules_java++toolchains+local_jdk. Either register a Java toolchain with a newer java_runtime or specify a lower --java_runtime_version.

Ohhhhh this looks so familiar. :thinking:

HTH