< prev index next >

make/autoconf/toolchain.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:

@@ -870,34 +870,47 @@
               $BUILD_DEVKIT_ROOT/devkit.info \
               > $CONFIGURESUPPORT_OUTPUTDIR/build-devkit.info
           . $CONFIGURESUPPORT_OUTPUTDIR/build-devkit.info
           # This potentially sets the following:
           # A descriptive name of the devkit
-          BASIC_EVAL_DEVKIT_VARIABLE([BUILD_DEVKIT_NAME])
+          BASIC_EVAL_BUILD_DEVKIT_VARIABLE([BUILD_DEVKIT_NAME])
           # Corresponds to --with-extra-path
-          BASIC_EVAL_DEVKIT_VARIABLE([BUILD_DEVKIT_EXTRA_PATH])
+          BASIC_EVAL_BUILD_DEVKIT_VARIABLE([BUILD_DEVKIT_EXTRA_PATH])
           # Corresponds to --with-toolchain-path
-          BASIC_EVAL_DEVKIT_VARIABLE([BUILD_DEVKIT_TOOLCHAIN_PATH])
+          BASIC_EVAL_BUILD_DEVKIT_VARIABLE([BUILD_DEVKIT_TOOLCHAIN_PATH])
           # Corresponds to --with-sysroot
-          BASIC_EVAL_DEVKIT_VARIABLE([BUILD_DEVKIT_SYSROOT])
-          # Skip the Window specific parts
+          BASIC_EVAL_BUILD_DEVKIT_VARIABLE([BUILD_DEVKIT_SYSROOT])
+
+          if test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
+            BASIC_EVAL_BUILD_DEVKIT_VARIABLE([BUILD_DEVKIT_VS_INCLUDE])
+            BASIC_EVAL_BUILD_DEVKIT_VARIABLE([BUILD_DEVKIT_VS_LIB])
+          fi
         fi
 
         AC_MSG_CHECKING([for build platform devkit])
         if test "x$BUILD_DEVKIT_NAME" != x; then
           AC_MSG_RESULT([$BUILD_DEVKIT_NAME in $BUILD_DEVKIT_ROOT])
         else
           AC_MSG_RESULT([$BUILD_DEVKIT_ROOT])
         fi
 
-        BUILD_SYSROOT="$BUILD_DEVKIT_SYSROOT"
+        UTIL_PREPEND_TO_PATH([PATH],$BUILD_DEVKIT_EXTRA_PATH)
 
          # Fallback default of just /bin if DEVKIT_PATH is not defined
         if test "x$BUILD_DEVKIT_TOOLCHAIN_PATH" = x; then
           BUILD_DEVKIT_TOOLCHAIN_PATH="$BUILD_DEVKIT_ROOT/bin"
         fi
-        PATH="$BUILD_DEVKIT_TOOLCHAIN_PATH:$BUILD_DEVKIT_EXTRA_PATH"
+        UTIL_PREPEND_TO_PATH([PATH],$BUILD_DEVKIT_TOOLCHAIN_PATH)
+
+        BUILD_SYSROOT="$BUILD_DEVKIT_SYSROOT"
+
+        if test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
+          BUILD_VS_INCLUDE="$BUILD_DEVKIT_VS_INCLUDE"
+          BUILD_VS_LIB="$BUILD_DEVKIT_VS_LIB"
+
+          TOOLCHAIN_SETUP_VISUAL_STUDIO_SYSROOT_FLAGS([BUILD_])
+        fi
       fi
     fi
 
     # FIXME: we should list the discovered compilers as an exclude pattern!
     # If we do that, we can do this detection before POST_DETECTION, and still

@@ -914,13 +927,41 @@
     UTIL_FIXUP_EXECUTABLE(BUILD_OBJCOPY)
     UTIL_PATH_PROGS(BUILD_STRIP, strip)
     UTIL_FIXUP_EXECUTABLE(BUILD_STRIP)
     # Assume the C compiler is the assembler
     BUILD_AS="$BUILD_CC -c"
+    if test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
+      # 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([BUILD_LD], [link$EXE_SUFFIX],[link$EXE_SUFFIX],,, [$CYGWIN_LINK])
+      UTIL_FIXUP_EXECUTABLE(BUILD_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=
+
+      "$BUILD_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"
+
+      BUILD_LDCXX="$BUILD_LD"
+    else
     # Just like for the target compiler, use the compiler as linker
     BUILD_LD="$BUILD_CC"
     BUILD_LDCXX="$BUILD_CXX"
+    fi
 
     PATH="$OLDPATH"
 
     TOOLCHAIN_EXTRACT_COMPILER_VERSION(BUILD_CC, [BuildC])
     TOOLCHAIN_EXTRACT_COMPILER_VERSION(BUILD_CXX, [BuildC++])

@@ -967,10 +1008,14 @@
       fi
     elif test "x$OPENJDK_TARGET_CPU" = "xx86_64"; then
       if test "x$COMPILER_CPU_TEST" != "xx64"; then
         AC_MSG_ERROR([Target CPU mismatch. We are building for $OPENJDK_TARGET_CPU but CL is for "$COMPILER_CPU_TEST"; expected "x64".])
       fi
+    elif test "x$OPENJDK_TARGET_CPU" = "xaarch64"; then
+      if test "x$COMPILER_CPU_TEST" != "xARM64"; then
+        AC_MSG_ERROR([Target CPU mismatch. We are building for $OPENJDK_TARGET_CPU but CL is for "$COMPILER_CPU_TEST"; expected "arm64".])
+      fi
     fi
   fi
 
   if test "x$TOOLCHAIN_TYPE" = xgcc || test "x$TOOLCHAIN_TYPE" = xclang; then
     # Check if linker has -z noexecstack.
< prev index next >