Skip to content

Commit

Permalink
Merge pull request #9319 from cms-sw/bazel-java17
Browse files Browse the repository at this point in the history
Bazel: Use Java 17 for el8 and above
  • Loading branch information
smuzaffar authored Jul 27, 2024
2 parents 40af025 + 47744e6 commit 6cd632a
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 5 deletions.
6 changes: 5 additions & 1 deletion bazel.spec
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,12 @@ Patch1: bazel-absl

%build

export EXTRA_BAZEL_ARGS="--host_javabase=@local_jdk//:jdk --jobs %{compiling_processes}"
export EXTRA_BAZEL_ARGS="--define=ABSOLUTE_JAVABASE=${JAVA_HOME} --jobs %{compiling_processes}"
export BAZEL_CXXOPTS="-std=c++%{cms_cxx_standard}"
${JAVA_HOME}/bin/java -version 2>&1 | grep -E -i 'openjdk version "[1-9]'
if [ $(${JAVA_HOME}/bin/java -version 2>&1 | grep -E -i 'openjdk version "[1-9]' | sed -E 's|.* "([0-9]+)[.].*|\1|') -ge 17 ] ; then
export JNI_FLAGS="--add-opens=java.base/java.nio=ALL-UNNAMED --add-opens=java.base/java.lang=ALL-UNNAMED"
fi
bash ./compile.sh

%install
Expand Down
10 changes: 7 additions & 3 deletions java-env.spec
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
### RPM external java-env 11.0
### RPM external java-env 11_17
## INITENV SET JAVA_HOME %{java_home}
## INITENV +PATH PATH %{java_home}/bin
## INITENV +PATH LD_LIBRARY_PATH %{java_home}/lib
## NOCOMPILER

#For RHEL: Use java 11 for el7 and java 17 for el8 and above
#Nor non RHEL e.g FC: use default system java
%define java_home /usr/lib/jvm/java
%if 0%{?rhel:1}
%if 0%{?rhel} < 9
# /usr/lib/jvm/java on EL8 contains java 1.8, and Bazel requires java 11
%if %{?rhel} < 8
%define java_home /usr/lib/jvm/java-11
%endif
%if %{?rhel} > 7
%define java_home /usr/lib/jvm/java-17
%endif
%endif
Source: none

Expand Down
10 changes: 9 additions & 1 deletion tensorflow-sources.file
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,15 @@ export USE_DEFAULT_PYTHON_LIB_PATH=1
export GCC_HOST_COMPILER_PATH="$(which gcc)"
export CC_OPT_FLAGS="-Wno-sign-compare"

BAZEL_OPTS="--batch --output_user_root ../build build -s --verbose_failures --distinct_host_configuration=false"
BAZEL_OPTS="--batch --output_user_root ../build"
# For Java17+
if [ $(${JAVA_HOME}/bin/java -version 2>&1 | grep -E -i 'openjdk version "[1-9]' | sed -E 's|.* "([0-9]+)[.].*|\1|') -ge 17 ] ; then
BAZEL_OPTS="$BAZEL_OPTS --host_jvm_args=--add-opens=java.base/java.nio=ALL-UNNAMED"
BAZEL_OPTS="$BAZEL_OPTS --host_jvm_args=--add-opens=java.base/java.lang=ALL-UNNAMED"
fi

BAZEL_OPTS="$BAZEL_OPTS build -s --verbose_failures --distinct_host_configuration=false"

%if "%{selected_microarch}"
BAZEL_OPTS="$BAZEL_OPTS --copt=%{selected_microarch}"
%if "%{selected_microarch}" != "%{default_microarch}"
Expand Down

0 comments on commit 6cd632a

Please sign in to comment.