Skip to content

Commit

Permalink
Include Comparison Improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
steelhead31 committed Feb 27, 2024
1 parent 769eecc commit df16245
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 18 deletions.
4 changes: 0 additions & 4 deletions tooling/repro_common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,11 @@ function removeSystemModulesHashBuilderParams() {
virtualFunction="invokevirtual"

systemModules="SystemModules\$0.class SystemModules\$all.class SystemModules\$default.class"
# echo "Removing SystemModules ModulesHashes\$Builder differences"
for systemModule in $systemModules
do
FILES=$(find "${JDK_DIR}" -type f -name "$systemModule")
for f in $FILES
do
# echo "Processing $f"
javap -v -sysinfo -l -p -c -s -constants "$f" > "$f.javap.tmp"
rm "$f"

Expand All @@ -107,7 +105,6 @@ function removeSystemModulesHashBuilderParams() {
if [[ "$cc" -eq 3 ]] && [[ "$line" =~ .*"$moduleString"[a-z\.]+.* ]]; then
found=true
module=$(echo "$line" | tr -s ' ' | tr -d '\r' | cut -d' ' -f6)
# echo "==> Found $module ModuleHashes\$Builder function, skipping hash parameter"
fi
# hasForModule function section finishes upon finding invokevirtual
if [[ "$found" = true ]] && [[ "$line" =~ .*"$virtualFunction".* ]]; then
Expand Down Expand Up @@ -141,7 +138,6 @@ function processModuleInfo() {
FILES=$(find "${JDK_DIR}" -type f -name "module-info.class")
for f in $FILES
do
# echo "javap and re-order ModuleAttributes for $f"
javap -v -sysinfo -l -p -c -s -constants "$f" > "$f.javap.tmp"
rm "$f"

Expand Down
82 changes: 68 additions & 14 deletions tooling/windows_repro_build_compare.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

# This script examines the given SBOM metadata file, and then builds the exact same binary
# and then compares with the Temurin JDK for the same build version, or the optionally supplied TARBALL_URL.
# Requires Cygwin On Windows To Run
# Requires Cygwin & Powershell Installed On Windows To Run

set -e

Expand Down Expand Up @@ -83,8 +83,6 @@ containsElement () {

# Function To Check The SBOM
Check_Parameters() {
# REMOVE echo "About To Check Supplied Parameters Are As Expected For Windows"
# REMOVE echo ""
if [[ $SBOM_URL == *windows*json ]]; then
echo "SBOM Filename Format Is OK"
else
Expand All @@ -105,7 +103,7 @@ Create_WorkDir() {
echo "Checking If Working Directory: $WORK_DIR Exists"
if [ -d "$WORK_DIR" ]; then
# Folder exists, delete it
rm -r "$WORK_DIR"
rm -rf "$WORK_DIR"
echo "Folder Exists - Removing '$WORK_DIR'"
fi
echo "Creating "$WORK_DIR" "
Expand Down Expand Up @@ -333,13 +331,11 @@ Check_VS_Versions() {
CPP_CL_PATHS=$(find "$MSVS_SEARCH_PATH" -type f -name "$CPP_COMPILER_EXE" | grep $CPP_COMPILER_PATH)

if [ -z "$C_CL_PATHS" ] ; then
# echo "ERROR - No MSVS C Compilers At The Correct Version: $msvsCCompiler Found - Exiting"
echo "ERROR - No MSVS C Compilers Found - Exiting"
exit 1
fi

if [ -z "$CPP_CL_PATHS" ] ; then
# echo "ERROR - No MSVS C++ Compilers At The Correct Version: $msvsCppCompiler Found - Exiting"
echo "ERROR - No MSVS C++ Compilers Found - Exiting"
exit 1
fi
Expand All @@ -353,7 +349,6 @@ Check_VS_Versions() {
echo "Found C Compiler : $C_COMPILER_FOUND : Version : $C_COMPILER_VERSION_OUTPUT"
if [ $msvsCCompiler = $C_COMPILER_VERSION_OUTPUT ] ; then
c_comp_count=$(expr "$c_comp_count" + 1)
# REMOVE echo "Yes, Count = $c_comp_count"
found_c_compiler="$C_COMPILER_FOUND"
fi
done
Expand All @@ -372,16 +367,13 @@ Check_VS_Versions() {

if [ $c_comp_count -eq 1 ] ; then
single_c_compiler=$found_c_compiler
# REMOVE echo "Build Will Use This Compiler: $single_c_compiler"
fi

if [ $cpp_comp_count -eq 1 ] ; then
single_cpp_compiler=$found_cpp_compiler
# REMOVE echo "Build Will Use This Compiler: $single_cpp_compiler"
fi

## Exit If Either Compiler Is At The Wrong Versions Or Multiple Compilers Are Detected As That Shouldnt Happen!

if [ $c_comp_count -eq 0 ] || [ $cpp_comp_count -eq 0 ] ; then
"ERROR - A C or C++ Compiler Matching The Version In The SBOM Could Not Be Found - Exiting"
exit 1
Expand All @@ -396,20 +388,19 @@ Check_VS_Versions() {
Get_SRC_UCRT_Version() {
# Extract The ucrtbase.dll from the SRC JDK Zip File
# Requires A Jump Out To Powershell To Extract File Version From DLL
# Only Required Until SDK Version Is Added To SBOM
mkdir $WORK_DIR/temp
unzip -j -o -q "$DISTLocalPath" -d $WORK_DIR/temp
UCRT_FILE=`cygpath -m $WORK_DIR/temp/ucrtbase.dll`
# REMOVE echo "File = "$UCRT_FILE
REQ_UCRT_VERSION=`powershell.exe "(Get-Command "$UCRT_FILE").FileVersionInfo.FileVersion"`
# REMOVE echo "UCRT = "$REQ_UCRT_VERSION
rm -rf $WORK_DIR/temp
}

Check_UCRT_Location() {
echo "Check For UCRT DLL In : $WIN_URCT_BASE"
URCT_CYGPATH=`cygpath -u $WIN_URCT_BASE`
## Add Architecture To PATH
WIN_URCT_PATH="$URCT_CYGPATH"
# Only Search For DLLs for the correct architecture
UCRTCOUNT=`find $WIN_URCT_PATH | grep $msvsArch | grep -i ucrtbase.dll|wc -l`
if [ $UCRTCOUNT -eq 0 ] ; then
echo "ERROR - NO ucrtbase.dll Could Be Found For The Base Path Specified - Exiting"
Expand Down Expand Up @@ -572,7 +563,7 @@ Prepare_Env_For_Build() {
if [ $fixed_param == "--freetype-dir" ]; then fixed_value="$fixed_value " ; fi
if [ $fixed_param == "--with-toolchain-version" ]; then fixed_value="$visualStudioVersion " ; fi
if [ $fixed_param == "--with-ucrt-dll-dir" ]; then fixed_value="temporary_speech_mark_placeholder"$UCRT_PARAM_PATH"temporary_speech_mark_placeholder""""" ; fi
if [ $fixed_param == "--target-file-name" ]; then fixed_value="$fixed_value " ; fi
if [ $fixed_param == "--target-file-name" ]; then target_file="$fixed_value" ; fixed_value="$fixed_value " ; fi
if [ $fixed_param == "--tag" ]; then fixed_value="$fixed_value " ; fi

# Fix Build Variant Parameter To Strip JDK Version
Expand Down Expand Up @@ -634,6 +625,67 @@ Build_JDK() {
cd $WORK_DIR
# $WORK_DIR/temurin-build/build-farm/makejdk-any-platform.sh $final_params
echo " cd temurin-build && ./makejdk-any-platform.sh $final_params 2>&1 | tee build.$$.log" | sh
# Copy The Built JDK To The Working Directory
cp "$WORK_DIR/temurin-build/workspace/target/$target_file" "$WORK_DIR/built_jdk.zip"
}

Compare_JDK() {
echo "Comparing JDKs"
echo ""
cd $WORK_DIR
mkdir $WORK_DIR/compare
cp $WORK_DIR/src_jdk_dist.zip $WORK_DIR/compare
cp $WORK_DIR/built_jdk.zip $WORK_DIR/compare
# Get The Current Versions Of The Reproducible Build Scripts
# wget -o $WORK_DIR/ repro_common.sh https://github.com/adoptium/temurin-build/blob/master/tooling/repro_common.sh
# wget -o $WORK_DIR/ repro_compare.sh https://github.com/adoptium/temurin-build/blob/master/tooling/repro_compare.#!/bin/sh
# wget -o $WORK_DIR/ repro_process.sh https://github.com/adoptium/temurin-build/blob/master/tooling/repro_process.sh

# Temp - Get From My Fork
wget -q -O $WORK_DIR/compare/repro_common.sh https://raw.githubusercontent.com/steelhead31/temurin-build/add_win_sbom_repro/tooling/repro_common.sh
wget -q -O $WORK_DIR/compare/repro_compare.sh https://raw.githubusercontent.com/steelhead31/temurin-build/add_win_sbom_repro/tooling/repro_compare.sh
wget -q -O $WORK_DIR/compare/repro_process.sh https://raw.githubusercontent.com/steelhead31/temurin-build/add_win_sbom_repro/tooling/repro_process.sh

# Set Permissions
chmod +x $WORK_DIR/compare/*sh
cd $WORK_DIR/compare

# Unzip And Rename The Source JDK
echo "Unzip Source"

unzip -q -o src_jdk_dist.zip
original_directory_name=$(ls -d */ | head -n 1 | sed 's#/##')
mv $original_directory_name src_jdk

#Unzip And Rename The Target JDK
echo "Unzip Target"
unzip -q -o built_jdk.zip
original_directory_name=$(ls -d */ | head -n 1 | sed 's#/##')
mv $original_directory_name tar_jdk

# These Two Files Are Generate Classes And Should Be Removed Prior To Running The Comparison
#src_jdk/bin/server/classes.jsa and tar_jdk/bin/server/classes.jsa differ
#src_jdk/bin/server/classes_nocoops.jsa and tar_jdk/bin/server/classes_nocoops.jsa differ

if [ -f "$WORK_DIR/compare/src_jdk/bin/server/classes.jsa" ] ; then
rm -rf "$WORK_DIR/compare/src_jdk/bin/server/classes.jsa"
fi

if [ -f "$WORK_DIR/compare/tar_jdk/bin/server/classes.jsa" ] ; then
rm -rf "$WORK_DIR/compare/tar_jdk/bin/server/classes.jsa"
fi

if [ -f "$WORK_DIR/compare/src_jdk/bin/server/classes_nocoops.jsa" ] ; then
rm -rf "$WORK_DIR/compare/src_jdk/bin/server/classes_nocoops.jsa"
fi

if [ -f "$WORK_DIR/compare/tar_jdk/bin/server/classes_nocoops.jsa" ] ; then
rm -rf "$WORK_DIR/compare/tar_jdk/bin/server/classes_nocoops.jsa"
fi

# Run Comparison Script
cd $WORK_DIR/compare
./repro_compare.sh temurin src_jdk temurin tar_jdk CYGWIN
}

Clean_Up_Everything() {
Expand Down Expand Up @@ -686,4 +738,6 @@ Prepare_Env_For_Build
echo "---------------------------------------------"
Build_JDK
echo "---------------------------------------------"
Compare_JDK
echo "---------------------------------------------"
Clean_Up_Everything

0 comments on commit df16245

Please sign in to comment.