Skip to content

Commit

Permalink
Make graalvm a remote java repo
Browse files Browse the repository at this point in the history
Summary:
Switch from deb to a tar, and then use the `remote_java_repository`
rule to fetch it as needed instead of installing it on the dev image.

Test Plan: All graal builds and tests work.

Reviewers: zasgar, jamesbartlett, #third_party_approvers

Reviewed By: zasgar, jamesbartlett, #third_party_approvers

Signed-off-by: Vihang Mehta <[email protected]>

Differential Revision: https://phab.corp.pixielabs.ai/D12733

GitOrigin-RevId: 7c61893f0fb21acd9f6a503455535bcf749be809
  • Loading branch information
vihangm authored and copybaranaut committed Jan 7, 2023
1 parent 3cfaf59 commit cee45ae
Show file tree
Hide file tree
Showing 14 changed files with 44 additions and 133 deletions.
4 changes: 0 additions & 4 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -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()
24 changes: 0 additions & 24 deletions bazel/graal/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -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",
)
10 changes: 7 additions & 3 deletions bazel/graal/rules.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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 [
Expand All @@ -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,
Expand Down
41 changes: 0 additions & 41 deletions bazel/graal/toolchain.bzl

This file was deleted.

16 changes: 12 additions & 4 deletions bazel/repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion bazel/toolchain_transitions.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
2 changes: 1 addition & 1 deletion docker.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
DOCKER_IMAGE_TAG=202301070001
DOCKER_IMAGE_TAG=202301061715
Original file line number Diff line number Diff line change
Expand Up @@ -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",
)
Expand Down
9 changes: 0 additions & 9 deletions tools/chef/cookbooks/pixielabs/attributes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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'] = {}
Expand Down Expand Up @@ -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"
Expand Down
1 change: 0 additions & 1 deletion tools/chef/cookbooks/pixielabs/recipes/linux.rb
Original file line number Diff line number Diff line change
Expand Up @@ -92,4 +92,3 @@

include_recipe 'pixielabs::linux_clang'
include_recipe 'pixielabs::linux_gcc_musl'
include_recipe 'pixielabs::linux_graalvm'
31 changes: 0 additions & 31 deletions tools/chef/cookbooks/pixielabs/recipes/linux_graalvm.rb

This file was deleted.

7 changes: 0 additions & 7 deletions tools/chef/cookbooks/pixielabs/recipes/mac_os_x.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
20 changes: 19 additions & 1 deletion tools/docker/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 ."]

0 comments on commit cee45ae

Please sign in to comment.