From dcf6916f9977dd01c00c042727dd946c62c610ab Mon Sep 17 00:00:00 2001 From: Navid Qaragozlou Date: Fri, 3 Jan 2025 07:33:58 -0800 Subject: [PATCH] Unify toolchain to use graalvm everywhere Summary: We have successfully switched from OpenJDK to GraalVM for running kotlincd and javacd actions in Buck2. GraalVM offers a smaller size, reducing download requirements on remote execution (RE), and it runs short-lived Java applications, like build actions, more efficiently. In this update, we are standardizing our Buck toolchain to use GraalVM instead of JDK for all JVM-based build actions. This is a significant change across the board. Our toolchain allows users to provide their own java implementation, which can override the default GraalVM setup. This is the approach used in fbcode. Reviewed By: IanChilds Differential Revision: D67767200 fbshipit-source-id: 510f6378906eb339256974d3520096f2aaaf5ec2 --- prelude/java/java_toolchain.bzl | 2 -- prelude/java/javacd_jar_creator.bzl | 2 +- prelude/kotlin/kotlincd_jar_creator.bzl | 2 +- 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/prelude/java/java_toolchain.bzl b/prelude/java/java_toolchain.bzl index e6029d3142c0..78e1a526805f 100644 --- a/prelude/java/java_toolchain.bzl +++ b/prelude/java/java_toolchain.bzl @@ -36,7 +36,6 @@ JavaToolchainInfo = provider( "gen_class_to_source_map_debuginfo": provider_field(typing.Any, default = None), # optional "gen_class_to_source_map_include_sourceless_compiled_packages": provider_field(typing.Any, default = None), "global_code_config": provider_field(typing.Any, default = None), - "graalvm_java": provider_field(typing.Any, default = None), "is_bootstrap_toolchain": provider_field(typing.Any, default = None), "jar": provider_field(typing.Any, default = None), "jar_builder": provider_field(typing.Any, default = None), @@ -61,7 +60,6 @@ JavaToolchainInfo = provider( "src_root_prefixes": provider_field(typing.Any, default = None), "target_level": provider_field(typing.Any, default = None), "track_class_usage": provider_field(bool, default = True), - "use_graalvm_java_for_javacd": provider_field(typing.Any, default = None), "zip_scrubber": provider_field(typing.Any, default = None), }, ) diff --git a/prelude/java/javacd_jar_creator.bzl b/prelude/java/javacd_jar_creator.bzl index 76f5195052ba..5ed5ddca076d 100644 --- a/prelude/java/javacd_jar_creator.bzl +++ b/prelude/java/javacd_jar_creator.bzl @@ -163,7 +163,7 @@ def create_jar_artifact_javacd( compiler = java_toolchain.javac[DefaultInfo].default_outputs[0] exe, local_only = prepare_cd_exe( qualified_name, - java = java_toolchain.graalvm_java[RunInfo] if java_toolchain.use_graalvm_java_for_javacd else java_toolchain.java[RunInfo], + java = java_toolchain.java[RunInfo], class_loader_bootstrapper = java_toolchain.class_loader_bootstrapper, compiler = compiler, main_class = java_toolchain.javacd_main_class, diff --git a/prelude/kotlin/kotlincd_jar_creator.bzl b/prelude/kotlin/kotlincd_jar_creator.bzl index 73b50c8f47e1..978ec6288db5 100644 --- a/prelude/kotlin/kotlincd_jar_creator.bzl +++ b/prelude/kotlin/kotlincd_jar_creator.bzl @@ -225,7 +225,7 @@ def create_jar_artifact_kotlincd( compiler = kotlin_toolchain.kotlinc[DefaultInfo].default_outputs[0] exe, local_only = prepare_cd_exe( qualified_name, - java = java_toolchain.graalvm_java[RunInfo] if java_toolchain.use_graalvm_java_for_javacd else java_toolchain.java[RunInfo], + java = java_toolchain.java[RunInfo], class_loader_bootstrapper = kotlin_toolchain.class_loader_bootstrapper, compiler = compiler, main_class = kotlin_toolchain.kotlincd_main_class,