[8u] PATCH: Bundle correct DLLs for later versions of VS

Ali Ince ali.ince at gmail.com
Mon Aug 26 22:34:40 UTC 2019


Hi All,

This is a third attempt of my patch, following my initial [1] "Prevent 
MSDOS8.3 named DLL in built image" and a larger one with more changes 
around getting VS2017 build warnings to a minimum [2]. The latter one 
did bring several upstream changes (with local modifications) into the 
patch which is probably not the desired approach.

Here is a downsized version of the changes, which include the following 
fixes - which are only applicable to jdk8u.

- Prevent MSDOS8.3 named DLL in built image;

vcruntime140.dll, which is part of VS2017 built images, is copied to the 
built image named as `vcrunt~1.dll` which is basically because of the 
extra call to `BASIC_FIXUP_PATH` call in `toolchain_windows.m4` file. If 
the call is removed, everything works fine. On previous versions of VS, 
the VC runtime DLL was originally named in 8.3 style (ex. msvcr100.dll) 
and BASIC_FIXUP_PATH did not have any affect on the file name itself. 
I've checked with `toolchain_windows.m4` files in jdk11u and onwards and 
also saw that this call doesn't exist.

- Copy other required MSVC DLLs, other than MSVCR_DLL into the JDK 
binary folder;

VS2010 builds of JDK only depend on msvcr100.dll, and this is place both 
under 'bin' and 'jre\bin' directories in the built image. However, 
builds with later versions of VS depend on additional redistributable 
DLLs. For VS2013, the dependent DLLs are both msvcr120.dll and 
msvcp120.dll; and for VS2017, they are vcruntime140.dll, msvcp140.dll 
and also the several api-ms-win*.dll which are usually referred as UCRT 
DLLs. It should be noted that these mentioned DLLs are already present 
in 'jre\bin' directory and it is required for them to be placed in the 
'jdk' directory as well for the executables (javac.exe, etc.) to be able 
resolve them successfully. This is similar to the requirement of 
msvcr100.dll to be placed in both directories when built with VS2010.

- Add recent MSVC versions.

I would be grateful if someone could sponsor this change for me.

Thanks.

Ali

[1] https://mail.openjdk.java.net/pipermail/jdk8u-dev/2019-March/009012.html
[2] https://mail.openjdk.java.net/pipermail/jdk8u-dev/2019-June/009668.html

PATCH:
---------------

# cd . && hg diff
diff -r 2cd484c5b7f8 common/autoconf/toolchain_windows.m4
--- a/common/autoconf/toolchain_windows.m4	Thu Aug 22 17:51:13 2019 +0100
+++ b/common/autoconf/toolchain_windows.m4	Mon Aug 26 23:00:21 2019 +0100
@@ -493,7 +493,6 @@
      if $ECHO "$MSVC_DLL_FILETYPE" | $GREP "$CORRECT_MSVCR_ARCH" 2>&1 > 
/dev/null; then
        AC_MSG_RESULT([ok])
        MSVC_DLL="$POSSIBLE_MSVC_DLL"
-      BASIC_FIXUP_PATH(MSVC_DLL)
        AC_MSG_CHECKING([for $DLL_NAME])
        AC_MSG_RESULT([$MSVC_DLL])
      else

# cd ./hotspot && hg diff
diff -r bf9503046dd4 make/windows/makefiles/compile.make
--- a/make/windows/makefiles/compile.make	Fri Dec 14 11:22:26 2018 +0100
+++ b/make/windows/makefiles/compile.make	Mon Aug 26 23:00:22 2019 +0100
@@ -159,6 +159,15 @@
  !if "$(MSC_VER)" == "1913"
  COMPILER_NAME=VS2017
  !endif
+!if "$(MSC_VER)" == "1914"
+COMPILER_NAME=VS2017
+!endif
+!if "$(MSC_VER)" == "1915"
+COMPILER_NAME=VS2017
+!endif
+!if "$(MSC_VER)" == "1916"
+COMPILER_NAME=VS2017
+!endif
  !endif

  # By default, we do not want to use the debug version of the 
msvcrt.dll file
diff -r bf9503046dd4 make/windows/makefiles/sanity.make
--- a/make/windows/makefiles/sanity.make	Fri Dec 14 11:22:26 2018 +0100
+++ b/make/windows/makefiles/sanity.make	Mon Aug 26 23:00:22 2019 +0100
@@ -31,6 +31,10 @@
  	if "$(MSC_VER)" NEQ "1800" \
  	if "$(MSC_VER)" NEQ "1900" \
  	if "$(MSC_VER)" NEQ "1912" \
