Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 6 additions & 8 deletions .github/workflows/build-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -101,18 +101,16 @@ jobs:
shell: bash

- name: 'Pack bundles'
if: matrix.debug-level == 'release'
run: |
tar czf CompoundVM_${{ steps.version.outputs.version }}_${{ inputs.platform }}.tar.gz -C output CompoundVM_${{ steps.version.outputs.version }}_${{ inputs.platform }}
tar czf CompoundVM_${{ steps.version.outputs.version }}_jvm_patch_${{ inputs.platform }}.tar.gz -C output/CompoundVM_${{ steps.version.outputs.version }}_jvm_patch_${{ inputs.platform }} .
tar czf CompoundVM_${{ steps.version.outputs.version }}_${{ inputs.platform }}_${{ matrix.debug-level }}.tar.gz -C output CompoundVM_${{ steps.version.outputs.version }}_${{ inputs.platform }}
tar czf CompoundVM_${{ steps.version.outputs.version }}_jvm_patch_${{ inputs.platform }}_${{ matrix.debug-level }}.tar.gz -C output/CompoundVM_${{ steps.version.outputs.version }}_jvm_patch_${{ inputs.platform }} .
shell: bash

- name: 'Upload bundles'
uses: actions/upload-artifact@v4
if: matrix.debug-level == 'release'
with:
name: CompoundVM_${{ steps.version.outputs.version }}_${{ inputs.platform }}.tar.gz
path: CompoundVM_${{ steps.version.outputs.version }}_${{ inputs.platform }}.tar.gz
name: CompoundVM_${{ steps.version.outputs.version }}_${{ inputs.platform }}_${{ matrix.debug-level }}.tar.gz
path: CompoundVM_${{ steps.version.outputs.version }}_${{ inputs.platform }}_${{ matrix.debug-level }}.tar.gz
retention-days: 1
if-no-files-found: error
overwrite: true
Expand All @@ -121,8 +119,8 @@ jobs:
uses: actions/upload-artifact@v4
if: matrix.debug-level == 'release'
with:
name: CompoundVM_${{ steps.version.outputs.version }}_jvm_patch_${{ inputs.platform }}.tar.gz
path: CompoundVM_${{ steps.version.outputs.version }}_jvm_patch_${{ inputs.platform }}.tar.gz
name: CompoundVM_${{ steps.version.outputs.version }}_jvm_patch_${{ inputs.platform }}_${{ matrix.debug-level }}.tar.gz
path: CompoundVM_${{ steps.version.outputs.version }}_jvm_patch_${{ inputs.platform }}_${{ matrix.debug-level }}.tar.gz
retention-days: 1
if-no-files-found: error
overwrite: true
116 changes: 116 additions & 0 deletions .github/workflows/gtest-linux.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
# This project is a modified version of OpenJDK, licensed under GPL v2.
# Modifications Copyright (C) 2025 ByteDance Inc.
#
# Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 only, as
# published by the Free Software Foundation. Oracle designates this
# particular file as subject to the "Classpath" exception as provided
# by Oracle in the LICENSE file that accompanied this code.
#
# This code is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# version 2 for more details (a copy is included in the LICENSE file that
# accompanied this code).
#
# You should have received a copy of the GNU General Public License version
# 2 along with this work; if not, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
# or visit www.oracle.com if you need additional information or have any
# questions.
#

name: 'GTest (linux)'

permissions:
contents: read
pull-requests: write

on:
workflow_call:
inputs:
platform:
required: true
type: string
runs-on:
required: true
type: string
debug-levels:
required: false
type: string
default: '[ "fastdebug", "release" ]'
apt-gcc-version:
required: true
type: string
apt-architecture:
required: false
type: string
apt-extra-packages:
required: false
type: string

jobs:
gtest-linux:
name: gtest
runs-on: ${{ inputs.runs-on }}

strategy:
fail-fast: false
matrix:
debug-level: ${{ fromJSON(inputs.debug-levels) }}

steps:
- name: 'Checkout the JDK source'
uses: actions/checkout@v3

- name: 'Determine version'
id: version
run: echo "::set-output name=version::$(cat ./cvm/conf/version)"

- name: 'Set architecture'
id: arch
run: |
# Set a proper suffix for packages if using a different architecture
if [[ '${{ inputs.apt-architecture }}' != '' ]]; then
echo 'suffix=:${{ inputs.apt-architecture }}' >> $GITHUB_OUTPUT
fi

