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

FreeBSD 13 bazel build problem about java jdk, can not use local_jdk #20229

Closed
UlasSAYGINIM opened this issue Mar 5, 2022 · 12 comments
Closed
Labels
area/build stale stalebot believes this issue/PR has not been touched recently

Comments

@UlasSAYGINIM
Copy link

Title: FreeBSD 13 bazel build gives error about jdk toolchain

Description:

I am trying to build envoy on freebsd 13 with bazel 5.0.0 but i am not able to compile with openjdk on freebsd.
does not matter what java parameter i use for runtime, such as --tool_java_language_version=11 --java_runtime_version=11 --java_language_version=11
it gives errors below. i can not make bazel use local jdk and it seems envoy java configurations does not detect freebsd java to compile.
but if i execute command bazel info --java_runtime_version=11 , that shows bazel knows openjdk and seems connected.
you can see logs for this command below.

bazel build //:envoy --sandbox_debug --java_runtime_version=local_jdk
INFO: Build option --extra_toolchains has changed, discarding analysis cache.
INFO: Repository remote_java_tools instantiated at:
/DEFAULT.WORKSPACE.SUFFIX:360:6: in
/root/.cache/bazel/_bazel_root/4e47b77d977b209382cf04b3ae32963e/external/bazel_tools/tools/build_defs/repo/utils.bzl:233:18: in maybe
Repository rule http_archive defined at:
/root/.cache/bazel/_bazel_root/4e47b77d977b209382cf04b3ae32963e/external/bazel_tools/tools/build_defs/repo/http.bzl:364:31: in
INFO: Repository v8 instantiated at:
/root/envoy/WORKSPACE:13:19: in
/root/envoy/bazel/repositories.bzl:192:8: in envoy_dependencies
/root/envoy/bazel/repositories.bzl:787:26: in _v8
/root/envoy/bazel/repositories.bzl:29:23: in external_http_archive
/root/.cache/bazel/_bazel_root/4e47b77d977b209382cf04b3ae32963e/external/envoy_api/bazel/envoy_http_archive.bzl:16:17: in envoy_http_archive
Repository rule http_archive defined at:
/root/.cache/bazel/_bazel_root/4e47b77d977b209382cf04b3ae32963e/external/bazel_tools/tools/build_defs/repo/http.bzl:364:31: in
ERROR: /root/.cache/bazel/_bazel_root/4e47b77d977b209382cf04b3ae32963e/external/bazel_tools/tools/jdk/BUILD:29:19: While resolving toolchains for target @bazel_tools//tools/jdk:current_java_runtime: no matching toolchains found for types @bazel_tools//tools/jdk:runtime_toolchain_type
ERROR: Analysis of target '//:envoy' failed; build aborted:
INFO: Elapsed time: 1.398s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (0 packages loaded, 14115 targets configured)
Fetching @com_github_lyft_protoc_gen_star; Restarting.
Fetching @bazel_gazelle_go_repository_config; Restarting.
Fetching @bazel_gazelle_go_repository_tools; fetching
Fetching https://mirror.bazel.build/bazel_java_tools/releases/java/v11.6/java_tools-v11.6.zip
Fetching https://storage.googleapis.com/envoyproxy-wee8/v8-9.9.115.5.tar.gz

second time i try without any java config.
bazel build //:envoy
INFO: Build option --java_runtime_version has changed, discarding analysis cache.
INFO: Repository v8 instantiated at:
/root/envoy/WORKSPACE:13:19: in
/root/envoy/bazel/repositories.bzl:192:8: in envoy_dependencies
/root/envoy/bazel/repositories.bzl:787:26: in _v8
/root/envoy/bazel/repositories.bzl:29:23: in external_http_archive
/root/.cache/bazel/_bazel_root/4e47b77d977b209382cf04b3ae32963e/external/envoy_api/bazel/envoy_http_archive.bzl:16:17: in envoy_http_archive
Repository rule http_archive defined at:
/root/.cache/bazel/_bazel_root/4e47b77d977b209382cf04b3ae32963e/external/bazel_tools/tools/build_defs/repo/http.bzl:364:31: in
INFO: Repository remote_java_tools instantiated at:
/DEFAULT.WORKSPACE.SUFFIX:360:6: in
/root/.cache/bazel/_bazel_root/4e47b77d977b209382cf04b3ae32963e/external/bazel_tools/tools/build_defs/repo/utils.bzl:233:18: in maybe
Repository rule http_archive defined at:
/root/.cache/bazel/_bazel_root/4e47b77d977b209382cf04b3ae32963e/external/bazel_tools/tools/build_defs/repo/http.bzl:364:31: in
ERROR: /root/.cache/bazel/_bazel_root/4e47b77d977b209382cf04b3ae32963e/external/bazel_tools/tools/jdk/BUILD:29:19: While resolving toolchains for target @bazel_tools//tools/jdk:current_java_runtime: no matching toolchains found for types @bazel_tools//tools/jdk:runtime_toolchain_type
ERROR: Analysis of target '//:envoy' failed; build aborted:
INFO: Elapsed time: 1.192s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (0 packages loaded, 16404 targets configured)
Fetching https://storage.googleapis.com/envoyproxy-wee8/v8-9.9.115.5.tar.gz
Fetching https://mirror.bazel.build/bazel_java_tools/releases/java/v11.6/java_tools-v11.6.zip

