Skip to content

Commit 67f008f

Browse files
author
duke
committed
Automatic merge of jdk:master into master
2 parents 24086f5 + b0485b9 commit 67f008f

File tree

4 files changed

+54
-20
lines changed

4 files changed

+54
-20
lines changed

make/autoconf/configure.ac

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,8 @@ FLAGS_POST_TOOLCHAIN
203203
PLATFORM_SETUP_OPENJDK_TARGET_BITS
204204
PLATFORM_SETUP_OPENJDK_TARGET_ENDIANNESS
205205

206-
# Configure flags for the tools
206+
# Configure flags for the tools. Need to know if we should build reproducible.
207+
JDKOPT_SETUP_REPRODUCIBLE_BUILD
207208
FLAGS_SETUP_FLAGS
208209

209210
# Setup debug symbols (need objcopy from the toolchain for that)
@@ -247,7 +248,6 @@ JDKOPT_ENABLE_DISABLE_GENERATE_CLASSLIST
247248
JDKOPT_EXCLUDE_TRANSLATIONS
248249
JDKOPT_ENABLE_DISABLE_MANPAGES
249250
JDKOPT_ENABLE_DISABLE_CDS_ARCHIVE
250-
JDKOPT_SETUP_REPRODUCIBLE_BUILD
251251

252252
###############################################################################
253253
#