+	if "$(MSC_VER)" NEQ "1913" \
+	if "$(MSC_VER)" NEQ "1914" \
+	if "$(MSC_VER)" NEQ "1915" \
+	if "$(MSC_VER)" NEQ "1916" \
  	echo *** WARNING *** unrecognized cl.exe version $(MSC_VER) 
($(RAW_MSC_VER)).  Use FORCE_MSC_VER to override automatic detection.

  checkLink:
@@ -39,4 +43,8 @@
  	if "$(LD_VER)" NEQ "1300" \
  	if "$(LD_VER)" NEQ "1400" \
  	if "$(LD_VER)" NEQ "1412" \
+	if "$(LD_VER)" NEQ "1413" \
+	if "$(LD_VER)" NEQ "1414" \
+	if "$(LD_VER)" NEQ "1415" \
+	if "$(LD_VER)" NEQ "1416" \
  	echo *** WARNING *** unrecognized link.exe version $(LD_VER) 
($(RAW_LD_VER)).  Use FORCE_LD_VER to override automatic detection.
diff -r bf9503046dd4 src/share/vm/runtime/vm_version.cpp
--- a/src/share/vm/runtime/vm_version.cpp	Fri Dec 14 11:22:26 2018 +0100
+++ b/src/share/vm/runtime/vm_version.cpp	Mon Aug 26 23:00:22 2019 +0100
@@ -231,6 +231,12 @@
          #define HOTSPOT_BUILD_COMPILER "MS VC++ 15.5 (VS2017)"
        #elif _MSC_VER == 1913
          #define HOTSPOT_BUILD_COMPILER "MS VC++ 15.6 (VS2017)"
+      #elif _MSC_VER == 1914
+        #define HOTSPOT_BUILD_COMPILER "MS VC++ 15.7 (VS2017)"
+      #elif _MSC_VER == 1915
+        #define HOTSPOT_BUILD_COMPILER "MS VC++ 15.8 (VS2017)"
+      #elif _MSC_VER == 1916
+        #define HOTSPOT_BUILD_COMPILER "MS VC++ 15.9 (VS2017)"
        #else
          #define HOTSPOT_BUILD_COMPILER "unknown MS VC++:" XSTR(_MSC_VER)
        #endif

# cd ./jdk && hg diff
diff -r 1417d2539c57 make/Images.gmk
--- a/make/Images.gmk	Fri Aug 23 20:14:36 2019 +0000
+++ b/make/Images.gmk	Mon Aug 26 23:00:23 2019 +0100
@@ -130,10 +130,22 @@
        hsdb$(EXE_SUFFIX)
  endif

+# Build a list of platform DLL's to keep in the built image folder
+# Note that JDK image built on VS2010 requires only MSVCR_DLL to be 
present, but this has
+# changed with later versions and we require more DLL's to be copied 
over JDK image bin
+# folder
+ifeq ($(OPENJDK_TARGET_OS), windows)
+    KEEP_MSVC_DLLS = $(MSVCR_DLL) $(MSVCP_DLL)
+
+    ifneq ($(UCRT_DLL_DIR), )
+       KEEP_MSVC_DLLS += $(wildcard $(UCRT_DLL_DIR)/*.dll)
+    endif
+endif
+
  WINDOWS_JDK_BIN_FILES = \
      $(EXE_SUFFIX) \
      $(LIBRARY_PREFIX)jli$(SHARED_LIBRARY_SUFFIX) \
-    $(notdir $(MSVCR_DLL))
+    $(notdir $(KEEP_MSVC_DLLS))

  WINDOWS_JDKJRE_BIN_FILES := \
      $(LIBRARY_PREFIX)attach$(SHARED_LIBRARY_SUFFIX) \
@@ -649,7 +661,7 @@

  ifneq ($(POST_STRIP_CMD), )
    ifeq ($(OPENJDK_TARGET_OS), windows)
-    EXEC_LIST_BIN := $(filter-out %$(notdir $(MSVCR_DLL)), $(filter 
%.exe %.dll, $(ALL_BIN_LIST)))
+    EXEC_LIST_BIN := $(filter-out %$(notdir $(KEEP_MSVC_DLLS)), 
$(filter %.exe %.dll, $(ALL_BIN_LIST)))
    else
      # Find all executables in JDK_OUTPUTDIR since they exist when this 
makefile is parsed
      EXEC_LIST_BIN := $(shell $(FILE) `$(FIND) $(JDK_OUTPUTDIR)/bin 
-type f -name \*$(EXE_SUFFIX) ! -name \*.debuginfo` \
# exit code 0


More information about the jdk8u-dev mailing list