--- old/make/Images.gmk 2018-12-13 10:21:44.638690900 -0800 +++ new/make/Images.gmk 2018-12-13 10:21:43.966861800 -0800 @@ -99,7 +99,7 @@ ) ifeq ($(BUILD_CDS_ARCHIVE), true) $(call LogWarn, Creating CDS archive for jdk image) - $(JDK_IMAGE_DIR)/bin/java -Xshare:dump -Xmx128M -Xms128M $(LOG_INFO) + $(JDK_IMAGE_DIR)/bin/java$(EXE_SUFFIX) -Xshare:dump -Xmx128M -Xms128M $(LOG_INFO) endif $(TOUCH) $@ @@ -114,7 +114,7 @@ ) ifeq ($(BUILD_CDS_ARCHIVE), true) $(call LogWarn, Creating CDS archive for jre image) - $(JRE_IMAGE_DIR)/bin/java -Xshare:dump -Xmx128M -Xms128M $(LOG_INFO) + $(JRE_IMAGE_DIR)/bin/java$(EXE_SUFFIX) -Xshare:dump -Xmx128M -Xms128M $(LOG_INFO) endif $(TOUCH) $@ --- old/make/autoconf/basics.m4 2018-12-13 10:21:47.404575400 -0800 +++ new/make/autoconf/basics.m4 2018-12-13 10:21:46.733887900 -0800 @@ -223,6 +223,8 @@ BASIC_FIXUP_PATH_CYGWIN($1) elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then BASIC_FIXUP_PATH_MSYS($1) + elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.wsl"; then + BASIC_FIXUP_PATH_WSL($1) else # We're on a unix platform. Hooray! :) path="[$]$1" @@ -270,6 +272,8 @@ BASIC_FIXUP_EXECUTABLE_CYGWIN($1) elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then BASIC_FIXUP_EXECUTABLE_MSYS($1) + elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.wsl"; then + BASIC_FIXUP_EXECUTABLE_WSL($1) else # We're on a unix platform. Hooray! :) # First separate the path from the arguments. This will split at the first @@ -607,10 +611,13 @@ # These are not required on all platforms BASIC_PATH_PROGS(CYGPATH, cygpath) + BASIC_PATH_PROGS(WSLPATH, wslpath) BASIC_PATH_PROGS(DF, df) BASIC_PATH_PROGS(CPIO, [cpio bsdcpio]) BASIC_PATH_PROGS(NICE, nice) BASIC_PATH_PROGS(PANDOC, pandoc) + + BASIC_PATH_PROGS(CMD, [cmd.exe /mnt/c/Windows/System32/cmd.exe]) ]) ############################################################################### @@ -634,8 +641,10 @@ BASIC_CHECK_PATHS_WINDOWS else PATH_SEP=":" + EXECUTABLE_SUFFIX="" fi AC_SUBST(PATH_SEP) + AC_SUBST(EXECUTABLE_SUFFIX) # We get the top-level directory from the supporting wrappers. AC_MSG_CHECKING([for top-level directory]) @@ -980,6 +989,8 @@ MAKE_EXPECTED_ENV='cygwin' elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then MAKE_EXPECTED_ENV='msys' + elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.wsl"; then + MAKE_EXPECTED_ENV='x86_64-pc-linux-gnu' else AC_MSG_ERROR([Unknown Windows environment]) fi --- old/make/autoconf/basics_windows.m4 2018-12-13 10:21:49.811231600 -0800 +++ new/make/autoconf/basics_windows.m4 2018-12-13 10:21:49.279999700 -0800 @@ -32,6 +32,13 @@ elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then unix_path=`$ECHO "$windows_path" | $SED -e 's,^\\(.\\):,/\\1,g' -e 's,\\\\,/,g'` $1="$unix_path" + elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.wsl"; then + # wslpath does not check the input, only call if an actual windows path was + # given. + if $ECHO "$windows_path" | $GREP -q ["^[a-zA-Z]:[\\\\/]"]; then + unix_path=`$WSLPATH -u "$windows_path"` + $1="$unix_path" + fi fi ]) @@ -44,6 +51,9 @@ elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then windows_path=`cmd //c echo $unix_path` $1="$windows_path" + elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.wsl"; then + windows_path=`$WSLPATH -m "$unix_path"` + $1="$windows_path" fi ]) @@ -100,6 +110,31 @@ fi ]) +# Helper function which possibly converts a path using DOS-style short mode. +# If so, the updated path is stored in $new_path. +# $1: The path to check +AC_DEFUN([BASIC_MAKE_WINDOWS_SPACE_SAFE_WSL], +[ + input_path="$1" + # Check if we need to convert this using DOS-style short mode. If the path + # contains just simple characters, use it. Otherwise (spaces, weird characters), + # take no chances and rewrite it. + # Note: m4 eats our [], so we need to use @<:@ and @:>@ instead. + has_forbidden_chars=`$ECHO "$input_path" | $GREP [[^-_/:a-zA-Z0-9\\.]]` + if test "x$has_forbidden_chars" != x; then + # Now convert it to mixed DOS-style, short mode (no spaces, and / instead of \) + TOPDIR_windows="$TOPDIR" + BASIC_WINDOWS_REWRITE_AS_WINDOWS_MIXED_PATH([TOPDIR_windows]) + # First convert to Windows path to make input valid for cmd + BASIC_WINDOWS_REWRITE_AS_WINDOWS_MIXED_PATH([input_path]) + new_path=`$CMD /c $TOPDIR_windows/make/scripts/windowsShortName.cmd "$input_path" \ + | $SED -e 's|\r||g' \ + | $TR \\\\\\\\ / | $TR 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` + # Rewrite back to unix style + BASIC_WINDOWS_REWRITE_AS_UNIX_PATH([new_path]) + fi +]) + # FIXME: The BASIC_FIXUP_*_CYGWIN/MSYS is most likely too convoluted # and could probably be heavily simplified. However, all changes in this # area tend to need lot of testing in different scenarios, and in lack of @@ -157,6 +192,23 @@ all_fixpath_prefixes=("${all_fixpath_prefixes@<:@@@:>@}" "${new_path:0:10}") ]) +AC_DEFUN([BASIC_FIXUP_PATH_WSL], +[ + # Input might be given as Windows format, start by converting to + # unix format. + new_path="[$]$1" + BASIC_WINDOWS_REWRITE_AS_UNIX_PATH([new_path]) + + # Call helper function which possibly converts this using DOS-style short mode. + # If so, the updated path is stored in $new_path. + BASIC_MAKE_WINDOWS_SPACE_SAFE_WSL([$new_path]) + + if test "x$path" != "x$new_path"; then + $1="$new_path" + AC_MSG_NOTICE([Rewriting $1 to "$new_path"]) + fi +]) + AC_DEFUN([BASIC_FIXUP_EXECUTABLE_CYGWIN], [ # First separate the path from the arguments. This will split at the first @@ -305,6 +357,79 @@ fi ]) +AC_DEFUN([BASIC_FIXUP_EXECUTABLE_WSL], +[ + # First separate the path from the arguments. This will split at the first + # space. + complete="[$]$1" + path="${complete%% *}" + tmp="$complete EOL" + arguments="${tmp#* }" + + # Input might be given as Windows format, start by converting to + # unix format. + new_path="$path" + BASIC_WINDOWS_REWRITE_AS_UNIX_PATH([new_path]) + + # Now try to locate executable using which + new_path_bak="$new_path" + new_path=`$WHICH "$new_path" 2> /dev/null` + # bat and cmd files are not considered executable in WSL + if test "x$new_path" = x \ + && test "x`$ECHO \"$path\" | $GREP -i -e \"\\.bat$\" -e \"\\.cmd$\"`" != x \ + && test "x`$LS \"$path\" 2>/dev/null`" != x; then + new_path="$new_path_back" + fi + if test "x$new_path" = x; then + # Oops. Which didn't find the executable. + # The splitting of arguments from the executable at a space might have been incorrect, + # since paths with space are more likely in Windows. Give it another try with the whole + # argument. + path="$complete" + arguments="EOL" + new_path="$path" + BASIC_WINDOWS_REWRITE_AS_UNIX_PATH([new_path]) + new_path_bak="$new_path" + new_path=`$WHICH "$new_path" 2> /dev/null` + # bat and cmd files are not considered executable in WSL + if test "x$new_path" = x \ + && test "x`$ECHO \"$path\" | $GREP -i -e \"\\.bat$\" -e \"\\.cmd$\"`" != x \ + && test "x`$LS \"$path\" 2>/dev/null`" != x; then + new_path="$new_path_bak" + fi + if test "x$new_path" = x; then + # It's still not found. Now this is an unrecoverable error. + AC_MSG_NOTICE([The path of $1, which resolves as "$complete", is not found.]) + has_space=`$ECHO "$complete" | $GREP " "` + if test "x$has_space" != x; then + AC_MSG_NOTICE([You might be mixing spaces in the path and extra arguments, which is not allowed.]) + fi + AC_MSG_ERROR([Cannot locate the the path of $1]) + fi + fi + + # In WSL, suffixes must be present for Windows executables + if test ! -f "$new_path"; then + # Try adding .exe or .cmd + if test -f "${new_path}.exe"; then + input_to_shortpath="${new_path}.exe" + elif test -f "${new_path}.cmd"; then + input_to_shortpath="${new_path}.cmd" + else + AC_MSG_NOTICE([The path of $1, which resolves as "$new_path", is invalid.]) + AC_MSG_NOTICE([Neither "$new_path" nor "$new_path.exe/cmd" can be found]) + AC_MSG_ERROR([Cannot locate the the path of $1]) + fi + else + input_to_shortpath="$new_path" + fi + + # Call helper function which possibly converts this using DOS-style short mode. + # If so, the updated path is stored in $new_path. + new_path="$input_to_shortpath" + BASIC_MAKE_WINDOWS_SPACE_SAFE_WSL([$input_to_shortpath]) +]) + # Setup basic configuration paths, and platform-specific stuff related to PATHs. AC_DEFUN([BASIC_CHECK_PATHS_WINDOWS], [ @@ -339,6 +464,7 @@ if test "x$test_cygdrive_prefix" = x; then AC_MSG_ERROR([Your cygdrive prefix is not /cygdrive. This is currently not supported. Change with mount -c.]) fi + EXECUTABLE_SUFFIX="" elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then AC_MSG_CHECKING([msys release]) MSYS_VERSION=`$UNAME -r` @@ -353,8 +479,11 @@ BASIC_WINDOWS_REWRITE_AS_UNIX_PATH(MSYS_ROOT_PATH) AC_MSG_RESULT([$MSYS_ROOT_PATH]) WINDOWS_ENV_ROOT_PATH="$MSYS_ROOT_PATH" + EXECUTABLE_SUFFIX="" + elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.wsl"; then + EXECUTABLE_SUFFIX=".exe" else - AC_MSG_ERROR([Unknown Windows environment. Neither cygwin nor msys was detected.]) + AC_MSG_ERROR([Unknown Windows environment. Neither cygwin, msys, nor wsl was detected.]) fi # Test if windows or unix (cygwin/msys) find is first in path. @@ -395,6 +524,8 @@ | tr ' ' '\n' | $GREP '^/./' | $SORT | $UNIQ` fixpath_argument_list=`echo $all_unique_prefixes | tr ' ' '@'` FIXPATH="$FIXPATH_BIN -m$fixpath_argument_list" + elif test "x$OPENJDK_BUILD_OS_ENV" = xwindows.wsl; then + FIXPATH="$FIXPATH_BIN -w" fi FIXPATH_SRC_W="$FIXPATH_SRC" FIXPATH_BIN_W="$FIXPATH_BIN" --- old/make/autoconf/boot-jdk.m4 2018-12-13 10:21:52.311784600 -0800 +++ new/make/autoconf/boot-jdk.m4 2018-12-13 10:21:51.796187500 -0800 @@ -63,18 +63,18 @@ # If previous step claimed to have found a JDK, check it to see if it seems to be valid. if test "x$BOOT_JDK_FOUND" = xmaybe; then # Do we have a bin/java? - if test ! -x "$BOOT_JDK/bin/java"; then + if test ! -x "$BOOT_JDK/bin/java$EXECUTABLE_SUFFIX"; then AC_MSG_NOTICE([Potential Boot JDK found at $BOOT_JDK did not contain bin/java; ignoring]) BOOT_JDK_FOUND=no else # Do we have a bin/javac? - if test ! -x "$BOOT_JDK/bin/javac"; then + if test ! -x "$BOOT_JDK/bin/javac$EXECUTABLE_SUFFIX"; then AC_MSG_NOTICE([Potential Boot JDK found at $BOOT_JDK did not contain bin/javac; ignoring]) AC_MSG_NOTICE([(This might be an JRE instead of an JDK)]) BOOT_JDK_FOUND=no else # Oh, this is looking good! We probably have found a proper JDK. Is it the correct version? - BOOT_JDK_VERSION=`"$BOOT_JDK/bin/java" $USER_BOOT_JDK_OPTIONS -version 2>&1 | $HEAD -n 1` + BOOT_JDK_VERSION=`"$BOOT_JDK/bin/java$EXECUTABLE_SUFFIX" $USER_BOOT_JDK_OPTIONS -version 2>&1 | $HEAD -n 1` if [ [[ "$BOOT_JDK_VERSION" =~ "Picked up" ]] ]; then AC_MSG_NOTICE([You have _JAVA_OPTIONS or JAVA_TOOL_OPTIONS set. This can mess up the build. Please use --with-boot-jdk-jvmargs instead.]) AC_MSG_NOTICE([Java reports: "$BOOT_JDK_VERSION".]) @@ -101,7 +101,7 @@ AC_MSG_CHECKING([for Boot JDK]) AC_MSG_RESULT([$BOOT_JDK]) AC_MSG_CHECKING([Boot JDK version]) - BOOT_JDK_VERSION=`"$BOOT_JDK/bin/java" $USER_BOOT_JDK_OPTIONS -version 2>&1 | $TR '\n\r' ' '` + BOOT_JDK_VERSION=`"$BOOT_JDK/bin/java$EXECUTABLE_SUFFIX" $USER_BOOT_JDK_OPTIONS -version 2>&1 | $TR '\n\r' ' '` AC_MSG_RESULT([$BOOT_JDK_VERSION]) fi # end check jdk version fi # end check javac @@ -335,11 +335,11 @@ AC_SUBST(BOOT_JDK) # Setup tools from the Boot JDK. - BOOTJDK_CHECK_TOOL_IN_BOOTJDK(JAVA, java) - BOOTJDK_CHECK_TOOL_IN_BOOTJDK(JAVAC, javac) - BOOTJDK_CHECK_TOOL_IN_BOOTJDK(JAVADOC, javadoc) - BOOTJDK_CHECK_TOOL_IN_BOOTJDK(JAR, jar) - BOOTJDK_CHECK_TOOL_IN_BOOTJDK(JARSIGNER, jarsigner) + BOOTJDK_CHECK_TOOL_IN_BOOTJDK(JAVA, java$EXECUTABLE_SUFFIX) + BOOTJDK_CHECK_TOOL_IN_BOOTJDK(JAVAC, javac$EXECUTABLE_SUFFIX) + BOOTJDK_CHECK_TOOL_IN_BOOTJDK(JAVADOC, javadoc$EXECUTABLE_SUFFIX) + BOOTJDK_CHECK_TOOL_IN_BOOTJDK(JAR, jar$EXECUTABLE_SUFFIX) + BOOTJDK_CHECK_TOOL_IN_BOOTJDK(JARSIGNER, jarsigner$EXECUTABLE_SUFFIX) # Finally, set some other options... --- old/make/autoconf/build-aux/config.guess 2018-12-13 10:21:54.810607600 -0800 +++ new/make/autoconf/build-aux/config.guess 2018-12-13 10:21:54.310644400 -0800 @@ -60,6 +60,15 @@ esac fi +# Test and fix wsl +echo $OUT | grep x86_64-unknown-linux-gnu > /dev/null 2> /dev/null +if test $? = 0; then + uname -r | grep Microsoft > /dev/null 2> /dev/null + if test $? = 0; then + OUT="x86_64-pc-wsl" + fi +fi + # Test and fix architecture string on AIX # On AIX 'config.guess' returns 'powerpc' as architecture but 'powerpc' is # implicitely handled as 32-bit architecture in 'platform.m4' so we check --- old/make/autoconf/build-aux/config.sub 2018-12-13 10:21:57.108085500 -0800 +++ new/make/autoconf/build-aux/config.sub 2018-12-13 10:21:56.561383000 -0800 @@ -29,7 +29,13 @@ DIR=`dirname $0` -# First, filter out everything that doesn't begin with "aarch64-" +# Allow wsl +if echo $* | grep x86_64-pc-wsl >/dev/null ; then + echo $* + exit +fi + +# Filter out everything that doesn't begin with "aarch64-" if ! echo $* | grep '^aarch64-' >/dev/null ; then . $DIR/autoconf-config.sub "$@" # autoconf-config.sub exits, so we never reach here, but just in --- old/make/autoconf/platform.m4 2018-12-13 10:21:59.404850900 -0800 +++ new/make/autoconf/platform.m4 2018-12-13 10:21:58.826765900 -0800 @@ -188,6 +188,10 @@ VAR_OS=windows VAR_OS_ENV=windows.cygwin ;; + *wsl*) + VAR_OS=windows + VAR_OS_ENV=windows.wsl + ;; *mingw*) VAR_OS=windows VAR_OS_ENV=windows.msys --- old/make/autoconf/spec.gmk.in 2018-12-13 10:22:01.498329400 -0800 +++ new/make/autoconf/spec.gmk.in 2018-12-13 10:22:00.935863400 -0800 @@ -122,7 +122,12 @@ ifeq ($(OPENJDK_TARGET_OS), windows) # On Windows, the Visual Studio toolchain needs the PATH to be adjusted # to include Visual Studio tools (this needs to be in cygwin/msys style). - export PATH:=@VS_PATH@ + ifeq ($(OPENJDK_TARGET_OS_ENV), windows.wsl) + export PATH:=$(ORIGINAL_PATH):@VS_PATH@ + export WSLENV:=$(WSLENV):PATH/l + else + export PATH:=@VS_PATH@ + endif endif SYSROOT_CFLAGS := @SYSROOT_CFLAGS@ --- old/make/autoconf/toolchain.m4 2018-12-13 10:22:03.857418300 -0800 +++ new/make/autoconf/toolchain.m4 2018-12-13 10:22:03.294901000 -0800 @@ -281,13 +281,13 @@ TOOLCHAIN_CC_BINARY_clang="clang" TOOLCHAIN_CC_BINARY_gcc="gcc" - TOOLCHAIN_CC_BINARY_microsoft="cl" + TOOLCHAIN_CC_BINARY_microsoft="cl$EXECUTABLE_SUFFIX" TOOLCHAIN_CC_BINARY_solstudio="cc" TOOLCHAIN_CC_BINARY_xlc="xlc_r" TOOLCHAIN_CXX_BINARY_clang="clang++" TOOLCHAIN_CXX_BINARY_gcc="g++" - TOOLCHAIN_CXX_BINARY_microsoft="cl" + TOOLCHAIN_CXX_BINARY_microsoft="cl$EXECUTABLE_SUFFIX" TOOLCHAIN_CXX_BINARY_solstudio="CC" TOOLCHAIN_CXX_BINARY_xlc="xlC_r" @@ -333,9 +333,17 @@ if test "x$OPENJDK_BUILD_OS" = "xwindows" \ && test "x$TOOLCHAIN_TYPE" = "xmicrosoft"; then TOOLCHAIN_SETUP_VISUAL_STUDIO_ENV - # Reset path to VS_PATH. It will include everything that was on PATH at the time we - # ran TOOLCHAIN_SETUP_VISUAL_STUDIO_ENV. - PATH="$VS_PATH" + if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.wsl"; then + # Append VS_PATH + BASIC_APPEND_TO_PATH(PATH, $VS_PATH) + BASIC_APPEND_TO_PATH(WSLENV, "PATH/l:LIB:INCLUDE") + export WSLENV + else + # Reset path to VS_PATH. It will include everything that was on PATH at the time we + # ran TOOLCHAIN_SETUP_VISUAL_STUDIO_ENV. + BASIC_APPEND_TO_PATH(PATH, $VS_PATH) + AC_MSG_NOTICE(PATH $PATH) + fi # The microsoft toolchain also requires INCLUDE and LIB to be set. export INCLUDE="$VS_INCLUDE" export LIB="$VS_LIB" @@ -430,7 +438,7 @@ # There is no specific version flag, but all output starts with a version string. # First line typically looks something like: # Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 16.00.40219.01 for 80x86 - COMPILER_VERSION_OUTPUT=`$COMPILER 2>&1 | $HEAD -n 1 | $TR -d '\r'` + COMPILER_VERSION_OUTPUT=`"$COMPILER" 2>&1 | $HEAD -n 1 | $TR -d '\r'` # Check that this is likely to be Microsoft CL.EXE. $ECHO "$COMPILER_VERSION_OUTPUT" | $GREP "Microsoft.*Compiler" > /dev/null if test $? -ne 0; then @@ -698,7 +706,7 @@ # In the Microsoft toolchain we have a separate LD command "link". # Make sure we reject /usr/bin/link (as determined in CYGWIN_LINK), which is # a cygwin program for something completely different. - AC_CHECK_PROG([LD], [link],[link],,, [$CYGWIN_LINK]) + AC_CHECK_PROG([LD], [link.exe],[link.exe],,, [$CYGWIN_LINK]) BASIC_FIXUP_EXECUTABLE(LD) # Verify that we indeed succeeded with this trick. AC_MSG_CHECKING([if the found link.exe is actually the Visual Studio linker]) @@ -750,7 +758,7 @@ # if test "x$TOOLCHAIN_TYPE" = xmicrosoft; then # The corresponding ar tool is lib.exe (used to create static libraries) - AC_CHECK_PROG([AR], [lib],[lib],,,) + AC_CHECK_PROG([AR], [lib.exe],[lib.exe],,,) elif test "x$TOOLCHAIN_TYPE" = xgcc; then BASIC_CHECK_TOOLS(AR, ar gcc-ar) else @@ -774,12 +782,12 @@ fi if test "x$TOOLCHAIN_TYPE" = xmicrosoft; then - AC_CHECK_PROG([MT], [mt], [mt],,, [/usr/bin/mt]) + AC_CHECK_PROG([MT], [mt.exe], [mt.exe],,, [/usr/bin/mt]) BASIC_FIXUP_EXECUTABLE(MT) # Setup the resource compiler (RC) - AC_CHECK_PROG([RC], [rc], [rc],,, [/usr/bin/rc]) + AC_CHECK_PROG([RC], [rc.exe], [rc.exe],,, [/usr/bin/rc]) BASIC_FIXUP_EXECUTABLE(RC) - AC_CHECK_PROG([DUMPBIN], [dumpbin], [dumpbin],,,) + AC_CHECK_PROG([DUMPBIN], [dumpbin.exe], [dumpbin.exe],,,) BASIC_FIXUP_EXECUTABLE(DUMPBIN) # We need to check for 'msbuild.exe' because at the place where we expect to # find 'msbuild.exe' there's also a directory called 'msbuild' and configure --- old/make/autoconf/toolchain_windows.m4 2018-12-13 10:22:06.201523000 -0800 +++ new/make/autoconf/toolchain_windows.m4 2018-12-13 10:22:05.654896600 -0800 @@ -115,7 +115,7 @@ VCVARSFILES="vc/bin/vcvars32.bat vc/auxiliary/build/vcvars32.bat" else VCVARSFILES="vc/bin/amd64/vcvars64.bat vc/bin/x86_amd64/vcvarsx86_amd64.bat \ - vc/auxiliary/build/vcvarsx86_amd64.bat vc/auxiliary/build/vcvars64.bat" + VC/Auxiliary/Build/vcvarsx86_amd64.bat VC/Auxiliary/Build/vcvars64.bat" fi for VCVARSFILE in $VCVARSFILES; do @@ -222,7 +222,6 @@ [C:/Program Files/$VS_INSTALL_DIR], [well-known name]) TOOLCHAIN_CHECK_POSSIBLE_VISUAL_STUDIO_ROOT([${VS_VERSION}], [C:/Program Files (x86)/$VS_INSTALL_DIR], [well-known name]) - if test "x$SDK_INSTALL_DIR" != x; then if test "x$ProgramW6432" != x; then TOOLCHAIN_CHECK_POSSIBLE_WIN_SDK_ROOT([${VS_VERSION}], @@ -339,7 +338,7 @@ [ # Store path to cygwin link.exe to help excluding it when searching for # VS linker. This must be done before changing the PATH when looking for VS. - AC_PATH_PROG(CYGWIN_LINK, link) + AC_PATH_PROG(CYGWIN_LINK, link.exe) if test "x$CYGWIN_LINK" != x; then AC_MSG_CHECKING([if the first found link.exe is actually the Cygwin link tool]) "$CYGWIN_LINK" --version > /dev/null @@ -372,8 +371,13 @@ # Instead create a shell script which will set the relevant variables when run. WINPATH_VS_ENV_CMD="$VS_ENV_CMD" BASIC_WINDOWS_REWRITE_AS_WINDOWS_MIXED_PATH([WINPATH_VS_ENV_CMD]) - WINPATH_BASH="$BASH" - BASIC_WINDOWS_REWRITE_AS_WINDOWS_MIXED_PATH([WINPATH_BASH]) + + if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.wsl"; then + WINPATH_BASH="bash" + else + WINPATH_BASH="$BASH" + BASIC_WINDOWS_REWRITE_AS_WINDOWS_MIXED_PATH([WINPATH_BASH]) + fi # Generate a DOS batch file which runs $VS_ENV_CMD, and then creates a shell # script (executable by bash) that will setup the important variables. @@ -381,7 +385,7 @@ $ECHO "@echo off" > $EXTRACT_VC_ENV_BAT_FILE # This will end up something like: # call C:/progra~2/micros~2.0/vc/bin/amd64/vcvars64.bat - $ECHO "call $WINPATH_VS_ENV_CMD $VS_ENV_ARGS" >> $EXTRACT_VC_ENV_BAT_FILE + $ECHO "call \"$WINPATH_VS_ENV_CMD\" $VS_ENV_ARGS" >> $EXTRACT_VC_ENV_BAT_FILE # In some cases, the VS_ENV_CMD will change directory, change back so # the set-vs-env.sh ends up in the right place. $ECHO 'cd %~dp0' >> $EXTRACT_VC_ENV_BAT_FILE @@ -389,33 +393,38 @@ # C:/CygWin/bin/bash -c 'echo VS_PATH=\"$PATH\" > localdevenv.sh # The trailing space for everyone except PATH is no typo, but is needed due # to trailing \ in the Windows paths. These will be stripped later. - $ECHO "$WINPATH_BASH -c 'echo VS_PATH="'\"$PATH\" > set-vs-env.sh' \ + # Trying pure CMD extract. This results in windows paths that need to + # be converted post extraction, but a simpler script. + $ECHO 'echo VS_PATH="%PATH%" > set-vs-env.sh' \ >> $EXTRACT_VC_ENV_BAT_FILE - $ECHO "$WINPATH_BASH -c 'echo VS_INCLUDE="'\"$INCLUDE\;$include \" >> set-vs-env.sh' \ + $ECHO 'echo VS_INCLUDE="%INCLUDE% " >> set-vs-env.sh' \ >> $EXTRACT_VC_ENV_BAT_FILE - $ECHO "$WINPATH_BASH -c 'echo VS_LIB="'\"$LIB\;$lib \" >> set-vs-env.sh' \ + $ECHO 'echo VS_LIB="%LIB% " >> set-vs-env.sh' \ >> $EXTRACT_VC_ENV_BAT_FILE - $ECHO "$WINPATH_BASH -c 'echo VCINSTALLDIR="'\"$VCINSTALLDIR \" >> set-vs-env.sh' \ + $ECHO 'echo VCINSTALLDIR="%VCINSTALLDIR% " >> set-vs-env.sh' \ >> $EXTRACT_VC_ENV_BAT_FILE - $ECHO "$WINPATH_BASH -c 'echo WindowsSdkDir="'\"$WindowsSdkDir \" >> set-vs-env.sh' \ + $ECHO 'echo WindowsSdkDir="%WindowsSdkDir% " >> set-vs-env.sh' \ >> $EXTRACT_VC_ENV_BAT_FILE - $ECHO "$WINPATH_BASH -c 'echo WINDOWSSDKDIR="'\"$WINDOWSSDKDIR \" >> set-vs-env.sh' \ + $ECHO 'echo WINDOWSSDKDIR="%WINDOWSSDKDIR% " >> set-vs-env.sh' \ >> $EXTRACT_VC_ENV_BAT_FILE # Now execute the newly created bat file. # The | cat is to stop SetEnv.Cmd to mess with system colors on msys. # Change directory so we don't need to mess with Windows paths in redirects. cd $VS_ENV_TMP_DIR - cmd /c extract-vs-env.bat | $CAT + $CMD /c extract-vs-env.bat | $CAT cd $CURDIR if test ! -s $VS_ENV_TMP_DIR/set-vs-env.sh; then - AC_MSG_NOTICE([Could not succesfully extract the envionment variables needed for the VS setup.]) + AC_MSG_NOTICE([Could not succesfully extract the environment variables needed for the VS setup.]) AC_MSG_NOTICE([Try setting --with-tools-dir to the VC/bin directory within the VS installation]) AC_MSG_NOTICE([or run "bash.exe -l" from a VS command prompt and then run configure from there.]) AC_MSG_ERROR([Cannot continue]) fi + # Remove windows line endings + $SED -i -e 's|\r||g' $VS_ENV_TMP_DIR/set-vs-env.sh + # Now set all paths and other env variables. This will allow the rest of # the configure script to find and run the compiler in the proper way. AC_MSG_NOTICE([Setting extracted environment variables]) @@ -455,9 +464,27 @@ AC_SUBST(VS_INCLUDE) AC_SUBST(VS_LIB) - # Convert VS_INCLUDE into SYSROOT_CFLAGS + # Convert VS_PATH to unix style OLDIFS="$IFS" IFS=";" + VS_PATH_WINDOWS="$VS_PATH" + VS_PATH="" + for i in $VS_PATH_WINDOWS; do + path=$i + # Only process non-empty elements + if test "x$path" != x; then + IFS="$OLDIFS" + # Check that directory exists before calling fixup_path + testpath=$path + BASIC_WINDOWS_REWRITE_AS_UNIX_PATH([testpath]) + if test -d "$testpath"; then + BASIC_FIXUP_PATH([path]) + BASIC_APPEND_TO_PATH(VS_PATH, $path) + fi + IFS=";" + fi + done + # Convert VS_INCLUDE into SYSROOT_CFLAGS for i in $VS_INCLUDE; do ipath=$i # Only process non-empty elements @@ -693,7 +720,7 @@ if test "x$USE_UCRT" = "xtrue"; then AC_MSG_CHECKING([for UCRT DLL dir]) if test "x$with_ucrt_dll_dir" != x; then - if test -z "$(ls -d "$with_ucrt_dll_dir/*.dll" 2> /dev/null)"; then + if test -z "$(ls -d $with_ucrt_dll_dir/*.dll 2> /dev/null)"; then AC_MSG_RESULT([no]) AC_MSG_ERROR([Could not find any dlls in $with_ucrt_dll_dir]) else @@ -713,8 +740,16 @@ fi UCRT_DLL_DIR="$CYGWIN_WINDOWSSDKDIR/Redist/ucrt/DLLs/$dll_subdir" if test -z "$(ls -d "$UCRT_DLL_DIR/"*.dll 2> /dev/null)"; then - AC_MSG_RESULT([no]) - AC_MSG_ERROR([Could not find any dlls in $UCRT_DLL_DIR]) + # Try with version subdir + UCRT_DLL_DIR="`ls -d $CYGWIN_WINDOWSSDKDIR/Redist/*/ucrt/DLLs/$dll_subdir \ + 2> /dev/null | $SORT -d | $HEAD -n1`" + if test -z "$UCRT_DLL_DIR" \ + || test -z "$(ls -d "$UCRT_DLL_DIR/"*.dll 2> /dev/null)"; then + AC_MSG_RESULT([no]) + AC_MSG_ERROR([Could not find any dlls in $UCRT_DLL_DIR]) + else + AC_MSG_RESULT($UCRT_DLL_DIR) + fi else AC_MSG_RESULT($UCRT_DLL_DIR) fi --- old/make/gendata/Gendata-java.base.gmk 2018-12-13 10:22:08.498869100 -0800 +++ new/make/gendata/Gendata-java.base.gmk 2018-12-13 10:22:07.967657300 -0800 @@ -55,7 +55,7 @@ $(GENDATA_CURDATA): $(TOPDIR)/make/data/currency/CurrencyData.properties $(BUILD_TOOLS_JDK) $(call MakeDir, $(@D)) $(RM) $@ - $(TOOL_GENERATECURRENCYDATA) -o $@.tmp < $< + $(TOOL_GENERATECURRENCYDATA) -o $@.tmp -i $< $(MV) $@.tmp $@ $(CHMOD) 444 $@ --- old/make/gensrc/GensrcBuffer.gmk 2018-12-13 10:22:10.843853600 -0800 +++ new/make/gensrc/GensrcBuffer.gmk 2018-12-13 10:22:10.373435000 -0800 @@ -230,7 +230,8 @@ endif $$($1_DST): $$($1_DEP) $(GENSRC_BUFFER_DST)/_the.buffer.dir - $(TOOL_SPP) < $$($1_SRC) > $$($1_OUT).tmp \ + $(RM) $$($1_OUT).tmp + $(TOOL_SPP) -i$$($1_SRC) -o$$($1_OUT).tmp \ -K$$($1_type) \ -K$$($1_category) \ -K$$($1_streams) \ @@ -260,12 +261,12 @@ ifeq ($$($1_BIN), 1) $(SED) -e '/#BIN/,$$$$d' < $$($1_OUT) > $$($1_DST).tmp $(RM) $$($1_OUT) - $$($1_char_CMD) < $$($1_SRC_BIN) >> $$($1_DST).tmp - $$($1_short_CMD) < $$($1_SRC_BIN) >> $$($1_DST).tmp - $$($1_int_CMD) < $$($1_SRC_BIN) >> $$($1_DST).tmp - $$($1_long_CMD) < $$($1_SRC_BIN) >> $$($1_DST).tmp - $$($1_float_CMD) < $$($1_SRC_BIN) >> $$($1_DST).tmp - $$($1_double_CMD) < $$($1_SRC_BIN) >> $$($1_DST).tmp + $$($1_char_CMD) -i$$($1_SRC_BIN) -o$$($1_DST).tmp + $$($1_short_CMD) -i$$($1_SRC_BIN) -o$$($1_DST).tmp + $$($1_int_CMD) -i$$($1_SRC_BIN) -o$$($1_DST).tmp + $$($1_long_CMD) -i$$($1_SRC_BIN) -o$$($1_DST).tmp + $$($1_float_CMD) -i$$($1_SRC_BIN) -o$$($1_DST).tmp + $$($1_double_CMD) -i$$($1_SRC_BIN) -o$$($1_DST).tmp $(PRINTF) "}\n" >> $$($1_DST).tmp mv $$($1_DST).tmp $$($1_DST) endif --- old/make/gensrc/GensrcCharsetCoder.gmk 2018-12-13 10:22:13.108117200 -0800 +++ new/make/gensrc/GensrcCharsetCoder.gmk 2018-12-13 10:22:12.624912300 -0800 @@ -36,7 +36,7 @@ $(GENSRC_CHARSETCODER_DST)/CharsetDecoder.java: $(GENSRC_CHARSETCODER_TEMPLATE) $(call MakeTargetDir) $(RM) $@.tmp - $(TOOL_SPP) < $< >$@.tmp \ + $(TOOL_SPP) -i$< -o$@.tmp \ -Kdecoder \ -DA='A' \ -Da='a' \ @@ -71,7 +71,7 @@ $(GENSRC_CHARSETCODER_DST)/CharsetEncoder.java: $(GENSRC_CHARSETCODER_TEMPLATE) $(call MakeTargetDir) $(RM) $@.tmp - $(TOOL_SPP) < $< >$@.tmp \ + $(TOOL_SPP) -i$< -o$@.tmp \ -Kencoder \ -DA='An' \ -Da='an' \ --- old/make/gensrc/GensrcVarHandles.gmk 2018-12-13 10:22:15.232332300 -0800 +++ new/make/gensrc/GensrcVarHandles.gmk 2018-12-13 10:22:14.623320000 -0800 @@ -59,8 +59,9 @@ $$(eval $1_type := $$$$(shell $(TR) '[:upper:]' '[:lower:]' <<< $$$$($1_Type))) endif $$(call MakeDir, $$(@D)) + $(RM) $$@ $(TOOL_SPP) -nel -K$$($1_type) -Dtype=$$($1_type) -DType=$$($1_Type) \ - $$($1_ARGS) < $$< > $$@ + $$($1_ARGS) -i$$< -o$$@ GENSRC_VARHANDLES += $$($1_FILENAME) endef @@ -147,10 +148,11 @@ $$($1_FILENAME): $(VARHANDLES_SRC_DIR)/X-VarHandleByteArrayView.java.template $(BUILD_TOOLS_JDK) $$(call MakeDir, $$(@D)) + $(RM) $$@ $(TOOL_SPP) -nel -K$$($1_type) \ -Dtype=$$($1_type) -DType=$$($1_Type) -DBoxType=$$($1_BoxType) \ -DrawType=$$($1_rawType) -DRawType=$$($1_RawType) -DRawBoxType=$$($1_RawBoxType) \ - $$($1_ARGS) < $$< > $$@ + $$($1_ARGS) -i$$< -o$$@ GENSRC_VARHANDLES += $$($1_FILENAME) endef --- old/make/jdk/src/classes/build/tools/generatecurrencydata/GenerateCurrencyData.java 2018-12-13 10:22:17.264965400 -0800 +++ new/make/jdk/src/classes/build/tools/generatecurrencydata/GenerateCurrencyData.java 2018-12-13 10:22:16.717297200 -0800 @@ -28,7 +28,9 @@ import java.io.IOException; import java.io.FileNotFoundException; import java.io.DataOutputStream; +import java.io.FileInputStream; import java.io.FileOutputStream; +import java.io.InputStream; import java.text.SimpleDateFormat; import java.util.Date; import java.util.HashMap; @@ -134,19 +136,44 @@ private static String currenciesWithMinorUnitsUndefined; public static void main(String[] args) { - + InputStream in = System.in; // Look for "-o outputfilename" option - if ( args.length == 2 && args[0].equals("-o") ) { - try { - out = new DataOutputStream(new FileOutputStream(args[1])); - } catch ( FileNotFoundException e ) { - System.err.println("Error: " + e.getMessage()); - e.printStackTrace(System.err); - System.exit(1); - } - } else { - System.err.println("Error: Illegal arg count"); - System.exit(1); + for (int n = 0; n < args.length; ++n) { + if (args[n].equals("-o")) { + ++n; + if (n >= args.length) { + System.err.println("Error: Invalid argument format"); + System.exit(1); + } + try { + out = new DataOutputStream(new FileOutputStream(args[n])); + } catch ( FileNotFoundException e ) { + System.err.println("Error: " + e.getMessage()); + e.printStackTrace(System.err); + System.exit(1); + } + } else if (args[n].equals("-i")) { + ++n; + if (n >= args.length) { + System.err.println("Error: Invalid argument format"); + System.exit(1); + } + try { + in = new FileInputStream(args[n]); + } catch ( FileNotFoundException e ) { + System.err.println("Error: " + e.getMessage()); + e.printStackTrace(System.err); + System.exit(1); + } + } else { + System.err.println("Error: Invalid argument " + args[n]); + System.exit(1); + } + } + + if (out == null) { + System.err.println("Error: Invalid argument format"); + System.exit(1); } format = new SimpleDateFormat("yyyy-MM-dd-HH-mm-ss", Locale.US); @@ -154,7 +181,7 @@ format.setLenient(false); try { - readInput(); + readInput(in); buildMainAndSpecialCaseTables(); buildOtherTables(); writeOutput(); @@ -167,9 +194,9 @@ } } - private static void readInput() throws IOException { + private static void readInput(InputStream in) throws IOException { currencyData = new Properties(); - currencyData.load(System.in); + currencyData.load(in); // initialize other lookup strings formatVersion = (String) currencyData.get("formatVersion"); --- old/make/jdk/src/classes/build/tools/spp/Spp.java 2018-12-13 10:22:19.451907000 -0800 +++ new/make/jdk/src/classes/build/tools/spp/Spp.java 2018-12-13 10:22:18.873824600 -0800 @@ -25,6 +25,8 @@ package build.tools.spp; +import java.io.FileInputStream; +import java.io.FileOutputStream; import java.util.*; import java.util.regex.*; @@ -69,6 +71,8 @@ Set keys = new HashSet<>(); boolean be = false; boolean el = true; + String inputFile = null; + String outputFile = null; for (String arg:args) { if (arg.startsWith("-D")) { @@ -76,6 +80,10 @@ vars.put(arg.substring(2, i),arg.substring(i+1)); } else if (arg.startsWith("-K")) { keys.add(arg.substring(2)); + } else if (arg.startsWith("-i")) { + inputFile = arg.substring(2); + } else if (arg.startsWith("-o")) { + outputFile = arg.substring(2); } else if ("-be".equals(arg)) { be = true; } else if ("-nel".equals(arg)) { @@ -87,11 +95,11 @@ } StringBuffer out = new StringBuffer(); - new Spp().spp(new Scanner(System.in), + new Spp().spp(new Scanner(new FileInputStream(inputFile)), out, "", keys, vars, be, el, false); - System.out.print(out.toString()); + new FileOutputStream(outputFile, true).write(out.toString().getBytes()); } static final String LNSEP = System.getProperty("line.separator"); --- old/make/src/native/fixpath.c 2018-12-13 10:22:21.513789700 -0800 +++ new/make/src/native/fixpath.c 2018-12-13 10:22:20.966952000 -0800 @@ -24,6 +24,7 @@ */ #include +#include #include #include #include @@ -53,25 +54,16 @@ } /* - * Test if pos points to /cygdrive/_/ where _ can + * Test if pos points to /prefix/_/ where _ can * be any character. */ -int is_cygdrive_here(int pos, char const *in, int len) +int is_prefix_here(int pos, char const *in, int len, const char* prefix) { - // Length of /cygdrive/c/ is 12 - if (pos+12 > len) return 0; - if (in[pos+11]=='/' && - in[pos+9]=='/' && - in[pos+8]=='e' && - in[pos+7]=='v' && - in[pos+6]=='i' && - in[pos+5]=='r' && - in[pos+4]=='d' && - in[pos+3]=='g' && - in[pos+2]=='y' && - in[pos+1]=='c' && - in[pos+0]=='/') { - return 1; + // Length of c/ is 2 + int prefix_size = strlen(prefix); + if (pos+prefix_size+2 > len) return 0; + if (in[pos+prefix_size+1]=='/') { + return strncmp(in + pos, prefix, prefix_size) == 0; } return 0; } @@ -93,7 +85,7 @@ } for (i = 0, j = 0; i [--detach] /cygdrive/c/WINDOWS/notepad.exe [/cygdrive/c/x/test.txt|@/cygdrive/c/x/atfile]\n"); + debug_fixpath = (getenv("DEBUG_FIXPATH") != NULL); + + if (argc<2 || argv[1][0] != '-' || (argv[1][1] != 'c' && argv[1][1] != 'm' && argv[1][1] != 'w')) { + fprintf(stderr, "Usage: fixpath -c|m|w [--detach] /cygdrive/c/WINDOWS/notepad.exe [/cygdrive/c/x/test.txt|@/cygdrive/c/x/atfile]\n"); exit(0); } - if (getenv("DEBUG_FIXPATH") != NULL) { + if (debug_fixpath) { char const * cmdline = GetCommandLine(); fprintf(stderr, "fixpath input line >%s<\n", strstr(cmdline, argv[1])); } if (argv[1][1] == 'c' && argv[1][2] == '\0') { - if (getenv("DEBUG_FIXPATH") != NULL) { + if (debug_fixpath) { fprintf(stderr, "fixpath using cygwin mode\n"); } replace_cygdrive = replace_cygdrive_cygwin; } else if (argv[1][1] == 'm') { - if (getenv("DEBUG_FIXPATH") != NULL) { + if (debug_fixpath) { fprintf(stderr, "fixpath using msys mode, with path list: %s\n", &argv[1][2]); } setup_msys_path_list(argv[1]); replace_cygdrive = replace_cygdrive_msys; + } else if (argv[1][1] == 'w') { + if (debug_fixpath) { + fprintf(stderr, "fixpath using wsl mode, with path list: %s\n", &argv[1][2]); + } + replace_cygdrive = replace_cygdrive_wsl; } else { fprintf(stderr, "fixpath Unknown mode: %s\n", argv[1]); exit(-1); @@ -391,7 +422,7 @@ if (argv[2][0] == '-') { if (strcmp(argv[2], "--detach") == 0) { - if (getenv("DEBUG_FIXPATH") != NULL) { + if (debug_fixpath) { fprintf(stderr, "fixpath in detached mode\n"); } processFlags |= DETACHED_PROCESS; @@ -417,7 +448,7 @@ var[var_len - 1] = '\0'; strupr(var); - if (getenv("DEBUG_FIXPATH") != NULL) { + if (debug_fixpath) { fprintf(stderr, "fixpath setting var >%s< to >%s<\n", var, val); } @@ -480,12 +511,12 @@ } *current = '\0'; - if (getenv("DEBUG_FIXPATH") != NULL) { + if (debug_fixpath) { fprintf(stderr, "fixpath converted line >%s<\n", line); } if (cmd == argc) { - if (getenv("DEBUG_FIXPATH") != NULL) { + if (debug_fixpath) { fprintf(stderr, "fixpath no command provided!\n"); } exit(0); @@ -518,7 +549,7 @@ WaitForSingleObject(pi.hProcess, INFINITE); GetExitCodeProcess(pi.hProcess, &exitCode); - if (getenv("DEBUG_FIXPATH") != NULL) { + if (debug_fixpath) { for (i=0; i