< prev index next >

make/autoconf/toolchain_windows.m4

Print this page
8248238: Adding Windows support to OpenJDK on AArch64

Summary: Adding Windows support for AArch64

Contributed-by: Ludovic Henry <luhenry@microsoft.com>, Monica Beckwith <monica.beckwith@microsoft.com>
Reviewed-by:


 110 [
 111   if test "x$VS_ENV_CMD" = x; then
 112     VS_VERSION="$1"
 113     VS_BASE="$2"
 114     METHOD="$3"
 115 
 116     UTIL_REWRITE_AS_UNIX_PATH(VS_BASE)
 117     # In VS 2017 and VS 2019, the default installation is in a subdir named after the edition.
 118     # Find the first one present and use that.
 119     if test "x$VS_EDITIONS" != x; then
 120       for edition in $VS_EDITIONS; do
 121         if test -d "$VS_BASE/$edition"; then
 122           VS_BASE="$VS_BASE/$edition"
 123           break
 124         fi
 125       done
 126     fi
 127 
 128     if test -d "$VS_BASE"; then
 129       AC_MSG_NOTICE([Found Visual Studio installation at $VS_BASE using $METHOD])
 130       if test "x$OPENJDK_TARGET_CPU_BITS" = x32; then
 131         VCVARSFILES="vc/bin/vcvars32.bat vc/auxiliary/build/vcvars32.bat"
 132       else
 133         VCVARSFILES="vc/bin/amd64/vcvars64.bat vc/bin/x86_amd64/vcvarsx86_amd64.bat \
 134             VC/Auxiliary/Build/vcvarsx86_amd64.bat VC/Auxiliary/Build/vcvars64.bat"




 135       fi
 136 
 137       for VCVARSFILE in $VCVARSFILES; do
 138         if test -f "$VS_BASE/$VCVARSFILE"; then
 139           VS_ENV_CMD="$VS_BASE/$VCVARSFILE"
 140           break
 141         fi
 142       done
 143 
 144       if test "x$VS_ENV_CMD" = x; then
 145         AC_MSG_NOTICE([Warning: None of $VCVARSFILES were found, Visual Studio installation not recognized. Ignoring])
 146       else
 147         # PLATFORM_TOOLSET is used during the compilation of the freetype sources
 148         # (see 'LIB_BUILD_FREETYPE' in libraries.m4) and must be one of 'v100',
 149         # 'v110' or 'v120' for VS 2010, 2012 or VS2013
 150         eval PLATFORM_TOOLSET="\${VS_VS_PLATFORM_NAME_${VS_VERSION}}"
 151       fi
 152     fi
 153   fi
 154 ])
 155 
 156 ################################################################################
 157 
 158 AC_DEFUN([TOOLCHAIN_CHECK_POSSIBLE_WIN_SDK_ROOT],
 159 [
 160   if test "x$VS_ENV_CMD" = x; then
 161     VS_VERSION="$1"
 162     WIN_SDK_BASE="$2"
 163     METHOD="$3"
 164     UTIL_REWRITE_AS_UNIX_PATH(WIN_SDK_BASE)
 165     if test -d "$WIN_SDK_BASE"; then
 166       # There have been cases of partial or broken SDK installations. A missing
 167       # lib dir is not going to work.
 168       if test ! -d "$WIN_SDK_BASE/lib"; then
 169         AC_MSG_NOTICE([Found Windows SDK installation at $WIN_SDK_BASE using $METHOD])
 170         AC_MSG_NOTICE([Warning: Installation is broken, lib dir is missing. Ignoring])
 171       elif test -f "$WIN_SDK_BASE/Bin/SetEnv.Cmd"; then
 172         AC_MSG_NOTICE([Found Windows SDK installation at $WIN_SDK_BASE using $METHOD])
 173         VS_ENV_CMD="$WIN_SDK_BASE/Bin/SetEnv.Cmd"
 174         if test "x$OPENJDK_TARGET_CPU_BITS" = x32; then
 175           VS_ENV_ARGS="/x86"
 176         else
 177           VS_ENV_ARGS="/x64"


 178         fi
 179         # PLATFORM_TOOLSET is used during the compilation of the freetype sources (see
 180         # 'LIB_BUILD_FREETYPE' in libraries.m4) and must be 'Windows7.1SDK' for Windows7.1SDK
 181         # TODO: improve detection for other versions of SDK
 182         eval PLATFORM_TOOLSET="\${VS_SDK_PLATFORM_NAME_${VS_VERSION}}"
 183       else
 184         AC_MSG_NOTICE([Found Windows SDK installation at $WIN_SDK_BASE using $METHOD])
 185         AC_MSG_NOTICE([Warning: Installation is broken, SetEnv.Cmd is missing. Ignoring])
 186       fi
 187     fi
 188   fi
 189 ])
 190 
 191 ################################################################################
 192 # Finds the bat or cmd file in Visual Studio or the SDK that sets up a proper
 193 # build environment and assigns it to VS_ENV_CMD
 194 AC_DEFUN([TOOLCHAIN_FIND_VISUAL_STUDIO_BAT_FILE],
 195 [
 196   # VS2017 provides the option to install previous minor versions of the MSVC
 197   # toolsets. It is not possible to directly download earlier minor versions of


 551     else
 552       AC_MSG_RESULT([ok])
 553       # Remove any trailing "\" ";" and " " from the variables.
 554       VS_INCLUDE=`$ECHO "$VS_INCLUDE" | $SED -e 's/\\\\*;* *$//'`
 555       VS_LIB=`$ECHO "$VS_LIB" | $SED 's/\\\\*;* *$//'`
 556       VCINSTALLDIR=`$ECHO "$VCINSTALLDIR" | $SED 's/\\\\* *$//'`
 557       VCToolsRedistDir=`$ECHO "$VCToolsRedistDir" | $SED 's/\\\\* *$//'`
 558       WindowsSdkDir=`$ECHO "$WindowsSdkDir" | $SED 's/\\\\* *$//'`
 559       WINDOWSSDKDIR=`$ECHO "$WINDOWSSDKDIR" | $SED 's/\\\\* *$//'`
 560       if test -z "$WINDOWSSDKDIR"; then
 561         WINDOWSSDKDIR="$WindowsSdkDir"
 562       fi
 563       # Remove any paths containing # (typically F#) as that messes up make. This
 564       # is needed if visual studio was installed with F# support.
 565       VS_PATH=`$ECHO "$VS_PATH" | $SED 's/[[^:#]]*#[^:]*://g'`
 566 
 567       AC_SUBST(VS_PATH)
 568       AC_SUBST(VS_INCLUDE)
 569       AC_SUBST(VS_LIB)
 570 
 571       # Convert VS_INCLUDE into SYSROOT_CFLAGS
 572       OLDIFS="$IFS"
 573       IFS=";"
 574       for i in $VS_INCLUDE; do
 575         ipath=$i
 576         # Only process non-empty elements
 577         if test "x$ipath" != x; then
 578           IFS="$OLDIFS"
 579           # Check that directory exists before calling fixup_path
 580           testpath=$ipath
 581           UTIL_REWRITE_AS_UNIX_PATH([testpath])
 582           if test -d "$testpath"; then
 583             UTIL_FIXUP_PATH([ipath])
 584             SYSROOT_CFLAGS="$SYSROOT_CFLAGS -I$ipath"
 585           fi
 586           IFS=";"
 587         fi
 588       done
 589       # Convert VS_LIB into SYSROOT_LDFLAGS
 590       for i in $VS_LIB; do
 591         libpath=$i
 592         # Only process non-empty elements
 593         if test "x$libpath" != x; then
 594           IFS="$OLDIFS"
 595           # Check that directory exists before calling fixup_path
 596           testpath=$libpath
 597           UTIL_REWRITE_AS_UNIX_PATH([testpath])
 598           if test -d "$testpath"; then
 599             UTIL_FIXUP_PATH([libpath])
 600             SYSROOT_LDFLAGS="$SYSROOT_LDFLAGS -libpath:$libpath"
 601           fi
 602           IFS=";"
 603         fi
 604       done
 605       IFS="$OLDIFS"
 606 
 607       AC_SUBST(VS_PATH_WINDOWS)
 608     fi
 609   else
 610     AC_MSG_RESULT([not found])
 611 
 612     if test "x$VS_ENV_CMD" = x; then
 613       AC_MSG_NOTICE([Cannot locate a valid Visual Studio or Windows SDK installation on disk,])
 614       AC_MSG_NOTICE([nor is this script run from a Visual Studio command prompt.])
 615     else
 616       AC_MSG_NOTICE([Running the extraction script failed.])
 617     fi
 618     AC_MSG_NOTICE([Try setting --with-tools-dir to the VC/bin directory within the VS installation])
 619     AC_MSG_NOTICE([or run "bash.exe -l" from a VS command prompt and then run configure from there.])
 620     AC_MSG_ERROR([Cannot continue])
 621   fi
 622 ])
 623 
 624 AC_DEFUN([TOOLCHAIN_CHECK_POSSIBLE_MSVC_DLL],
 625 [
 626   DLL_NAME="$1"
 627   POSSIBLE_MSVC_DLL="$2"
 628   METHOD="$3"
 629   if test -n "$POSSIBLE_MSVC_DLL" -a -e "$POSSIBLE_MSVC_DLL"; then
 630     AC_MSG_NOTICE([Found $DLL_NAME at $POSSIBLE_MSVC_DLL using $METHOD])
 631 
 632     # Need to check if the found msvcr is correct architecture
 633     AC_MSG_CHECKING([found $DLL_NAME architecture])
 634     MSVC_DLL_FILETYPE=`$FILE -b "$POSSIBLE_MSVC_DLL"`
 635     if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then
 636       # The MSYS 'file' command returns "PE32 executable for MS Windows (DLL) (GUI) Intel 80386 32-bit"
 637       # on x32 and "PE32+ executable for MS Windows (DLL) (GUI) Mono/.Net assembly" on x64 systems.
 638       if test "x$OPENJDK_TARGET_CPU_BITS" = x32; then
 639         CORRECT_MSVCR_ARCH="PE32 executable"
 640       else
 641         CORRECT_MSVCR_ARCH="PE32+ executable"
 642       fi
 643     else
 644       if test "x$OPENJDK_TARGET_CPU_BITS" = x32; then
 645         CORRECT_MSVCR_ARCH=386
 646       else
 647         CORRECT_MSVCR_ARCH=x86-64






 648       fi
 649     fi
 650     if $ECHO "$MSVC_DLL_FILETYPE" | $GREP "$CORRECT_MSVCR_ARCH" 2>&1 > /dev/null; then
 651       AC_MSG_RESULT([ok])
 652       MSVC_DLL="$POSSIBLE_MSVC_DLL"
 653       AC_MSG_CHECKING([for $DLL_NAME])
 654       AC_MSG_RESULT([$MSVC_DLL])
 655     else
 656       AC_MSG_RESULT([incorrect, ignoring])
 657       AC_MSG_NOTICE([The file type of the located $DLL_NAME is $MSVC_DLL_FILETYPE])
 658     fi
 659   fi
 660 ])
 661 
 662 AC_DEFUN([TOOLCHAIN_SETUP_MSVC_DLL],
 663 [
 664   DLL_NAME="$1"
 665   MSVC_DLL=
 666 
 667   if test "x$MSVC_DLL" = x; then
 668     if test "x$VCINSTALLDIR" != x; then
 669       CYGWIN_VC_INSTALL_DIR="$VCINSTALLDIR"
 670       UTIL_FIXUP_PATH(CYGWIN_VC_INSTALL_DIR)
 671       if test "$VS_VERSION" -lt 2017; then
 672         # Probe: Using well-known location from Visual Studio 12.0 and older
 673         if test "x$OPENJDK_TARGET_CPU_BITS" = x64; then


 674           POSSIBLE_MSVC_DLL="$CYGWIN_VC_INSTALL_DIR/redist/x64/Microsoft.VC${VS_VERSION_INTERNAL}.CRT/$DLL_NAME"
 675         else
 676           POSSIBLE_MSVC_DLL="$CYGWIN_VC_INSTALL_DIR/redist/x86/Microsoft.VC${VS_VERSION_INTERNAL}.CRT/$DLL_NAME"
 677         fi
 678       else
 679         CYGWIN_VC_TOOLS_REDIST_DIR="$VCToolsRedistDir"
 680         UTIL_FIXUP_PATH(CYGWIN_VC_TOOLS_REDIST_DIR)
 681         # Probe: Using well-known location from VS 2017 and VS 2019
 682         if test "x$OPENJDK_TARGET_CPU_BITS" = x64; then


 683           POSSIBLE_MSVC_DLL="`ls $CYGWIN_VC_TOOLS_REDIST_DIR/x64/Microsoft.VC${VS_VERSION_INTERNAL}.CRT/$DLL_NAME`"
 684         else
 685           POSSIBLE_MSVC_DLL="`ls $CYGWIN_VC_TOOLS_REDIST_DIR/x86/Microsoft.VC${VS_VERSION_INTERNAL}.CRT/$DLL_NAME`"
 686         fi
 687       fi
 688       # In case any of the above finds more than one file, loop over them.
 689       for possible_msvc_dll in $POSSIBLE_MSVC_DLL; do
 690         $ECHO "POSSIBLE_MSVC_DLL $possible_msvc_dll"
 691         TOOLCHAIN_CHECK_POSSIBLE_MSVC_DLL([$DLL_NAME], [$possible_msvc_dll],
 692             [well-known location in VCINSTALLDIR])
 693       done
 694     fi
 695   fi
 696 
 697   if test "x$MSVC_DLL" = x; then
 698     # Probe: Check in the Boot JDK directory.
 699     POSSIBLE_MSVC_DLL="$BOOT_JDK/bin/$DLL_NAME"
 700     TOOLCHAIN_CHECK_POSSIBLE_MSVC_DLL([$DLL_NAME], [$POSSIBLE_MSVC_DLL],
 701         [well-known location in Boot JDK])
 702   fi
 703 
 704   if test "x$MSVC_DLL" = x; then
 705     # Probe: Look in the Windows system32 directory
 706     CYGWIN_SYSTEMROOT="$SYSTEMROOT"
 707     UTIL_REWRITE_AS_UNIX_PATH(CYGWIN_SYSTEMROOT)
 708     POSSIBLE_MSVC_DLL="$CYGWIN_SYSTEMROOT/system32/$DLL_NAME"
 709     TOOLCHAIN_CHECK_POSSIBLE_MSVC_DLL([$DLL_NAME], [$POSSIBLE_MSVC_DLL],
 710         [well-known location in SYSTEMROOT])
 711   fi
 712 
 713   if test "x$MSVC_DLL" = x; then
 714     # Probe: If Visual Studio Express is installed, there is usually one with the debugger
 715     if test "x$VS100COMNTOOLS" != x; then
 716       CYGWIN_VS_TOOLS_DIR="$VS100COMNTOOLS/.."
 717       UTIL_REWRITE_AS_UNIX_PATH(CYGWIN_VS_TOOLS_DIR)
 718       if test "x$OPENJDK_TARGET_CPU_BITS" = x64; then



 719         POSSIBLE_MSVC_DLL=`$FIND "$CYGWIN_VS_TOOLS_DIR" -name $DLL_NAME \
 720         | $GREP -i /x64/ | $HEAD --lines 1`
 721       else
 722         POSSIBLE_MSVC_DLL=`$FIND "$CYGWIN_VS_TOOLS_DIR" -name $DLL_NAME \
 723         | $GREP -i /x86/ | $HEAD --lines 1`
 724       fi
 725       TOOLCHAIN_CHECK_POSSIBLE_MSVC_DLL([$DLL_NAME], [$POSSIBLE_MSVC_DLL],
 726           [search of VS100COMNTOOLS])
 727     fi
 728   fi
 729 
 730   if test "x$MSVC_DLL" = x; then
 731     # Probe: Search wildly in the VCINSTALLDIR. We've probably lost by now.
 732     # (This was the original behaviour; kept since it might turn something up)
 733     if test "x$CYGWIN_VC_INSTALL_DIR" != x; then
 734       if test "x$OPENJDK_TARGET_CPU_BITS" = x64; then



 735         POSSIBLE_MSVC_DLL=`$FIND "$CYGWIN_VC_INSTALL_DIR" -name $DLL_NAME \
 736         | $GREP x64 | $HEAD --lines 1`
 737       else
 738         POSSIBLE_MSVC_DLL=`$FIND "$CYGWIN_VC_INSTALL_DIR" -name $DLL_NAME \
 739         | $GREP x86 | $GREP -v ia64 | $GREP -v x64 | $HEAD --lines 1`
 740         if test "x$POSSIBLE_MSVC_DLL" = x; then
 741           # We're grasping at straws now...
 742           POSSIBLE_MSVC_DLL=`$FIND "$CYGWIN_VC_INSTALL_DIR" -name $DLL_NAME \
 743           | $HEAD --lines 1`
 744         fi
 745       fi
 746 
 747       TOOLCHAIN_CHECK_POSSIBLE_MSVC_DLL([$DLL_NAME], [$POSSIBLE_MSVC_DLL],
 748           [search of VCINSTALLDIR])
 749     fi
 750   fi
 751 
 752   if test "x$MSVC_DLL" = x; then
 753     AC_MSG_CHECKING([for $DLL_NAME])
 754     AC_MSG_RESULT([no])
 755     AC_MSG_ERROR([Could not find $DLL_NAME. Please specify using --with-msvcr-dll.])
 756   fi
 757 ])
 758 
 759 AC_DEFUN([TOOLCHAIN_SETUP_VS_RUNTIME_DLLS],


 832   AC_ARG_WITH(ucrt-dll-dir, [AS_HELP_STRING([--with-ucrt-dll-dir],
 833       [path to Microsoft Windows Kit UCRT DLL dir (Windows only) @<:@probed@:>@])])
 834 
 835   if test "x$USE_UCRT" = "xtrue"; then
 836     AC_MSG_CHECKING([for UCRT DLL dir])
 837     if test "x$with_ucrt_dll_dir" != x; then
 838       if test -z "$(ls -d "$with_ucrt_dll_dir/"*.dll 2> /dev/null)"; then
 839         AC_MSG_RESULT([no])
 840         AC_MSG_ERROR([Could not find any dlls in $with_ucrt_dll_dir])
 841       else
 842         AC_MSG_RESULT([$with_ucrt_dll_dir])
 843         UCRT_DLL_DIR="$with_ucrt_dll_dir"
 844         UTIL_FIXUP_PATH([UCRT_DLL_DIR])
 845       fi
 846     elif test "x$DEVKIT_UCRT_DLL_DIR" != "x"; then
 847       UCRT_DLL_DIR="$DEVKIT_UCRT_DLL_DIR"
 848       AC_MSG_RESULT($UCRT_DLL_DIR)
 849     else
 850       CYGWIN_WINDOWSSDKDIR="${WINDOWSSDKDIR}"
 851       UTIL_FIXUP_PATH([CYGWIN_WINDOWSSDKDIR])
 852       dll_subdir=$OPENJDK_TARGET_CPU
 853       if test "x$dll_subdir" = "xx86_64"; then

 854         dll_subdir="x64"


 855       fi
 856       UCRT_DLL_DIR="$CYGWIN_WINDOWSSDKDIR/Redist/ucrt/DLLs/$dll_subdir"
 857       if test -z "$(ls -d "$UCRT_DLL_DIR/"*.dll 2> /dev/null)"; then
 858         # Try with version subdir
 859         UCRT_DLL_DIR="`ls -d $CYGWIN_WINDOWSSDKDIR/Redist/*/ucrt/DLLs/$dll_subdir \
 860             2> /dev/null | $SORT -d | $HEAD -n1`"
 861         if test -z "$UCRT_DLL_DIR" \
 862             || test -z "$(ls -d "$UCRT_DLL_DIR/"*.dll 2> /dev/null)"; then
 863           AC_MSG_RESULT([no])
 864           AC_MSG_ERROR([Could not find any dlls in $UCRT_DLL_DIR])
 865         else
 866           AC_MSG_RESULT($UCRT_DLL_DIR)
 867         fi
 868       else
 869         AC_MSG_RESULT($UCRT_DLL_DIR)
 870       fi
 871     fi
 872   else
 873     UCRT_DLL_DIR=
 874   fi
 875   AC_SUBST(UCRT_DLL_DIR)














































 876 ])


 110 [
 111   if test "x$VS_ENV_CMD" = x; then
 112     VS_VERSION="$1"
 113     VS_BASE="$2"
 114     METHOD="$3"
 115 
 116     UTIL_REWRITE_AS_UNIX_PATH(VS_BASE)
 117     # In VS 2017 and VS 2019, the default installation is in a subdir named after the edition.
 118     # Find the first one present and use that.
 119     if test "x$VS_EDITIONS" != x; then
 120       for edition in $VS_EDITIONS; do
 121         if test -d "$VS_BASE/$edition"; then
 122           VS_BASE="$VS_BASE/$edition"
 123           break
 124         fi
 125       done
 126     fi
 127 
 128     if test -d "$VS_BASE"; then
 129       AC_MSG_NOTICE([Found Visual Studio installation at $VS_BASE using $METHOD])
 130       if test "x$OPENJDK_TARGET_CPU" = xx86; then
 131         VCVARSFILES="vc/bin/vcvars32.bat vc/auxiliary/build/vcvars32.bat"
 132       elif test "x$OPENJDK_TARGET_CPU" = xx86_64; then
 133         VCVARSFILES="vc/bin/amd64/vcvars64.bat vc/bin/x86_amd64/vcvarsx86_amd64.bat \
 134             VC/Auxiliary/Build/vcvarsx86_amd64.bat VC/Auxiliary/Build/vcvars64.bat"
 135       elif test "x$OPENJDK_TARGET_CPU" = xaarch64; then
 136         # for host x86-64, target aarch64
 137         VCVARSFILES="vc/auxiliary/build/vcvarsamd64_arm64.bat \
 138             vc/auxiliary/build/vcvarsx86_arm64.bat"
 139       fi
 140 
 141       for VCVARSFILE in $VCVARSFILES; do
 142         if test -f "$VS_BASE/$VCVARSFILE"; then
 143           VS_ENV_CMD="$VS_BASE/$VCVARSFILE"
 144           break
 145         fi
 146       done
 147 
 148       if test "x$VS_ENV_CMD" = x; then
 149         AC_MSG_NOTICE([Warning: None of $VCVARSFILES were found, Visual Studio installation not recognized. Ignoring])
 150       else
 151         # PLATFORM_TOOLSET is used during the compilation of the freetype sources
 152         # (see 'LIB_BUILD_FREETYPE' in libraries.m4) and must be one of 'v100',
 153         # 'v110' or 'v120' for VS 2010, 2012 or VS2013
 154         eval PLATFORM_TOOLSET="\${VS_VS_PLATFORM_NAME_${VS_VERSION}}"
 155       fi
 156     fi
 157   fi
 158 ])
 159 
 160 ################################################################################
 161 
 162 AC_DEFUN([TOOLCHAIN_CHECK_POSSIBLE_WIN_SDK_ROOT],
 163 [
 164   if test "x$VS_ENV_CMD" = x; then
 165     VS_VERSION="$1"
 166     WIN_SDK_BASE="$2"
 167     METHOD="$3"
 168     UTIL_REWRITE_AS_UNIX_PATH(WIN_SDK_BASE)
 169     if test -d "$WIN_SDK_BASE"; then
 170       # There have been cases of partial or broken SDK installations. A missing
 171       # lib dir is not going to work.
 172       if test ! -d "$WIN_SDK_BASE/lib"; then
 173         AC_MSG_NOTICE([Found Windows SDK installation at $WIN_SDK_BASE using $METHOD])
 174         AC_MSG_NOTICE([Warning: Installation is broken, lib dir is missing. Ignoring])
 175       elif test -f "$WIN_SDK_BASE/Bin/SetEnv.Cmd"; then
 176         AC_MSG_NOTICE([Found Windows SDK installation at $WIN_SDK_BASE using $METHOD])
 177         VS_ENV_CMD="$WIN_SDK_BASE/Bin/SetEnv.Cmd"
 178         if test "x$OPENJDK_TARGET_CPU" = xx86; then
 179           VS_ENV_ARGS="/x86"
 180         elif test "x$OPENJDK_TARGET_CPU" = xx86_64; then
 181           VS_ENV_ARGS="/x64"
 182         elif test "x$OPENJDK_TARGET_CPU" = xaarch64; then
 183           VS_ENV_ARGS="/arm64"
 184         fi
 185         # PLATFORM_TOOLSET is used during the compilation of the freetype sources (see
 186         # 'LIB_BUILD_FREETYPE' in libraries.m4) and must be 'Windows7.1SDK' for Windows7.1SDK
 187         # TODO: improve detection for other versions of SDK
 188         eval PLATFORM_TOOLSET="\${VS_SDK_PLATFORM_NAME_${VS_VERSION}}"
 189       else
 190         AC_MSG_NOTICE([Found Windows SDK installation at $WIN_SDK_BASE using $METHOD])
 191         AC_MSG_NOTICE([Warning: Installation is broken, SetEnv.Cmd is missing. Ignoring])
 192       fi
 193     fi
 194   fi
 195 ])
 196 
 197 ################################################################################
 198 # Finds the bat or cmd file in Visual Studio or the SDK that sets up a proper
 199 # build environment and assigns it to VS_ENV_CMD
 200 AC_DEFUN([TOOLCHAIN_FIND_VISUAL_STUDIO_BAT_FILE],
 201 [
 202   # VS2017 provides the option to install previous minor versions of the MSVC
 203   # toolsets. It is not possible to directly download earlier minor versions of


 557     else
 558       AC_MSG_RESULT([ok])
 559       # Remove any trailing "\" ";" and " " from the variables.
 560       VS_INCLUDE=`$ECHO "$VS_INCLUDE" | $SED -e 's/\\\\*;* *$//'`
 561       VS_LIB=`$ECHO "$VS_LIB" | $SED 's/\\\\*;* *$//'`
 562       VCINSTALLDIR=`$ECHO "$VCINSTALLDIR" | $SED 's/\\\\* *$//'`
 563       VCToolsRedistDir=`$ECHO "$VCToolsRedistDir" | $SED 's/\\\\* *$//'`
 564       WindowsSdkDir=`$ECHO "$WindowsSdkDir" | $SED 's/\\\\* *$//'`
 565       WINDOWSSDKDIR=`$ECHO "$WINDOWSSDKDIR" | $SED 's/\\\\* *$//'`
 566       if test -z "$WINDOWSSDKDIR"; then
 567         WINDOWSSDKDIR="$WindowsSdkDir"
 568       fi
 569       # Remove any paths containing # (typically F#) as that messes up make. This
 570       # is needed if visual studio was installed with F# support.
 571       VS_PATH=`$ECHO "$VS_PATH" | $SED 's/[[^:#]]*#[^:]*://g'`
 572 
 573       AC_SUBST(VS_PATH)
 574       AC_SUBST(VS_INCLUDE)
 575       AC_SUBST(VS_LIB)
 576 
 577       TOOLCHAIN_SETUP_VISUAL_STUDIO_SYSROOT_FLAGS


































 578 
 579       AC_SUBST(VS_PATH_WINDOWS)
 580     fi
 581   else
 582     AC_MSG_RESULT([not found])
 583 
 584     if test "x$VS_ENV_CMD" = x; then
 585       AC_MSG_NOTICE([Cannot locate a valid Visual Studio or Windows SDK installation on disk,])
 586       AC_MSG_NOTICE([nor is this script run from a Visual Studio command prompt.])
 587     else
 588       AC_MSG_NOTICE([Running the extraction script failed.])
 589     fi
 590     AC_MSG_NOTICE([Try setting --with-tools-dir to the VC/bin directory within the VS installation])
 591     AC_MSG_NOTICE([or run "bash.exe -l" from a VS command prompt and then run configure from there.])
 592     AC_MSG_ERROR([Cannot continue])
 593   fi
 594 ])
 595 
 596 AC_DEFUN([TOOLCHAIN_CHECK_POSSIBLE_MSVC_DLL],
 597 [
 598   DLL_NAME="$1"
 599   POSSIBLE_MSVC_DLL="$2"
 600   METHOD="$3"
 601   if test -n "$POSSIBLE_MSVC_DLL" -a -e "$POSSIBLE_MSVC_DLL"; then
 602     AC_MSG_NOTICE([Found $DLL_NAME at $POSSIBLE_MSVC_DLL using $METHOD])
 603 
 604     # Need to check if the found msvcr is correct architecture
 605     AC_MSG_CHECKING([found $DLL_NAME architecture])
 606     MSVC_DLL_FILETYPE=`$FILE -b "$POSSIBLE_MSVC_DLL"`
 607     if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then
 608       # The MSYS 'file' command returns "PE32 executable for MS Windows (DLL) (GUI) Intel 80386 32-bit"
 609       # on x32 and "PE32+ executable for MS Windows (DLL) (GUI) Mono/.Net assembly" on x64 systems.
 610       if test "x$OPENJDK_TARGET_CPU_BITS" = x32; then
 611         CORRECT_MSVCR_ARCH="PE32 executable"
 612       else
 613         CORRECT_MSVCR_ARCH="PE32+ executable"
 614       fi
 615     else
 616       if test "x$OPENJDK_TARGET_CPU" = xx86; then
 617         CORRECT_MSVCR_ARCH=386
 618       elif test "x$OPENJDK_TARGET_CPU" = xx86_64; then
 619         CORRECT_MSVCR_ARCH=x86-64
 620       elif test "x$OPENJDK_TARGET_CPU" = xaarch64; then
 621         # The cygwin 'file' command only returns "PE32+ executable (DLL) (console), for MS Windows",
 622         # without specifying which architecture it is for specifically.
 623         # This has been fixed upstream for file(1) [1], and thus this will might break in the future.
 624         # [1] https://github.com/file/file/commit/b849b1af098ddd530094bf779b58431395db2e10#diff-ff2eced09e6860de75057dd731d092aeR142
 625         CORRECT_MSVCR_ARCH="PE32+ executable"
 626       fi
 627     fi
 628     if $ECHO "$MSVC_DLL_FILETYPE" | $GREP "$CORRECT_MSVCR_ARCH" 2>&1 > /dev/null; then
 629       AC_MSG_RESULT([ok])
 630       MSVC_DLL="$POSSIBLE_MSVC_DLL"
 631       AC_MSG_CHECKING([for $DLL_NAME])
 632       AC_MSG_RESULT([$MSVC_DLL])
 633     else
 634       AC_MSG_RESULT([incorrect, ignoring])
 635       AC_MSG_NOTICE([The file type of the located $DLL_NAME is $MSVC_DLL_FILETYPE])
 636     fi
 637   fi
 638 ])
 639 
 640 AC_DEFUN([TOOLCHAIN_SETUP_MSVC_DLL],
 641 [
 642   DLL_NAME="$1"
 643   MSVC_DLL=
 644 
 645   if test "x$MSVC_DLL" = x; then
 646     if test "x$VCINSTALLDIR" != x; then
 647       CYGWIN_VC_INSTALL_DIR="$VCINSTALLDIR"
 648       UTIL_FIXUP_PATH(CYGWIN_VC_INSTALL_DIR)
 649       if test "$VS_VERSION" -lt 2017; then
 650         # Probe: Using well-known location from Visual Studio 12.0 and older
 651         if test "x$OPENJDK_TARGET_CPU" = xaarch64; then
 652           POSSIBLE_MSVC_DLL="$CYGWIN_VC_INSTALL_DIR/redist/arm64/Microsoft.VC${VS_VERSION_INTERNAL}.CRT/$DLL_NAME"
 653         elif test "x$OPENJDK_TARGET_CPU" = xx86_64; then
 654           POSSIBLE_MSVC_DLL="$CYGWIN_VC_INSTALL_DIR/redist/x64/Microsoft.VC${VS_VERSION_INTERNAL}.CRT/$DLL_NAME"
 655         elif test "x$OPENJDK_TARGET_CPU" = xx86; then
 656           POSSIBLE_MSVC_DLL="$CYGWIN_VC_INSTALL_DIR/redist/x86/Microsoft.VC${VS_VERSION_INTERNAL}.CRT/$DLL_NAME"
 657         fi
 658       else
 659         CYGWIN_VC_TOOLS_REDIST_DIR="$VCToolsRedistDir"
 660         UTIL_FIXUP_PATH(CYGWIN_VC_TOOLS_REDIST_DIR)
 661         # Probe: Using well-known location from VS 2017 and VS 2019
 662         if test "x$OPENJDK_TARGET_CPU" = xaarch64; then
 663           POSSIBLE_MSVC_DLL="`ls $CYGWIN_VC_TOOLS_REDIST_DIR/arm64/Microsoft.VC${VS_VERSION_INTERNAL}.CRT/$DLL_NAME`"
 664         elif test "x$OPENJDK_TARGET_CPU" = xx86_64; then
 665           POSSIBLE_MSVC_DLL="`ls $CYGWIN_VC_TOOLS_REDIST_DIR/x64/Microsoft.VC${VS_VERSION_INTERNAL}.CRT/$DLL_NAME`"
 666         elif test "x$OPENJDK_TARGET_CPU" = xx86; then
 667           POSSIBLE_MSVC_DLL="`ls $CYGWIN_VC_TOOLS_REDIST_DIR/x86/Microsoft.VC${VS_VERSION_INTERNAL}.CRT/$DLL_NAME`"
 668         fi
 669       fi
 670       # In case any of the above finds more than one file, loop over them.
 671       for possible_msvc_dll in $POSSIBLE_MSVC_DLL; do
 672         $ECHO "POSSIBLE_MSVC_DLL $possible_msvc_dll"
 673         TOOLCHAIN_CHECK_POSSIBLE_MSVC_DLL([$DLL_NAME], [$possible_msvc_dll],
 674             [well-known location in VCINSTALLDIR])
 675       done
 676     fi
 677   fi
 678 
 679   if test "x$MSVC_DLL" = x; then
 680     # Probe: Check in the Boot JDK directory.
 681     POSSIBLE_MSVC_DLL="$BOOT_JDK/bin/$DLL_NAME"
 682     TOOLCHAIN_CHECK_POSSIBLE_MSVC_DLL([$DLL_NAME], [$POSSIBLE_MSVC_DLL],
 683         [well-known location in Boot JDK])
 684   fi
 685 
 686   if test "x$MSVC_DLL" = x; then
 687     # Probe: Look in the Windows system32 directory
 688     CYGWIN_SYSTEMROOT="$SYSTEMROOT"
 689     UTIL_REWRITE_AS_UNIX_PATH(CYGWIN_SYSTEMROOT)
 690     POSSIBLE_MSVC_DLL="$CYGWIN_SYSTEMROOT/system32/$DLL_NAME"
 691     TOOLCHAIN_CHECK_POSSIBLE_MSVC_DLL([$DLL_NAME], [$POSSIBLE_MSVC_DLL],
 692         [well-known location in SYSTEMROOT])
 693   fi
 694 
 695   if test "x$MSVC_DLL" = x; then
 696     # Probe: If Visual Studio Express is installed, there is usually one with the debugger
 697     if test "x$VS100COMNTOOLS" != x; then
 698       CYGWIN_VS_TOOLS_DIR="$VS100COMNTOOLS/.."
 699       UTIL_REWRITE_AS_UNIX_PATH(CYGWIN_VS_TOOLS_DIR)
 700       if test "x$OPENJDK_TARGET_CPU" = xaarch64; then
 701         POSSIBLE_MSVC_DLL=`$FIND "$CYGWIN_VS_TOOLS_DIR" -name $DLL_NAME \
 702         | $GREP -i /arm64/ | $HEAD --lines 1`
 703       elif test "x$OPENJDK_TARGET_CPU" = xx86_64; then
 704         POSSIBLE_MSVC_DLL=`$FIND "$CYGWIN_VS_TOOLS_DIR" -name $DLL_NAME \
 705         | $GREP -i /x64/ | $HEAD --lines 1`
 706       elif test "x$OPENJDK_TARGET_CPU" = xx86; then
 707         POSSIBLE_MSVC_DLL=`$FIND "$CYGWIN_VS_TOOLS_DIR" -name $DLL_NAME \
 708         | $GREP -i /x86/ | $HEAD --lines 1`
 709       fi
 710       TOOLCHAIN_CHECK_POSSIBLE_MSVC_DLL([$DLL_NAME], [$POSSIBLE_MSVC_DLL],
 711           [search of VS100COMNTOOLS])
 712     fi
 713   fi
 714 
 715   if test "x$MSVC_DLL" = x; then
 716     # Probe: Search wildly in the VCINSTALLDIR. We've probably lost by now.
 717     # (This was the original behaviour; kept since it might turn something up)
 718     if test "x$CYGWIN_VC_INSTALL_DIR" != x; then
 719       if test "x$OPENJDK_TARGET_CPU" = xaarch64; then
 720         POSSIBLE_MSVC_DLL=`$FIND "$CYGWIN_VC_INSTALL_DIR" -name $DLL_NAME \
 721         | $GREP arm64 | $HEAD --lines 1`
 722       elif test "x$OPENJDK_TARGET_CPU" = xx86_64; then
 723         POSSIBLE_MSVC_DLL=`$FIND "$CYGWIN_VC_INSTALL_DIR" -name $DLL_NAME \
 724         | $GREP x64 | $HEAD --lines 1`
 725       elif test "x$OPENJDK_TARGET_CPU" = xx86; then
 726         POSSIBLE_MSVC_DLL=`$FIND "$CYGWIN_VC_INSTALL_DIR" -name $DLL_NAME \
 727         | $GREP x86 | $GREP -v ia64 | $GREP -v x64 | $GREP -v arm64 | $HEAD --lines 1`
 728         if test "x$POSSIBLE_MSVC_DLL" = x; then
 729           # We're grasping at straws now...
 730           POSSIBLE_MSVC_DLL=`$FIND "$CYGWIN_VC_INSTALL_DIR" -name $DLL_NAME \
 731           | $HEAD --lines 1`
 732         fi
 733       fi
 734 
 735       TOOLCHAIN_CHECK_POSSIBLE_MSVC_DLL([$DLL_NAME], [$POSSIBLE_MSVC_DLL],
 736           [search of VCINSTALLDIR])
 737     fi
 738   fi
 739 
 740   if test "x$MSVC_DLL" = x; then
 741     AC_MSG_CHECKING([for $DLL_NAME])
 742     AC_MSG_RESULT([no])
 743     AC_MSG_ERROR([Could not find $DLL_NAME. Please specify using --with-msvcr-dll.])
 744   fi
 745 ])
 746 
 747 AC_DEFUN([TOOLCHAIN_SETUP_VS_RUNTIME_DLLS],


 820   AC_ARG_WITH(ucrt-dll-dir, [AS_HELP_STRING([--with-ucrt-dll-dir],
 821       [path to Microsoft Windows Kit UCRT DLL dir (Windows only) @<:@probed@:>@])])
 822 
 823   if test "x$USE_UCRT" = "xtrue"; then
 824     AC_MSG_CHECKING([for UCRT DLL dir])
 825     if test "x$with_ucrt_dll_dir" != x; then
 826       if test -z "$(ls -d "$with_ucrt_dll_dir/"*.dll 2> /dev/null)"; then
 827         AC_MSG_RESULT([no])
 828         AC_MSG_ERROR([Could not find any dlls in $with_ucrt_dll_dir])
 829       else
 830         AC_MSG_RESULT([$with_ucrt_dll_dir])
 831         UCRT_DLL_DIR="$with_ucrt_dll_dir"
 832         UTIL_FIXUP_PATH([UCRT_DLL_DIR])
 833       fi
 834     elif test "x$DEVKIT_UCRT_DLL_DIR" != "x"; then
 835       UCRT_DLL_DIR="$DEVKIT_UCRT_DLL_DIR"
 836       AC_MSG_RESULT($UCRT_DLL_DIR)
 837     else
 838       CYGWIN_WINDOWSSDKDIR="${WINDOWSSDKDIR}"
 839       UTIL_FIXUP_PATH([CYGWIN_WINDOWSSDKDIR])
 840       if test "x$OPENJDK_TARGET_CPU" = "xaarch64"; then
 841         dll_subdir="arm64"
 842       elif test "x$OPENJDK_TARGET_CPU" = "xx86_64"; then
 843         dll_subdir="x64"
 844       elif test "x$OPENJDK_TARGET_CPU" = "xx86"; then
 845         dll_subdir="x86"
 846       fi
 847       UCRT_DLL_DIR="$CYGWIN_WINDOWSSDKDIR/Redist/ucrt/DLLs/$dll_subdir"
 848       if test -z "$(ls -d "$UCRT_DLL_DIR/"*.dll 2> /dev/null)"; then
 849         # Try with version subdir
 850         UCRT_DLL_DIR="`ls -d $CYGWIN_WINDOWSSDKDIR/Redist/*/ucrt/DLLs/$dll_subdir \
 851             2> /dev/null | $SORT -d | $HEAD -n1`"
 852         if test -z "$UCRT_DLL_DIR" \
 853             || test -z "$(ls -d "$UCRT_DLL_DIR/"*.dll 2> /dev/null)"; then
 854           AC_MSG_RESULT([no])
 855           AC_MSG_ERROR([Could not find any dlls in $UCRT_DLL_DIR])
 856         else
 857           AC_MSG_RESULT($UCRT_DLL_DIR)
 858         fi
 859       else
 860         AC_MSG_RESULT($UCRT_DLL_DIR)
 861       fi
 862     fi
 863   else
 864     UCRT_DLL_DIR=
 865   fi
 866   AC_SUBST(UCRT_DLL_DIR)
 867 ])
 868 
 869 # Setup the sysroot flags and add them to global CFLAGS and LDFLAGS so
 870 # that configure can use them while detecting compilers.
 871 # TOOLCHAIN_TYPE is available here.
 872 # Param 1 - Optional prefix to all variables. (e.g BUILD_)
 873 AC_DEFUN([TOOLCHAIN_SETUP_VISUAL_STUDIO_SYSROOT_FLAGS],
 874 [
 875   OLDIFS="$IFS"
 876   IFS=";"
 877   # Convert $1VS_INCLUDE into $1SYSROOT_CFLAGS
 878   for i in [$]$1VS_INCLUDE; do
 879     ipath=$i
 880     # Only process non-empty elements
 881     if test "x$ipath" != x; then
 882       IFS="$OLDIFS"
 883       # Check that directory exists before calling fixup_path
 884       testpath=$ipath
 885       UTIL_REWRITE_AS_UNIX_PATH([testpath])
 886       if test -d "$testpath"; then
 887         UTIL_FIXUP_PATH([ipath])
 888         $1SYSROOT_CFLAGS="[$]$1SYSROOT_CFLAGS -I$ipath"
 889       fi
 890       IFS=";"
 891     fi
 892   done
 893   # Convert $1VS_LIB into $1SYSROOT_LDFLAGS
 894   for i in [$]$1VS_LIB; do
 895     libpath=$i
 896     # Only process non-empty elements
 897     if test "x$libpath" != x; then
 898       IFS="$OLDIFS"
 899       # Check that directory exists before calling fixup_path
 900       testpath=$libpath
 901       UTIL_REWRITE_AS_UNIX_PATH([testpath])
 902       if test -d "$testpath"; then
 903         UTIL_FIXUP_PATH([libpath])
 904         $1SYSROOT_LDFLAGS="[$]$1SYSROOT_LDFLAGS -libpath:$libpath"
 905       fi
 906       IFS=";"
 907     fi
 908   done
 909   IFS="$OLDIFS"
 910 
 911   AC_SUBST($1SYSROOT_CFLAGS)
 912   AC_SUBST($1SYSROOT_LDFLAGS)
 913 ])
< prev index next >