common/autoconf/toolchain.m4
changeset 24911 a039e17f8896
parent 23429 fe4f0848a307
child 25034 d9ca34c227b8
--- a/common/autoconf/toolchain.m4	Wed Jul 05 19:44:08 2017 +0200
+++ b/common/autoconf/toolchain.m4	Thu Jun 12 16:33:32 2014 -0700
@@ -24,11 +24,11 @@
 #
 
 ########################################################################
-# This file is responsible for detecting, verifying and setting up the 
-# toolchain, i.e. the compiler, linker and related utilities. It will setup 
+# This file is responsible for detecting, verifying and setting up the
+# toolchain, i.e. the compiler, linker and related utilities. It will setup
 # proper paths to the binaries, but it will not setup any flags.
 #
-# The binaries used is determined by the toolchain type, which is the family of 
+# The binaries used is determined by the toolchain type, which is the family of
 # compilers and related tools that are used.
 ########################################################################
 
@@ -83,7 +83,7 @@
   AC_SUBST(SHARED_LIBRARY)
   AC_SUBST(STATIC_LIBRARY)
   AC_SUBST(OBJ_SUFFIX)
-  AC_SUBST(EXE_SUFFIX)  
+  AC_SUBST(EXE_SUFFIX)
 ])
 
 # Determine which toolchain type to use, and make sure it is valid for this
@@ -117,7 +117,7 @@
     # First toolchain type in the list is the default
     DEFAULT_TOOLCHAIN=${VALID_TOOLCHAINS%% *}
   fi
-  
+
   if test "x$with_toolchain_type" = xlist; then
     # List all toolchains
     AC_MSG_NOTICE([The following toolchains are valid on this platform:])
@@ -126,7 +126,7 @@
       TOOLCHAIN_DESCRIPTION=${!toolchain_var_name}
       $PRINTF "  %-10s  %s\n" $toolchain "$TOOLCHAIN_DESCRIPTION"
     done
-    
+
     exit 0
   elif test "x$with_toolchain_type" != x; then
     # User override; check that it is valid
@@ -168,10 +168,10 @@
     AC_MSG_NOTICE([Using default toolchain $TOOLCHAIN_TYPE ($TOOLCHAIN_DESCRIPTION)])
   else
     AC_MSG_NOTICE([Using user selected toolchain $TOOLCHAIN_TYPE ($TOOLCHAIN_DESCRIPTION). Default toolchain is $DEFAULT_TOOLCHAIN.])
-  fi 
+  fi
 ])
 
-# Before we start detecting the toolchain executables, we might need some 
+# Before we start detecting the toolchain executables, we might need some
 # special setup, e.g. additional paths etc.
 AC_DEFUN_ONCE([TOOLCHAIN_PRE_DETECTION],
 [
@@ -184,7 +184,7 @@
   ORG_OBJCFLAGS="$OBJCFLAGS"
 
   # On Windows, we need to detect the visual studio installation first.
-  # This will change the PATH, but we need to keep that new PATH even 
+  # This will change the PATH, but we need to keep that new PATH even
   # after toolchain detection is done, since the compiler (on x86) uses
   # it for DLL resolution in runtime.
   if test "x$OPENJDK_BUILD_OS" = "xwindows" && test "x$TOOLCHAIN_TYPE" = "xmicrosoft"; then
@@ -208,7 +208,7 @@
     PATH="/usr/ccs/bin:$PATH"
   fi
 
-  # Finally add TOOLCHAIN_PATH at the beginning, to allow --with-tools-dir to 
+  # Finally add TOOLCHAIN_PATH at the beginning, to allow --with-tools-dir to
   # override all other locations.
   if test "x$TOOLCHAIN_PATH" != x; then
     PATH=$TOOLCHAIN_PATH:$PATH
@@ -254,7 +254,7 @@
       AC_MSG_NOTICE([The result from running with --version was: "$ALT_VERSION_OUTPUT"])
       AC_MSG_ERROR([A $TOOLCHAIN_TYPE compiler is required. Try setting --with-tools-dir.])
     fi
-    # Remove usage instructions (if present), and 
+    # Remove usage instructions (if present), and
     # collapse compiler output into a single line
     COMPILER_VERSION_STRING=`$ECHO $COMPILER_VERSION_OUTPUT | \
         $SED -e 's/ *@<:@Uu@:>@sage:.*//'`
@@ -282,7 +282,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
@@ -360,7 +360,7 @@
     AC_MSG_NOTICE([Will use user supplied compiler $1=[$]$1])
     if test "x`basename [$]$1`" = "x[$]$1"; then
       # A command without a complete path is provided, search $PATH.
-      
+
       AC_PATH_PROGS(POTENTIAL_$1, [$]$1)
       if test "x$POTENTIAL_$1" != x; then
         $1=$POTENTIAL_$1
@@ -375,12 +375,12 @@
     fi
   else
     # No user supplied value. Locate compiler ourselves.
-    
+
     # If we are cross compiling, assume cross compilation tools follows the
     # cross compilation standard where they are prefixed with the autoconf
-    # standard name for the target. For example the binary 
+    # standard name for the target. For example the binary
     # i686-sun-solaris2.10-gcc will cross compile for i686-sun-solaris2.10.
-    # If we are not cross compiling, then the default compiler name will be 
+    # If we are not cross compiling, then the default compiler name will be
     # used.
 
     $1=
@@ -450,9 +450,9 @@
   TOOLCHAIN_CHECK_COMPILER_VERSION([$1], [$COMPILER_NAME])
 ])
 
