Restructure the build so a minimal initial build is then used for the final build (with docs)

This reduces pressure on the system JDK and ensures the JDK being built can do a full build
This commit is contained in:
Andrew John Hughes 2021-10-26 16:35:41 +01:00
parent 18b2f76565
commit 28b9940eba
1 changed files with 130 additions and 94 deletions

View File

@ -192,12 +192,12 @@
%global static_libs_target %{nil} %global static_libs_target %{nil}
%endif %endif
# RPM JDK builds keep the debug symbols internal, to be later stripped by RPM
%global debug_symbols internal
# unlike portables,the rpms have to use static_libs_target very dynamically # unlike portables,the rpms have to use static_libs_target very dynamically
%if %{bootstrap_build} %global bootstrap_targets images
%global release_targets bootcycle-images docs-zip
%else
%global release_targets images docs-zip %global release_targets images docs-zip
%endif
# No docs nor bootcycle for debug builds # No docs nor bootcycle for debug builds
%global debug_targets images %global debug_targets images
@ -298,7 +298,7 @@
%global top_level_dir_name %{origin} %global top_level_dir_name %{origin}
%global top_level_dir_name_backup %{top_level_dir_name}-backup %global top_level_dir_name_backup %{top_level_dir_name}-backup
%global buildver 12 %global buildver 12
%global rpmrelease 3 %global rpmrelease 4
# Priority must be 8 digits in total; up to openjdk 1.8, we were using 18..... so when we moved to 11, we had to add another digit # Priority must be 8 digits in total; up to openjdk 1.8, we were using 18..... so when we moved to 11, we had to add another digit
%if %is_system_jdk %if %is_system_jdk
# Using 10 digits may overflow the int used for priority, so we combine the patch and build versions # Using 10 digits may overflow the int used for priority, so we combine the patch and build versions
@ -1676,62 +1676,46 @@ EXTRA_CFLAGS="$EXTRA_CFLAGS -fno-strict-aliasing"
%endif %endif
export EXTRA_CFLAGS export EXTRA_CFLAGS
for suffix in %{build_loop} ; do function buildjdk() {
if [ "x$suffix" = "x" ] ; then local outputdir=${1}
debugbuild=release local buildjdk=${2}
debug_symbols=internal local maketargets="${3}"
else local debuglevel=${4}
# change --something to something local link_opt=${5}
debugbuild=`echo $suffix | sed "s/-//g"`
debug_symbols=internal
fi
for loop in %{main_suffix} %{staticlibs_loop} ; do local top_dir_abs_src_path=$(pwd)/%{top_level_dir_name}
local top_dir_abs_build_path=$(pwd)/${outputdir}
if test "x${loop}" = "x%{main_suffix}" ; then # The OpenJDK version file includes the current
# Copy the source tree so we can remove all in-tree libraries # upstream version information. For some reason,
cp -a %{top_level_dir_name} %{top_level_dir_name_backup} # configure does not automatically use the
# Remove all libraries that are linked # default pre-version supplied there (despite
sh %{SOURCE12} %{top_level_dir_name} full # what the file claims), so we pass it manually
# Variable used by configure and hs_err hook on build failures # to configure
link_opt="system" VERSION_FILE=${top_dir_abs_src_path}/make/conf/version-numbers.conf
# Debug builds don't need same targets as release for if [ -f ${VERSION_FILE} ] ; then
# build speed-up EA_DESIGNATOR=$(grep '^DEFAULT_PROMOTED_VERSION_PRE' ${VERSION_FILE} | cut -d '=' -f 2)
maketargets="%{release_targets}" else
if echo $debugbuild | grep -q "debug" ; then echo "Could not find OpenJDK version file.";
maketargets="%{debug_targets}" exit 16
fi
if [ "x${EA_DESIGNATOR}" != "x%{expected_ea_designator}" ] ; then
echo "Spec file is configured for a %{build_type} build, but upstream version-pre setting is ${EA_DESIGNATOR}";
exit 17
fi fi
else
# Variable used by configure and hs_err hook on build failures
link_opt="bundled"
# Static library cycle only builds the static libraries
maketargets="%{static_libs_target}"
fi
top_dir_abs_src_path=$(pwd)/%{top_level_dir_name} echo "Using output directory: ${outputdir}";
top_dir_abs_build_path=$(pwd)/%{buildoutputdir -- ${suffix}${loop}} echo "Checking build JDK ${buildjdk} is operational..."
# The OpenJDK version file includes the current ${buildjdk}/bin/java -version
# upstream version information. For some reason, echo "Using make targets: ${maketargets}"
# configure does not automatically use the echo "Using debuglevel: ${debuglevel}"
# default pre-version supplied there (despite echo "Using link_opt: ${link_opt}"
# what the file claims), so we pass it manually echo "Building %{newjavaver}-%{buildver}, pre=${EA_DESIGNATOR}, opt=%{lts_designator}"
# to configure
VERSION_FILE=${top_dir_abs_src_path}/make/conf/version-numbers.conf
if [ -f ${VERSION_FILE} ] ; then
EA_DESIGNATOR=$(grep '^DEFAULT_PROMOTED_VERSION_PRE' ${VERSION_FILE} | cut -d '=' -f 2)
else
echo "Could not find OpenJDK version file.";
exit 16
fi
if [ "x${EA_DESIGNATOR}" != "x%{expected_ea_designator}" ] ; then
echo "Spec file is configured for a %{build_type} build, but upstream version-pre setting is ${EA_DESIGNATOR}";
exit 17
fi
mkdir -p ${top_dir_abs_build_path} mkdir -p ${outputdir}
pushd ${top_dir_abs_build_path} pushd ${outputdir}
bash ${top_dir_abs_src_path}/configure \ bash ${top_dir_abs_src_path}/configure \
%ifnarch %{jit_arches} %ifnarch %{jit_arches}
--with-jvm-variants=zero \ --with-jvm-variants=zero \
%endif %endif
@ -1746,9 +1730,9 @@ bash ${top_dir_abs_src_path}/configure \
--with-vendor-url="https://www.redhat.com/" \ --with-vendor-url="https://www.redhat.com/" \
--with-vendor-bug-url="%{bugs}" \ --with-vendor-bug-url="%{bugs}" \
--with-vendor-vm-bug-url="%{bugs}" \ --with-vendor-vm-bug-url="%{bugs}" \
--with-boot-jdk=/usr/lib/jvm/java-%{buildjdkver}-openjdk \ --with-boot-jdk=${buildjdk} \
--with-debug-level=$debugbuild \ --with-debug-level=${debuglevel} \
--with-native-debug-symbols=$debug_symbols \ --with-native-debug-symbols="%{debug_symbols}" \
--enable-sysconf-nss \ --enable-sysconf-nss \
--enable-unlimited-crypto \ --enable-unlimited-crypto \
--with-zlib=system \ --with-zlib=system \
@ -1769,53 +1753,101 @@ bash ${top_dir_abs_src_path}/configure \
%endif %endif
--disable-warnings-as-errors --disable-warnings-as-errors
make \ cat spec.gmk
LOG=trace \
WARNINGS_ARE_ERRORS="-Wno-error" \
CFLAGS_WARNINGS_ARE_ERRORS="-Wno-error" \
$maketargets || ( pwd; find ${top_dir_abs_src_path} ${top_dir_abs_build_path} -name "hs_err_pid*.log" | xargs cat && false )
popd make \
LOG=trace \
WARNINGS_ARE_ERRORS="-Wno-error" \
CFLAGS_WARNINGS_ARE_ERRORS="-Wno-error" \
$maketargets || ( pwd; find ${top_dir_abs_src_path} ${top_dir_abs_build_path} -name "hs_err_pid*.log" | xargs cat && false )
# Restore original source tree if we modified it by removing full in-tree sources popd
if [ -d %{top_level_dir_name_backup} ] ; then }
rm -rf %{top_level_dir_name}
mv %{top_level_dir_name_backup} %{top_level_dir_name}
fi
done # end of main / staticlibs loop function installjdk() {
local imagepath=${1}
top_dir_abs_main_build_path=$(pwd)/%{buildoutputdir -- ${suffix}%{main_suffix}} # the build (erroneously) removes read permissions from some jars
# this is a regression in OpenJDK 7 (our compiler):
# http://icedtea.classpath.org/bugzilla/show_bug.cgi?id=1437
find ${imagepath} -iname '*.jar' -exec chmod ugo+r {} \;
# the build (erroneously) removes read permissions from some jars # Build screws up permissions on binaries
# this is a regression in OpenJDK 7 (our compiler): # https://bugs.openjdk.java.net/browse/JDK-8173610
# http://icedtea.classpath.org/bugzilla/show_bug.cgi?id=1437 find ${imagepath} -iname '*.so' -exec chmod +x {} \;
find ${top_dir_abs_main_build_path}/images/%{jdkimage} -iname '*.jar' -exec chmod ugo+r {} \; find ${imagepath}/bin/ -exec chmod +x {} \;
# Build screws up permissions on binaries # Install nss.cfg right away as we will be using the JRE above
# https://bugs.openjdk.java.net/browse/JDK-8173610 install -m 644 nss.cfg ${imagepath}/conf/security/
find ${top_dir_abs_main_build_path}/images/%{jdkimage} -iname '*.so' -exec chmod +x {} \;
find ${top_dir_abs_main_build_path}/images/%{jdkimage}/bin/ -exec chmod +x {} \;
# Install nss.cfg right away as we will be using the JRE above # Install nss.fips.cfg: NSS configuration for global FIPS mode (crypto-policies)
export JAVA_HOME=${top_dir_abs_main_build_path}/images/%{jdkimage} install -m 644 nss.fips.cfg ${imagepath}/conf/security/
# Install nss.cfg right away as we will be using the JRE above # Use system-wide tzdata
install -m 644 nss.cfg $JAVA_HOME/conf/security/ rm ${imagepath}/lib/tzdb.dat
ln -s %{_datadir}/javazi-1.8/tzdb.dat ${imagepath}/lib/tzdb.dat
# Install nss.fips.cfg: NSS configuration for global FIPS mode (crypto-policies) # Create fake alt-java as a placeholder for future alt-java
install -m 644 nss.fips.cfg $JAVA_HOME/conf/security/ pushd ${imagepath}
# add alt-java man page
echo "Hardened java binary recommended for launching untrusted code from the Web e.g. javaws" > man/man1/%{alt_java_name}.1
cat man/man1/java.1 >> man/man1/%{alt_java_name}.1
popd
}
# Use system-wide tzdata for suffix in %{build_loop} ; do
rm $JAVA_HOME/lib/tzdb.dat
ln -s %{_datadir}/javazi-1.8/tzdb.dat $JAVA_HOME/lib/tzdb.dat
# Create fake alt-java as a placeholder for future alt-java if [ "x$suffix" = "x" ] ; then
pushd ${JAVA_HOME} debugbuild=release
# add alt-java man page else
echo "Hardened java binary recommended for launching untrusted code from the Web e.g. javaws" > man/man1/%{alt_java_name}.1 # change --something to something
cat man/man1/java.1 >> man/man1/%{alt_java_name}.1 debugbuild=`echo $suffix | sed "s/-//g"`
popd fi
systemjdk=/usr/lib/jvm/java-%{buildjdkver}-openjdk
for loop in %{main_suffix} %{staticlibs_loop} ; do
builddir=%{buildoutputdir -- ${suffix}${loop}}
bootbuilddir=boot${builddir}
if test "x${loop}" = "x%{main_suffix}" ; then
# Copy the source tree so we can remove all in-tree libraries
cp -a %{top_level_dir_name} %{top_level_dir_name_backup}
# Remove all libraries that are linked
sh %{SOURCE12} %{top_level_dir_name} full
# Use system libraries
link_opt="system"
# Debug builds don't need same targets as release for
# build speed-up
maketargets="%{release_targets}"
if echo $debugbuild | grep -q "debug" ; then
maketargets="%{debug_targets}"
fi
%if %{bootstrap_build}
buildjdk ${bootbuilddir} ${systemjdk} "%{bootstrap_targets}" ${debugbuild} ${link_opt}
buildjdk ${builddir} $(pwd)/${bootbuilddir}/images/%{jdkimage} "${maketargets}" ${debugbuild} ${link_opt}
rm -rf ${bootbuilddir}
%else
buildjdk ${builddir} ${systemjdk} "${maketargets}" ${debugbuild} ${link_opt}
%endif
# Restore original source tree we modified by removing full in-tree sources
rm -rf %{top_level_dir_name}
mv %{top_level_dir_name_backup} %{top_level_dir_name}
else
# Use bundled libraries for building statically
link_opt="bundled"
# Static library cycle only builds the static libraries
maketargets="%{static_libs_target}"
# Always just do the one build for the static libraries
buildjdk ${builddir} ${systemjdk} "${maketargets}" ${debugbuild} ${link_opt}
fi
done # end of main / staticlibs loop
# Final setup on the main image
top_dir_abs_main_build_path=$(pwd)/%{buildoutputdir -- ${suffix}%{main_suffix}}
installjdk ${top_dir_abs_main_build_path}/images/%{jdkimage}
# build cycles # build cycles
done # end of release / debug cycle loop done # end of release / debug cycle loop
@ -2326,6 +2358,10 @@ cjc.mainProgram(args)
%endif %endif
%changelog %changelog
* Tue Oct 26 2021 Andrew Hughes <gnu.andrew@redhat.com> - 1:17.0.1.0.12-4.rolling
- Restructure the build so a minimal initial build is then used for the final build (with docs)
- This reduces pressure on the system JDK and ensures the JDK being built can do a full build
* Tue Oct 26 2021 Jiri Vanek <jvanek@redhat.com> - 1:17.0.1.0.12-3.rolling * Tue Oct 26 2021 Jiri Vanek <jvanek@redhat.com> - 1:17.0.1.0.12-3.rolling
- Minor cosmetic improvements to make spec more comparable between variants - Minor cosmetic improvements to make spec more comparable between variants