changeset 59290:d6768149ecb6

8245033: Fixes for building in WSL Reviewed-by: erikj
author ihse
date Thu, 14 May 2020 18:56:30 +0200
parents defb37fc7b1a
children 1d9325b4b7e9
files make/TestImage.gmk make/autoconf/basic.m4 make/autoconf/basic_tools.m4 make/autoconf/toolchain.m4 make/autoconf/toolchain_windows.m4 make/autoconf/util.m4 make/autoconf/util_windows.m4 make/common/MakeBase.gmk make/common/NativeCompilation.gmk make/conf/jib-profiles.js
diffstat 10 files changed, 53 insertions(+), 30 deletions(-) [+]
line wrap: on
line diff
--- a/make/TestImage.gmk	Thu May 14 23:09:52 2020 +0800
+++ b/make/TestImage.gmk	Thu May 14 18:56:30 2020 +0200
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2017, 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
@@ -35,17 +35,22 @@
 
   $(FIXPATH_COPY): $(firstword $(FIXPATH))
 	$(call install-file)
+
+  FIXPATH_WORKSPACE_ROOT := $(call FixPath, $(WORKSPACE_ROOT))
+  FIXPATH_OUTPUTDIR := $(call FixPath, $(OUTPUTDIR))
+else
+  FIXPATH_WORKSPACE_ROOT := $(WORKSPACE_ROOT)
+  FIXPATH_OUTPUTDIR := $(OUTPUTDIR)
 endif
 
+
 BUILD_INFO_PROPERTIES := $(TEST_IMAGE_DIR)/build-info.properties
 
-FIXPATH_ECHO := $(FIXPATH) $(call FixPath, $(ECHO))
-
 $(BUILD_INFO_PROPERTIES):
 	$(call MakeTargetDir)
 	$(ECHO) "# Build info properties for JDK tests" > $@
-	$(FIXPATH_ECHO) "build.workspace.root=$(WORKSPACE_ROOT)" >> $@
-	$(FIXPATH_ECHO) "build.output.root=$(OUTPUTDIR)" >> $@
+	$(ECHO) "build.workspace.root=$(FIXPATH_WORKSPACE_ROOT)" >> $@
+	$(ECHO) "build.output.root=$(FIXPATH_OUTPUTDIR)" >> $@
 
 prepare-test-image: $(FIXPATH_COPY) $(BUILD_INFO_PROPERTIES)
 	$(call MakeDir, $(TEST_IMAGE_DIR))
--- a/make/autoconf/basic.m4	Thu May 14 23:09:52 2020 +0800
+++ b/make/autoconf/basic.m4	Thu May 14 18:56:30 2020 +0200
@@ -423,24 +423,16 @@
     # is the same. On older AIXes we just continue to live with a "not local build" warning.
     if test "x$OPENJDK_TARGET_OS" = xaix; then
       DF_LOCAL_ONLY_OPTION='-T local'
+    elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.wsl"; then
+      # In WSL, we can only build on a drvfs file system (that is, a mounted real Windows drive)
+      DF_LOCAL_ONLY_OPTION='-t drvfs'
     else
       DF_LOCAL_ONLY_OPTION='-l'
     fi
     if $DF $DF_LOCAL_ONLY_OPTION $1 > /dev/null 2>&1; then
       $2
     else
-      # In WSL, local Windows drives are considered remote by df, but we are
-      # required to build into a directory accessible from windows, so consider
-      # them local here.
-      if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.wsl"; then
-        if $DF $1 | $GREP -q "^[[A-Z]]:"; then
-          $2
-        else
-          $3
-        fi
-      else
-        $3
-      fi
+      $3
     fi
   fi
 ])
--- a/make/autoconf/basic_tools.m4	Thu May 14 23:09:52 2020 +0800
+++ b/make/autoconf/basic_tools.m4	Thu May 14 18:56:30 2020 +0200
@@ -97,7 +97,7 @@
   UTIL_PATH_PROGS(NICE, nice)
 
   UTIL_PATH_PROGS(LSB_RELEASE, lsb_release)
