Skip to content
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.2.0 fails to build due to Java mismatch issues #22789

Closed
stamenminkov opened this issue Jun 18, 2024 · 6 comments
Closed

Bazel 7.2.0 fails to build due to Java mismatch issues #22789

stamenminkov opened this issue Jun 18, 2024 · 6 comments
Labels
team-Rules-CPP Issues for C++ rules team-Rules-Java Issues for Java rules type: bug untriaged

Comments

@stamenminkov
Copy link

stamenminkov commented Jun 18, 2024

Description of the bug:

Hi,

I'm currently trying to build Bazel 7.2.0 as an EasyBuild module (that might not be the relevant part tho, as the procedure doesn't differ really that much). I'm using GCC-13, which has already given me troubles when I've tried to install previous versions of Bazel (6.X.X), as it fails due to a huge number of formatting issues with Abseil.

I've now tried with the latest release, but here the issue is different:

  • First of all, if using JAVA-11, the build fails immediately with the following error:
Building Bazel from scratch
ERROR: JDK version (1.11) is lower than 21, please set $JAVA_HOME.
  • If I switch to JAVA-21, the build ignites, however it fails after about a minute with a huge number of errors of these types:
  bad class file: derived/jars/protobuf~/java/core/libcore.jar(/com/google/protobuf/GeneratedMessageV3.class)
    class file has wrong version 65.0, should be 55.0
    Please remove or make sure it appears in the correct subdirectory of the classpath.
derived/src/java/build/bazel/remote/asset/v1/FetchBlobRequestOrBuilder.java:8: error: cannot access MessageOrBuilder
    com.google.protobuf.MessageOrBuilder {

and

  symbol:   class UnusedPrivateParameter
  location: class FetchBlobRequest
derived/src/java/build/bazel/remote/execution/v2/DigestFunction.java:29: error: cannot find symbol
      UnusedPrivateParameter unused) {
      ^

And eventually:

100 errors
Target //src:bazel_nojdk failed to build
INFO: Elapsed time: 13.976s, Critical Path: 5.23s
INFO: 869 processes: 317 internal, 552 local.
ERROR: Build did NOT complete successfully

As I checked, the 55.0 version it's posteriorly asking for corresponds to Java-11 , however at the beginning it's asking for Java-21. Tbh, it's quite confusing why this Java mismatch is happening.

Which category does this issue belong to?

C++ Rules, Java Rules

What's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

I can provide with the EasyBuild recipe, however it's quite standard, it just lists the Bazel version and its dependencies.

Which operating system are you running Bazel on?

RHEL 9.2

What is the output of bazel info release?

No response

If bazel info release returns development 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 HEAD ?

No response

If this is a regression, please try to identify the Bazel commit where the bug was introduced with bazelisk --bisect.

No response

Have you found anything relevant by searching the web?

I found this: #18309, and I've tried passing --java_language_version=21 to the build, however it does nothing... (Same for --java_language_version=11).

Any other information, logs, or outputs that you want to share?

No response

@github-actions github-actions bot added team-Rules-CPP Issues for C++ rules team-Rules-Java Issues for Java rules labels Jun 18, 2024
@stamenminkov stamenminkov changed the title Bazel 7.2.0 fails to build due to Java issues Bazel 7.2.0 fails to build due to Java mismatch issues Jun 18, 2024
@fmeum
Copy link
Collaborator

fmeum commented Jun 18, 2024

Could you share the recipe or at least the Bazel invocation that is used in the build?

@stamenminkov
Copy link
Author

stamenminkov commented Jun 18, 2024

@fmeum This is the invocation file:
https://github.com/easybuilders/easybuild-easyblocks/blob/develop/easybuild/easyblocks/b/bazel.py

And this is my recipe:

name = 'Bazel'
version = '7.2.0'

homepage = 'https://bazel.io/'
description = """Bazel is a build tool that builds code quickly and reliably.
It is used to build the majority of Google's software."""

toolchain = {'name': 'GCCcore', 'version': '13.2.0'}

source_urls = ['https://github.com/bazelbuild/%(namelower)s/releases/download/%(version)s']
sources = ['%(namelower)s-%(version)s-dist.zip']
#patches = ['Bazel-6.3.1_add-symlinks-in-runfiles.patch']
checksums = [
    {'bazel-7.2.0-dist.zip': '2070e03d97c4f5ee2d245832d78d17a18f8a4db0669f72a362ff0f84fb091ee1'},
#    {'Bazel-6.3.1_add-symlinks-in-runfiles.patch': '81db53aa87229557480b6f719c99a0f1af9c69dfec12185451e520b0128c3ae2'},
]

builddependencies = [
    ('binutils', '2.40'),
    ('Python', '3.11.5'),
    ('protobuf-python', '4.25.3'),
    ('Zip', '3.0'),
]

dependencies = [
    ('Java', '21', '', SYSTEM),
]

buildopts = " --java_language_version=21 "
runtest = True
testopts = "-- //examples/cpp:hello-success_test //examples/py/... //examples/py_native:test //examples/shell/..."

moduleclass = 'devel'

Thank you!

@fmeum
Copy link
Collaborator

fmeum commented Jun 18, 2024

You are probably missing --tool_java_runtime_version=local_jdk from https://bazel.build/install/compile-source#bootstrap-unix.

@stamenminkov
Copy link
Author

Hi @fmeum , thanks again!

At what moment shall this be applied? I guess since it's build time it should be something like the code below, however it's not working:

name = 'Bazel'
version = '7.2.0'

homepage = 'https://bazel.io/'
description = """Bazel is a build tool that builds code quickly and reliably.
It is used to build the majority of Google's software."""

toolchain = {'name': 'GCCcore', 'version': '13.2.0'}

source_urls = ['https://github.com/bazelbuild/%(namelower)s/releases/download/%(version)s']
sources = ['%(namelower)s-%(version)s-dist.zip']
#patches = ['Bazel-6.3.1_add-symlinks-in-runfiles.patch']
checksums = [
    {'bazel-7.2.0-dist.zip': '2070e03d97c4f5ee2d245832d78d17a18f8a4db0669f72a362ff0f84fb091ee1'},
#    {'Bazel-6.3.1_add-symlinks-in-runfiles.patch': '81db53aa87229557480b6f719c99a0f1af9c69dfec12185451e520b0128c3ae2'},
]

builddependencies = [
    ('binutils', '2.40'),
    ('Python', '3.11.5'),
    ('protobuf-python', '4.25.3'),
    ('Zip', '3.0'),
]

dependencies = [
    ('Java', '21', '', SYSTEM),
]

buildopts = " --tool_java_runtime_version=local_jdk"
buildopts += " --java_language_version=21"
runtest = True
testopts = "-- //examples/cpp:hello-success_test //examples/py/... //examples/py_native:test //examples/shell/..."

moduleclass = 'devel'

@fmeum
Copy link
Collaborator

fmeum commented Jun 18, 2024

It needs to replace this, I think:
https://github.com/easybuilders/easybuild-easyblocks/blob/develop/easybuild/easyblocks/b/bazel.py#L167

@stamenminkov
Copy link
Author

Thanks @fmeum , looks like this has worked!!! 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
team-Rules-CPP Issues for C++ rules team-Rules-Java Issues for Java rules type: bug untriaged
Projects
None yet
Development

No branches or pull requests

5 participants