From 4744d6be5ba3e445a49c2a934bce280bc57bf615 Mon Sep 17 00:00:00 2001 From: Peter Shipton Date: Thu, 8 Sep 2022 14:24:47 -0400 Subject: [PATCH] Include vcruntime140_1.dll when compiling with VS2019 Signed-off-by: Peter Shipton --- make/CreateJmods.gmk | 5 ++++ make/autoconf/basics.m4 | 4 ++- make/autoconf/spec.gmk.in | 1 + make/autoconf/toolchain_windows.m4 | 30 ++++++++++++++++++- make/copy/Copy-java.base.gmk | 9 ++++-- make/devkit/createWindowsDevkit2019.sh | 4 ++- make/lib/CoreLibraries.gmk | 3 ++ src/java.base/windows/native/libjli/java_md.c | 19 +++++++++++- 8 files changed, 69 insertions(+), 6 deletions(-) diff --git a/make/CreateJmods.gmk b/make/CreateJmods.gmk index c2a8b8b352a..de068ecf071 100644 --- a/make/CreateJmods.gmk +++ b/make/CreateJmods.gmk @@ -173,6 +173,11 @@ else # not java.base JMOD_FLAGS += --exclude '$(notdir $(MSVCR_DLL))' endif endif + ifneq ($(VCRUNTIME_1_DLL), ) + ifneq ($(wildcard $(LIBS_DIR)/$(notdir $(VCRUNTIME_1_DLL))), ) + JMOD_FLAGS += --exclude '$(notdir $(VCRUNTIME_1_DLL))' + endif + endif ifneq ($(MSVCP_DLL), ) ifneq ($(wildcard $(LIBS_DIR)/$(notdir $(MSVCP_DLL))), ) JMOD_FLAGS += --exclude '$(notdir $(MSVCP_DLL))' diff --git a/make/autoconf/basics.m4 b/make/autoconf/basics.m4 index 90df36dc94b..7f0db90f119 100644 --- a/make/autoconf/basics.m4 +++ b/make/autoconf/basics.m4 @@ -1,5 +1,5 @@ # -# Copyright (c) 2011, 2019, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2011, 2020, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -737,6 +737,8 @@ AC_DEFUN_ONCE([BASIC_SETUP_DEVKIT], BASIC_EVAL_DEVKIT_VARIABLE([DEVKIT_VS_LIB]) # Corresponds to --with-msvcr-dll BASIC_EVAL_DEVKIT_VARIABLE([DEVKIT_MSVCR_DLL]) + # Corresponds to --with-vcruntime-1-dll + BASIC_EVAL_DEVKIT_VARIABLE([DEVKIT_VCRUNTIME_1_DLL]) # Corresponds to --with-msvcp-dll BASIC_EVAL_DEVKIT_VARIABLE([DEVKIT_MSVCP_DLL]) # Corresponds to --with-ucrt-dll-dir diff --git a/make/autoconf/spec.gmk.in b/make/autoconf/spec.gmk.in index e1f2feb7273..85a9aaac55d 100644 --- a/make/autoconf/spec.gmk.in +++ b/make/autoconf/spec.gmk.in @@ -780,6 +780,7 @@ LIBZ_CFLAGS:=@LIBZ_CFLAGS@ LIBZ_LIBS:=@LIBZ_LIBS@ LIBZIP_CAN_USE_MMAP:=@LIBZIP_CAN_USE_MMAP@ MSVCR_DLL:=@MSVCR_DLL@ +VCRUNTIME_1_DLL:=@VCRUNTIME_1_DLL@ MSVCP_DLL:=@MSVCP_DLL@ UCRT_DLL_DIR:=@UCRT_DLL_DIR@ STLPORT_LIB:=@STLPORT_LIB@ diff --git a/make/autoconf/toolchain_windows.m4 b/make/autoconf/toolchain_windows.m4 index ff408c3c959..98e416f07e9 100644 --- a/make/autoconf/toolchain_windows.m4 +++ b/make/autoconf/toolchain_windows.m4 @@ -1,5 +1,5 @@ # -# Copyright (c) 2011, 2019, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2011, 2020, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -92,6 +92,7 @@ VS_TOOLSET_SUPPORTED_2017=true VS_DESCRIPTION_2019="Microsoft Visual Studio 2019" VS_VERSION_INTERNAL_2019=141 VS_MSVCR_2019=vcruntime140.dll +VS_VCRUNTIME_1_2019=vcruntime140_1.dll VS_MSVCP_2019=msvcp140.dll VS_ENVVAR_2019="VS160COMNTOOLS" VS_USE_UCRT_2019="true" @@ -306,6 +307,7 @@ AC_DEFUN([TOOLCHAIN_FIND_VISUAL_STUDIO], fi eval VS_VERSION_INTERNAL="\${VS_VERSION_INTERNAL_${VS_VERSION}}" eval MSVCR_NAME="\${VS_MSVCR_${VS_VERSION}}" + eval VCRUNTIME_1_NAME="\${VS_VCRUNTIME_1_${VS_VERSION}}" eval MSVCP_NAME="\${VS_MSVCP_${VS_VERSION}}" eval USE_UCRT="\${VS_USE_UCRT_${VS_VERSION}}" eval VS_SUPPORTED="\${VS_SUPPORTED_${VS_VERSION}}" @@ -353,6 +355,7 @@ AC_DEFUN([TOOLCHAIN_FIND_VISUAL_STUDIO], eval VS_DESCRIPTION="\${VS_DESCRIPTION_${VS_VERSION}}" eval VS_VERSION_INTERNAL="\${VS_VERSION_INTERNAL_${VS_VERSION}}" eval MSVCR_NAME="\${VS_MSVCR_${VS_VERSION}}" + eval VCRUNTIME_1_NAME="\${VS_VCRUNTIME_1_${VS_VERSION}}" eval MSVCP_NAME="\${VS_MSVCP_${VS_VERSION}}" eval USE_UCRT="\${VS_USE_UCRT_${VS_VERSION}}" eval VS_SUPPORTED="\${VS_SUPPORTED_${VS_VERSION}}" @@ -695,6 +698,31 @@ AC_DEFUN([TOOLCHAIN_SETUP_VS_RUNTIME_DLLS], AC_SUBST(MSVCP_DLL) fi + AC_ARG_WITH(vcruntime-1-dll, [AS_HELP_STRING([--with-vcruntime-1-dll], + [path to microsoft C++ runtime dll (vcruntime*_1.dll) (Windows x64 only) @<:@probed@:>@])]) + + if test "x$VCRUNTIME_1_NAME" != "x" && test "x$OPENJDK_TARGET_CPU" = xx86_64; then + if test "x$with_vcruntime_1_dll" != x; then + # If given explicitly by user, do not probe. If not present, fail directly. + TOOLCHAIN_CHECK_POSSIBLE_MSVC_DLL($VCRUNTIME_1_NAME, [$with_vcruntime_1_dll], + [--with-vcruntime-1-dll]) + if test "x$MSVC_DLL" = x; then + AC_MSG_ERROR([Could not find a proper $VCRUNTIME_1_NAME as specified by --with-vcruntime-1-dll]) + fi + VCRUNTIME_1_DLL="$MSVC_DLL" + elif test "x$DEVKIT_VCRUNTIME_1_DLL" != x; then + TOOLCHAIN_CHECK_POSSIBLE_MSVC_DLL($VCRUNTIME_1_NAME, [$DEVKIT_VCRUNTIME_1_DLL], [devkit]) + if test "x$MSVC_DLL" = x; then + AC_MSG_ERROR([Could not find a proper $VCRUNTIME_1_NAME as specified by devkit]) + fi + VCRUNTIME_1_DLL="$MSVC_DLL" + else + TOOLCHAIN_SETUP_MSVC_DLL([${VCRUNTIME_1_NAME}]) + VCRUNTIME_1_DLL="$MSVC_DLL" + fi + fi + AC_SUBST(VCRUNTIME_1_DLL) + AC_ARG_WITH(ucrt-dll-dir, [AS_HELP_STRING([--with-ucrt-dll-dir], [path to Microsoft Windows Kit UCRT DLL dir (Windows only) @<:@probed@:>@])]) diff --git a/make/copy/Copy-java.base.gmk b/make/copy/Copy-java.base.gmk index 1964932f14b..a108ffbf46a 100644 --- a/make/copy/Copy-java.base.gmk +++ b/make/copy/Copy-java.base.gmk @@ -1,5 +1,5 @@ # -# Copyright (c) 2014, 2019, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2014, 2020, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -59,12 +59,17 @@ ifeq ($(OPENJDK_TARGET_OS), windows) FILES := $(MSVCR_DLL), \ MACRO := copy-and-chmod)) + $(eval $(call SetupCopyFiles,COPY_VCRUNTIME_1, \ + DEST := $(LIB_DST_DIR), \ + FILES := $(VCRUNTIME_1_DLL), \ + MACRO := copy-and-chmod)) + $(eval $(call SetupCopyFiles,COPY_MSVCP, \ DEST := $(LIB_DST_DIR), \ FILES := $(MSVCP_DLL), \ MACRO := copy-and-chmod)) - TARGETS += $(COPY_MSVCR) $(COPY_MSVCP) + TARGETS += $(COPY_MSVCR) $(COPY_VCRUNTIME_1) $(COPY_MSVCP) ifneq ($(UCRT_DLL_DIR), ) $(eval $(call SetupCopyFiles, COPY_UCRT_DLLS, \ diff --git a/make/devkit/createWindowsDevkit2019.sh b/make/devkit/createWindowsDevkit2019.sh index ef3720648a0..25c9df0fe15 100644 --- a/make/devkit/createWindowsDevkit2019.sh +++ b/make/devkit/createWindowsDevkit2019.sh @@ -1,6 +1,6 @@ #!/bin/bash # -# Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2019, 2020, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -102,6 +102,7 @@ DEVKIT_BUNDLE="${DEVKIT_ROOT}.tar.gz" echo "Creating devkit in $DEVKIT_ROOT" MSVCR_DLL=${MSVC_DIR}/vcruntime${VS_DLL_VERSION}.dll +VCRUNTIME_1_DLL=${MSVC_DIR}/vcruntime${VS_DLL_VERSION}_1.dll MSVCP_DLL=${MSVC_DIR}/msvcp${VS_DLL_VERSION}.dll ################################################################################ @@ -188,6 +189,7 @@ echo-info "DEVKIT_TOOLCHAIN_PATH_x86_64=\"\$DEVKIT_ROOT/VC/bin/x64:\$DEVKIT_ROOT echo-info "DEVKIT_VS_INCLUDE_x86_64=\"\$DEVKIT_ROOT/VC/include;\$DEVKIT_ROOT/VC/atlmfc/include;\$DEVKIT_ROOT/$SDK_VERSION/include/shared;\$DEVKIT_ROOT/$SDK_VERSION/include/ucrt;\$DEVKIT_ROOT/$SDK_VERSION/include/um;\$DEVKIT_ROOT/$SDK_VERSION/include/winrt\"" echo-info "DEVKIT_VS_LIB_x86_64=\"\$DEVKIT_ROOT/VC/lib/x64;\$DEVKIT_ROOT/VC/atlmfc/lib/x64;\$DEVKIT_ROOT/$SDK_VERSION/lib/x64\"" echo-info "DEVKIT_MSVCR_DLL_x86_64=\"\$DEVKIT_ROOT/VC/redist/x64/$MSVCR_DLL\"" +echo-info "DEVKIT_VCRUNTIME_1_DLL_x86_64=\"\$DEVKIT_ROOT/VC/redist/x64/$VCRUNTIME_1_DLL\"" echo-info "DEVKIT_MSVCP_DLL_x86_64=\"\$DEVKIT_ROOT/VC/redist/x64/$MSVCP_DLL\"" echo-info "DEVKIT_UCRT_DLL_DIR_x86_64=\"\$DEVKIT_ROOT/10/Redist/ucrt/DLLs/x64\"" echo-info "" diff --git a/make/lib/CoreLibraries.gmk b/make/lib/CoreLibraries.gmk index b5c3d0a775e..37fed495955 100644 --- a/make/lib/CoreLibraries.gmk +++ b/make/lib/CoreLibraries.gmk @@ -212,6 +212,9 @@ ifeq ($(OPENJDK_TARGET_OS), windows) LIBJLI_OUTPUT_DIR := $(INSTALL_LIBRARIES_HERE) # Supply the name of the C runtime lib. LIBJLI_CFLAGS += -DMSVCR_DLL_NAME='"$(notdir $(MSVCR_DLL))"' + ifneq ($(VCRUNTIME_1_DLL), ) + LIBJLI_CFLAGS += -DVCRUNTIME_1_DLL_NAME='"$(notdir $(VCRUNTIME_1_DLL))"' + endif ifneq ($(MSVCP_DLL), ) LIBJLI_CFLAGS += -DMSVCP_DLL_NAME='"$(notdir $(MSVCP_DLL))"' endif diff --git a/src/java.base/windows/native/libjli/java_md.c b/src/java.base/windows/native/libjli/java_md.c index 69d09a678b7..1cba8c58ea3 100644 --- a/src/java.base/windows/native/libjli/java_md.c +++ b/src/java.base/windows/native/libjli/java_md.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -252,6 +252,23 @@ LoadMSVCRT() } } #endif /* MSVCR_DLL_NAME */ +#ifdef VCRUNTIME_1_DLL_NAME + if (GetJREPath(crtpath, MAXPATHLEN)) { + if (JLI_StrLen(crtpath) + JLI_StrLen("\\bin\\") + + JLI_StrLen(VCRUNTIME_1_DLL_NAME) >= MAXPATHLEN) { + JLI_ReportErrorMessage(JRE_ERROR11); + return JNI_FALSE; + } + (void)JLI_StrCat(crtpath, "\\bin\\" VCRUNTIME_1_DLL_NAME); /* Add crt dll */ + JLI_TraceLauncher("CRT path is %s\n", crtpath); + if (_access(crtpath, 0) == 0) { + if (LoadLibrary(crtpath) == 0) { + JLI_ReportErrorMessage(DLL_ERROR4, crtpath); + return JNI_FALSE; + } + } + } +#endif /* VCRUNTIME_1_DLL_NAME */ #ifdef MSVCP_DLL_NAME if (GetJREPath(crtpath, MAXPATHLEN)) { if (JLI_StrLen(crtpath) + JLI_StrLen("\\bin\\") +