diff --git a/bazel.spec b/bazel.spec index 6b072a29565..fc30cde0050 100644 --- a/bazel.spec +++ b/bazel.spec @@ -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 diff --git a/java-env.spec b/java-env.spec index 2a18620a49d..75e3f1ee949 100644 --- a/java-env.spec +++ b/java-env.spec @@ -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 diff --git a/tensorflow-sources.file b/tensorflow-sources.file index 6e0f891b017..ac87f1e98cc 100644 --- a/tensorflow-sources.file +++ b/tensorflow-sources.file @@ -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}"