make/autoconf/flags-cflags.m4

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -757,6 +757,18 @@ AC_DEFUN([FLAGS_SETUP_CFLAGS_CPU_DEP],
757757
$1_WARNING_CFLAGS_JVM="-Wno-format-zero-length -Wtype-limits -Wuninitialized"
758758
fi
759759
760+
if test "x$TOOLCHAIN_TYPE" = xmicrosoft && test "x$ENABLE_REPRODUCIBLE_BUILD" = xtrue; then
761+
# Enabling deterministic creates warnings if __DATE__ or __TIME__ are
762+
# used, and since we are, silence that warning.
763+
REPRODUCIBLE_CFLAGS="-experimental:deterministic -wd5048"
764+
FLAGS_COMPILER_CHECK_ARGUMENTS(ARGUMENT: [${REPRODUCIBLE_CFLAGS}],
765+
PREFIX: $3,
766+
IF_FALSE: [
767+
REPRODUCIBLE_CFLAGS=
768+
]
769+
)
770+
fi
771+
760772
# Prevent the __FILE__ macro from generating absolute paths into the built
761773
# binaries. Depending on toolchain, different mitigations are possible.
762774
# * GCC and Clang of new enough versions have -fmacro-prefix-map.
@@ -775,6 +787,30 @@ AC_DEFUN([FLAGS_SETUP_CFLAGS_CPU_DEP],
775787
FILE_MACRO_CFLAGS=
776788
]
777789
)
790+
elif test "x$TOOLCHAIN_TYPE" = xmicrosoft &&
791+
test "x$ENABLE_REPRODUCIBLE_BUILD" = xtrue; then
792+
# There is a known issue with the pathmap if the mapping is made to the
793+
# empty string. Add a minimal string "s" as prefix to work around this.
794+
workspace_root_win="${WORKSPACE_ROOT%/}"
795+
UTIL_REWRITE_AS_WINDOWS_MIXED_PATH([workspace_root_win])
796+
# PATHMAP_FLAGS is also added to LDFLAGS in flags-ldflags.m4.
797+
PATHMAP_FLAGS="-pathmap:${workspace_root_win//\//\\\\}=s \
798+
-pathmap:${workspace_root_win}=s"
799+
FILE_MACRO_CFLAGS="$PATHMAP_FLAGS"
800+
FLAGS_COMPILER_CHECK_ARGUMENTS(ARGUMENT: [${FILE_MACRO_CFLAGS}],
801+
PREFIX: $3,
802+
IF_FALSE: [
803+
PATHMAP_FLAGS=
804+
FILE_MACRO_CFLAGS=
805+
]
806+
)
807+
fi
808+
809+
AC_MSG_CHECKING([how to prevent absolute paths in output])
810+
if test "x$FILE_MACRO_CFLAGS" != x; then
811+
AC_MSG_RESULT([using compiler options])
812+
else
813+
AC_MSG_RESULT([using relative paths])
778814
fi
779815
fi
780816
AC_SUBST(FILE_MACRO_CFLAGS)
@@ -783,12 +819,13 @@ AC_DEFUN([FLAGS_SETUP_CFLAGS_CPU_DEP],
783819
CFLAGS_JVM_COMMON="$ALWAYS_CFLAGS_JVM $ALWAYS_DEFINES_JVM \
784820
$TOOLCHAIN_CFLAGS_JVM ${$1_TOOLCHAIN_CFLAGS_JVM} \
785821
$OS_CFLAGS $OS_CFLAGS_JVM $CFLAGS_OS_DEF_JVM $DEBUG_CFLAGS_JVM \
786-
$WARNING_CFLAGS $WARNING_CFLAGS_JVM $JVM_PICFLAG $FILE_MACRO_CFLAGS"
822+
$WARNING_CFLAGS $WARNING_CFLAGS_JVM $JVM_PICFLAG $FILE_MACRO_CFLAGS \
823+
$REPRODUCIBLE_CFLAGS"
787824
788825
CFLAGS_JDK_COMMON="$ALWAYS_CFLAGS_JDK $ALWAYS_DEFINES_JDK $TOOLCHAIN_CFLAGS_JDK \
789826
$OS_CFLAGS $CFLAGS_OS_DEF_JDK $DEBUG_CFLAGS_JDK $DEBUG_OPTIONS_FLAGS_JDK \
790827
$WARNING_CFLAGS $WARNING_CFLAGS_JDK $DEBUG_SYMBOLS_CFLAGS_JDK \
791-
$FILE_MACRO_CFLAGS"
828+
$FILE_MACRO_CFLAGS $REPRODUCIBLE_CFLAGS"
792829
793830
# Use ${$2EXTRA_CFLAGS} to block EXTRA_CFLAGS to be added to build flags.
794831
# (Currently we don't have any OPENJDK_BUILD_EXTRA_CFLAGS, but that might

make/autoconf/flags-ldflags.m4

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,9 +137,17 @@ AC_DEFUN([FLAGS_SETUP_LDFLAGS_HELPER],
137137
fi
138138
fi
139139
140+
if test "x$ENABLE_REPRODUCIBLE_BUILD" = "xtrue"; then
141+
if test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
142+
REPRODUCIBLE_LDFLAGS="-experimental:deterministic"
143+
fi
144+
fi
145+
140146
if test "x$ALLOW_ABSOLUTE_PATHS_IN_OUTPUT" = "xfalse"; then
141147
if test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
142148
BASIC_LDFLAGS="$BASIC_LDFLAGS -pdbaltpath:%_PDB%"
149+
# PATHMAP_FLAGS is setup in flags-cflags.m4.
150+
FILE_MACRO_LDFLAGS="${PATHMAP_FLAGS}"
143151
fi
144152
fi
145153
@@ -187,13 +195,15 @@ AC_DEFUN([FLAGS_SETUP_LDFLAGS_CPU_DEP],
187195
LDFLAGS_JDK_COMMON="$BASIC_LDFLAGS $BASIC_LDFLAGS_JDK_ONLY \
188196
$OS_LDFLAGS_JDK_ONLY $DEBUGLEVEL_LDFLAGS_JDK_ONLY ${$2EXTRA_LDFLAGS}"
189197
$2LDFLAGS_JDKLIB="$LDFLAGS_JDK_COMMON $BASIC_LDFLAGS_JDK_LIB_ONLY \
190-
${$1_LDFLAGS_JDK_LIBPATH} $SHARED_LIBRARY_FLAGS"
198+
${$1_LDFLAGS_JDK_LIBPATH} $SHARED_LIBRARY_FLAGS \
199+
$REPRODUCIBLE_LDFLAGS $FILE_MACRO_LDFLAGS"
191200
$2LDFLAGS_JDKEXE="$LDFLAGS_JDK_COMMON $EXECUTABLE_LDFLAGS \
192-
${$1_CPU_EXECUTABLE_LDFLAGS}"
201+
${$1_CPU_EXECUTABLE_LDFLAGS} $REPRODUCIBLE_LDFLAGS $FILE_MACRO_LDFLAGS"
193202
194203
$2JVM_LDFLAGS="$BASIC_LDFLAGS $BASIC_LDFLAGS_JVM_ONLY $OS_LDFLAGS_JVM_ONLY \
195204
$DEBUGLEVEL_LDFLAGS $DEBUGLEVEL_LDFLAGS_JVM_ONLY $BASIC_LDFLAGS_ONLYCXX \
196-
${$1_CPU_LDFLAGS} ${$1_CPU_LDFLAGS_JVM_ONLY} ${$2EXTRA_LDFLAGS}"
205+
${$1_CPU_LDFLAGS} ${$1_CPU_LDFLAGS_JVM_ONLY} ${$2EXTRA_LDFLAGS} \
206+
$REPRODUCIBLE_LDFLAGS $FILE_MACRO_LDFLAGS"
197207
198208
AC_SUBST($2LDFLAGS_JDKLIB)
199209
AC_SUBST($2LDFLAGS_JDKEXE)

test/jdk/build/AbsPathsInImage.java

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -151,11 +151,6 @@ public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IO
151151
return super.visitFile(file, attrs);
152152
} else if (fileName.endsWith(".debuginfo") || fileName.endsWith(".pdb")) {
153153
// Do nothing
154-
} else if (fileName.endsWith(".dll")) {
155-
// On Windows, the Microsoft toolchain does not provide a way
156-
// to reliably remove all absolute paths from __FILE__ usage.
157-
// Until that is fixed, we simply exclude *.dll from this
158-
// test.
159154
} else if (fileName.endsWith(".zip")) {
160155
scanZipFile(file, searchPatterns);
161156
} else {
@@ -168,14 +163,6 @@ public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IO
168163

169164
private void scanFile(Path file, List<byte[]> searchPatterns) throws IOException {
170165
List<String> matches = scanBytes(Files.readAllBytes(file), searchPatterns);
171-
// For the same reason as the *.dll above, the jdk.jpackage module
172-
// contains some unavoidable header references in the launcher which is
173-
// stored as a java resource inside the modules file.
174-
if (IS_WINDOWS && file.toString().endsWith("modules")) {
175-
matches = matches.stream()
176-
.filter(f -> !f.matches(".*jdk\\.jpackage.*\\.h.*"))
177-
.collect(Collectors.toList());
178-
}
179166
if (matches.size() > 0) {
180167
matchFound = true;
181168
System.out.println(file + ":");

0 commit comments

Comments
 (0)