[optional Relevant Links:]

bazel info --java_runtime_version=11
bazel-bin: /root/.cache/bazel/_bazel_root/4e47b77d977b209382cf04b3ae32963e/execroot/envoy/bazel-out/freebsd-fastbuild/bin
bazel-genfiles: /root/.cache/bazel/_bazel_root/4e47b77d977b209382cf04b3ae32963e/execroot/envoy/bazel-out/freebsd-fastbuild/bin
bazel-testlogs: /root/.cache/bazel/_bazel_root/4e47b77d977b209382cf04b3ae32963e/execroot/envoy/bazel-out/freebsd-fastbuild/testlogs
character-encoding: file.encoding = ISO-8859-1, defaultCharset = ISO-8859-1
command_log: /root/.cache/bazel/_bazel_root/4e47b77d977b209382cf04b3ae32963e/command.log
committed-heap-size: 377MB
execution_root: /root/.cache/bazel/_bazel_root/4e47b77d977b209382cf04b3ae32963e/execroot/envoy
gc-count: 176
gc-time: 8759ms
install_base: /root/.cache/bazel/_bazel_root/install/2557632c4e47522f0c8c6a1c0eabdaa0
java-home: /usr/local/openjdk11
java-runtime: OpenJDK Runtime Environment (build 11.0.14+9-1) by OpenJDK BSD Porting Team
java-vm: OpenJDK 64-Bit Server VM (build 11.0.14+9-1, mixed mode) by OpenJDK BSD Porting Team
max-heap-size: 2147MB
output_base: /root/.cache/bazel/_bazel_root/4e47b77d977b209382cf04b3ae32963e
output_path: /root/.cache/bazel/_bazel_root/4e47b77d977b209382cf04b3ae32963e/execroot/envoy/bazel-out
package_path: %workspace%
release: release 5.0.0
repository_cache: /root/.cache/bazel/_bazel_root/cache/repos/v1
server_log: /root/.cache/bazel/_bazel_root/4e47b77d977b209382cf04b3ae32963e/java.log.unknown.root.log.java.20220305-151817.5791
server_pid: 5791
used-heap-size: 278MB
workspace: /root/envoy

@UlasSAYGINIM UlasSAYGINIM added the triage Issue requires triage label Mar 5, 2022
@RyanTheOptimist
Copy link
Contributor

cc @lizan do you have any insight here?

@lizan
Copy link
Member

lizan commented Mar 11, 2022

It seems to be a Bazel issue. Though we don't support FreeBSD either.

@UlasSAYGINIM
Copy link
Author

you have freebsd support in your bazel configuration and there is port on freebsd port tree. @lizan .
i will try sample java project to test your idea, if it is bazel issue, i will be sure but i think it is related to bazel configuration,
which envoy has. can you tell me, how can i config envoy bazel settings to set jdk 11 and toolchain of its own?

@UlasSAYGINIM
Copy link
Author

UlasSAYGINIM commented Mar 16, 2022

i think it is related to changes of bazel 5.0.0 , bazelbuild/bazel#7849
@lizan can i ask your opinion? because it seems it is NOT related to freebsd issue only.

@SimonVleugels
Copy link

SimonVleugels commented Mar 24, 2022

It also took me a while to figure it out how to run bazel using the local installed jdk. Not sure if it helps, but this is what I did for using a local installed jdk17 on CentOS7 with Bazel 5.0.0:

JAVA_HOME=/usr/lib/jvm/java-17-openjdk
bazel build --java_language_version=17 --java_runtime_version=local_jdk --tool_java_language_version=17 --tool_java_runtime_version=local_jdk

@UlasSAYGINIM
Copy link
Author

thank you for answer. i found out this command is not working if project has bazel.rc file and it disregards your commands.
you should edit bazel.rc like this command you gave or change what is required for you.

in addition this, bazel has problem about charset. if i use another charset than C.utf8 on freebsd like turkish.utf8 it will not work starlark as intenteded it will give error but it will not tell you about charset issue. i also saw this problem on tensorflow project github issues but i didnt have link for now. i tried from their soluton by changing OS charset. it solved the problem it causes.
i will post the problem and issue link when i found it.

