< prev index next >

make/autoconf/flags-cflags.m4

Print this page

        

@@ -774,10 +774,37 @@
     $1_TOOLCHAIN_CFLAGS="${$1_GCC6_CFLAGS}"
 
     $1_WARNING_CFLAGS_JVM="-Wno-format-zero-length -Wtype-limits -Wuninitialized"
   fi
 
+  case $TOOLCHAIN_TYPE in
+    gcc)
+      $2NO_SPECULATIVE_CTI_CFLAGS="-mindirect-branch=thunk \
+          -mfunction-return=thunk -mindirect-branch-register"
+      ;;
+    microsoft)
+      $2NO_SPECULATIVE_CTI_CFLAGS="-Qspectre"
+      ;;
+    *)
+      $2NO_SPECULATIVE_CTI_CFLAGS=""
+      ;;
+  esac
+  if test -n "${$2NO_SPECULATIVE_CTI_CFLAGS}"; then
+    FLAGS_COMPILER_CHECK_ARGUMENTS(ARGUMENT: [${$2NO_SPECULATIVE_CTI_CFLAGS}],
+        IF_FALSE: [
+          AC_MSG_WARN([Speculative call mitigations not available with compiler version])
+          $2NO_SPECULATIVE_CTI_CFLAGS=""
+        ]
+    )
+  fi
+  AC_MSG_CHECKING([for speculative calls mitigation flags for $1])
+  if test -n "${$2NO_SPECULATIVE_CTI_CFLAGS}"; then
+    AC_MSG_RESULT(${$2NO_SPECULATIVE_CTI_CFLAGS})
+  else
+    AC_MSG_RESULT(no)
+  fi
+
   # EXPORT to API
   CFLAGS_JVM_COMMON="$ALWAYS_CFLAGS_JVM $ALWAYS_DEFINES_JVM $TOOLCHAIN_CFLAGS_JVM \
       $OS_CFLAGS $OS_CFLAGS_JVM $CFLAGS_OS_DEF_JVM $DEBUG_CFLAGS_JVM \
       $WARNING_CFLAGS $WARNING_CFLAGS_JVM $JVM_PICFLAG"
 

@@ -792,12 +819,16 @@
   CFLAGS_JDK_COMMON_CONLY="$TOOLCHAIN_CFLAGS_JDK_CONLY  \
       $WARNING_CFLAGS_JDK_CONLY ${$2EXTRA_CFLAGS}"
   CFLAGS_JDK_COMMON_CXXONLY="$ALWAYS_DEFINES_JDK_CXXONLY $TOOLCHAIN_CFLAGS_JDK_CXXONLY \
       $WARNING_CFLAGS_JDK_CXXONLY ${$2EXTRA_CXXFLAGS}"
 
-  $1_CFLAGS_JVM="${$1_DEFINES_CPU_JVM} ${$1_CFLAGS_CPU} ${$1_CFLAGS_CPU_JVM} ${$1_TOOLCHAIN_CFLAGS} ${$1_WARNING_CFLAGS_JVM}"
-  $1_CFLAGS_JDK="${$1_DEFINES_CPU_JDK} ${$1_CFLAGS_CPU} ${$1_CFLAGS_CPU_JDK} ${$1_TOOLCHAIN_CFLAGS}"
+  # The jdk libraries always use the speculative calls mitigations, while it's
+  # optional for the JVM.
+  $1_CFLAGS_JVM="${$1_DEFINES_CPU_JVM} ${$1_CFLAGS_CPU} ${$1_CFLAGS_CPU_JVM} \
+      ${$1_TOOLCHAIN_CFLAGS} ${$1_WARNING_CFLAGS_JVM}"
+  $1_CFLAGS_JDK="${$1_DEFINES_CPU_JDK} ${$1_CFLAGS_CPU} ${$1_CFLAGS_CPU_JDK} \
+      ${$1_TOOLCHAIN_CFLAGS} ${$2NO_SPECULATIVE_CTI_CFLAGS}"
 
   $2JVM_CFLAGS="$CFLAGS_JVM_COMMON ${$1_CFLAGS_JVM} ${$2EXTRA_CXXFLAGS}"
 
   $2CFLAGS_JDKEXE="$CFLAGS_JDK_COMMON $CFLAGS_JDK_COMMON_CONLY ${$1_CFLAGS_JDK}"
   $2CXXFLAGS_JDKEXE="$CFLAGS_JDK_COMMON $CFLAGS_JDK_COMMON_CXXONLY ${$1_CFLAGS_JDK}"

@@ -807,10 +838,11 @@
   AC_SUBST($2JVM_CFLAGS)
   AC_SUBST($2CFLAGS_JDKLIB)
   AC_SUBST($2CFLAGS_JDKEXE)
   AC_SUBST($2CXXFLAGS_JDKLIB)
   AC_SUBST($2CXXFLAGS_JDKEXE)
+  AC_SUBST($2NO_SPECULATIVE_CTI_CFLAGS)
 ])
 
 # FLAGS_SETUP_GCC6_COMPILER_FLAGS([PREFIX])
 # Arguments:
 # $1 - Prefix for each variable defined.
< prev index next >