Skip to content

Commit

Permalink
Same results for similar and identical (#4128)
Browse files Browse the repository at this point in the history
* Align diff of identical and comparable jdk

It seems usefull to have same diff output after both comparable and
reproducible builds. This commit is adding PREPROCESS flag to
repro_compare.sh. If set to "no", repro_compare.sh. will not run
preprocessing, but will just print diff - in same way as when called on
reproducible builds.

* Moved jdk check out of the loop for better readability
  • Loading branch information
judovana authored Feb 10, 2025
1 parent d1c15a6 commit a858651
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 7 deletions.
2 changes: 1 addition & 1 deletion tooling/reproducible/ReproducibleBuilds.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ The patching process involves:
- Remove any non-deterministic build process artifact strings, like Manifest Created-By stamps.
- Zero out CRC in .gnu_debuglink ELF sections to eliminate .debuginfo-induced differences.

**warning:** If you run `comparable_patch.sh`, do not use `repro_compare.sh` for final comparison. You would get false negatives. Run plain `diff jdk1 jdk2` with any switches you need.
**warning:** If you run `comparable_patch.sh`, do not use `repro_compare.sh` for final comparison. You would get false negatives. Run plain `diff jdk1 jdk2` with any switches you need, or use `PREPROCESS=no repro_compare.sh` with the flag `PREPROCESS=no`. Any other value then `no` would lead again to preprocessing, and thus false negatives.

### How to setup and run comparable_patch.sh on Windows

Expand Down
30 changes: 24 additions & 6 deletions tooling/reproducible/repro_compare.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,34 @@ BLD_TYPE2="$3"
JDK_DIR2="$4"
OS="$5"

checkJdkDir() {
JDK_DIR="${1}"
if [[ ! -d "${JDK_DIR}" ]] || [[ ! -d "${JDK_DIR}/bin" ]]; then
echo "$JDK_DIR does not exist or does not point at a JDK"
echo "repro_compare.sh (temurin|openjdk) JDK_DIR1 (temurin|openjdk) JDK_DIR2 OS"
exit 1
fi
}

checkJdkDir "${JDK_DIR1}"
checkJdkDir "${JDK_DIR2}"

# if PREPROCESS flag is set to 'no', then preprocessing is not run
# this is usefull, if yo want to compare two identical copies of JDK
# or if you want to run repro_compare.sh only as result generator after you
# run comparable_patch.sh. This helps to keep diff in unified output
if [ -z "${PREPROCESS:-}" ] ; then
PREPROCESS="yes"
fi

mkdir "${JDK_DIR}_BK"
cp -R "${JDK_DIR1}"/* "${JDK_DIR}"_BK
BK_JDK_DIR=$(realpath "${JDK_DIR}"_BK/)

JDK_DIR_Arr=("${JDK_DIR1}" "${JDK_DIR2}")
if [ "$PREPROCESS" != "no" ] ; then
for JDK_DIR in "${JDK_DIR_Arr[@]}"
do
if [[ ! -d "${JDK_DIR}" ]] || [[ ! -d "${JDK_DIR}/bin" ]]; then
echo "$JDK_DIR does not exist or does not point at a JDK"
echo "repro_compare.sh (temurin|openjdk) JDK_DIR1 (temurin|openjdk) JDK_DIR2 OS"
exit 1
fi

echo "$(date +%T) : Pre-processing ${JDK_DIR}"
rc=0
source "$(dirname "$0")"/repro_process.sh "${JDK_DIR}" "${OS}" || rc=$?
Expand All @@ -54,6 +69,9 @@ do
processModuleInfo "${JDK_DIR}" "${OS}" "${BK_JDK_DIR}"
fi
done
else
echo "Preprocessing skipped on user request. Generating just diff."
fi

files1=$(find "${JDK_DIR1}" -type f | wc -l)
echo "Number of files: ${files1}"
Expand Down

0 comments on commit a858651

Please sign in to comment.