8328106: COMPARE_BUILD improvements

Reviewed-by: erikj
This commit is contained in:
Magnus Ihse Bursie 2024-03-14 07:30:42 +00:00
parent fadc4b197e
commit fcf746dede
5 changed files with 68 additions and 29 deletions

View File

@ -1,5 +1,5 @@
# #
# Copyright (c) 2014, 2023, Oracle and/or its affiliates. All rights reserved. # Copyright (c) 2014, 2024, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
# #
# This code is free software; you can redistribute it and/or modify it # This code is free software; you can redistribute it and/or modify it
@ -144,6 +144,14 @@ define CreateCDSArchive
$1_$2_CDS_ARCHIVE := lib/$1/classes$2.jsa $1_$2_CDS_ARCHIVE := lib/$1/classes$2.jsa
endif endif
ifneq ($(COMPARE_BUILD), )
DEBUG_CDS_ARCHIVE := true
endif
ifeq ($(DEBUG_CDS_ARCHIVE), true)
$1_$2_CDS_DUMP_FLAGS += -Xlog:cds+map*=trace:file=$$(JDK_IMAGE_DIR)/$$($1_$2_CDS_ARCHIVE).cdsmap:none:filesize=0
endif
$$(eval $$(call SetupExecute, $1_$2_gen_cds_archive_jdk, \ $$(eval $$(call SetupExecute, $1_$2_gen_cds_archive_jdk, \
WARN := Creating CDS$$($1_$2_DUMP_TYPE) archive for jdk image for $1, \ WARN := Creating CDS$$($1_$2_DUMP_TYPE) archive for jdk image for $1, \
INFO := Using CDS flags for $1: $$($1_$2_CDS_DUMP_FLAGS), \ INFO := Using CDS flags for $1: $$($1_$2_CDS_DUMP_FLAGS), \

View File

@ -442,10 +442,10 @@ else # $(HAS_SPEC)=true
# Compare first and second build. Ignore any error code from compare.sh. # Compare first and second build. Ignore any error code from compare.sh.
$(ECHO) "Comparing between comparison rebuild (this/new) and baseline (other/old)" $(ECHO) "Comparing between comparison rebuild (this/new) and baseline (other/old)"
$(if $(COMPARE_BUILD_COMP_DIR), \ $(if $(COMPARE_BUILD_COMP_DIR), \
+(cd $(COMPARE_BUILD_OUTPUTDIR) && ./compare.sh -vv $(COMPARE_BUILD_COMP_OPTS) \ +(cd $(COMPARE_BUILD_OUTPUTDIR) && ./compare.sh --diffs $(COMPARE_BUILD_COMP_OPTS) \
-2dirs $(COMPARE_BUILD_OUTPUTDIR)/$(COMPARE_BUILD_COMP_DIR) \ -2dirs $(COMPARE_BUILD_OUTPUTDIR)/$(COMPARE_BUILD_COMP_DIR) \
$(OUTPUTDIR)/$(COMPARE_BUILD_COMP_DIR) $(COMPARE_BUILD_IGNORE_RESULT)), \ $(OUTPUTDIR)/$(COMPARE_BUILD_COMP_DIR) $(COMPARE_BUILD_IGNORE_RESULT)), \
+(cd $(COMPARE_BUILD_OUTPUTDIR) && ./compare.sh -vv $(COMPARE_BUILD_COMP_OPTS) \ +(cd $(COMPARE_BUILD_OUTPUTDIR) && ./compare.sh --diffs $(COMPARE_BUILD_COMP_OPTS) \
-o $(OUTPUTDIR) $(COMPARE_BUILD_IGNORE_RESULT)) \ -o $(OUTPUTDIR) $(COMPARE_BUILD_IGNORE_RESULT)) \
) )
endef endef

View File

@ -1,6 +1,6 @@
#!/bin/bash #!/bin/bash
# #
# Copyright (c) 2012, 2022, Oracle and/or its affiliates. All rights reserved. # Copyright (c) 2012, 2024, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
# #
# This code is free software; you can redistribute it and/or modify it # This code is free software; you can redistribute it and/or modify it
@ -45,11 +45,13 @@ export CP="@CP@"
export CUT="@CUT@" export CUT="@CUT@"
export DIFF="@DIFF@" export DIFF="@DIFF@"
export DUMPBIN="@DUMPBIN@" export DUMPBIN="@DUMPBIN@"
export ECHO="@ECHO@"
export EXPR="@EXPR@" export EXPR="@EXPR@"
export FILE="@FILE@" export FILE="@FILE@"
export FIND="@FIND@" export FIND="@FIND@"
export GREP="@GREP@" export GREP="@GREP@"
export GUNZIP="@GUNZIP@" export GUNZIP="@GUNZIP@"
export HEAD="@HEAD@"
export LDD="@LDD@" export LDD="@LDD@"
export LN="@LN@" export LN="@LN@"
export MKDIR="@MKDIR@" export MKDIR="@MKDIR@"

View File

@ -38,7 +38,7 @@ fi
export LC_ALL=C export LC_ALL=C
if [ "$OPENJDK_TARGET_OS" = "macosx" ]; then if [ "$OPENJDK_TARGET_OS" = "macosx" ]; then
FULLDUMP_CMD="$OTOOL -v -V -h -X -d" FULLDUMP_CMD="$OTOOL -a -C -d -f -G -h -H -I -j -l -L -m -M -o -P -r -R -S -t -T -v -V -X -dyld_info -dyld_opcodes"
LDD_CMD="$OTOOL -L" LDD_CMD="$OTOOL -L"
DIS_CMD="$OTOOL -v -V -t" DIS_CMD="$OTOOL -v -V -t"
STAT_PRINT_SIZE="-f %z" STAT_PRINT_SIZE="-f %z"
@ -117,7 +117,7 @@ diff_text() {
SUFFIX="${THIS_FILE##*.}" SUFFIX="${THIS_FILE##*.}"
NAME="${THIS_FILE##*/}" NAME="${THIS_FILE##*/}"
TMP=$($DIFF $THIS_FILE $OTHER_FILE) TMP=$($DIFF -u $THIS_FILE $OTHER_FILE)
if test -n "$TMP"; then if test -n "$TMP"; then
@ -438,7 +438,7 @@ compare_zip_file() {
$RM -f $WORK_DIR/$ZIP_FILE.diffs $RM -f $WORK_DIR/$ZIP_FILE.diffs
for file in $DIFFING_TEXT_FILES; do for file in $DIFFING_TEXT_FILES; do
if [[ "$ACCEPTED_JARZIP_CONTENTS $EXCEPTIONS" != *"$file"* ]]; then if [[ "$ACCEPTED_JARZIP_CONTENTS" != *"$file"* ]]; then
diff_text $OTHER_UNZIPDIR/$file $THIS_UNZIPDIR/$file >> $WORK_DIR/$ZIP_FILE.diffs diff_text $OTHER_UNZIPDIR/$file $THIS_UNZIPDIR/$file >> $WORK_DIR/$ZIP_FILE.diffs
fi fi
done done
@ -454,11 +454,11 @@ compare_zip_file() {
if [ -n "$SHOW_DIFFS" ]; then if [ -n "$SHOW_DIFFS" ]; then
for i in $(cat $WORK_DIR/$ZIP_FILE.difflist) ; do for i in $(cat $WORK_DIR/$ZIP_FILE.difflist) ; do
if [ -f "${OTHER_UNZIPDIR}/$i.javap" ]; then if [ -f "${OTHER_UNZIPDIR}/$i.javap" ]; then
$DIFF ${OTHER_UNZIPDIR}/$i.javap ${THIS_UNZIPDIR}/$i.javap $DIFF -u ${OTHER_UNZIPDIR}/$i.javap ${THIS_UNZIPDIR}/$i.javap
elif [ -f "${OTHER_UNZIPDIR}/$i.cleaned" ]; then elif [ -f "${OTHER_UNZIPDIR}/$i.cleaned" ]; then
$DIFF ${OTHER_UNZIPDIR}/$i.cleaned ${THIS_UNZIPDIR}/$i $DIFF -u ${OTHER_UNZIPDIR}/$i.cleaned ${THIS_UNZIPDIR}/$i
else else
$DIFF ${OTHER_UNZIPDIR}/$i ${THIS_UNZIPDIR}/$i $DIFF -u ${OTHER_UNZIPDIR}/$i ${THIS_UNZIPDIR}/$i
fi fi
done done
fi fi
@ -788,7 +788,7 @@ compare_bin_file() {
> $WORK_FILE_BASE.symbols.this > $WORK_FILE_BASE.symbols.this
fi fi
$DIFF $WORK_FILE_BASE.symbols.other $WORK_FILE_BASE.symbols.this > $WORK_FILE_BASE.symbols.diff $DIFF -u $WORK_FILE_BASE.symbols.other $WORK_FILE_BASE.symbols.this > $WORK_FILE_BASE.symbols.diff
if [ -s $WORK_FILE_BASE.symbols.diff ]; then if [ -s $WORK_FILE_BASE.symbols.diff ]; then
SYM_MSG=" diff " SYM_MSG=" diff "
if [[ "$ACCEPTED_SYM_DIFF" != *"$BIN_FILE"* ]]; then if [[ "$ACCEPTED_SYM_DIFF" != *"$BIN_FILE"* ]]; then
@ -828,9 +828,9 @@ compare_bin_file() {
| $UNIQ > $WORK_FILE_BASE.deps.this.uniq) | $UNIQ > $WORK_FILE_BASE.deps.this.uniq)
(cd $FILE_WORK_DIR && $RM -f $NAME) (cd $FILE_WORK_DIR && $RM -f $NAME)
$DIFF $WORK_FILE_BASE.deps.other $WORK_FILE_BASE.deps.this \ $DIFF -u $WORK_FILE_BASE.deps.other $WORK_FILE_BASE.deps.this \
> $WORK_FILE_BASE.deps.diff > $WORK_FILE_BASE.deps.diff
$DIFF $WORK_FILE_BASE.deps.other.uniq $WORK_FILE_BASE.deps.this.uniq \ $DIFF -u $WORK_FILE_BASE.deps.other.uniq $WORK_FILE_BASE.deps.this.uniq \
> $WORK_FILE_BASE.deps.diff.uniq > $WORK_FILE_BASE.deps.diff.uniq
if [ -s $WORK_FILE_BASE.deps.diff ]; then if [ -s $WORK_FILE_BASE.deps.diff ]; then
@ -880,7 +880,7 @@ compare_bin_file() {
> $WORK_FILE_BASE.fulldump.this 2>&1 & > $WORK_FILE_BASE.fulldump.this 2>&1 &
wait wait
$DIFF $WORK_FILE_BASE.fulldump.other $WORK_FILE_BASE.fulldump.this \ $DIFF -u $WORK_FILE_BASE.fulldump.other $WORK_FILE_BASE.fulldump.this \
> $WORK_FILE_BASE.fulldump.diff > $WORK_FILE_BASE.fulldump.diff
if [ -s $WORK_FILE_BASE.fulldump.diff ]; then if [ -s $WORK_FILE_BASE.fulldump.diff ]; then
@ -927,7 +927,7 @@ compare_bin_file() {
| eval "$this_DIS_DIFF_FILTER" > $WORK_FILE_BASE.dis.this 2>&1 & | eval "$this_DIS_DIFF_FILTER" > $WORK_FILE_BASE.dis.this 2>&1 &
wait wait
$DIFF $WORK_FILE_BASE.dis.other $WORK_FILE_BASE.dis.this > $WORK_FILE_BASE.dis.diff $DIFF -u $WORK_FILE_BASE.dis.other $WORK_FILE_BASE.dis.this > $WORK_FILE_BASE.dis.diff
if [ -s $WORK_FILE_BASE.dis.diff ]; then if [ -s $WORK_FILE_BASE.dis.diff ]; then
DIS_DIFF_SIZE=$(ls -n $WORK_FILE_BASE.dis.diff | awk '{print $5}') DIS_DIFF_SIZE=$(ls -n $WORK_FILE_BASE.dis.diff | awk '{print $5}')
@ -968,20 +968,20 @@ compare_bin_file() {
echo " $BIN_FILE" echo " $BIN_FILE"
if [ "$SHOW_DIFFS" = "true" ]; then if [ "$SHOW_DIFFS" = "true" ]; then
if [ -s "$WORK_FILE_BASE.symbols.diff" ]; then if [ -s "$WORK_FILE_BASE.symbols.diff" ]; then
echo "Symbols diff:" echo "Symbols diff $SHOW_DIFF_INFO:"
$CAT $WORK_FILE_BASE.symbols.diff $SHOW_DIFF_CMD $WORK_FILE_BASE.symbols.diff
fi fi
if [ -s "$WORK_FILE_BASE.deps.diff" ]; then if [ -s "$WORK_FILE_BASE.deps.diff" ]; then
echo "Deps diff:" echo "Deps diff $SHOW_DIFF_INFO:"
$CAT $WORK_FILE_BASE.deps.diff $SHOW_DIFF_CMD $WORK_FILE_BASE.deps.diff
fi fi
if [ -s "$WORK_FILE_BASE.fulldump.diff" ]; then if [ -s "$WORK_FILE_BASE.fulldump.diff" ]; then
echo "Fulldump diff:" echo "Fulldump diff $SHOW_DIFF_INFO:"
$CAT $WORK_FILE_BASE.fulldump.diff $SHOW_DIFF_CMD $WORK_FILE_BASE.fulldump.diff
fi fi
if [ -s "$WORK_FILE_BASE.dis.diff" ]; then if [ -s "$WORK_FILE_BASE.dis.diff" ]; then
echo "Disassembly diff:" echo "Disassembly diff $SHOW_DIFF_INFO:"
$CAT $WORK_FILE_BASE.dis.diff $SHOW_DIFF_CMD $WORK_FILE_BASE.dis.diff
fi fi
fi fi
return 1 return 1
@ -1077,7 +1077,7 @@ compare_all_debug_files() {
else else
OTHER_FILE=$OTHER_DIR/$f OTHER_FILE=$OTHER_DIR/$f
THIS_FILE=$THIS_DIR/$f THIS_FILE=$THIS_DIR/$f
DIFF_OUT=$($DIFF $OTHER_FILE $THIS_FILE 2>&1) DIFF_OUT=$($DIFF -u $OTHER_FILE $THIS_FILE 2>&1)
fi fi
if [ -n "$DIFF_OUT" ]; then if [ -n "$DIFF_OUT" ]; then
@ -1108,6 +1108,16 @@ compare_all_other_files() {
if [[ "$f" == */native/* ]]; then if [[ "$f" == */native/* ]]; then
continue continue
fi fi
NAME=$(basename $f)
WORK_FILE_BASE=$WORK_DIR/$f
FILE_WORK_DIR=$(dirname $WORK_FILE_BASE)
$MKDIR -p $FILE_WORK_DIR
# Make soft links to original files from work dir to facilitate debugging
$LN -f -s $THIS_FILE $WORK_FILE_BASE.this
$LN -f -s $OTHER_FILE $WORK_FILE_BASE.other
if [ -e $OTHER_DIR/$f ]; then if [ -e $OTHER_DIR/$f ]; then
SUFFIX="${f##*.}" SUFFIX="${f##*.}"
if [ "$(basename $f)" = "release" ]; then if [ "$(basename $f)" = "release" ]; then
@ -1133,12 +1143,14 @@ compare_all_other_files() {
OTHER_FILE=$OTHER_DIR/$f OTHER_FILE=$OTHER_DIR/$f
THIS_FILE=$THIS_DIR/$f THIS_FILE=$THIS_DIR/$f
fi fi
DIFF_OUT=$($DIFF $OTHER_FILE $THIS_FILE 2>&1)
if [ -n "$DIFF_OUT" ]; then $DIFF -u $OTHER_FILE $THIS_FILE > $WORK_FILE_BASE.diff 2>&1
echo $f if [ -s $WORK_FILE_BASE.diff ]; then
echo "$f (diff size $(ls -n $WORK_FILE_BASE.diff | awk '{print $5}'))"
REGRESSIONS=true REGRESSIONS=true
if [ "$SHOW_DIFFS" = "true" ]; then if [ "$SHOW_DIFFS" = "true" ]; then
echo "$DIFF_OUT" echo SHOW DIFF $SHOW_DIFF_INFO: $WORK_FILE_BASE.diff
$SHOW_DIFF_CMD "$WORK_FILE_BASE.diff"
fi fi
fi fi
fi fi
@ -1166,8 +1178,10 @@ if [ -z "$1" ] || [ "$1" = "-h" ] || [ "$1" = "-?" ] || [ "$1" = "/h" ] || [ "$1
echo "-jmods Compare the listings of all jmod files" echo "-jmods Compare the listings of all jmod files"
echo "-libs Compare all native libraries" echo "-libs Compare all native libraries"
echo "-execs Compare all executables" echo "-execs Compare all executables"
echo "--diffs Shows abridged diff output of all comparisons"
echo "--diffs=full Shows full diff output of all comparisons (Warning! Log can be huge)"
echo "-v Verbose output, does not hide known differences" echo "-v Verbose output, does not hide known differences"
echo "-vv More verbose output, shows diff output of all comparisons" echo "-vv Alias for -v --diffs"
echo "-o [OTHER] Compare with build in other directory. Will default to the old build directory" echo "-o [OTHER] Compare with build in other directory. Will default to the old build directory"
echo "" echo ""
echo "--sort-symbols Sort all symbols before comparing" echo "--sort-symbols Sort all symbols before comparing"
@ -1205,6 +1219,13 @@ while [ -n "$1" ]; do
VERBOSE=true VERBOSE=true
SHOW_DIFFS=true SHOW_DIFFS=true
;; ;;
--diffs)
SHOW_DIFFS=true
;;
--diffs=full)
SHOW_DIFFS=true
SHOW_FULL_DIFFS=true
;;
-o) -o)
OTHER="$2" OTHER="$2"
shift shift
@ -1366,6 +1387,14 @@ if [ "$CMP_NAMES" = "false" ] \
CMP_EXECS=true CMP_EXECS=true
fi fi
if [ "$SHOW_FULL_DIFFS" = "true" ]; then
SHOW_DIFF_CMD="$CAT"
SHOW_DIFF_INFO="(full diff)"
else
SHOW_DIFF_CMD="$HEAD -n 500"
SHOW_DIFF_INFO="(first 500 lines)"
fi
if [ -z "$FILTER" ]; then if [ -z "$FILTER" ]; then
FILTER="$CAT" FILTER="$CAT"
fi fi