-  UTIL_PATH_PROGS(CMD, [cmd.exe /mnt/c/Windows/System32/cmd.exe])
+  UTIL_PATH_PROGS(CMD, cmd.exe, /mnt/c/Windows/System32)
 ])
 
 ###############################################################################
--- a/make/autoconf/toolchain.m4	Thu May 14 23:09:52 2020 +0800
+++ b/make/autoconf/toolchain.m4	Thu May 14 18:56:30 2020 +0200
@@ -634,7 +634,12 @@
     # There is no specific version flag, but all output starts with a version string.
     # First line typically looks something like:
     #   Microsoft (R) Incremental Linker Version 12.00.31101.0
+    # Reset PATH since it can contain a mix of WSL/linux paths and Windows paths from VS,
+    # which, in combination with WSLENV, will make the WSL layer complain
+    old_path="$PATH"
+    PATH=
     LINKER_VERSION_STRING=`$LD 2>&1 | $HEAD -n 1 | $TR -d '\r'`
+    PATH="$old_path"
     # Extract version number
     [ LINKER_VERSION_NUMBER=`$ECHO $LINKER_VERSION_STRING | \
         $SED -e 's/.* \([0-9][0-9]*\(\.[0-9][0-9]*\)*\).*/\1/'` ]
@@ -732,13 +737,23 @@
     UTIL_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])
+
+    # Reset PATH since it can contain a mix of WSL/linux paths and Windows paths from VS,
+    # which, in combination with WSLENV, will make the WSL layer complain
+    old_path="$PATH"
+    PATH=
+
     "$LD" --version > /dev/null
+
     if test $? -eq 0 ; then
       AC_MSG_RESULT([no])
       AC_MSG_ERROR([This is the Cygwin link tool. Please check your PATH and rerun configure.])
     else
       AC_MSG_RESULT([yes])
     fi
+
+    PATH="$old_path"
+
     LDCXX="$LD"
     # jaotc being a windows program expects the linker to be supplied with exe suffix.
     LD_JAOTC="$LD$EXE_SUFFIX"
--- a/make/autoconf/toolchain_windows.m4	Thu May 14 23:09:52 2020 +0800
+++ b/make/autoconf/toolchain_windows.m4	Thu May 14 18:56:30 2020 +0200
@@ -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
@@ -485,10 +485,9 @@
       fi
 
       # 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 > extract-vs-env.log 2>&1
       cd $CONFIGURE_START_DIR
 
       if test ! -s $VS_ENV_TMP_DIR/set-vs-env.sh; then
--- a/make/autoconf/util.m4	Thu May 14 23:09:52 2020 +0800
+++ b/make/autoconf/util.m4	Thu May 14 18:56:30 2020 +0200
@@ -534,7 +534,7 @@
           # Otherwise we believe it is a complete path. Use it as it is.
           AC_MSG_NOTICE([Will use user supplied tool "$tool_command"])
           AC_MSG_CHECKING([for $tool_command])
-          if test ! -x "$tool_command"; then
+          if test ! -x "$tool_command" && test ! -x "$tool_command.exe"; then
             AC_MSG_RESULT([not found])
             AC_MSG_ERROR([User supplied tool $1="$tool_command" does not exist or is not executable])
           fi
--- a/make/autoconf/util_windows.m4	Thu May 14 23:09:52 2020 +0800
+++ b/make/autoconf/util_windows.m4	Thu May 14 18:56:30 2020 +0200
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2011, 2016, 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
@@ -127,10 +127,15 @@
     UTIL_REWRITE_AS_WINDOWS_MIXED_PATH([TOPDIR_windows])
     # First convert to Windows path to make input valid for cmd
     UTIL_REWRITE_AS_WINDOWS_MIXED_PATH([input_path])
