diff --git a/WORKSPACE b/WORKSPACE index b1988532c99..e3356217047 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -244,7 +244,3 @@ pip_parse( load("@amqp_bpf_test_requirements//:requirements.bzl", ampq_bpf_test_install_deps = "install_deps") ampq_bpf_test_install_deps() - -load("//bazel/graal:toolchain.bzl", "register_graal_toolchains") - -register_graal_toolchains() diff --git a/bazel/graal/BUILD.bazel b/bazel/graal/BUILD.bazel index 5f3cae9266e..14ca481dc04 100644 --- a/bazel/graal/BUILD.bazel +++ b/bazel/graal/BUILD.bazel @@ -13,27 +13,3 @@ # limitations under the License. # # SPDX-License-Identifier: Apache-2.0 - -load("//bazel/graal:toolchain.bzl", "graal_native_toolchain") - -toolchain_type( - name = "toolchain_type", -) - -graal_native_toolchain( - name = "graal_native_image_compiler", - graal_path = "/opt/graalvm-ce-java17-22.3.0", -) - -toolchain( - name = "graal-native-image-linux", - exec_compatible_with = [ - "@platforms//os:linux", - "@platforms//cpu:x86_64", - ], - target_compatible_with = [ - "@platforms//os:linux", - ], - toolchain = ":graal_native_image_compiler", - toolchain_type = ":toolchain_type", -) diff --git a/bazel/graal/rules.bzl b/bazel/graal/rules.bzl index ccb7067287d..030670319e8 100644 --- a/bazel/graal/rules.bzl +++ b/bazel/graal/rules.bzl @@ -15,7 +15,6 @@ # SPDX-License-Identifier: Apache-2.0 def _graal_native_binary_impl(ctx): - native_image_binary_path = ctx.toolchains["//bazel/graal:toolchain_type"].graal_native.native_image_binary_path cc_compiler_path = ctx.toolchains["@bazel_tools//tools/cpp:toolchain_type"].cc.compiler_executable # TODO(james): this is a bit of a hack because bazel's JavaInfo doesn't currently have starlark definitions, @@ -35,6 +34,7 @@ def _graal_native_binary_impl(ctx): out = ctx.actions.declare_file(out_name) + graal_runtime = ctx.attr.graal_runtime[java_common.JavaRuntimeInfo] args = [ "-cp", jar.path, @@ -51,8 +51,9 @@ def _graal_native_binary_impl(ctx): ctx.actions.run( outputs = [out], inputs = [jar], - executable = native_image_binary_path, + executable = graal_runtime.java_home + "/bin/native-image", arguments = args, + tools = [graal_runtime.files], ) return [ @@ -68,13 +69,16 @@ graal_native_binary = rule( implementation = _graal_native_binary_impl, attrs = { "extra_args": attr.string_list(), + "graal_runtime": attr.label( + providers = [java_common.JavaRuntimeInfo], + allow_files = True, + ), "java_binary": attr.label( providers = [JavaInfo, DefaultInfo], ), "output_name": attr.string(), }, toolchains = [ - "//bazel/graal:toolchain_type", "@bazel_tools//tools/cpp:toolchain_type", ], executable = True, diff --git a/bazel/graal/toolchain.bzl b/bazel/graal/toolchain.bzl deleted file mode 100644 index 39d215ad8f3..00000000000 --- a/bazel/graal/toolchain.bzl +++ /dev/null @@ -1,41 +0,0 @@ -# Copyright 2018- The Pixie Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# SPDX-License-Identifier: Apache-2.0 - -GraalNativeToolchainInfo = provider( - doc = "Information about the graal native-image toolchain", - fields = ["native_image_binary_path"], -) - -def _graal_native_toolchain_impl(ctx): - return [ - platform_common.ToolchainInfo( - graal_native = GraalNativeToolchainInfo( - native_image_binary_path = ctx.attr.graal_path + "/bin/native-image", - ), - ), - ] - -graal_native_toolchain = rule( - implementation = _graal_native_toolchain_impl, - attrs = { - "graal_path": attr.string(mandatory = True), - }, -) - -def _register_graal_toolchains(): - native.register_toolchains("//bazel/graal:graal-native-image-linux") - -register_graal_toolchains = _register_graal_toolchains diff --git a/bazel/repositories.bzl b/bazel/repositories.bzl index 0d8faf6f64c..6294a574ec9 100644 --- a/bazel/repositories.bzl +++ b/bazel/repositories.bzl @@ -16,7 +16,7 @@ load("@bazel_tools//tools/build_defs/repo:git.bzl", "new_git_repository") load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") -load("@bazel_tools//tools/jdk:local_java_repository.bzl", "local_java_repository") +load("@bazel_tools//tools/jdk:remote_java_repository.bzl", "remote_java_repository") load("//bazel/cc_toolchains:deps.bzl", "cc_toolchain_config_repo") load("//bazel/cc_toolchains:toolchains.bzl", "pl_register_cc_toolchains") load(":repository_locations.bzl", "GIT_REPOSITORY_LOCATIONS", "LOCAL_REPOSITORY_LOCATIONS", "REPOSITORY_LOCATIONS") @@ -178,10 +178,18 @@ def _cc_deps(): def _java_deps(): _bazel_repo("com_oracle_openjdk_18", build_file = "//bazel/external:jdk_includes.BUILD") - local_java_repository( - name = "openjdk_graal", + remote_java_repository( + name = "remotejdk_openjdk_graal_17", version = "17", - java_home = "/opt/graalvm-ce-java17-22.3.0", + prefix = "remotejdk_openjdk_graal", + target_compatible_with = [ + "@platforms//os:linux", + "@platforms//cpu:x86_64", + ], + sha256 = "102db28b450ff5eb8c497aacaececc5263a4e50e64b7cdc5c7baa8b216e73531", + urls = [ + "https://storage.googleapis.com/pixie-dev-public/graalvm-native-image-22.3.0-pl1.tar.gz", + ], ) def _list_pl_deps(name): diff --git a/bazel/toolchain_transitions.bzl b/bazel/toolchain_transitions.bzl index a05ab12fe80..10faa6f71a4 100644 --- a/bazel/toolchain_transitions.bzl +++ b/bazel/toolchain_transitions.bzl @@ -28,7 +28,7 @@ cc_static_musl_binary = meta.wrap_with_transition( java_graal_binary = meta.wrap_with_transition( native.java_binary, { - "java_runtime_version": meta.replace_with("openjdk_graal_17"), + "java_runtime_version": meta.replace_with("remotejdk_openjdk_graal_17"), }, executable = True, ) diff --git a/docker.properties b/docker.properties index 702e4cc8981..6d5c598f597 100644 --- a/docker.properties +++ b/docker.properties @@ -1 +1 @@ -DOCKER_IMAGE_TAG=202301070001 +DOCKER_IMAGE_TAG=202301061715 diff --git a/src/stirling/source_connectors/perf_profiler/testing/java/BUILD.bazel b/src/stirling/source_connectors/perf_profiler/testing/java/BUILD.bazel index 72f2e8ae7fd..02c08d6957f 100644 --- a/src/stirling/source_connectors/perf_profiler/testing/java/BUILD.bazel +++ b/src/stirling/source_connectors/perf_profiler/testing/java/BUILD.bazel @@ -118,6 +118,7 @@ graal_native_binary( "-H:+PreserveFramePointer", "-H:+ReportUnsupportedElementsAtRuntime", ], + graal_runtime = "@remotejdk_openjdk_graal_17//:jdk", java_binary = ":graal_java_fib", output_name = "JavaFib", ) diff --git a/tools/chef/cookbooks/pixielabs/attributes/default.rb b/tools/chef/cookbooks/pixielabs/attributes/default.rb index 22629f1f218..09c8b4521c8 100644 --- a/tools/chef/cookbooks/pixielabs/attributes/default.rb +++ b/tools/chef/cookbooks/pixielabs/attributes/default.rb @@ -42,9 +42,6 @@ "https://raw.githubusercontent.com/bazelbuild/bazel/#{default['bazel']['version']}/scripts/zsh_completion/_bazel" default['bazel']['zcomp_sha256'] = '4094dc84add2f23823bc341186adf6b8487fbd5d4164bd52d98891c41511eba4' -default["graalvm-native-image"] = {} -default["graalvm-native-image"]["path"] = "/opt/graalvm-ce-java17-22.3.0" - default['skaffold'] = {} default['kubectl'] = {} default['golang'] = {} @@ -170,12 +167,6 @@ default['gcc-musl']['deb_sha256'] = 'ba52df92bce02f3c2bc53604466e0fac8844f941ae6d2d44061e48403f5752fb' default['gcc-musl']['version'] = "11.2.0" - - default['graalvm-native-image']['deb'] = - 'https://storage.googleapis.com/pixie-dev-public/graalvm-native-image-22.3.0.deb' - default['graalvm-native-image']['deb_sha256'] = - '19c8e25511fd9a364ff301e34771abb262e34ab0df4ffef2df36497af4abe1b7' - default['graalvm-native-image']['version'] = "22.3.0" elsif node[:platform] == 'mac_os_x' || node[:platform] == 'macos' default['bazel']['download_path'] = "https://github.com/bazelbuild/bazel/releases/download/#{default['bazel']['version']}/bazel-#{default['bazel']['version']}-darwin-x86_64" diff --git a/tools/chef/cookbooks/pixielabs/recipes/linux.rb b/tools/chef/cookbooks/pixielabs/recipes/linux.rb index e9d8cbdfdf0..f1fce7f9cf3 100644 --- a/tools/chef/cookbooks/pixielabs/recipes/linux.rb +++ b/tools/chef/cookbooks/pixielabs/recipes/linux.rb @@ -92,4 +92,3 @@ include_recipe 'pixielabs::linux_clang' include_recipe 'pixielabs::linux_gcc_musl' -include_recipe 'pixielabs::linux_graalvm' diff --git a/tools/chef/cookbooks/pixielabs/recipes/linux_graalvm.rb b/tools/chef/cookbooks/pixielabs/recipes/linux_graalvm.rb deleted file mode 100644 index db8479f0f2c..00000000000 --- a/tools/chef/cookbooks/pixielabs/recipes/linux_graalvm.rb +++ /dev/null @@ -1,31 +0,0 @@ -# Copyright 2018- The Pixie Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# SPDX-License-Identifier: Apache-2.0 - -remote_file '/tmp/graalvm-native-image.deb' do - source node['graalvm-native-image']['deb'] - mode 0644 - checksum node['graalvm-native-image']['deb_sha256'] -end - -dpkg_package 'graalvm-native-image' do - source '/tmp/graalvm-native-image.deb' - action :install - version node['graalvm-native-image']['version'] -end - -file '/tmp/graalvm-native-image.deb' do - action :delete -end diff --git a/tools/chef/cookbooks/pixielabs/recipes/mac_os_x.rb b/tools/chef/cookbooks/pixielabs/recipes/mac_os_x.rb index b041ed95c0b..3c8bdaec8c8 100644 --- a/tools/chef/cookbooks/pixielabs/recipes/mac_os_x.rb +++ b/tools/chef/cookbooks/pixielabs/recipes/mac_os_x.rb @@ -21,10 +21,3 @@ homebrew_package 'postgresql@14' homebrew_package 'pyenv' homebrew_package 'php' - -directory node['graalvm-native-image']['path'] do - owner user - group root_group - mode '0755' - action :create -end diff --git a/tools/docker/Makefile b/tools/docker/Makefile index 3f9eb77e5ab..cdd643bc06a 100644 --- a/tools/docker/Makefile +++ b/tools/docker/Makefile @@ -28,12 +28,18 @@ clang_linters_deb_fname := "clang-linters-$(CLANG_TAG).deb" clang_gs_path := gs://pixie-dev-public/clang/$(CLANG_TAG) clang_deb_image_tag := "gcr.io/pixie-oss/pixie-dev-public/clang_deb_builder_image:$(CLANG_VERSION)" -## Clang deb parameters +## gperftools parameters GPERFTOOLS_DEB_IMAGE_VERSION := 2.7-pl2 gperftools_deb_fname := "gperftools-pixie-$(GPERFTOOLS_DEB_IMAGE_VERSION).deb" gperftools_deb_gs_path := gs://pixie-dev-public/$(gperftools_deb_fname) gperftools_deb_image_tag := "gcr.io/pixie-oss/pixie-dev-public/gperftools_deb_image:$(GPERFTOOLS_DEB_IMAGE_VERSION)" +## graalvm parameters +GRAALVM_IMAGE_VERSION := pl1 +GRAALVM_ARCHIVE_IMAGE_TAG := graalvm-$(GRAALVM_IMAGE_VERSION) +GRAALVM_ARCHIVE_FNAME := graalvm-native-image-22.3.0.tar.gz +GRAALVM_ARCHIVE_GS_PATH := gs://pixie-dev-public/graalvm-native-image-22.3.0-$(GRAALVM_IMAGE_VERSION).tar.gz + ## Linux image parameters LINUX_HEADER_BUILD_DIR := $(BUILD_DIR)/linux_headers LINUX_HEADER_ASSETS_BUILD_DIR := $(LINUX_HEADER_BUILD_DIR)/assets @@ -101,6 +107,18 @@ upload_gperftools_deb: build_gperftools_deb_image ## Target to build and upload sha256sum $(gperftools_deb_fname) rm -f $(gperftools_deb_fname) +.PHONY: build_graalvm_archive_image +build_graalvm_archive_image: + $(DOCKER) build graalvm_archive_image -t $(GRAALVM_ARCHIVE_IMAGE_TAG) + +.PHONY: upload_graalvm_archive +upload_graalvm_archive: build_graalvm_archive_image + mkdir -p $(BUILD_DIR) + $(DOCKER) run --rm -v $(PWD)/$(BUILD_DIR):/archive $(GRAALVM_ARCHIVE_IMAGE_TAG) + gsutil cp $(PWD)/$(BUILD_DIR)/$(GRAALVM_ARCHIVE_FNAME) $(GRAALVM_ARCHIVE_GS_PATH) + @echo "SHA: " + sha256sum $(PWD)/$(BUILD_DIR)/$(GRAALVM_ARCHIVE_FNAME) + $(LINUX_HEADER_ASSETS_BUILD_DIR)/linux-headers-%.tar.gz: linux_headers_image/Dockerfile linux_headers_image/config ifndef LINUX_HEADERS_REV $(error set LINUX_HEADERS_REV to a valid value) diff --git a/tools/docker/graal_deb_image/Dockerfile b/tools/docker/graalvm_archive_image/Dockerfile similarity index 77% rename from tools/docker/graal_deb_image/Dockerfile rename to tools/docker/graalvm_archive_image/Dockerfile index 64da75ffcb6..0a537e1845a 100644 --- a/tools/docker/graal_deb_image/Dockerfile +++ b/tools/docker/graalvm_archive_image/Dockerfile @@ -18,8 +18,7 @@ FROM ubuntu:22.04 ENV DEBIAN_FRONTEND=noninteractive RUN apt-get update -y --fix-missing -RUN apt-get install -y binutils ruby ruby-dev rubygems curl -RUN gem install --no-document fpm +RUN apt-get install -y curl WORKDIR /data RUN curl -L https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-22.3.0/graalvm-ce-java17-linux-amd64-22.3.0.tar.gz --output dist.tar.gz @@ -29,7 +28,5 @@ RUN tar -xzf /data/dist.tar.gz RUN /opt/graalvm-ce-java17-22.3.0/bin/gu install native-image WORKDIR /opt -VOLUME /image -ENV deb_name graalvm-native-image-22.3.0.deb -CMD ["sh", "-c", "fpm -p /image/${deb_name} \ - -s dir -t deb -n graalvm-native-image -v 22.3.0 --prefix=/opt graalvm-ce-java17-22.3.0"] +VOLUME /archive +CMD ["sh", "-c", "tar -C graalvm-ce-java17-22.3.0 -czf /archive/graalvm-native-image-22.3.0.tar.gz ."]