55 TOOLCHAIN_MINIMUM_VERSION_gcc="4.7" |
55 TOOLCHAIN_MINIMUM_VERSION_gcc="4.7" |
56 TOOLCHAIN_MINIMUM_VERSION_microsoft="16.00.30319.01" # VS2010 |
56 TOOLCHAIN_MINIMUM_VERSION_microsoft="16.00.30319.01" # VS2010 |
57 TOOLCHAIN_MINIMUM_VERSION_solstudio="5.13" |
57 TOOLCHAIN_MINIMUM_VERSION_solstudio="5.13" |
58 TOOLCHAIN_MINIMUM_VERSION_xlc="" |
58 TOOLCHAIN_MINIMUM_VERSION_xlc="" |
59 |
59 |
|
60 # Minimum supported linker versions, empty means unspecified |
|
61 TOOLCHAIN_MINIMUM_LD_VERSION_gcc="2.18" |
|
62 |
60 # Prepare the system so that TOOLCHAIN_CHECK_COMPILER_VERSION can be called. |
63 # Prepare the system so that TOOLCHAIN_CHECK_COMPILER_VERSION can be called. |
61 # Must have CC_VERSION_NUMBER and CXX_VERSION_NUMBER. |
64 # Must have CC_VERSION_NUMBER and CXX_VERSION_NUMBER. |
62 # $1 - optional variable prefix for compiler and version variables (BUILD_) |
65 # $1 - optional variable prefix for compiler and version variables (BUILD_) |
63 # $2 - optional variable prefix for comparable variable (OPENJDK_BUILD_) |
66 # $2 - optional variable prefix for comparable variable (OPENJDK_BUILD_) |
64 AC_DEFUN([TOOLCHAIN_PREPARE_FOR_VERSION_COMPARISONS], |
67 AC_DEFUN([TOOLCHAIN_PREPARE_FOR_VERSION_COMPARISONS], |
104 |
107 |
105 # Version comparison method inspired by http://stackoverflow.com/a/24067243 |
108 # Version comparison method inspired by http://stackoverflow.com/a/24067243 |
106 COMPARABLE_REFERENCE_VERSION=`$AWK -F. '{ printf("%05d%05d%05d%05d\n", [$]1, [$]2, [$]3, [$]4) }' <<< "$REFERENCE_VERSION"` |
109 COMPARABLE_REFERENCE_VERSION=`$AWK -F. '{ printf("%05d%05d%05d%05d\n", [$]1, [$]2, [$]3, [$]4) }' <<< "$REFERENCE_VERSION"` |
107 |
110 |
108 if test [$]ARG_PREFIX[COMPARABLE_ACTUAL_VERSION] -ge $COMPARABLE_REFERENCE_VERSION ; then |
111 if test [$]ARG_PREFIX[COMPARABLE_ACTUAL_VERSION] -ge $COMPARABLE_REFERENCE_VERSION ; then |
|
112 : |
|
113 ARG_IF_AT_LEAST |
|
114 else |
|
115 : |
|
116 ARG_IF_OLDER_THAN |
|
117 fi |
|
118 ]) |
|
119 |
|
120 # Prepare the system so that TOOLCHAIN_CHECK_COMPILER_VERSION can be called. |
|
121 # Must have LD_VERSION_NUMBER. |
|
122 # $1 - optional variable prefix for compiler and version variables (BUILD_) |
|
123 # $2 - optional variable prefix for comparable variable (OPENJDK_BUILD_) |
|
124 AC_DEFUN([TOOLCHAIN_PREPARE_FOR_LD_VERSION_COMPARISONS], |
|
125 [ |
|
126 if [ [[ "[$]$1LD_VERSION_NUMBER" =~ (.*\.){4} ]] ]; then |
|
127 AC_MSG_WARN([Linker version number has more than four parts (W.X.Y.Z): [$]$1LD_VERSION_NUMBER. Comparisons might be wrong.]) |
|
128 fi |
|
129 |
|
130 if [ [[ "[$]$1LD_VERSION_NUMBER" =~ [0-9]{6} ]] ]; then |
|
131 AC_MSG_WARN([Linker version number has a part larger than 99999: [$]$1LD_VERSION_NUMBER. Comparisons might be wrong.]) |
|
132 fi |
|
133 |
|
134 $2COMPARABLE_ACTUAL_LD_VERSION=`$AWK -F. '{ printf("%05d%05d%05d%05d\n", [$]1, [$]2, [$]3, [$]4) }' <<< "[$]$1LD_VERSION_NUMBER"` |
|
135 ]) |
|
136 |
|
137 # Check if the configured linker is of a specific version or |
|
138 # newer. TOOLCHAIN_PREPARE_FOR_LD_VERSION_COMPARISONS must have been called before. |
|
139 # |
|
140 # Arguments: |
|
141 # VERSION: The version string to check against the found version |
|
142 # IF_AT_LEAST: block to run if the compiler is at least this version (>=) |
|
143 # IF_OLDER_THAN: block to run if the compiler is older than this version (<) |
|
144 # PREFIX: Optional variable prefix for compiler to compare version for (OPENJDK_BUILD_) |
|
145 BASIC_DEFUN_NAMED([TOOLCHAIN_CHECK_LINKER_VERSION], |
|
146 [*VERSION PREFIX IF_AT_LEAST IF_OLDER_THAN], [$@], |
|
147 [ |
|
148 # Need to assign to a variable since m4 is blocked from modifying parts in []. |
|
149 REFERENCE_VERSION=ARG_VERSION |
|
150 |
|
151 if [ [[ "$REFERENCE_VERSION" =~ (.*\.){4} ]] ]; then |
|
152 AC_MSG_ERROR([Internal error: Cannot compare to ARG_VERSION, only four parts (W.X.Y.Z) is supported]) |
|
153 fi |
|
154 |
|
155 if [ [[ "$REFERENCE_VERSION" =~ [0-9]{6} ]] ]; then |
|
156 AC_MSG_ERROR([Internal error: Cannot compare to ARG_VERSION, only parts < 99999 is supported]) |
|
157 fi |
|
158 |
|
159 # Version comparison method inspired by http://stackoverflow.com/a/24067243 |
|
160 COMPARABLE_REFERENCE_VERSION=`$AWK -F. '{ printf("%05d%05d%05d%05d\n", [$]1, [$]2, [$]3, [$]4) }' <<< "$REFERENCE_VERSION"` |
|
161 |
|
162 if test [$]ARG_PREFIX[COMPARABLE_ACTUAL_LD_VERSION] -ge $COMPARABLE_REFERENCE_VERSION ; then |
109 : |
163 : |
110 ARG_IF_AT_LEAST |
164 ARG_IF_AT_LEAST |
111 else |
165 else |
112 : |
166 : |
113 ARG_IF_OLDER_THAN |
167 ARG_IF_OLDER_THAN |
239 # Use indirect variable referencing |
293 # Use indirect variable referencing |
240 toolchain_var_name=TOOLCHAIN_DESCRIPTION_$TOOLCHAIN_TYPE |
294 toolchain_var_name=TOOLCHAIN_DESCRIPTION_$TOOLCHAIN_TYPE |
241 TOOLCHAIN_DESCRIPTION=${!toolchain_var_name} |
295 TOOLCHAIN_DESCRIPTION=${!toolchain_var_name} |
242 toolchain_var_name=TOOLCHAIN_MINIMUM_VERSION_$TOOLCHAIN_TYPE |
296 toolchain_var_name=TOOLCHAIN_MINIMUM_VERSION_$TOOLCHAIN_TYPE |
243 TOOLCHAIN_MINIMUM_VERSION=${!toolchain_var_name} |
297 TOOLCHAIN_MINIMUM_VERSION=${!toolchain_var_name} |
|
298 toolchain_var_name=TOOLCHAIN_MINIMUM_LD_VERSION_$TOOLCHAIN_TYPE |
|
299 TOOLCHAIN_MINIMUM_LD_VERSION=${!toolchain_var_name} |
244 toolchain_var_name=TOOLCHAIN_CC_BINARY_$TOOLCHAIN_TYPE |
300 toolchain_var_name=TOOLCHAIN_CC_BINARY_$TOOLCHAIN_TYPE |
245 TOOLCHAIN_CC_BINARY=${!toolchain_var_name} |
301 TOOLCHAIN_CC_BINARY=${!toolchain_var_name} |
246 toolchain_var_name=TOOLCHAIN_CXX_BINARY_$TOOLCHAIN_TYPE |
302 toolchain_var_name=TOOLCHAIN_CXX_BINARY_$TOOLCHAIN_TYPE |
247 TOOLCHAIN_CXX_BINARY=${!toolchain_var_name} |
303 TOOLCHAIN_CXX_BINARY=${!toolchain_var_name} |
248 |
304 |
522 fi |
578 fi |
523 |
579 |
524 TOOLCHAIN_EXTRACT_COMPILER_VERSION([$1], [$COMPILER_NAME]) |
580 TOOLCHAIN_EXTRACT_COMPILER_VERSION([$1], [$COMPILER_NAME]) |
525 ]) |
581 ]) |
526 |
582 |
|
583 # Retrieve the linker version number and store it in LD_VERSION_NUMBER |
|
584 # (as a dotted number), and |
|
585 # the full version string in LD_VERSION_STRING. |
|
586 # |
|
587 # $1 = linker to test (LD or BUILD_LD) |
|
588 # $2 = human readable name of linker (Linker or BuildLinker) |
|
589 AC_DEFUN([TOOLCHAIN_EXTRACT_LD_VERSION], |
|
590 [ |
|
591 LINKER=[$]$1 |
|
592 LINKER_NAME=$2 |
|
593 |
|
594 if test "x$TOOLCHAIN_TYPE" = xsolstudio; then |
|
595 # cc -Wl,-V output typically looks like |
|
596 # ld: Software Generation Utilities - Solaris Link Editors: 5.11-1.2329 |
|
597 |
|
598 # solstudio cc requires us to have an existing file to pass as argument, |
|
599 # but it need not be a syntactically correct C file, so just use |
|
600 # ourself. :) |
|
601 LINKER_VERSION_STRING=`$LD -Wl,-V $TOPDIR/configure 2>&1 | $HEAD -n 1 | $SED -e 's/ld: //'` |
|
602 # Extract version number |
|
603 [ LINKER_VERSION_NUMBER=`$ECHO $LINKER_VERSION_STRING | \ |
|
604 $SED -e 's/.* \([0-9][0-9]*\.[0-9][0-9]*\)-\([0-9][0-9]*\.[0-9][0-9]*\)/\1.\2/'` ] |
|
605 elif test "x$TOOLCHAIN_TYPE" = xxlc; then |
|
606 LINKER_VERSION_STRING="Unknown" |
|
607 LINKER_VERSION_NUMBER="0.0" |
|
608 elif test "x$TOOLCHAIN_TYPE" = xmicrosoft; then |
|
609 # There is no specific version flag, but all output starts with a version string. |
|
610 # First line typically looks something like: |
|
611 # Microsoft (R) Incremental Linker Version 12.00.31101.0 |
|
612 LINKER_VERSION_STRING=`$LD 2>&1 | $HEAD -n 1 | $TR -d '\r'` |
|
613 # Extract version number |
|
614 [ LINKER_VERSION_NUMBER=`$ECHO $LINKER_VERSION_STRING | \ |
|
615 $SED -e 's/.* \([0-9][0-9]*\(\.[0-9][0-9]*\)*\).*/\1/'` ] |
|
616 elif test "x$TOOLCHAIN_TYPE" = xgcc; then |
|
617 # gcc -Wl,-version output typically looks like |
|
618 # GNU ld (GNU Binutils for Ubuntu) 2.26.1 |
|
619 # Copyright (C) 2015 Free Software Foundation, Inc. |
|
620 # This program is free software; [...] |
|
621 LINKER_VERSION_STRING=`$LD -Wl,-version 2>&1 | $HEAD -n 1` |
|
622 # Extract version number |
|
623 [ LINKER_VERSION_NUMBER=`$ECHO $LINKER_VERSION_STRING | \ |
|
624 $SED -e 's/.* \([0-9][0-9]*\(\.[0-9][0-9]*\)*\).*/\1/'` ] |
|
625 elif test "x$TOOLCHAIN_TYPE" = xclang; then |
|
626 # clang -Wl,-v output typically looks like |
|
627 # @(#)PROGRAM:ld PROJECT:ld64-305 |
|
628 # configured to support archs: armv6 armv7 armv7s arm64 i386 x86_64 x86_64h armv6m armv7k armv7m armv7em (tvOS) |
|
629 # Library search paths: [...] |
|
630 # or |
|
631 # GNU ld (GNU Binutils for Ubuntu) 2.26.1 |
|
632 |
|
633 LINKER_VERSION_STRING=`$LD -Wl,-v 2>&1 | $HEAD -n 1` |
|
634 # Check if we're using the GNU ld |
|
635 $ECHO "$LINKER_VERSION_STRING" | $GREP "GNU" > /dev/null |
|
636 if test $? -eq 0; then |
|
637 # Extract version number |
|
638 [ LINKER_VERSION_NUMBER=`$ECHO $LINKER_VERSION_STRING | \ |
|
639 $SED -e 's/.* \([0-9][0-9]*\(\.[0-9][0-9]*\)*\).*/\1/'` ] |
|
640 else |
|
641 # Extract version number |
|
642 [ LINKER_VERSION_NUMBER=`$ECHO $LINKER_VERSION_STRING | \ |
|
643 $SED -e 's/.*-\([0-9][0-9]*\)/\1/'` ] |
|
644 fi |
|
645 fi |
|
646 |
|
647 $1_VERSION_NUMBER="$LINKER_VERSION_NUMBER" |
|
648 $1_VERSION_STRING="$LINKER_VERSION_STRING" |
|
649 |
|
650 AC_MSG_NOTICE([Using $TOOLCHAIN_TYPE $LINKER_NAME version $LINKER_VERSION_NUMBER @<:@$LINKER_VERSION_STRING@:>@]) |
|
651 ]) |
|
652 |
527 # Detect the core components of the toolchain, i.e. the compilers (CC and CXX), |
653 # Detect the core components of the toolchain, i.e. the compilers (CC and CXX), |
528 # preprocessor (CPP and CXXCPP), the linker (LD), the assembler (AS) and the |
654 # preprocessor (CPP and CXXCPP), the linker (LD), the assembler (AS) and the |
529 # archiver (AR). Verify that the compilers are correct according to the |
655 # archiver (AR). Verify that the compilers are correct according to the |
530 # toolchain type. |
656 # toolchain type. |
531 AC_DEFUN_ONCE([TOOLCHAIN_DETECT_TOOLCHAIN_CORE], |
657 AC_DEFUN_ONCE([TOOLCHAIN_DETECT_TOOLCHAIN_CORE], |
816 PATH="$OLDPATH" |
953 PATH="$OLDPATH" |
817 |
954 |
818 TOOLCHAIN_EXTRACT_COMPILER_VERSION(BUILD_CC, [BuildC]) |
955 TOOLCHAIN_EXTRACT_COMPILER_VERSION(BUILD_CC, [BuildC]) |
819 TOOLCHAIN_EXTRACT_COMPILER_VERSION(BUILD_CXX, [BuildC++]) |
956 TOOLCHAIN_EXTRACT_COMPILER_VERSION(BUILD_CXX, [BuildC++]) |
820 TOOLCHAIN_PREPARE_FOR_VERSION_COMPARISONS([BUILD_], [OPENJDK_BUILD_]) |
957 TOOLCHAIN_PREPARE_FOR_VERSION_COMPARISONS([BUILD_], [OPENJDK_BUILD_]) |
|
958 TOOLCHAIN_EXTRACT_LD_VERSION(BUILD_LD, [build linker]) |
|
959 TOOLCHAIN_PREPARE_FOR_LD_VERSION_COMPARISONS([BUILD_], [OPENJDK_BUILD_]) |
821 else |
960 else |
822 # If we are not cross compiling, use the normal target compilers for |
961 # If we are not cross compiling, use the normal target compilers for |
823 # building the build platform executables. |
962 # building the build platform executables. |
824 BUILD_CC="$CC" |
963 BUILD_CC="$CC" |
825 BUILD_CXX="$CXX" |
964 BUILD_CXX="$CXX" |