+    # Reset PATH since it can contain a mix of WSL/linux paths and Windows paths from VS,
+    # which, in combination with WSLENV, will make the WSL layer complain
+    old_path="$PATH"
+    PATH=
     new_path=`$CMD /c $TOPDIR_windows/make/scripts/windowsShortName.bat "$input_path" \
         | $SED -e 's|\r||g' \
         | $TR \\\\\\\\ / | $TR 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
     # Rewrite back to unix style
+    PATH="$old_path"
     UTIL_REWRITE_AS_UNIX_PATH([new_path])
   fi
 ])
--- a/make/common/MakeBase.gmk	Thu May 14 23:09:52 2020 +0800
+++ b/make/common/MakeBase.gmk	Thu May 14 18:56:30 2020 +0200
@@ -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
@@ -465,8 +465,13 @@
 # This is normally not needed since we use the FIXPATH prefix for command lines,
 # but might be needed in certain circumstances.
 ifeq ($(call isTargetOs, windows), true)
-  FixPath = \
+  ifeq ($(call isBuildOsEnv, windows.wsl), true)
+    FixPath = \
+      $(shell $(WSLPATH) -m $1)
+  else
+    FixPath = \
       $(shell $(CYGPATH) -m $1)
+  endif
 else
   FixPath = \
       $1
--- a/make/common/NativeCompilation.gmk	Thu May 14 23:09:52 2020 +0800
+++ b/make/common/NativeCompilation.gmk	Thu May 14 18:56:30 2020 +0200
@@ -1049,7 +1049,7 @@
   endif
 
   ifeq ($$($1_TYPE), STATIC_LIBRARY)
-    $1_VARDEPS := $$($1_AR) $$($1_ARFLAGS) $$($1_LIBS) \
+    $1_VARDEPS := $$($1_AR) $$(ARFLAGS) $$($1_ARFLAGS) $$($1_LIBS) \
         $$($1_EXTRA_LIBS)
     $1_VARDEPS_FILE := $$(call DependOnVariable, $1_VARDEPS, \
         $$($1_OBJECT_DIR)/$$($1_NOSUFFIX).vardeps)
@@ -1067,7 +1067,7 @@
 	$$(call LogInfo, Building static library $$($1_BASENAME))
 	$$(call MakeDir, $$($1_OUTPUT_DIR) $$($1_SYMBOLS_DIR))
 	$$(call ExecuteWithLog, $$($1_OBJECT_DIR)/$$($1_SAFE_NAME)_link, \
-	    $$($1_AR) $$($1_ARFLAGS) $(AR_OUT_OPTION)$$($1_TARGET) $$($1_ALL_OBJS) \
+	    $$($1_AR) $$(ARFLAGS) $$($1_ARFLAGS) $(AR_OUT_OPTION)$$($1_TARGET) $$($1_ALL_OBJS) \
 	        $$($1_RES))
         ifeq ($(STATIC_BUILD), true)
           ifeq ($$($1_USE_MAPFILE_FOR_SYMBOLS), true)
--- a/make/conf/jib-profiles.js	Thu May 14 23:09:52 2020 +0800
+++ b/make/conf/jib-profiles.js	Thu May 14 18:56:30 2020 +0200
@@ -998,9 +998,11 @@
         : input.target_platform);
 
     var devkit_cross_prefix = "";
-    if (input.build_platform != input.target_platform
-       && input.build_platform != devkit_platform) {
-        devkit_cross_prefix = input.build_platform + "-to-";
+    if (!(input.target_os == "windows" && isWsl(input))) {
+        if (input.build_platform != input.target_platform
+           && input.build_platform != devkit_platform) {
+            devkit_cross_prefix = input.build_platform + "-to-";
+        }
     }
 
     var boot_jdk_platform = (input.build_os == "macosx" ? "osx" : input.build_os)