# Upgrading apt to solve libc6 installation bugs, see JDK-8260460.
- name: 'Install toolchain and dependencies'
run: |
# Install dependencies using apt-get
if [[ '${{ inputs.apt-architecture }}' != '' ]]; then
sudo dpkg --add-architecture ${{ inputs.apt-architecture }}
fi
sudo apt-get update
sudo apt-get install --only-upgrade apt
sudo apt-get install gcc-${{ inputs.apt-gcc-version }} g++-${{ inputs.apt-gcc-version }} libxrandr-dev${{ steps.arch.outputs.suffix }} libxtst-dev${{ steps.arch.outputs.suffix }} libcups2-dev${{ steps.arch.outputs.suffix }} libasound2-dev${{ steps.arch.outputs.suffix }} ${{ inputs.apt-extra-packages }}
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-${{ inputs.apt-gcc-version }} 100 --slave /usr/bin/g++ g++ /usr/bin/g++-${{ inputs.apt-gcc-version }}

- name: 'Build'
run: |
make -f cvm.mk build_gtest_hotspot17 MODE=${{ matrix.debug-level}} SKIP_BUILD=true
shell: bash

- name: 'Get bundles'
uses: actions/download-artifact@v4
with:
name: CompoundVM_${{ steps.version.outputs.version }}_${{ inputs.platform }}_${{ matrix.debug-level }}.tar.gz
path: .

- name: 'Unpack bundles'
run: |
rm -rf gtest-jdk
mkdir gtest-jdk
tar xzvf CompoundVM_${{ steps.version.outputs.version }}_${{ inputs.platform }}_${{ matrix.debug-level }}.tar.gz -C gtest-jdk --strip-components=1
shell: bash

- name: 'Run gtests'
run: |
make -f cvm.mk test_gtest_hotspot17 MODE=${{ matrix.debug-level}} SKIP_BUILD=true HOTSPOT_GTEST_JDKDIR=${PWD}/gtest-jdk
shell: bash
Comment thread
github-advanced-security[bot] marked this conversation as resolved.
Fixed
26 changes: 26 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,30 @@ jobs:
# The linux-aarch64 jdk bundle is used as buildjdk for the cross-compile job
if: needs.select.outputs.linux-aarch64 == 'true' || needs.select.outputs.linux-cross-compile == 'true'

###
### GTest jobs
###

gtest-linux-x64:
name: linux-x64
needs:
- build-linux-x64
uses: ./.github/workflows/gtest-linux.yml
with:
platform: linux_x64
apt-gcc-version: '9'
runs-on: ubuntu-22.04

gtest-linux-aarch64:
name: linux-aarch64
needs:
- build-linux-aarch64
uses: ./.github/workflows/gtest-linux.yml
with:
platform: linux_aarch64
apt-gcc-version: '9'
runs-on: ubuntu-22.04-arm

###
### Test jobs
###
Expand Down Expand Up @@ -165,8 +189,10 @@ jobs:
if: always()
needs:
- build-linux-x64
- gtest-linux-x64
- test-linux-x64
- build-linux-aarch64
- gtest-linux-aarch64
- test-linux-aarch64

steps:
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/test-cvm8+17.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,14 @@ jobs:
- name: 'Get bundles'
uses: actions/download-artifact@v4
with:
name: CompoundVM_${{ steps.version.outputs.version }}_${{ inputs.platform }}.tar.gz
name: CompoundVM_${{ steps.version.outputs.version }}_${{ inputs.platform }}_${{ inputs.debug-level }}.tar.gz
path: .

- name: 'Unpack bundles'
run: |
rm -rf cvm/build/jdk8
mkdir -p cvm/build/jdk8
tar xzvf CompoundVM_${{ steps.version.outputs.version }}_${{ inputs.platform }}.tar.gz -C cvm/build/jdk8 --strip-components=1
tar xzvf CompoundVM_${{ steps.version.outputs.version }}_${{ inputs.platform }}_${{ inputs.debug-level }}.tar.gz -C cvm/build/jdk8 --strip-components=1
shell: bash

- name: 'Run tests'
Expand All @@ -100,13 +100,13 @@ jobs:
- name: 'Get bundles jvm patch'
uses: actions/download-artifact@v4
with:
name: CompoundVM_${{ steps.version.outputs.version }}_jvm_patch_${{ inputs.platform }}.tar.gz
name: CompoundVM_${{ steps.version.outputs.version }}_jvm_patch_${{ inputs.platform }}_${{ inputs.debug-level }}.tar.gz
path: .