-# Detect the core components of the toolchain, i.e. the compilers (CC and CXX), 
-# preprocessor (CPP and CXXCPP), the linker (LD), the assembler (AS) and the 
-# archiver (AR). Verify that the compilers are correct according to the 
+# Detect the core components of the toolchain, i.e. the compilers (CC and CXX),
+# preprocessor (CPP and CXXCPP), the linker (LD), the assembler (AS) and the
+# archiver (AR). Verify that the compilers are correct according to the
 # toolchain type.
 AC_DEFUN_ONCE([TOOLCHAIN_DETECT_TOOLCHAIN_CORE],
 [
@@ -529,7 +529,7 @@
 ])
 
 # Setup additional tools that is considered a part of the toolchain, but not the
-# core part. Many of these are highly platform-specific and do not exist, 
+# core part. Many of these are highly platform-specific and do not exist,
 # and/or are not needed on all platforms.
 AC_DEFUN_ONCE([TOOLCHAIN_DETECT_TOOLCHAIN_EXTRA],
 [
@@ -551,7 +551,7 @@
     AC_CHECK_PROG([DUMPBIN], [dumpbin], [dumpbin],,,)
     BASIC_FIXUP_EXECUTABLE(DUMPBIN)
   fi
-  
+
   if test "x$OPENJDK_TARGET_OS" = xsolaris; then
     BASIC_PATH_PROGS(STRIP, strip)
     BASIC_FIXUP_EXECUTABLE(STRIP)
@@ -559,7 +559,7 @@
     BASIC_FIXUP_EXECUTABLE(NM)
     BASIC_PATH_PROGS(GNM, gnm)
     BASIC_FIXUP_EXECUTABLE(GNM)
-    
+
     BASIC_PATH_PROGS(MCS, mcs)
     BASIC_FIXUP_EXECUTABLE(MCS)
   elif test "x$OPENJDK_TARGET_OS" != xwindows; then
@@ -592,17 +592,17 @@
 
 # Setup the build tools (i.e, the compiler and linker used to build programs
 # that should be run on the build platform, not the target platform, as a build
-# helper). Since the non-cross-compile case uses the normal, target compilers 
+# helper). Since the non-cross-compile case uses the normal, target compilers
 # for this, we can only do this after these have been setup.
 AC_DEFUN_ONCE([TOOLCHAIN_SETUP_BUILD_COMPILERS],
-[  
+[
   if test "x$COMPILE_TYPE" = "xcross"; then
     # Now we need to find a C/C++ compiler that can build executables for the
     # build platform. We can't use the AC_PROG_CC macro, since it can only be
     # used once. Also, we need to do this without adding a tools dir to the
     # path, otherwise we might pick up cross-compilers which don't use standard
     # naming.
-    
+
     # 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
     # find the build compilers in the tools dir, if needed.
@@ -690,15 +690,39 @@
     # If this is a --hash-style=gnu system, use --hash-style=both, why?
     HAS_GNU_HASH=`$CC -dumpspecs 2>/dev/null | $GREP 'hash-style=gnu'`
     # This is later checked when setting flags.
+
+    # "-Og" suppported for GCC 4.8 and later
+    CFLAG_OPTIMIZE_DEBUG_FLAG="-Og"
+    FLAGS_COMPILER_CHECK_ARGUMENTS([$CFLAG_OPTIMIZE_DEBUG_FLAG],
+      [HAS_CFLAG_OPTIMIZE_DEBUG=true],
+      [HAS_CFLAG_OPTIMIZE_DEBUG=false])
+
+    # "-fsanitize=undefined" supported for GCC 4.9 and later
+    CFLAG_DETECT_UNDEFINED_BEHAVIOR_FLAG="-fsanitize=undefined -fsanitize-recover"
+    FLAGS_COMPILER_CHECK_ARGUMENTS([$CFLAG_DETECT_UNDEFINED_BEHAVIOR_FLAG],
+      [HAS_CFLAG_DETECT_UNDEFINED_BEHAVIOR=true],
+      [HAS_CFLAG_DETECT_UNDEFINED_BEHAVIOR=false])
+
+    # "-z relro" supported in GNU binutils 2.17 and later
+    LINKER_RELRO_FLAG="-Xlinker -z -Xlinker relro"
+    FLAGS_LINKER_CHECK_ARGUMENTS([$LINKER_RELRO_FLAG],
+      [HAS_LINKER_RELRO=true],
+      [HAS_LINKER_RELRO=false])
+
+    # "-z now" supported in GNU binutils 2.11 and later
+    LINKER_NOW_FLAG="-Xlinker -z -Xlinker now"
+    FLAGS_LINKER_CHECK_ARGUMENTS([$LINKER_NOW_FLAG],
+      [HAS_LINKER_NOW=true],
+      [HAS_LINKER_NOW=false])
   fi
 
-  # Check for broken SuSE 'ld' for which 'Only anonymous version tag is allowed 
+  # Check for broken SuSE 'ld' for which 'Only anonymous version tag is allowed
   # in executable.'
   USING_BROKEN_SUSE_LD=no
   if test "x$OPENJDK_TARGET_OS" = xlinux && test "x$TOOLCHAIN_TYPE" = xgcc; then
     AC_MSG_CHECKING([for broken SuSE 'ld' which only understands anonymous version tags in executables])
-    echo "SUNWprivate_1.1 { local: *; };" > version-script.map
-    echo "int main() { }" > main.c
+    $ECHO "SUNWprivate_1.1 { local: *; };" > version-script.map
+    $ECHO "int main() { }" > main.c
     if $CXX -Xlinker -version-script=version-script.map main.c 2>&AS_MESSAGE_LOG_FD >&AS_MESSAGE_LOG_FD; then
       AC_MSG_RESULT(no)
       USING_BROKEN_SUSE_LD=no