thanks a lot for your kind help.

@UlasSAYGINIM
Copy link
Author

@SimonVleugels i forgot to tag you sorry. thank you for your help. have a nice day.

@SimonVleugels
Copy link

SimonVleugels commented Mar 25, 2022

thank you for answer. i found out this command is not working if project has bazel.rc file and it disregards your commands. you should edit bazel.rc like this command you gave or change what is required for you.

No it does not.

.bazelrc:

build:toolchaindebug --toolchain_resolution_debug='.*'

Bazel test:

#bazel test --config=toolchaindebug --java_language_version=17 --java_runtime_version=remotejdk_17 --tool_java_language_version=17 --tool_java_runtime_version=remotejdk_17 tests:cppcheck
Extracting Bazel installation...
Starting local Bazel server and connecting to it...
INFO: ToolchainResolution: Target platform @local_config_platform//:host: Selected execution platform @local_config_platform//:host,
INFO: ToolchainResolution: Target platform @local_config_platform//:host: Selected execution platform @local_config_platform//:host,
INFO: ToolchainResolution: Target platform @local_config_platform//:host: Selected execution platform @local_config_platform//:host,
Analyzing: target //tests:cppcheck-test-1 (6 packages loaded, 27 targets configured)
    Fetching @remotejdk17_linux; fetching

As you can see in the output I get the ToolchainResolution info I requested in the .bazelrc with the flag --toolchain_resolution_debug and bazel is fetching remotejdk17_linux as requested with the java command line options.
This also works when using a local installed jdk.

Nevertheless adding all the java options in your .bazelrc should also work.
.bazelrc:

build:java17 --java_language_version=17
build:java17 --java_runtime_version=local_jdk
build:java17 --tool_java_language_version=17
build:java17 --tool_java_runtime_version=local_jdk

Bazel command:

# bazel test --config=java17 tests:cppcheck

@UlasSAYGINIM
Copy link
Author

thank you for information. i knew that. it is good to you explained detailed version, it will help someone who needs later.
i am sharing the github issue about language problem.

i was facing the error below. i solved the error by changing langueage as C.UTF-8 as locale in login.conf.

i am sharing the issue is not related to my problem but similary error and changing language idea solved my problem.

tensorflow/tensorflow#34833

root@fbsd122:~/examples/cpp-tutorial/stage1 # bazel build --announce_rc //main:hello-world
INFO: Options provided by the client:
  Inherited 'common' options: --isatty=1 --terminal_columns=237
INFO: Reading rc options for 'build' from /usr/local/etc/bazel/bazel.bazelrc:
  'build' options: --strategy=Javac=standalone --java_runtime_version=11 --tool_java_runtime_version=11 --action_env=PATH=/bin:/usr/bin/:/usr/local/bin
ERROR: /root/.cache/bazel/_bazel_root/226a657e3ffc703888af21dbab4728de/external/bazel_tools/tools/jdk/BUILD:432:8: In rule 'proguard_whitelister_test', size 'medium' is not a valid size.
ERROR: /root/.cache/bazel/_bazel_root/226a657e3ffc703888af21dbab4728de/external/bazel_tools/tools/jdk/BUILD:432:8: In rule 'proguard_whitelister_test', timeout 'illegal' is not a valid timeout.
ERROR: Analysis of target '//main:hello-world' failed; build aborted: error loading package '@bazel_tools//tools/jdk': Package 'tools/jdk' contains errors
INFO: Elapsed time: 0,278s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (0 packages loaded, 0 targets configured)

@github-actions
Copy link

This issue has been automatically marked as stale because it has not had activity in the last 30 days. It will be closed in the next 7 days unless it is tagged "help wanted" or "no stalebot" or other activity occurs. Thank you for your contributions.

@github-actions github-actions bot added the stale stalebot believes this issue/PR has not been touched recently label Apr 24, 2022
@github-actions
Copy link

github-actions bot commented May 1, 2022

This issue has been automatically closed because it has not had activity in the last 37 days. If this issue is still valid, please ping a maintainer and ask them to label it as "help wanted" or "no stalebot". Thank you for your contributions.

@github-actions github-actions bot closed this as completed May 1, 2022
@UlasSAYGINIM
Copy link
Author

@lizan dont you support macos?
because same problem happened on macos.
you can check here, if you solve for macos and it will be solved for freesd also.
that means if you are supporting macos, you are also supporting FreeBSD :) prove me , i am wrong :)

bazelbuild/bazel#14891 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/build stale stalebot believes this issue/PR has not been touched recently
Projects
None yet
Development

No branches or pull requests

4 participants