- name: 'Run sanity test jvm patch'
run: |
wget -nc https://github.com/adoptium/temurin8-binaries/releases/download/jdk8u372-b07/OpenJDK8U-jdk_${{ inputs.arch }}_linux_hotspot_8u372b07.tar.gz
tar xzf OpenJDK8U-jdk_${{ inputs.arch }}_linux_hotspot_8u372b07.tar.gz
tar xzf CompoundVM_${{ steps.version.outputs.version }}_jvm_patch_${{ inputs.platform }}.tar.gz -C jdk8u372-b07/
tar xzf CompoundVM_${{ steps.version.outputs.version }}_jvm_patch_${{ inputs.platform }}_${{ inputs.debug-level }}.tar.gz -C jdk8u372-b07/
jdk8u372-b07/bin/java -version 2>&1 | grep "CompoundVM"
shell: bash
103 changes: 91 additions & 12 deletions cvm.mk
Original file line number Diff line number Diff line change
Expand Up @@ -238,26 +238,102 @@ build_jdk8u: -bootstrap $(JDK8_JDK_SRC)
[[ $$? -eq 0 ]] || exit 127; \
}

# configure for jdk17u
# $1 extra configure options
define configure_jdk17u
bash configure \
--with-debug-level=$(MODE) \
--with-boot-jdk=$(BOOTJDK17) \
--with-hotspot-target-classlib=8 \
--with-vendor-name="ByteDance" \
--with-vendor-url="https://github.com/bytedance/CompoundVM" \
--with-vendor-bug-url="https://github.com/bytedance/CompoundVM/issues" \
--with-vendor-vm-bug-url="https://github.com/bytedance/CompoundVM/issues" \
--without-version-pre \
--without-version-opt \
--with-cvm-version-string=$(VERSION) \
--with-vendor-name="CompoundVM" \
$(1)
endef

# compile hotspot and java.base from jdk17u
build_jdk17u: -bootstrap
{ \
if [[ "x$$(find ./build -type f -name config.log | grep $(MODE))" = "x" ]]; then \
bash configure --with-debug-level=$(MODE) \
--with-boot-jdk=$(BOOTJDK17) \
--with-hotspot-target-classlib=8 \
--with-vendor-name="ByteDance" \
--with-vendor-url="https://github.com/bytedance/CompoundVM" \
--with-vendor-bug-url="https://github.com/bytedance/CompoundVM/issues" \
--with-vendor-vm-bug-url="https://github.com/bytedance/CompoundVM/issues" \
--without-version-pre \
--without-version-opt \
--with-cvm-version-string=$(VERSION) \
--with-vendor-name="CompoundVM" \
; \
$(call configure_jdk17u) ; \
fi; \
}
make $(JDK_MAKE_OPTS) CONF=linux-$(CVM_ARCH)-server-$(MODE) hotspot jdk.jdwp.agent

GTEST_VERSION ?= $(shell sed -n 's/^GTEST_VERSION=//p' $(WORKSPACE)/make/conf/github-actions.conf | head -n 1)
GTEST_ROOT := $(WORKSPACE)/.gtest
GTEST_ARCHIVE := $(GTEST_ROOT)/release-$(GTEST_VERSION).tar.gz
GTEST_URL := https://github.com/google/googletest/archive/refs/tags/v$(GTEST_VERSION).tar.gz
GTEST_DIR := $(GTEST_ROOT)/googletest-$(GTEST_VERSION)
GTEST_HEADER := $(GTEST_DIR)/googletest/include/gtest/gtest.h

$(GTEST_HEADER):
@echo "Installing googletest $(GTEST_VERSION) to $(GTEST_DIR)"
{ \
set -e; \
[[ -d $(GTEST_ROOT) ]] || mkdir -p $(GTEST_ROOT); \
rm -f $(GTEST_ARCHIVE); \
wget -q $(GTEST_URL) -O $(GTEST_ARCHIVE); \
rm -fr $(GTEST_DIR); \
tar xf $(GTEST_ARCHIVE) -C $(GTEST_ROOT); \
rm -f $(GTEST_ARCHIVE); \
}

HOTSPOT_GTEST_BUILD_DIR := $(JDK17_SRCROOT)/build/linux-$(CVM_ARCH)-server-$(MODE)
HOTSPOT_GTEST_LAUNCHER := $(HOTSPOT_GTEST_BUILD_DIR)/images/test/hotspot/gtest/server/gtestLauncher
HOTSPOT_GTEST_TEST ?= gtest:all
HOTSPOT_GTEST_SELECTOR := $(patsubst %/server,%,$(patsubst gtest:%,%,$(HOTSPOT_GTEST_TEST)))
HOTSPOT_GTEST_FILTER := $(if $(filter all,$(HOTSPOT_GTEST_SELECTOR)),,--gtest_filter=$(HOTSPOT_GTEST_SELECTOR)*)
HOTSPOT_GTEST_JDKDIR := $(OUTPUTDIR)/$(DISTRO_NAME)
HOTSPOT_GTEST_WORKDIR := $(HOTSPOT_GTEST_BUILD_DIR)/gtest-manual
HOTSPOT_GTEST_RESULT_DIR := $(HOTSPOT_GTEST_BUILD_DIR)/gtest-results

ifeq ($(SKIP_BUILD), true)
-configure_jdk17u_gtest: $(GTEST_HEADER) -bootstrap
else
-configure_jdk17u_gtest: $(GTEST_HEADER) cvm8default17
endif
{ \
if [[ ! -f $(HOTSPOT_GTEST_BUILD_DIR)/spec.gmk ]] || \
! grep -Fqx 'GTEST_FRAMEWORK_SRC := $(GTEST_DIR)' $(HOTSPOT_GTEST_BUILD_DIR)/spec.gmk 2>/dev/null; then \
$(call configure_jdk17u,--with-gtest=$(GTEST_DIR)) ; \
fi; \
}

build_gtest_hotspot17: -configure_jdk17u_gtest
$(MAKE) $(JDK_MAKE_OPTS) CONF=linux-$(CVM_ARCH)-server-$(MODE) test-image-hotspot-gtest

ifeq ($(SKIP_BUILD), true)
test_gtest_hotspot17:
else
test_gtest_hotspot17: build_gtest_hotspot17
endif
@echo
@echo "Running hotspot gtest \"$(HOTSPOT_GTEST_TEST)\""
@echo " Launcher: $(HOTSPOT_GTEST_LAUNCHER)"
@echo " JDK under test: $(HOTSPOT_GTEST_JDKDIR)"
@echo " Work dir: $(HOTSPOT_GTEST_WORKDIR)"
@echo " Test report: $(HOTSPOT_GTEST_RESULT_DIR)"
@echo
@{ \
mkdir -p $(HOTSPOT_GTEST_WORKDIR) $(HOTSPOT_GTEST_RESULT_DIR) && \
cd $(HOTSPOT_GTEST_WORKDIR) && \
$(HOTSPOT_GTEST_LAUNCHER) \
-jdk $(HOTSPOT_GTEST_JDKDIR) \
$(HOTSPOT_GTEST_FILTER) \
--gtest_output=xml:$(HOTSPOT_GTEST_RESULT_DIR)/gtest.xml \
--gtest_catch_exceptions=0 \
> >(tee $(HOTSPOT_GTEST_RESULT_DIR)/gtest.txt); \
exit_code=$$?; \
echo $$exit_code > $(HOTSPOT_GTEST_RESULT_DIR)/exitcode.txt; \
exit $$exit_code; \
}

################ alternative kernel classes ########
# here we copy the JDK17 kernel classes to separate diretory,
# and tweak the code to fit into JDK8's boots.
Expand Down Expand Up @@ -400,3 +476,6 @@ help:
@echo " Run CVM8 jtreg8 tests in directory $(CVM8_SRCROOT)/hotspot/test"
@echo " make test_cvm8 JT_TEST=<test selection>"
@echo " Run additional jtreg8 tests for CVM8 in directory test"
@echo " make test_gtest_hotspot17 HOTSPOT_GTEST_TEST=<gtest selection>"
@echo " Run hotspot gtests directly against the CVM output image"
@echo " e.g. HOTSPOT_GTEST_TEST='gtest:all'"
8 changes: 8 additions & 0 deletions src/hotspot/os/linux/os_linux.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2707,10 +2707,18 @@ void os::jvm_path(char *buf, jint buflen) {
len = strlen(buf);
assert(len < buflen, "Ran out of buffer room");
jrelib_p = buf + len;

#if HOTSPOT_TARGET_CLASSLIB == 8
snprintf(jrelib_p, buflen-len, "/jre/lib/%s", HOTSPOT_LIB_ARCH);
Comment thread
K0u1e marked this conversation as resolved.
if (0 != access(buf, F_OK)) {
snprintf(jrelib_p, buflen-len, "/lib/%s", HOTSPOT_LIB_ARCH);
}
#else
snprintf(jrelib_p, buflen-len, "/jre/lib");
if (0 != access(buf, F_OK)) {
snprintf(jrelib_p, buflen-len, "/lib");
}
#endif

if (0 == access(buf, F_OK)) {
// Use current module name "libjvm.so"
Expand Down
Loading