make/autoconf/toolchain.m4
author fweimer
Tue, 12 Nov 2019 21:00:08 +0000
changeset 59041 d6d8fdc95ed2
parent 57975 a333fdeb8de0
permissions -rw-r--r--
8233880: Support compilers with multi-digit major version numbers Reviewed-by: tbell
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
13133
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
     1
#
57975
a333fdeb8de0 8224214: [AIX] Remove support for legacy xlc compiler
mbaesken
parents: 54148
diff changeset
     2
# Copyright (c) 2011, 2019, Oracle and/or its affiliates. All rights reserved.
13133
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
     3
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
     4
#
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
     5
# This code is free software; you can redistribute it and/or modify it
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
     6
# under the terms of the GNU General Public License version 2 only, as
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
     7
# published by the Free Software Foundation.  Oracle designates this
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
     8
# particular file as subject to the "Classpath" exception as provided
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
     9
# by Oracle in the LICENSE file that accompanied this code.
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
    10
#
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
    11
# This code is distributed in the hope that it will be useful, but WITHOUT
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
    12
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
    13
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
    14
# version 2 for more details (a copy is included in the LICENSE file that
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
    15
# accompanied this code).
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
    16
#
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
    17
# You should have received a copy of the GNU General Public License version
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
    18
# 2 along with this work; if not, write to the Free Software Foundation,
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
    19
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
    20
#
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
    21
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
    22
# or visit www.oracle.com if you need additional information or have any
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
    23
# questions.
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
    24
#
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
    25
22721
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
    26
########################################################################
24911
a039e17f8896 8032045: Enable compiler and linker safety switches for debug builds
mduigou
parents: 23429
diff changeset
    27
# This file is responsible for detecting, verifying and setting up the
a039e17f8896 8032045: Enable compiler and linker safety switches for debug builds
mduigou
parents: 23429
diff changeset
    28
# toolchain, i.e. the compiler, linker and related utilities. It will setup
22721
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
    29
# proper paths to the binaries, but it will not setup any flags.
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
    30
#
24911
a039e17f8896 8032045: Enable compiler and linker safety switches for debug builds
mduigou
parents: 23429
diff changeset
    31
# The binaries used is determined by the toolchain type, which is the family of
22721
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
    32
# compilers and related tools that are used.
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
    33
########################################################################
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
    34
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
    35
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
    36
# All valid toolchains, regardless of platform (used by help.m4)
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
    37
VALID_TOOLCHAINS_all="gcc clang solstudio xlc microsoft"
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
    38
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
    39
# These toolchains are valid on different platforms
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
    40
VALID_TOOLCHAINS_linux="gcc clang"
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
    41
VALID_TOOLCHAINS_solaris="solstudio"
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
    42
VALID_TOOLCHAINS_macosx="gcc clang"
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
    43
VALID_TOOLCHAINS_aix="xlc"
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
    44
VALID_TOOLCHAINS_windows="microsoft"
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
    45
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
    46
# Toolchain descriptions
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
    47
TOOLCHAIN_DESCRIPTION_clang="clang/LLVM"
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
    48
TOOLCHAIN_DESCRIPTION_gcc="GNU Compiler Collection"
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
    49
TOOLCHAIN_DESCRIPTION_microsoft="Microsoft Visual Studio"
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
    50
TOOLCHAIN_DESCRIPTION_solstudio="Oracle Solaris Studio"
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
    51
TOOLCHAIN_DESCRIPTION_xlc="IBM XL C/C++"
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
    52
35747
aeaa6d0101a8 8149647: Incremental enhancements from build-infra
ihse
parents: 35371
diff changeset
    53
# Minimum supported versions, empty means unspecified
aeaa6d0101a8 8149647: Incremental enhancements from build-infra
ihse
parents: 35371
diff changeset
    54
TOOLCHAIN_MINIMUM_VERSION_clang="3.2"
49200
a19a6228cdb2 8199405: Bump lowest supported gcc to 4.8
ihse
parents: 49199
diff changeset
    55
TOOLCHAIN_MINIMUM_VERSION_gcc="4.8"
42297
ebbd32ba8997 8170666: Test for microsoft compiler minimum version
ihse
parents: 42296
diff changeset
    56
TOOLCHAIN_MINIMUM_VERSION_microsoft="16.00.30319.01" # VS2010
39948
cfb05dbae510 8160825: Update minimum Solaris Studio compiler version to 5.13
sanzinger
parents: 39115
diff changeset
    57
TOOLCHAIN_MINIMUM_VERSION_solstudio="5.13"
35747
aeaa6d0101a8 8149647: Incremental enhancements from build-infra
ihse
parents: 35371
diff changeset
    58
TOOLCHAIN_MINIMUM_VERSION_xlc=""
aeaa6d0101a8 8149647: Incremental enhancements from build-infra
ihse
parents: 35371
diff changeset
    59
49199
986249df86ce 8199403: Require binutils 2.18 or newer
ihse
parents: 49120
diff changeset
    60
# Minimum supported linker versions, empty means unspecified
986249df86ce 8199403: Require binutils 2.18 or newer
ihse
parents: 49120
diff changeset
    61
TOOLCHAIN_MINIMUM_LD_VERSION_gcc="2.18"
986249df86ce 8199403: Require binutils 2.18 or newer
ihse
parents: 49120
diff changeset
    62
35747
aeaa6d0101a8 8149647: Incremental enhancements from build-infra
ihse
parents: 35371
diff changeset
    63
# Prepare the system so that TOOLCHAIN_CHECK_COMPILER_VERSION can be called.
aeaa6d0101a8 8149647: Incremental enhancements from build-infra
ihse
parents: 35371
diff changeset
    64
# Must have CC_VERSION_NUMBER and CXX_VERSION_NUMBER.
37864
5284b5a9fdc7 8155587: Cross compilation may cause compiler warnings for "build" compiler
erikj
parents: 37402
diff changeset
    65
# $1 - optional variable prefix for compiler and version variables (BUILD_)
5284b5a9fdc7 8155587: Cross compilation may cause compiler warnings for "build" compiler
erikj
parents: 37402
diff changeset
    66
# $2 - optional variable prefix for comparable variable (OPENJDK_BUILD_)
35747
aeaa6d0101a8 8149647: Incremental enhancements from build-infra
ihse
parents: 35371
diff changeset
    67
AC_DEFUN([TOOLCHAIN_PREPARE_FOR_VERSION_COMPARISONS],
aeaa6d0101a8 8149647: Incremental enhancements from build-infra
ihse
parents: 35371
diff changeset
    68
[
37864
5284b5a9fdc7 8155587: Cross compilation may cause compiler warnings for "build" compiler
erikj
parents: 37402
diff changeset
    69
  if test "x[$]$1CC_VERSION_NUMBER" != "x[$]$1CXX_VERSION_NUMBER"; then
5284b5a9fdc7 8155587: Cross compilation may cause compiler warnings for "build" compiler
erikj
parents: 37402
diff changeset
    70
    AC_MSG_WARN([C and C++ compiler have different version numbers, [$]$1CC_VERSION_NUMBER vs [$]$1CXX_VERSION_NUMBER.])
35747
aeaa6d0101a8 8149647: Incremental enhancements from build-infra
ihse
parents: 35371
diff changeset
    71
    AC_MSG_WARN([This typically indicates a broken setup, and is not supported])
aeaa6d0101a8 8149647: Incremental enhancements from build-infra
ihse
parents: 35371
diff changeset
    72
  fi
aeaa6d0101a8 8149647: Incremental enhancements from build-infra
ihse
parents: 35371
diff changeset
    73
aeaa6d0101a8 8149647: Incremental enhancements from build-infra
ihse
parents: 35371
diff changeset
    74
  # We only check CC_VERSION_NUMBER since we assume CXX_VERSION_NUMBER is equal.
42297
ebbd32ba8997 8170666: Test for microsoft compiler minimum version
ihse
parents: 42296
diff changeset
    75
  if [ [[ "[$]$1CC_VERSION_NUMBER" =~ (.*\.){4} ]] ]; then
ebbd32ba8997 8170666: Test for microsoft compiler minimum version
ihse
parents: 42296
diff changeset
    76
    AC_MSG_WARN([C compiler version number has more than four parts (W.X.Y.Z): [$]$1CC_VERSION_NUMBER. Comparisons might be wrong.])
35747
aeaa6d0101a8 8149647: Incremental enhancements from build-infra
ihse
parents: 35371
diff changeset
    77
  fi
aeaa6d0101a8 8149647: Incremental enhancements from build-infra
ihse
parents: 35371
diff changeset
    78
37864
5284b5a9fdc7 8155587: Cross compilation may cause compiler warnings for "build" compiler
erikj
parents: 37402
diff changeset
    79
  if [ [[  "[$]$1CC_VERSION_NUMBER" =~ [0-9]{6} ]] ]; then
5284b5a9fdc7 8155587: Cross compilation may cause compiler warnings for "build" compiler
erikj
parents: 37402
diff changeset
    80
    AC_MSG_WARN([C compiler version number has a part larger than 99999: [$]$1CC_VERSION_NUMBER. Comparisons might be wrong.])
35747
aeaa6d0101a8 8149647: Incremental enhancements from build-infra
ihse
parents: 35371
diff changeset
    81
  fi
aeaa6d0101a8 8149647: Incremental enhancements from build-infra
ihse
parents: 35371
diff changeset
    82
42297
ebbd32ba8997 8170666: Test for microsoft compiler minimum version
ihse
parents: 42296
diff changeset
    83
  $2COMPARABLE_ACTUAL_VERSION=`$AWK -F. '{ printf("%05d%05d%05d%05d\n", [$]1, [$]2, [$]3, [$]4) }' <<< "[$]$1CC_VERSION_NUMBER"`
35747
aeaa6d0101a8 8149647: Incremental enhancements from build-infra
ihse
parents: 35371
diff changeset
    84
])
aeaa6d0101a8 8149647: Incremental enhancements from build-infra
ihse
parents: 35371
diff changeset
    85
aeaa6d0101a8 8149647: Incremental enhancements from build-infra
ihse
parents: 35371
diff changeset
    86
# Check if the configured compiler (C and C++) is of a specific version or
aeaa6d0101a8 8149647: Incremental enhancements from build-infra
ihse
parents: 35371
diff changeset
    87
# newer. TOOLCHAIN_PREPARE_FOR_VERSION_COMPARISONS must have been called before.
aeaa6d0101a8 8149647: Incremental enhancements from build-infra
ihse
parents: 35371
diff changeset
    88
#
aeaa6d0101a8 8149647: Incremental enhancements from build-infra
ihse
parents: 35371
diff changeset
    89
# Arguments:
aeaa6d0101a8 8149647: Incremental enhancements from build-infra
ihse
parents: 35371
diff changeset
    90
#   VERSION:   The version string to check against the found version
aeaa6d0101a8 8149647: Incremental enhancements from build-infra
ihse
parents: 35371
diff changeset
    91
#   IF_AT_LEAST:   block to run if the compiler is at least this version (>=)
aeaa6d0101a8 8149647: Incremental enhancements from build-infra
ihse
parents: 35371
diff changeset
    92
#   IF_OLDER_THAN:   block to run if the compiler is older than this version (<)
37864
5284b5a9fdc7 8155587: Cross compilation may cause compiler warnings for "build" compiler
erikj
parents: 37402
diff changeset
    93
#   PREFIX:   Optional variable prefix for compiler to compare version for (OPENJDK_BUILD_)
35747
aeaa6d0101a8 8149647: Incremental enhancements from build-infra
ihse
parents: 35371
diff changeset
    94
BASIC_DEFUN_NAMED([TOOLCHAIN_CHECK_COMPILER_VERSION],
37864
5284b5a9fdc7 8155587: Cross compilation may cause compiler warnings for "build" compiler
erikj
parents: 37402
diff changeset
    95
    [*VERSION PREFIX IF_AT_LEAST IF_OLDER_THAN], [$@],
35747
aeaa6d0101a8 8149647: Incremental enhancements from build-infra
ihse
parents: 35371
diff changeset
    96
[
aeaa6d0101a8 8149647: Incremental enhancements from build-infra
ihse
parents: 35371
diff changeset
    97
  # Need to assign to a variable since m4 is blocked from modifying parts in [].
aeaa6d0101a8 8149647: Incremental enhancements from build-infra
ihse
parents: 35371
diff changeset
    98
  REFERENCE_VERSION=ARG_VERSION
aeaa6d0101a8 8149647: Incremental enhancements from build-infra
ihse
parents: 35371
diff changeset
    99
42297
ebbd32ba8997 8170666: Test for microsoft compiler minimum version
ihse
parents: 42296
diff changeset
   100
  if [ [[ "$REFERENCE_VERSION" =~ (.*\.){4} ]] ]; then
ebbd32ba8997 8170666: Test for microsoft compiler minimum version
ihse
parents: 42296
diff changeset
   101
    AC_MSG_ERROR([Internal error: Cannot compare to ARG_VERSION, only four parts (W.X.Y.Z) is supported])
35747
aeaa6d0101a8 8149647: Incremental enhancements from build-infra
ihse
parents: 35371
diff changeset
   102
  fi
aeaa6d0101a8 8149647: Incremental enhancements from build-infra
ihse
parents: 35371
diff changeset
   103
aeaa6d0101a8 8149647: Incremental enhancements from build-infra
ihse
parents: 35371
diff changeset
   104
  if [ [[ "$REFERENCE_VERSION" =~ [0-9]{6} ]] ]; then
36535
141db8da8c18 8151841: Build needs additional flags to compile with GCC 6
andrew
parents: 35747
diff changeset
   105
    AC_MSG_ERROR([Internal error: Cannot compare to ARG_VERSION, only parts < 99999 is supported])
35747
aeaa6d0101a8 8149647: Incremental enhancements from build-infra
ihse
parents: 35371
diff changeset
   106
  fi
aeaa6d0101a8 8149647: Incremental enhancements from build-infra
ihse
parents: 35371
diff changeset
   107
aeaa6d0101a8 8149647: Incremental enhancements from build-infra
ihse
parents: 35371
diff changeset
   108
  # Version comparison method inspired by http://stackoverflow.com/a/24067243
42297
ebbd32ba8997 8170666: Test for microsoft compiler minimum version
ihse
parents: 42296
diff changeset
   109
  COMPARABLE_REFERENCE_VERSION=`$AWK -F. '{ printf("%05d%05d%05d%05d\n", [$]1, [$]2, [$]3, [$]4) }' <<< "$REFERENCE_VERSION"`
35747
aeaa6d0101a8 8149647: Incremental enhancements from build-infra
ihse
parents: 35371
diff changeset
   110
37864
5284b5a9fdc7 8155587: Cross compilation may cause compiler warnings for "build" compiler
erikj
parents: 37402
diff changeset
   111
  if test [$]ARG_PREFIX[COMPARABLE_ACTUAL_VERSION] -ge $COMPARABLE_REFERENCE_VERSION ; then
35747
aeaa6d0101a8 8149647: Incremental enhancements from build-infra
ihse
parents: 35371
diff changeset
   112
    :
aeaa6d0101a8 8149647: Incremental enhancements from build-infra
ihse
parents: 35371
diff changeset
   113
    ARG_IF_AT_LEAST
aeaa6d0101a8 8149647: Incremental enhancements from build-infra
ihse
parents: 35371
diff changeset
   114
  else
aeaa6d0101a8 8149647: Incremental enhancements from build-infra
ihse
parents: 35371
diff changeset
   115
    :
aeaa6d0101a8 8149647: Incremental enhancements from build-infra
ihse
parents: 35371
diff changeset
   116
    ARG_IF_OLDER_THAN
aeaa6d0101a8 8149647: Incremental enhancements from build-infra
ihse
parents: 35371
diff changeset
   117
  fi
aeaa6d0101a8 8149647: Incremental enhancements from build-infra
ihse
parents: 35371
diff changeset
   118
])
aeaa6d0101a8 8149647: Incremental enhancements from build-infra
ihse
parents: 35371
diff changeset
   119
49199
986249df86ce 8199403: Require binutils 2.18 or newer
ihse
parents: 49120
diff changeset
   120
# Prepare the system so that TOOLCHAIN_CHECK_COMPILER_VERSION can be called.
986249df86ce 8199403: Require binutils 2.18 or newer
ihse
parents: 49120
diff changeset
   121
# Must have LD_VERSION_NUMBER.
986249df86ce 8199403: Require binutils 2.18 or newer
ihse
parents: 49120
diff changeset
   122
# $1 - optional variable prefix for compiler and version variables (BUILD_)
986249df86ce 8199403: Require binutils 2.18 or newer
ihse
parents: 49120
diff changeset
   123
# $2 - optional variable prefix for comparable variable (OPENJDK_BUILD_)
986249df86ce 8199403: Require binutils 2.18 or newer
ihse
parents: 49120
diff changeset
   124
AC_DEFUN([TOOLCHAIN_PREPARE_FOR_LD_VERSION_COMPARISONS],
986249df86ce 8199403: Require binutils 2.18 or newer
ihse
parents: 49120
diff changeset
   125
[
986249df86ce 8199403: Require binutils 2.18 or newer
ihse
parents: 49120
diff changeset
   126
  if [ [[ "[$]$1LD_VERSION_NUMBER" =~ (.*\.){4} ]] ]; then
986249df86ce 8199403: Require binutils 2.18 or newer
ihse
parents: 49120
diff changeset
   127
    AC_MSG_WARN([Linker version number has more than four parts (W.X.Y.Z): [$]$1LD_VERSION_NUMBER. Comparisons might be wrong.])
986249df86ce 8199403: Require binutils 2.18 or newer
ihse
parents: 49120
diff changeset
   128
  fi
986249df86ce 8199403: Require binutils 2.18 or newer
ihse
parents: 49120
diff changeset
   129
986249df86ce 8199403: Require binutils 2.18 or newer
ihse
parents: 49120
diff changeset
   130
  if [ [[  "[$]$1LD_VERSION_NUMBER" =~ [0-9]{6} ]] ]; then
986249df86ce 8199403: Require binutils 2.18 or newer
ihse
parents: 49120
diff changeset
   131
    AC_MSG_WARN([Linker version number has a part larger than 99999: [$]$1LD_VERSION_NUMBER. Comparisons might be wrong.])
986249df86ce 8199403: Require binutils 2.18 or newer
ihse
parents: 49120
diff changeset
   132
  fi
986249df86ce 8199403: Require binutils 2.18 or newer
ihse
parents: 49120
diff changeset
   133
986249df86ce 8199403: Require binutils 2.18 or newer
ihse
parents: 49120
diff changeset
   134
  $2COMPARABLE_ACTUAL_LD_VERSION=`$AWK -F. '{ printf("%05d%05d%05d%05d\n", [$]1, [$]2, [$]3, [$]4) }' <<< "[$]$1LD_VERSION_NUMBER"`
986249df86ce 8199403: Require binutils 2.18 or newer
ihse
parents: 49120
diff changeset
   135
])
986249df86ce 8199403: Require binutils 2.18 or newer
ihse
parents: 49120
diff changeset
   136
986249df86ce 8199403: Require binutils 2.18 or newer
ihse
parents: 49120
diff changeset
   137
# Check if the configured linker is of a specific version or
986249df86ce 8199403: Require binutils 2.18 or newer
ihse
parents: 49120
diff changeset
   138
# newer. TOOLCHAIN_PREPARE_FOR_LD_VERSION_COMPARISONS must have been called before.
986249df86ce 8199403: Require binutils 2.18 or newer
ihse
parents: 49120
diff changeset
   139
#
986249df86ce 8199403: Require binutils 2.18 or newer
ihse
parents: 49120
diff changeset
   140
# Arguments:
986249df86ce 8199403: Require binutils 2.18 or newer
ihse
parents: 49120
diff changeset
   141
#   VERSION:   The version string to check against the found version
986249df86ce 8199403: Require binutils 2.18 or newer
ihse
parents: 49120
diff changeset
   142
#   IF_AT_LEAST:   block to run if the compiler is at least this version (>=)
986249df86ce 8199403: Require binutils 2.18 or newer
ihse
parents: 49120
diff changeset
   143
#   IF_OLDER_THAN:   block to run if the compiler is older than this version (<)
986249df86ce 8199403: Require binutils 2.18 or newer
ihse
parents: 49120
diff changeset
   144
#   PREFIX:   Optional variable prefix for compiler to compare version for (OPENJDK_BUILD_)
986249df86ce 8199403: Require binutils 2.18 or newer
ihse
parents: 49120
diff changeset
   145
BASIC_DEFUN_NAMED([TOOLCHAIN_CHECK_LINKER_VERSION],
986249df86ce 8199403: Require binutils 2.18 or newer
ihse
parents: 49120
diff changeset
   146
    [*VERSION PREFIX IF_AT_LEAST IF_OLDER_THAN], [$@],
986249df86ce 8199403: Require binutils 2.18 or newer
ihse
parents: 49120
diff changeset
   147
[
986249df86ce 8199403: Require binutils 2.18 or newer
ihse
parents: 49120
diff changeset
   148
  # Need to assign to a variable since m4 is blocked from modifying parts in [].
986249df86ce 8199403: Require binutils 2.18 or newer
ihse
parents: 49120
diff changeset
   149
  REFERENCE_VERSION=ARG_VERSION
986249df86ce 8199403: Require binutils 2.18 or newer
ihse
parents: 49120
diff changeset
   150
986249df86ce 8199403: Require binutils 2.18 or newer
ihse
parents: 49120
diff changeset
   151
  if [ [[ "$REFERENCE_VERSION" =~ (.*\.){4} ]] ]; then
986249df86ce 8199403: Require binutils 2.18 or newer
ihse
parents: 49120
diff changeset
   152
    AC_MSG_ERROR([Internal error: Cannot compare to ARG_VERSION, only four parts (W.X.Y.Z) is supported])
986249df86ce 8199403: Require binutils 2.18 or newer
ihse
parents: 49120
diff changeset
   153
  fi
986249df86ce 8199403: Require binutils 2.18 or newer
ihse
parents: 49120
diff changeset
   154
986249df86ce 8199403: Require binutils 2.18 or newer
ihse
parents: 49120
diff changeset
   155
  if [ [[ "$REFERENCE_VERSION" =~ [0-9]{6} ]] ]; then
986249df86ce 8199403: Require binutils 2.18 or newer
ihse
parents: 49120
diff changeset
   156
    AC_MSG_ERROR([Internal error: Cannot compare to ARG_VERSION, only parts < 99999 is supported])
986249df86ce 8199403: Require binutils 2.18 or newer
ihse
parents: 49120
diff changeset
   157
  fi
986249df86ce 8199403: Require binutils 2.18 or newer
ihse
parents: 49120
diff changeset
   158
986249df86ce 8199403: Require binutils 2.18 or newer
ihse
parents: 49120
diff changeset
   159
  # Version comparison method inspired by http://stackoverflow.com/a/24067243
986249df86ce 8199403: Require binutils 2.18 or newer
ihse
parents: 49120
diff changeset
   160
  COMPARABLE_REFERENCE_VERSION=`$AWK -F. '{ printf("%05d%05d%05d%05d\n", [$]1, [$]2, [$]3, [$]4) }' <<< "$REFERENCE_VERSION"`
986249df86ce 8199403: Require binutils 2.18 or newer
ihse
parents: 49120
diff changeset
   161
986249df86ce 8199403: Require binutils 2.18 or newer
ihse
parents: 49120
diff changeset
   162
  if test [$]ARG_PREFIX[COMPARABLE_ACTUAL_LD_VERSION] -ge $COMPARABLE_REFERENCE_VERSION ; then
986249df86ce 8199403: Require binutils 2.18 or newer
ihse
parents: 49120
diff changeset
   163
    :
986249df86ce 8199403: Require binutils 2.18 or newer
ihse
parents: 49120
diff changeset
   164
    ARG_IF_AT_LEAST
986249df86ce 8199403: Require binutils 2.18 or newer
ihse
parents: 49120
diff changeset
   165
  else
986249df86ce 8199403: Require binutils 2.18 or newer
ihse
parents: 49120
diff changeset
   166
    :
986249df86ce 8199403: Require binutils 2.18 or newer
ihse
parents: 49120
diff changeset
   167
    ARG_IF_OLDER_THAN
986249df86ce 8199403: Require binutils 2.18 or newer
ihse
parents: 49120
diff changeset
   168
  fi
986249df86ce 8199403: Require binutils 2.18 or newer
ihse
parents: 49120
diff changeset
   169
])
986249df86ce 8199403: Require binutils 2.18 or newer
ihse
parents: 49120
diff changeset
   170
22721
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   171
# Setup a number of variables describing how native output files are
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   172
# named on this platform/toolchain.
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   173
AC_DEFUN([TOOLCHAIN_SETUP_FILENAME_PATTERNS],
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   174
[
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   175
  # Define filename patterns
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   176
  if test "x$OPENJDK_TARGET_OS" = xwindows; then
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   177
    LIBRARY_PREFIX=
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   178
    SHARED_LIBRARY_SUFFIX='.dll'
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   179
    STATIC_LIBRARY_SUFFIX='.lib'
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   180
    SHARED_LIBRARY='[$]1.dll'
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   181
    STATIC_LIBRARY='[$]1.lib'
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   182
    OBJ_SUFFIX='.obj'
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   183
  else
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   184
    LIBRARY_PREFIX=lib
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   185
    SHARED_LIBRARY_SUFFIX='.so'
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   186
    STATIC_LIBRARY_SUFFIX='.a'
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   187
    SHARED_LIBRARY='lib[$]1.so'
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   188
    STATIC_LIBRARY='lib[$]1.a'
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   189
    OBJ_SUFFIX='.o'
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   190
    if test "x$OPENJDK_TARGET_OS" = xmacosx; then
33562
c76b2fa11486 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32810
diff changeset
   191
      # For full static builds, we're overloading the SHARED_LIBRARY
c76b2fa11486 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32810
diff changeset
   192
      # variables in order to limit the amount of changes required.
c76b2fa11486 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32810
diff changeset
   193
      # It would be better to remove SHARED and just use LIBRARY and
34923
0a2be16ce53d 8146995: Introduce named arguments in configure
ihse
parents: 34596
diff changeset
   194
      # LIBRARY_SUFFIX for libraries that can be built either
0a2be16ce53d 8146995: Introduce named arguments in configure
ihse
parents: 34596
diff changeset
   195
      # shared or static and use STATIC_* for libraries that are
33562
c76b2fa11486 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32810
diff changeset
   196
      # always built statically.
c76b2fa11486 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32810
diff changeset
   197
      if test "x$STATIC_BUILD" = xtrue; then
c76b2fa11486 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32810
diff changeset
   198
        SHARED_LIBRARY='lib[$]1.a'
c76b2fa11486 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32810
diff changeset
   199
        SHARED_LIBRARY_SUFFIX='.a'
c76b2fa11486 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32810
diff changeset
   200
      else
c76b2fa11486 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32810
diff changeset
   201
        SHARED_LIBRARY='lib[$]1.dylib'
c76b2fa11486 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32810
diff changeset
   202
        SHARED_LIBRARY_SUFFIX='.dylib'
c76b2fa11486 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32810
diff changeset
   203
      fi
22721
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   204
    fi
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   205
  fi
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   206
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   207
  AC_SUBST(LIBRARY_PREFIX)
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   208
  AC_SUBST(SHARED_LIBRARY_SUFFIX)
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   209
  AC_SUBST(STATIC_LIBRARY_SUFFIX)
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   210
  AC_SUBST(SHARED_LIBRARY)
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   211
  AC_SUBST(STATIC_LIBRARY)
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   212
  AC_SUBST(OBJ_SUFFIX)
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   213
])
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   214
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   215
# Determine which toolchain type to use, and make sure it is valid for this
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   216
# platform. Setup various information about the selected toolchain.
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   217
AC_DEFUN_ONCE([TOOLCHAIN_DETERMINE_TOOLCHAIN_TYPE],
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   218
[
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   219
  AC_ARG_WITH(toolchain-type, [AS_HELP_STRING([--with-toolchain-type],
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   220
      [the toolchain type (or family) to use, use '--help' to show possible values @<:@platform dependent@:>@])])
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   221
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   222
  # Use indirect variable referencing
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   223
  toolchain_var_name=VALID_TOOLCHAINS_$OPENJDK_BUILD_OS
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   224
  VALID_TOOLCHAINS=${!toolchain_var_name}
23161
85635b5bf0a6 8019470: Changes needed to compile JDK 8 on MacOS with clang compiler
henryjen
parents: 22724
diff changeset
   225
85635b5bf0a6 8019470: Changes needed to compile JDK 8 on MacOS with clang compiler
henryjen
parents: 22724
diff changeset
   226
  if test "x$OPENJDK_TARGET_OS" = xmacosx; then
25034
d9ca34c227b8 8043340: [macosx] Fix hard-wired paths to JavaVM.framework
ddehaven
parents: 24911
diff changeset
   227
    if test -n "$XCODEBUILD"; then
d9ca34c227b8 8043340: [macosx] Fix hard-wired paths to JavaVM.framework
ddehaven
parents: 24911
diff changeset
   228
      # On Mac OS X, default toolchain to clang after Xcode 5
d9ca34c227b8 8043340: [macosx] Fix hard-wired paths to JavaVM.framework
ddehaven
parents: 24911
diff changeset
   229
      XCODE_VERSION_OUTPUT=`"$XCODEBUILD" -version 2>&1 | $HEAD -n 1`
d9ca34c227b8 8043340: [macosx] Fix hard-wired paths to JavaVM.framework
ddehaven
parents: 24911
diff changeset
   230
      $ECHO "$XCODE_VERSION_OUTPUT" | $GREP "Xcode " > /dev/null
d9ca34c227b8 8043340: [macosx] Fix hard-wired paths to JavaVM.framework
ddehaven
parents: 24911
diff changeset
   231
      if test $? -ne 0; then
51780
23e7cd5a9c54 8210723: Better information in configure for invalid Xcode
ihse
parents: 51605
diff changeset
   232
        AC_MSG_NOTICE([xcodebuild output: $XCODE_VERSION_OUTPUT])
25034
d9ca34c227b8 8043340: [macosx] Fix hard-wired paths to JavaVM.framework
ddehaven
parents: 24911
diff changeset
   233
        AC_MSG_ERROR([Failed to determine Xcode version.])
d9ca34c227b8 8043340: [macosx] Fix hard-wired paths to JavaVM.framework
ddehaven
parents: 24911
diff changeset
   234
      fi
d9ca34c227b8 8043340: [macosx] Fix hard-wired paths to JavaVM.framework
ddehaven
parents: 24911
diff changeset
   235
      XCODE_MAJOR_VERSION=`$ECHO $XCODE_VERSION_OUTPUT | \
d9ca34c227b8 8043340: [macosx] Fix hard-wired paths to JavaVM.framework
ddehaven
parents: 24911
diff changeset
   236
          $SED -e 's/^Xcode \(@<:@1-9@:>@@<:@0-9.@:>@*\)/\1/' | \
d9ca34c227b8 8043340: [macosx] Fix hard-wired paths to JavaVM.framework
ddehaven
parents: 24911
diff changeset
   237
          $CUT -f 1 -d .`
d9ca34c227b8 8043340: [macosx] Fix hard-wired paths to JavaVM.framework
ddehaven
parents: 24911
diff changeset
   238
      AC_MSG_NOTICE([Xcode major version: $XCODE_MAJOR_VERSION])
d9ca34c227b8 8043340: [macosx] Fix hard-wired paths to JavaVM.framework
ddehaven
parents: 24911
diff changeset
   239
      if test $XCODE_MAJOR_VERSION -ge 5; then
d9ca34c227b8 8043340: [macosx] Fix hard-wired paths to JavaVM.framework
ddehaven
parents: 24911
diff changeset
   240
          DEFAULT_TOOLCHAIN="clang"
d9ca34c227b8 8043340: [macosx] Fix hard-wired paths to JavaVM.framework
ddehaven
parents: 24911
diff changeset
   241
      else
d9ca34c227b8 8043340: [macosx] Fix hard-wired paths to JavaVM.framework
ddehaven
parents: 24911
diff changeset
   242
          DEFAULT_TOOLCHAIN="gcc"
d9ca34c227b8 8043340: [macosx] Fix hard-wired paths to JavaVM.framework
ddehaven
parents: 24911
diff changeset
   243
      fi
23161
85635b5bf0a6 8019470: Changes needed to compile JDK 8 on MacOS with clang compiler
henryjen
parents: 22724
diff changeset
   244
    else
25034
d9ca34c227b8 8043340: [macosx] Fix hard-wired paths to JavaVM.framework
ddehaven
parents: 24911
diff changeset
   245
      # If Xcode is not installed, but the command line tools are
d9ca34c227b8 8043340: [macosx] Fix hard-wired paths to JavaVM.framework
ddehaven
parents: 24911
diff changeset
   246
      # then we can't run xcodebuild. On these systems we should
d9ca34c227b8 8043340: [macosx] Fix hard-wired paths to JavaVM.framework
ddehaven
parents: 24911
diff changeset
   247
      # default to clang
d9ca34c227b8 8043340: [macosx] Fix hard-wired paths to JavaVM.framework
ddehaven
parents: 24911
diff changeset
   248
      DEFAULT_TOOLCHAIN="clang"
23161
85635b5bf0a6 8019470: Changes needed to compile JDK 8 on MacOS with clang compiler
henryjen
parents: 22724
diff changeset
   249
    fi
85635b5bf0a6 8019470: Changes needed to compile JDK 8 on MacOS with clang compiler
henryjen
parents: 22724
diff changeset
   250
  else
85635b5bf0a6 8019470: Changes needed to compile JDK 8 on MacOS with clang compiler
henryjen
parents: 22724
diff changeset
   251
    # First toolchain type in the list is the default
85635b5bf0a6 8019470: Changes needed to compile JDK 8 on MacOS with clang compiler
henryjen
parents: 22724
diff changeset
   252
    DEFAULT_TOOLCHAIN=${VALID_TOOLCHAINS%% *}
85635b5bf0a6 8019470: Changes needed to compile JDK 8 on MacOS with clang compiler
henryjen
parents: 22724
diff changeset
   253
  fi
24911
a039e17f8896 8032045: Enable compiler and linker safety switches for debug builds
mduigou
parents: 23429
diff changeset
   254
22721
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   255
  if test "x$with_toolchain_type" = xlist; then
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   256
    # List all toolchains
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   257
    AC_MSG_NOTICE([The following toolchains are valid on this platform:])
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   258
    for toolchain in $VALID_TOOLCHAINS; do
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   259
      toolchain_var_name=TOOLCHAIN_DESCRIPTION_$toolchain
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   260
      TOOLCHAIN_DESCRIPTION=${!toolchain_var_name}
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   261
      $PRINTF "  %-10s  %s\n" $toolchain "$TOOLCHAIN_DESCRIPTION"
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   262
    done
24911
a039e17f8896 8032045: Enable compiler and linker safety switches for debug builds
mduigou
parents: 23429
diff changeset
   263
22721
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   264
    exit 0
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   265
  elif test "x$with_toolchain_type" != x; then
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   266
    # User override; check that it is valid
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   267
    if test "x${VALID_TOOLCHAINS/$with_toolchain_type/}" = "x${VALID_TOOLCHAINS}"; then
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   268
      AC_MSG_NOTICE([Toolchain type $with_toolchain_type is not valid on this platform.])
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   269
      AC_MSG_NOTICE([Valid toolchains: $VALID_TOOLCHAINS.])
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   270
      AC_MSG_ERROR([Cannot continue.])
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   271
    fi
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   272
    TOOLCHAIN_TYPE=$with_toolchain_type
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   273
  else
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   274
    # No flag given, use default
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   275
    TOOLCHAIN_TYPE=$DEFAULT_TOOLCHAIN
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   276
  fi
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   277
  AC_SUBST(TOOLCHAIN_TYPE)
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   278
53837
b3f6ffbedd68 8218965: aix: support xlclang++ in the compiler detection
mbaesken
parents: 53643
diff changeset
   279
  # on AIX, check for xlclang++ on the PATH and TOOLCHAIN_PATH and use it if it is available
b3f6ffbedd68 8218965: aix: support xlclang++ in the compiler detection
mbaesken
parents: 53643
diff changeset
   280
  if test "x$OPENJDK_TARGET_OS" = xaix; then
b3f6ffbedd68 8218965: aix: support xlclang++ in the compiler detection
mbaesken
parents: 53643
diff changeset
   281
    if test "x$TOOLCHAIN_PATH" != x; then
b3f6ffbedd68 8218965: aix: support xlclang++ in the compiler detection
mbaesken
parents: 53643
diff changeset
   282
      XLC_TEST_PATH=${TOOLCHAIN_PATH}/
b3f6ffbedd68 8218965: aix: support xlclang++ in the compiler detection
mbaesken
parents: 53643
diff changeset
   283
    fi
b3f6ffbedd68 8218965: aix: support xlclang++ in the compiler detection
mbaesken
parents: 53643
diff changeset
   284
b3f6ffbedd68 8218965: aix: support xlclang++ in the compiler detection
mbaesken
parents: 53643
diff changeset
   285
    XLCLANG_VERSION_OUTPUT=`${XLC_TEST_PATH}xlclang++ -qversion 2>&1 | $HEAD -n 1`
b3f6ffbedd68 8218965: aix: support xlclang++ in the compiler detection
mbaesken
parents: 53643
diff changeset
   286
    $ECHO "$XLCLANG_VERSION_OUTPUT" | $GREP "IBM XL C/C++ for AIX" > /dev/null
b3f6ffbedd68 8218965: aix: support xlclang++ in the compiler detection
mbaesken
parents: 53643
diff changeset
   287
    if test $? -eq 0; then
b3f6ffbedd68 8218965: aix: support xlclang++ in the compiler detection
mbaesken
parents: 53643
diff changeset
   288
      AC_MSG_NOTICE([xlclang++ output: $XLCLANG_VERSION_OUTPUT])
57975
a333fdeb8de0 8224214: [AIX] Remove support for legacy xlc compiler
mbaesken
parents: 54148
diff changeset
   289
    else
a333fdeb8de0 8224214: [AIX] Remove support for legacy xlc compiler
mbaesken
parents: 54148
diff changeset
   290
      AC_MSG_ERROR([xlclang++ version output check failed, output: $XLCLANG_VERSION_OUTPUT])
53837
b3f6ffbedd68 8218965: aix: support xlclang++ in the compiler detection
mbaesken
parents: 53643
diff changeset
   291
    fi
b3f6ffbedd68 8218965: aix: support xlclang++ in the compiler detection
mbaesken
parents: 53643
diff changeset
   292
  fi
b3f6ffbedd68 8218965: aix: support xlclang++ in the compiler detection
mbaesken
parents: 53643
diff changeset
   293
22721
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   294
  TOOLCHAIN_CC_BINARY_clang="clang"
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   295
  TOOLCHAIN_CC_BINARY_gcc="gcc"
53110
50677f43ac3d 8215445: Enable building for Windows in WSL
erikj
parents: 51856
diff changeset
   296
  TOOLCHAIN_CC_BINARY_microsoft="cl$EXE_SUFFIX"
22721
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   297
  TOOLCHAIN_CC_BINARY_solstudio="cc"
57975
a333fdeb8de0 8224214: [AIX] Remove support for legacy xlc compiler
mbaesken
parents: 54148
diff changeset
   298
  TOOLCHAIN_CC_BINARY_xlc="xlclang"
22721
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   299
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   300
  TOOLCHAIN_CXX_BINARY_clang="clang++"
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   301
  TOOLCHAIN_CXX_BINARY_gcc="g++"
53110
50677f43ac3d 8215445: Enable building for Windows in WSL
erikj
parents: 51856
diff changeset
   302
  TOOLCHAIN_CXX_BINARY_microsoft="cl$EXE_SUFFIX"
22721
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   303
  TOOLCHAIN_CXX_BINARY_solstudio="CC"
57975
a333fdeb8de0 8224214: [AIX] Remove support for legacy xlc compiler
mbaesken
parents: 54148
diff changeset
   304
  TOOLCHAIN_CXX_BINARY_xlc="xlclang++"
53837
b3f6ffbedd68 8218965: aix: support xlclang++ in the compiler detection
mbaesken
parents: 53643
diff changeset
   305
22721
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   306
  # Use indirect variable referencing
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   307
  toolchain_var_name=TOOLCHAIN_DESCRIPTION_$TOOLCHAIN_TYPE
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   308
  TOOLCHAIN_DESCRIPTION=${!toolchain_var_name}
35747
aeaa6d0101a8 8149647: Incremental enhancements from build-infra
ihse
parents: 35371
diff changeset
   309
  toolchain_var_name=TOOLCHAIN_MINIMUM_VERSION_$TOOLCHAIN_TYPE
aeaa6d0101a8 8149647: Incremental enhancements from build-infra
ihse
parents: 35371
diff changeset
   310
  TOOLCHAIN_MINIMUM_VERSION=${!toolchain_var_name}
49199
986249df86ce 8199403: Require binutils 2.18 or newer
ihse
parents: 49120
diff changeset
   311
  toolchain_var_name=TOOLCHAIN_MINIMUM_LD_VERSION_$TOOLCHAIN_TYPE
986249df86ce 8199403: Require binutils 2.18 or newer
ihse
parents: 49120
diff changeset
   312
  TOOLCHAIN_MINIMUM_LD_VERSION=${!toolchain_var_name}
22721
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   313
  toolchain_var_name=TOOLCHAIN_CC_BINARY_$TOOLCHAIN_TYPE
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   314
  TOOLCHAIN_CC_BINARY=${!toolchain_var_name}
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   315
  toolchain_var_name=TOOLCHAIN_CXX_BINARY_$TOOLCHAIN_TYPE
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   316
  TOOLCHAIN_CXX_BINARY=${!toolchain_var_name}
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   317
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   318
  TOOLCHAIN_SETUP_FILENAME_PATTERNS
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   319
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   320
  if test "x$TOOLCHAIN_TYPE" = "x$DEFAULT_TOOLCHAIN"; then
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   321
    AC_MSG_NOTICE([Using default toolchain $TOOLCHAIN_TYPE ($TOOLCHAIN_DESCRIPTION)])
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   322
  else
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   323
    AC_MSG_NOTICE([Using user selected toolchain $TOOLCHAIN_TYPE ($TOOLCHAIN_DESCRIPTION). Default toolchain is $DEFAULT_TOOLCHAIN.])
24911
a039e17f8896 8032045: Enable compiler and linker safety switches for debug builds
mduigou
parents: 23429
diff changeset
   324
  fi
22721
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   325
])
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   326
24911
a039e17f8896 8032045: Enable compiler and linker safety switches for debug builds
mduigou
parents: 23429
diff changeset
   327
# Before we start detecting the toolchain executables, we might need some
22721
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   328
# special setup, e.g. additional paths etc.
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   329
AC_DEFUN_ONCE([TOOLCHAIN_PRE_DETECTION],
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   330
[
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   331
  # FIXME: Is this needed?
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   332
  AC_LANG(C++)
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   333
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   334
  # Store the CFLAGS etc passed to the configure script.
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   335
  ORG_CFLAGS="$CFLAGS"
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   336
  ORG_CXXFLAGS="$CXXFLAGS"
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   337
30022
362d77fbf008 8078437: Enable use of devkits for Windows
erikj
parents: 29866
diff changeset
   338
  # autoconf magic only relies on PATH, so update it if tools dir is specified
362d77fbf008 8078437: Enable use of devkits for Windows
erikj
parents: 29866
diff changeset
   339
  OLD_PATH="$PATH"
362d77fbf008 8078437: Enable use of devkits for Windows
erikj
parents: 29866
diff changeset
   340
22724
072f729936a9 8035725: Must keep microsoft VS_PATH on PATH after toolchain detection
ihse
parents: 22721
diff changeset
   341
  # On Windows, we need to detect the visual studio installation first.
24911
a039e17f8896 8032045: Enable compiler and linker safety switches for debug builds
mduigou
parents: 23429
diff changeset
   342
  # This will change the PATH, but we need to keep that new PATH even
22724
072f729936a9 8035725: Must keep microsoft VS_PATH on PATH after toolchain detection
ihse
parents: 22721
diff changeset
   343
  # after toolchain detection is done, since the compiler (on x86) uses
072f729936a9 8035725: Must keep microsoft VS_PATH on PATH after toolchain detection
ihse
parents: 22721
diff changeset
   344
  # it for DLL resolution in runtime.
30022
362d77fbf008 8078437: Enable use of devkits for Windows
erikj
parents: 29866
diff changeset
   345
  if test "x$OPENJDK_BUILD_OS" = "xwindows" \
362d77fbf008 8078437: Enable use of devkits for Windows
erikj
parents: 29866
diff changeset
   346
      && test "x$TOOLCHAIN_TYPE" = "xmicrosoft"; then
22724
072f729936a9 8035725: Must keep microsoft VS_PATH on PATH after toolchain detection
ihse
parents: 22721
diff changeset
   347
    TOOLCHAIN_SETUP_VISUAL_STUDIO_ENV
53110
50677f43ac3d 8215445: Enable building for Windows in WSL
erikj
parents: 51856
diff changeset
   348
    if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.wsl"; then
50677f43ac3d 8215445: Enable building for Windows in WSL
erikj
parents: 51856
diff changeset
   349
      # Append VS_PATH. In WSL, VS_PATH will not contain the WSL env path needed
50677f43ac3d 8215445: Enable building for Windows in WSL
erikj
parents: 51856
diff changeset
   350
      # for using basic Unix tools, so need to keep the original PATH.
50677f43ac3d 8215445: Enable building for Windows in WSL
erikj
parents: 51856
diff changeset
   351
      BASIC_APPEND_TO_PATH(PATH, $VS_PATH)
50677f43ac3d 8215445: Enable building for Windows in WSL
erikj
parents: 51856
diff changeset
   352
      BASIC_APPEND_TO_PATH(WSLENV, "PATH/l:LIB:INCLUDE")
50677f43ac3d 8215445: Enable building for Windows in WSL
erikj
parents: 51856
diff changeset
   353
      export WSLENV
50677f43ac3d 8215445: Enable building for Windows in WSL
erikj
parents: 51856
diff changeset
   354
    else
50677f43ac3d 8215445: Enable building for Windows in WSL
erikj
parents: 51856
diff changeset
   355
      # Reset path to VS_PATH. It will include everything that was on PATH at the time we
50677f43ac3d 8215445: Enable building for Windows in WSL
erikj
parents: 51856
diff changeset
   356
      # ran TOOLCHAIN_SETUP_VISUAL_STUDIO_ENV.
50677f43ac3d 8215445: Enable building for Windows in WSL
erikj
parents: 51856
diff changeset
   357
      PATH="$VS_PATH"
50677f43ac3d 8215445: Enable building for Windows in WSL
erikj
parents: 51856
diff changeset
   358
    fi
23429
fe4f0848a307 8035751: Clean up Visual Studio detection logic
ihse
parents: 23428
diff changeset
   359
    # The microsoft toolchain also requires INCLUDE and LIB to be set.
fe4f0848a307 8035751: Clean up Visual Studio detection logic
ihse
parents: 23428
diff changeset
   360
    export INCLUDE="$VS_INCLUDE"
fe4f0848a307 8035751: Clean up Visual Studio detection logic
ihse
parents: 23428
diff changeset
   361
    export LIB="$VS_LIB"
34596
e8328ce5b64e 8142907: Integration of minor fixes from the build-infra project
ihse
parents: 34102
diff changeset
   362
  else
35747
aeaa6d0101a8 8149647: Incremental enhancements from build-infra
ihse
parents: 35371
diff changeset
   363
    if test "x$XCODE_VERSION_OUTPUT" != x; then
aeaa6d0101a8 8149647: Incremental enhancements from build-infra
ihse
parents: 35371
diff changeset
   364
      # For Xcode, we set the Xcode version as TOOLCHAIN_VERSION
aeaa6d0101a8 8149647: Incremental enhancements from build-infra
ihse
parents: 35371
diff changeset
   365
      TOOLCHAIN_VERSION=`$ECHO $XCODE_VERSION_OUTPUT | $CUT -f 2 -d ' '`
48678
bcce1fa183e7 8196108: Add build support for VS 2015/2017
erikj
parents: 48032
diff changeset
   366
      TOOLCHAIN_DESCRIPTION="$TOOLCHAIN_DESCRIPTION from Xcode $TOOLCHAIN_VERSION"
35747
aeaa6d0101a8 8149647: Incremental enhancements from build-infra
ihse
parents: 35371
diff changeset
   367
    else
aeaa6d0101a8 8149647: Incremental enhancements from build-infra
ihse
parents: 35371
diff changeset
   368
      # Currently we do not define this for other toolchains. This might change as the need arise.
aeaa6d0101a8 8149647: Incremental enhancements from build-infra
ihse
parents: 35371
diff changeset
   369
      TOOLCHAIN_VERSION=
aeaa6d0101a8 8149647: Incremental enhancements from build-infra
ihse
parents: 35371
diff changeset
   370
    fi
22724
072f729936a9 8035725: Must keep microsoft VS_PATH on PATH after toolchain detection
ihse
parents: 22721
diff changeset
   371
  fi
34596
e8328ce5b64e 8142907: Integration of minor fixes from the build-infra project
ihse
parents: 34102
diff changeset
   372
  AC_SUBST(TOOLCHAIN_VERSION)
22724
072f729936a9 8035725: Must keep microsoft VS_PATH on PATH after toolchain detection
ihse
parents: 22721
diff changeset
   373
24911
a039e17f8896 8032045: Enable compiler and linker safety switches for debug builds
mduigou
parents: 23429
diff changeset
   374
  # Finally add TOOLCHAIN_PATH at the beginning, to allow --with-tools-dir to
22721
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   375
  # override all other locations.
23428
3c8a05bf4656 8038340: Cleanup and fix sysroot and devkit handling on Linux and Solaris
erikj
parents: 23161
diff changeset
   376
  if test "x$TOOLCHAIN_PATH" != x; then
3c8a05bf4656 8038340: Cleanup and fix sysroot and devkit handling on Linux and Solaris
erikj
parents: 23161
diff changeset
   377
    PATH=$TOOLCHAIN_PATH:$PATH
22721
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   378
  fi
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   379
])
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   380
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   381
# Restore path, etc
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   382
AC_DEFUN_ONCE([TOOLCHAIN_POST_DETECTION],
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   383
[
39928
8448cfeb0f1d 8079788: Fix broken CL version detection in configure for some Visual Studio configurations
erikj
parents: 39115
diff changeset
   384
  # Restore old path, except for the microsoft toolchain, which requires VS_PATH
8448cfeb0f1d 8079788: Fix broken CL version detection in configure for some Visual Studio configurations
erikj
parents: 39115
diff changeset
   385
  # to remain in place. Otherwise the compiler will not work in some siutations
8448cfeb0f1d 8079788: Fix broken CL version detection in configure for some Visual Studio configurations
erikj
parents: 39115
diff changeset
   386
  # in later configure checks.
8448cfeb0f1d 8079788: Fix broken CL version detection in configure for some Visual Studio configurations
erikj
parents: 39115
diff changeset
   387
  if test "x$TOOLCHAIN_TYPE" != "xmicrosoft"; then
8448cfeb0f1d 8079788: Fix broken CL version detection in configure for some Visual Studio configurations
erikj
parents: 39115
diff changeset
   388
    PATH="$OLD_PATH"
8448cfeb0f1d 8079788: Fix broken CL version detection in configure for some Visual Studio configurations
erikj
parents: 39115
diff changeset
   389
  fi
22721
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   390
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   391
  # Restore the flags to the user specified values.
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   392
  # This is necessary since AC_PROG_CC defaults CFLAGS to "-g -O2"
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   393
  CFLAGS="$ORG_CFLAGS"
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   394
  CXXFLAGS="$ORG_CXXFLAGS"
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   395
])
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   396
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   397
# Check if a compiler is of the toolchain type we expect, and save the version
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   398
# information from it. If the compiler does not match the expected type,
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   399
# this function will abort using AC_MSG_ERROR. If it matches, the version will
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   400
# be stored in CC_VERSION_NUMBER/CXX_VERSION_NUMBER (as a dotted number), and
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   401
# the full version string in CC_VERSION_STRING/CXX_VERSION_STRING.
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   402
#
14111
2a82ecb35fc7 8000992: Update new build-infra makefiles
ohair
parents: 13697
diff changeset
   403
# $1 = compiler to test (CC or CXX)
2a82ecb35fc7 8000992: Update new build-infra makefiles
ohair
parents: 13697
diff changeset
   404
# $2 = human readable name of compiler (C or C++)
35747
aeaa6d0101a8 8149647: Incremental enhancements from build-infra
ihse
parents: 35371
diff changeset
   405
AC_DEFUN([TOOLCHAIN_EXTRACT_COMPILER_VERSION],
13133
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
   406
[
14111
2a82ecb35fc7 8000992: Update new build-infra makefiles
ohair
parents: 13697
diff changeset
   407
  COMPILER=[$]$1
2a82ecb35fc7 8000992: Update new build-infra makefiles
ohair
parents: 13697
diff changeset
   408
  COMPILER_NAME=$2
13133
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
   409
22721
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   410
  if test "x$TOOLCHAIN_TYPE" = xsolstudio; then
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   411
    # cc -V output typically looks like
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   412
    #     cc: Sun C 5.12 Linux_i386 2011/11/16
42294
d8c997ec29fe 8164304: JDK should build with Oracle Developer Studio
erikj
parents: 41040
diff changeset
   413
    # or
d8c997ec29fe 8164304: JDK should build with Oracle Developer Studio
erikj
parents: 41040
diff changeset
   414
    #     cc: Studio 12.5 Sun C 5.14 SunOS_sparc 2016/05/31
22721
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   415
    COMPILER_VERSION_OUTPUT=`$COMPILER -V 2>&1`
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   416
    # Check that this is likely to be the Solaris Studio cc.
42294
d8c997ec29fe 8164304: JDK should build with Oracle Developer Studio
erikj
parents: 41040
diff changeset
   417
    $ECHO "$COMPILER_VERSION_OUTPUT" | $GREP "^.* Sun $COMPILER_NAME" > /dev/null
14111
2a82ecb35fc7 8000992: Update new build-infra makefiles
ohair
parents: 13697
diff changeset
   418
    if test $? -ne 0; then
22721
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   419
      ALT_VERSION_OUTPUT=`$COMPILER --version 2>&1`
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   420
      AC_MSG_NOTICE([The $COMPILER_NAME compiler (located as $COMPILER) does not seem to be the required $TOOLCHAIN_TYPE compiler.])
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   421
      AC_MSG_NOTICE([The result from running with -V was: "$COMPILER_VERSION_OUTPUT"])
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   422
      AC_MSG_NOTICE([The result from running with --version was: "$ALT_VERSION_OUTPUT"])
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   423
      AC_MSG_ERROR([A $TOOLCHAIN_TYPE compiler is required. Try setting --with-tools-dir.])
14111
2a82ecb35fc7 8000992: Update new build-infra makefiles
ohair
parents: 13697
diff changeset
   424
    fi
24911
a039e17f8896 8032045: Enable compiler and linker safety switches for debug builds
mduigou
parents: 23429
diff changeset
   425
    # Remove usage instructions (if present), and
22721
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   426
    # collapse compiler output into a single line
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   427
    COMPILER_VERSION_STRING=`$ECHO $COMPILER_VERSION_OUTPUT | \
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   428
        $SED -e 's/ *@<:@Uu@:>@sage:.*//'`
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   429
    COMPILER_VERSION_NUMBER=`$ECHO $COMPILER_VERSION_OUTPUT | \
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   430
        $SED -e "s/^.*@<:@ ,\t@:>@$COMPILER_NAME@<:@ ,\t@:>@\(@<:@1-9@:>@\.@<:@0-9@:>@@<:@0-9@:>@*\).*/\1/"`
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   431
  elif test  "x$TOOLCHAIN_TYPE" = xxlc; then
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   432
    # xlc -qversion output typically looks like
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   433
    #     IBM XL C/C++ for AIX, V11.1 (5724-X13)
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   434
    #     Version: 11.01.0000.0015
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   435
    COMPILER_VERSION_OUTPUT=`$COMPILER -qversion 2>&1`
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   436
    # Check that this is likely to be the IBM XL C compiler.
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   437
    $ECHO "$COMPILER_VERSION_OUTPUT" | $GREP "IBM XL C" > /dev/null
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   438
    if test $? -ne 0; then
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   439
      ALT_VERSION_OUTPUT=`$COMPILER --version 2>&1`
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   440
      AC_MSG_NOTICE([The $COMPILER_NAME compiler (located as $COMPILER) does not seem to be the required $TOOLCHAIN_TYPE compiler.])
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   441
      AC_MSG_NOTICE([The result from running with -qversion was: "$COMPILER_VERSION_OUTPUT"])
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   442
      AC_MSG_NOTICE([The result from running with --version was: "$ALT_VERSION_OUTPUT"])
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   443
      AC_MSG_ERROR([A $TOOLCHAIN_TYPE compiler is required. Try setting --with-tools-dir.])
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   444
    fi
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   445
    # Collapse compiler output into a single line
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   446
    COMPILER_VERSION_STRING=`$ECHO $COMPILER_VERSION_OUTPUT`
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   447
    COMPILER_VERSION_NUMBER=`$ECHO $COMPILER_VERSION_OUTPUT | \
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   448
        $SED -e 's/^.*, V\(@<:@1-9@:>@@<:@0-9.@:>@*\).*$/\1/'`
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   449
  elif test  "x$TOOLCHAIN_TYPE" = xmicrosoft; then
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   450
    # There is no specific version flag, but all output starts with a version string.
14111
2a82ecb35fc7 8000992: Update new build-infra makefiles
ohair
parents: 13697
diff changeset
   451
    # First line typically looks something like:
20362
5f8289bfda3e 8023611: Win32 and win64: Remove all the WARNINGS in JDK 8 builds for Windows 2008 and MSVS 2010 SP1
tbell
parents: 19763
diff changeset
   452
    # Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 16.00.40219.01 for 80x86
53110
50677f43ac3d 8215445: Enable building for Windows in WSL
erikj
parents: 51856
diff changeset
   453
    COMPILER_VERSION_OUTPUT=`"$COMPILER" 2>&1 | $GREP -v 'ERROR.*UtilTranslatePathList' | $HEAD -n 1 | $TR -d '\r'`
22721
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   454
    # Check that this is likely to be Microsoft CL.EXE.
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   455
    $ECHO "$COMPILER_VERSION_OUTPUT" | $GREP "Microsoft.*Compiler" > /dev/null
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   456
    if test $? -ne 0; then
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   457
      AC_MSG_NOTICE([The $COMPILER_NAME compiler (located as $COMPILER) does not seem to be the required $TOOLCHAIN_TYPE compiler.])
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   458
      AC_MSG_NOTICE([The result from running it was: "$COMPILER_VERSION_OUTPUT"])
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   459
      AC_MSG_ERROR([A $TOOLCHAIN_TYPE compiler is required. Try setting --with-tools-dir.])
14111
2a82ecb35fc7 8000992: Update new build-infra makefiles
ohair
parents: 13697
diff changeset
   460
    fi
22721
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   461
    # Collapse compiler output into a single line
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   462
    COMPILER_VERSION_STRING=`$ECHO $COMPILER_VERSION_OUTPUT`
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   463
    COMPILER_VERSION_NUMBER=`$ECHO $COMPILER_VERSION_OUTPUT | \
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   464
        $SED -e 's/^.*ersion.\(@<:@1-9@:>@@<:@0-9.@:>@*\) .*$/\1/'`
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   465
  elif test  "x$TOOLCHAIN_TYPE" = xgcc; then
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   466
    # gcc --version output typically looks like
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   467
    #     gcc (Ubuntu/Linaro 4.8.1-10ubuntu9) 4.8.1
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   468
    #     Copyright (C) 2013 Free Software Foundation, Inc.
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   469
    #     This is free software; see the source for copying conditions.  There is NO
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   470
    #     warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   471
    COMPILER_VERSION_OUTPUT=`$COMPILER --version 2>&1`
14111
2a82ecb35fc7 8000992: Update new build-infra makefiles
ohair
parents: 13697
diff changeset
   472
    # Check that this is likely to be GCC.
22721
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   473
    $ECHO "$COMPILER_VERSION_OUTPUT" | $GREP "Free Software Foundation" > /dev/null
14111
2a82ecb35fc7 8000992: Update new build-infra makefiles
ohair
parents: 13697
diff changeset
   474
    if test $? -ne 0; then
22721
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   475
      AC_MSG_NOTICE([The $COMPILER_NAME compiler (located as $COMPILER) does not seem to be the required $TOOLCHAIN_TYPE compiler.])
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   476
      AC_MSG_NOTICE([The result from running with --version was: "$COMPILER_VERSION"])
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   477
      AC_MSG_ERROR([A $TOOLCHAIN_TYPE compiler is required. Try setting --with-tools-dir.])
13697
5262b00bc10c 7197849: Update new build-infra makefiles
ohair
parents: 13133
diff changeset
   478
    fi
22721
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   479
    # Remove Copyright and legalese from version string, and
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   480
    # collapse into a single line
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   481
    COMPILER_VERSION_STRING=`$ECHO $COMPILER_VERSION_OUTPUT | \
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   482
        $SED -e 's/ *Copyright .*//'`
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   483
    COMPILER_VERSION_NUMBER=`$ECHO $COMPILER_VERSION_OUTPUT | \
59041
d6d8fdc95ed2 8233880: Support compilers with multi-digit major version numbers
fweimer
parents: 57975
diff changeset
   484
        $SED -e 's/^.* \(@<:@1-9@:>@<:@0-9@:>@*\.@<:@0-9.@:>@*\)@<:@^0-9.@:>@.*$/\1/'`
22721
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   485
  elif test  "x$TOOLCHAIN_TYPE" = xclang; then
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   486
    # clang --version output typically looks like
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   487
    #    Apple LLVM version 5.0 (clang-500.2.79) (based on LLVM 3.3svn)
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   488
    #    clang version 3.3 (tags/RELEASE_33/final)
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   489
    # or
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   490
    #    Debian clang version 3.2-7ubuntu1 (tags/RELEASE_32/final) (based on LLVM 3.2)
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   491
    #    Target: x86_64-pc-linux-gnu
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   492
    #    Thread model: posix
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   493
    COMPILER_VERSION_OUTPUT=`$COMPILER --version 2>&1`
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   494
    # Check that this is likely to be clang
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   495
    $ECHO "$COMPILER_VERSION_OUTPUT" | $GREP "clang" > /dev/null
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   496
    if test $? -ne 0; then
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   497
      AC_MSG_NOTICE([The $COMPILER_NAME compiler (located as $COMPILER) does not seem to be the required $TOOLCHAIN_TYPE compiler.])
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   498
      AC_MSG_NOTICE([The result from running with --version was: "$COMPILER_VERSION_OUTPUT"])
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   499
      AC_MSG_ERROR([A $TOOLCHAIN_TYPE compiler is required. Try setting --with-tools-dir.])
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   500
    fi
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   501
    # Collapse compiler output into a single line
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   502
    COMPILER_VERSION_STRING=`$ECHO $COMPILER_VERSION_OUTPUT`
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   503
    COMPILER_VERSION_NUMBER=`$ECHO $COMPILER_VERSION_OUTPUT | \
35747
aeaa6d0101a8 8149647: Incremental enhancements from build-infra
ihse
parents: 35371
diff changeset
   504
        $SED -e 's/^.* version \(@<:@1-9@:>@@<:@0-9.@:>@*\).*$/\1/'`
22721
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   505
  else
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   506
      AC_MSG_ERROR([Unknown toolchain type $TOOLCHAIN_TYPE.])
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   507
  fi
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   508
  # This sets CC_VERSION_NUMBER or CXX_VERSION_NUMBER. (This comment is a grep marker)
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   509
  $1_VERSION_NUMBER="$COMPILER_VERSION_NUMBER"
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   510
  # This sets CC_VERSION_STRING or CXX_VERSION_STRING. (This comment is a grep marker)
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   511
  $1_VERSION_STRING="$COMPILER_VERSION_STRING"
17664
2cb42641740b 8015510: (s) Improve JTReg location detection and provide location to test/Makefile
mduigou
parents: 17593
diff changeset
   512
22721
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   513
  AC_MSG_NOTICE([Using $TOOLCHAIN_TYPE $COMPILER_NAME compiler version $COMPILER_VERSION_NUMBER @<:@$COMPILER_VERSION_STRING@:>@])
13133
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
   514
])
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
   515
22721
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   516
# Try to locate the given C or C++ compiler in the path, or otherwise.
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   517
#
14111
2a82ecb35fc7 8000992: Update new build-infra makefiles
ohair
parents: 13697
diff changeset
   518
# $1 = compiler to test (CC or CXX)
2a82ecb35fc7 8000992: Update new build-infra makefiles
ohair
parents: 13697
diff changeset
   519
# $2 = human readable name of compiler (C or C++)
43918
6d31a727d6c1 8077113: Configure script do not properly detect cross-compilation gcc
erikj
parents: 42297
diff changeset
   520
# $3 = compiler name to search for
14111
2a82ecb35fc7 8000992: Update new build-infra makefiles
ohair
parents: 13697
diff changeset
   521
AC_DEFUN([TOOLCHAIN_FIND_COMPILER],
13133
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
   522
[
14111
2a82ecb35fc7 8000992: Update new build-infra makefiles
ohair
parents: 13697
diff changeset
   523
  COMPILER_NAME=$2
22458
6a74da13c52f 8022411: Allow overriding of CXX and CC with absolute path
ihse
parents: 22179
diff changeset
   524
  SEARCH_LIST="$3"
14111
2a82ecb35fc7 8000992: Update new build-infra makefiles
ohair
parents: 13697
diff changeset
   525
22458
6a74da13c52f 8022411: Allow overriding of CXX and CC with absolute path
ihse
parents: 22179
diff changeset
   526
  if test "x[$]$1" != x; then
6a74da13c52f 8022411: Allow overriding of CXX and CC with absolute path
ihse
parents: 22179
diff changeset
   527
    # User has supplied compiler name already, always let that override.
6a74da13c52f 8022411: Allow overriding of CXX and CC with absolute path
ihse
parents: 22179
diff changeset
   528
    AC_MSG_NOTICE([Will use user supplied compiler $1=[$]$1])
6a74da13c52f 8022411: Allow overriding of CXX and CC with absolute path
ihse
parents: 22179
diff changeset
   529
    if test "x`basename [$]$1`" = "x[$]$1"; then
6a74da13c52f 8022411: Allow overriding of CXX and CC with absolute path
ihse
parents: 22179
diff changeset
   530
      # A command without a complete path is provided, search $PATH.
24911
a039e17f8896 8032045: Enable compiler and linker safety switches for debug builds
mduigou
parents: 23429
diff changeset
   531
22458
6a74da13c52f 8022411: Allow overriding of CXX and CC with absolute path
ihse
parents: 22179
diff changeset
   532
      AC_PATH_PROGS(POTENTIAL_$1, [$]$1)
6a74da13c52f 8022411: Allow overriding of CXX and CC with absolute path
ihse
parents: 22179
diff changeset
   533
      if test "x$POTENTIAL_$1" != x; then
6a74da13c52f 8022411: Allow overriding of CXX and CC with absolute path
ihse
parents: 22179
diff changeset
   534
        $1=$POTENTIAL_$1
6a74da13c52f 8022411: Allow overriding of CXX and CC with absolute path
ihse
parents: 22179
diff changeset
   535
      else
6a74da13c52f 8022411: Allow overriding of CXX and CC with absolute path
ihse
parents: 22179
diff changeset
   536
        AC_MSG_ERROR([User supplied compiler $1=[$]$1 could not be found])
6a74da13c52f 8022411: Allow overriding of CXX and CC with absolute path
ihse
parents: 22179
diff changeset
   537
      fi
6a74da13c52f 8022411: Allow overriding of CXX and CC with absolute path
ihse
parents: 22179
diff changeset
   538
    else
6a74da13c52f 8022411: Allow overriding of CXX and CC with absolute path
ihse
parents: 22179
diff changeset
   539
      # Otherwise it might already be a complete path
6a74da13c52f 8022411: Allow overriding of CXX and CC with absolute path
ihse
parents: 22179
diff changeset
   540
      if test ! -x "[$]$1"; then
6a74da13c52f 8022411: Allow overriding of CXX and CC with absolute path
ihse
parents: 22179
diff changeset
   541
        AC_MSG_ERROR([User supplied compiler $1=[$]$1 does not exist])
6a74da13c52f 8022411: Allow overriding of CXX and CC with absolute path
ihse
parents: 22179
diff changeset
   542
      fi
6a74da13c52f 8022411: Allow overriding of CXX and CC with absolute path
ihse
parents: 22179
diff changeset
   543
    fi
6a74da13c52f 8022411: Allow overriding of CXX and CC with absolute path
ihse
parents: 22179
diff changeset
   544
  else
22721
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   545
    # No user supplied value. Locate compiler ourselves.
24911
a039e17f8896 8032045: Enable compiler and linker safety switches for debug builds
mduigou
parents: 23429
diff changeset
   546
22721
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   547
    # If we are cross compiling, assume cross compilation tools follows the
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   548
    # cross compilation standard where they are prefixed with the autoconf
24911
a039e17f8896 8032045: Enable compiler and linker safety switches for debug builds
mduigou
parents: 23429
diff changeset
   549
    # standard name for the target. For example the binary
22721
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   550
    # i686-sun-solaris2.10-gcc will cross compile for i686-sun-solaris2.10.
24911
a039e17f8896 8032045: Enable compiler and linker safety switches for debug builds
mduigou
parents: 23429
diff changeset
   551
    # If we are not cross compiling, then the default compiler name will be
22721
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   552
    # used.
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   553
22458
6a74da13c52f 8022411: Allow overriding of CXX and CC with absolute path
ihse
parents: 22179
diff changeset
   554
    $1=
23428
3c8a05bf4656 8038340: Cleanup and fix sysroot and devkit handling on Linux and Solaris
erikj
parents: 23161
diff changeset
   555
    # If TOOLCHAIN_PATH is set, check for all compiler names in there first
22458
6a74da13c52f 8022411: Allow overriding of CXX and CC with absolute path
ihse
parents: 22179
diff changeset
   556
    # before checking the rest of the PATH.
22721
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   557
    # FIXME: Now that we prefix the TOOLS_DIR to the PATH in the PRE_DETECTION
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   558
    # step, this should not be necessary.
23428
3c8a05bf4656 8038340: Cleanup and fix sysroot and devkit handling on Linux and Solaris
erikj
parents: 23161
diff changeset
   559
    if test -n "$TOOLCHAIN_PATH"; then
22458
6a74da13c52f 8022411: Allow overriding of CXX and CC with absolute path
ihse
parents: 22179
diff changeset
   560
      PATH_save="$PATH"
23428
3c8a05bf4656 8038340: Cleanup and fix sysroot and devkit handling on Linux and Solaris
erikj
parents: 23161
diff changeset
   561
      PATH="$TOOLCHAIN_PATH"
43918
6d31a727d6c1 8077113: Configure script do not properly detect cross-compilation gcc
erikj
parents: 42297
diff changeset
   562
      AC_PATH_TOOL(TOOLCHAIN_PATH_$1, $SEARCH_LIST)
23428
3c8a05bf4656 8038340: Cleanup and fix sysroot and devkit handling on Linux and Solaris
erikj
parents: 23161
diff changeset
   563
      $1=$TOOLCHAIN_PATH_$1
22458
6a74da13c52f 8022411: Allow overriding of CXX and CC with absolute path
ihse
parents: 22179
diff changeset
   564
      PATH="$PATH_save"
6a74da13c52f 8022411: Allow overriding of CXX and CC with absolute path
ihse
parents: 22179
diff changeset
   565
    fi
6a74da13c52f 8022411: Allow overriding of CXX and CC with absolute path
ihse
parents: 22179
diff changeset
   566
43918
6d31a727d6c1 8077113: Configure script do not properly detect cross-compilation gcc
erikj
parents: 42297
diff changeset
   567
    # AC_PATH_TOOL can't be run multiple times with the same variable,
22458
6a74da13c52f 8022411: Allow overriding of CXX and CC with absolute path
ihse
parents: 22179
diff changeset
   568
    # so create a new name for this run.
6a74da13c52f 8022411: Allow overriding of CXX and CC with absolute path
ihse
parents: 22179
diff changeset
   569
    if test "x[$]$1" = x; then
43918
6d31a727d6c1 8077113: Configure script do not properly detect cross-compilation gcc
erikj
parents: 42297
diff changeset
   570
      AC_PATH_TOOL(POTENTIAL_$1, $SEARCH_LIST)
22458
6a74da13c52f 8022411: Allow overriding of CXX and CC with absolute path
ihse
parents: 22179
diff changeset
   571
      $1=$POTENTIAL_$1
6a74da13c52f 8022411: Allow overriding of CXX and CC with absolute path
ihse
parents: 22179
diff changeset
   572
    fi
6a74da13c52f 8022411: Allow overriding of CXX and CC with absolute path
ihse
parents: 22179
diff changeset
   573
6a74da13c52f 8022411: Allow overriding of CXX and CC with absolute path
ihse
parents: 22179
diff changeset
   574
    if test "x[$]$1" = x; then
6a74da13c52f 8022411: Allow overriding of CXX and CC with absolute path
ihse
parents: 22179
diff changeset
   575
      HELP_MSG_MISSING_DEPENDENCY([devkit])
6a74da13c52f 8022411: Allow overriding of CXX and CC with absolute path
ihse
parents: 22179
diff changeset
   576
      AC_MSG_ERROR([Could not find a $COMPILER_NAME compiler. $HELP_MSG])
6a74da13c52f 8022411: Allow overriding of CXX and CC with absolute path
ihse
parents: 22179
diff changeset
   577
    fi
14614
3bb0a6b81bb9 8003945: build-infra: problems finding compiler when using --with-dev-kit
erikj
parents: 14467
diff changeset
   578
  fi
3bb0a6b81bb9 8003945: build-infra: problems finding compiler when using --with-dev-kit
erikj
parents: 14467
diff changeset
   579
22458
6a74da13c52f 8022411: Allow overriding of CXX and CC with absolute path
ihse
parents: 22179
diff changeset
   580
  # Now we have a compiler binary in $1. Make sure it's okay.
14111
2a82ecb35fc7 8000992: Update new build-infra makefiles
ohair
parents: 13697
diff changeset
   581
  BASIC_FIXUP_EXECUTABLE($1)
2a82ecb35fc7 8000992: Update new build-infra makefiles
ohair
parents: 13697
diff changeset
   582
  TEST_COMPILER="[$]$1"
2a82ecb35fc7 8000992: Update new build-infra makefiles
ohair
parents: 13697
diff changeset
   583
35371
7deccee1f94e 8148351: Only display resolved symlink for compiler, do not change path
ihse
parents: 34923
diff changeset
   584
  AC_MSG_CHECKING([resolved symbolic links for $1])
7deccee1f94e 8148351: Only display resolved symlink for compiler, do not change path
ihse
parents: 34923
diff changeset
   585
  SYMLINK_ORIGINAL="$TEST_COMPILER"
7deccee1f94e 8148351: Only display resolved symlink for compiler, do not change path
ihse
parents: 34923
diff changeset
   586
  BASIC_REMOVE_SYMBOLIC_LINKS(SYMLINK_ORIGINAL)
7deccee1f94e 8148351: Only display resolved symlink for compiler, do not change path
ihse
parents: 34923
diff changeset
   587
  if test "x$TEST_COMPILER" = "x$SYMLINK_ORIGINAL"; then
7deccee1f94e 8148351: Only display resolved symlink for compiler, do not change path
ihse
parents: 34923
diff changeset
   588
    AC_MSG_RESULT([no symlink])
7deccee1f94e 8148351: Only display resolved symlink for compiler, do not change path
ihse
parents: 34923
diff changeset
   589
  else
7deccee1f94e 8148351: Only display resolved symlink for compiler, do not change path
ihse
parents: 34923
diff changeset
   590
    AC_MSG_RESULT([$SYMLINK_ORIGINAL])
14111
2a82ecb35fc7 8000992: Update new build-infra makefiles
ohair
parents: 13697
diff changeset
   591
35371
7deccee1f94e 8148351: Only display resolved symlink for compiler, do not change path
ihse
parents: 34923
diff changeset
   592
    # We can't handle ccache by gcc wrappers, since we need to know if we're
7deccee1f94e 8148351: Only display resolved symlink for compiler, do not change path
ihse
parents: 34923
diff changeset
   593
    # using ccache. Instead ccache usage must be controlled by a configure option.
7deccee1f94e 8148351: Only display resolved symlink for compiler, do not change path
ihse
parents: 34923
diff changeset
   594
    COMPILER_BASENAME=`$BASENAME "$SYMLINK_ORIGINAL"`
7deccee1f94e 8148351: Only display resolved symlink for compiler, do not change path
ihse
parents: 34923
diff changeset
   595
    if test "x$COMPILER_BASENAME" = "xccache"; then
7deccee1f94e 8148351: Only display resolved symlink for compiler, do not change path
ihse
parents: 34923
diff changeset
   596
      AC_MSG_NOTICE([Please use --enable-ccache instead of providing a wrapped compiler.])
7deccee1f94e 8148351: Only display resolved symlink for compiler, do not change path
ihse
parents: 34923
diff changeset
   597
      AC_MSG_ERROR([$TEST_COMPILER is a symbolic link to ccache. This is not supported.])
7deccee1f94e 8148351: Only display resolved symlink for compiler, do not change path
ihse
parents: 34923
diff changeset
   598
    fi
14111
2a82ecb35fc7 8000992: Update new build-infra makefiles
ohair
parents: 13697
diff changeset
   599
  fi
22179
59d2bd4620b0 8031668: TOOLCHAIN_FIND_COMPILER unexpectedly resolves symbolic links
mduigou
parents: 22035
diff changeset
   600
35747
aeaa6d0101a8 8149647: Incremental enhancements from build-infra
ihse
parents: 35371
diff changeset
   601
  TOOLCHAIN_EXTRACT_COMPILER_VERSION([$1], [$COMPILER_NAME])
14111
2a82ecb35fc7 8000992: Update new build-infra makefiles
ohair
parents: 13697
diff changeset
   602
])
2a82ecb35fc7 8000992: Update new build-infra makefiles
ohair
parents: 13697
diff changeset
   603
49199
986249df86ce 8199403: Require binutils 2.18 or newer
ihse
parents: 49120
diff changeset
   604
# Retrieve the linker version number and store it in LD_VERSION_NUMBER
986249df86ce 8199403: Require binutils 2.18 or newer
ihse
parents: 49120
diff changeset
   605
# (as a dotted number), and
986249df86ce 8199403: Require binutils 2.18 or newer
ihse
parents: 49120
diff changeset
   606
# the full version string in LD_VERSION_STRING.
986249df86ce 8199403: Require binutils 2.18 or newer
ihse
parents: 49120
diff changeset
   607
#
986249df86ce 8199403: Require binutils 2.18 or newer
ihse
parents: 49120
diff changeset
   608
# $1 = linker to test (LD or BUILD_LD)
986249df86ce 8199403: Require binutils 2.18 or newer
ihse
parents: 49120
diff changeset
   609
# $2 = human readable name of linker (Linker or BuildLinker)
986249df86ce 8199403: Require binutils 2.18 or newer
ihse
parents: 49120
diff changeset
   610
AC_DEFUN([TOOLCHAIN_EXTRACT_LD_VERSION],
986249df86ce 8199403: Require binutils 2.18 or newer
ihse
parents: 49120
diff changeset
   611
[
986249df86ce 8199403: Require binutils 2.18 or newer
ihse
parents: 49120
diff changeset
   612
  LINKER=[$]$1
53643
1126811a5124 8160926: FLAGS_COMPILER_CHECK_ARGUMENTS doesn't handle cross-compilation
erikj
parents: 53460
diff changeset
   613
  LINKER_NAME="$2"
49199
986249df86ce 8199403: Require binutils 2.18 or newer
ihse
parents: 49120
diff changeset
   614
986249df86ce 8199403: Require binutils 2.18 or newer
ihse
parents: 49120
diff changeset
   615
  if test "x$TOOLCHAIN_TYPE" = xsolstudio; then
986249df86ce 8199403: Require binutils 2.18 or newer
ihse
parents: 49120
diff changeset
   616
    # cc -Wl,-V output typically looks like
986249df86ce 8199403: Require binutils 2.18 or newer
ihse
parents: 49120
diff changeset
   617
    #   ld: Software Generation Utilities - Solaris Link Editors: 5.11-1.2329
986249df86ce 8199403: Require binutils 2.18 or newer
ihse
parents: 49120
diff changeset
   618
986249df86ce 8199403: Require binutils 2.18 or newer
ihse
parents: 49120
diff changeset
   619
    # solstudio cc requires us to have an existing file to pass as argument,
986249df86ce 8199403: Require binutils 2.18 or newer
ihse
parents: 49120
diff changeset
   620
    # but it need not be a syntactically correct C file, so just use
49514
25695fce1601 8200267: a.out created at top dir by Solaris build
ihse
parents: 49412
diff changeset
   621
    # ourself. :) The intermediate 'cat' is needed to stop ld from leaving
25695fce1601 8200267: a.out created at top dir by Solaris build
ihse
parents: 49412
diff changeset
   622
    # a lingering a.out (!).
25695fce1601 8200267: a.out created at top dir by Solaris build
ihse
parents: 49412
diff changeset
   623
    LINKER_VERSION_STRING=`$LD -Wl,-V $TOPDIR/configure 2>&1 | $CAT | $HEAD -n 1 | $SED -e 's/ld: //'`
49199
986249df86ce 8199403: Require binutils 2.18 or newer
ihse
parents: 49120
diff changeset
   624
    # Extract version number
986249df86ce 8199403: Require binutils 2.18 or newer
ihse
parents: 49120
diff changeset
   625
    [ LINKER_VERSION_NUMBER=`$ECHO $LINKER_VERSION_STRING | \
986249df86ce 8199403: Require binutils 2.18 or newer
ihse
parents: 49120
diff changeset
   626
        $SED -e 's/.* \([0-9][0-9]*\.[0-9][0-9]*\)-\([0-9][0-9]*\.[0-9][0-9]*\)/\1.\2/'` ]
986249df86ce 8199403: Require binutils 2.18 or newer
ihse
parents: 49120
diff changeset
   627
  elif test  "x$TOOLCHAIN_TYPE" = xxlc; then
986249df86ce 8199403: Require binutils 2.18 or newer
ihse
parents: 49120
diff changeset
   628
    LINKER_VERSION_STRING="Unknown"
986249df86ce 8199403: Require binutils 2.18 or newer
ihse
parents: 49120
diff changeset
   629
    LINKER_VERSION_NUMBER="0.0"
986249df86ce 8199403: Require binutils 2.18 or newer
ihse
parents: 49120
diff changeset
   630
  elif test  "x$TOOLCHAIN_TYPE" = xmicrosoft; then
986249df86ce 8199403: Require binutils 2.18 or newer
ihse
parents: 49120
diff changeset
   631
    # There is no specific version flag, but all output starts with a version string.
986249df86ce 8199403: Require binutils 2.18 or newer
ihse
parents: 49120
diff changeset
   632
    # First line typically looks something like:
986249df86ce 8199403: Require binutils 2.18 or newer
ihse
parents: 49120
diff changeset
   633
    #   Microsoft (R) Incremental Linker Version 12.00.31101.0
986249df86ce 8199403: Require binutils 2.18 or newer
ihse
parents: 49120
diff changeset
   634
    LINKER_VERSION_STRING=`$LD 2>&1 | $HEAD -n 1 | $TR -d '\r'`
986249df86ce 8199403: Require binutils 2.18 or newer
ihse
parents: 49120
diff changeset
   635
    # Extract version number
986249df86ce 8199403: Require binutils 2.18 or newer
ihse
parents: 49120
diff changeset
   636
    [ LINKER_VERSION_NUMBER=`$ECHO $LINKER_VERSION_STRING | \
986249df86ce 8199403: Require binutils 2.18 or newer
ihse
parents: 49120
diff changeset
   637
        $SED -e 's/.* \([0-9][0-9]*\(\.[0-9][0-9]*\)*\).*/\1/'` ]
986249df86ce 8199403: Require binutils 2.18 or newer
ihse
parents: 49120
diff changeset
   638
  elif test  "x$TOOLCHAIN_TYPE" = xgcc; then
54148
62e4ada7c4c8 8220093: Change to GCC 8.2 for building on Linux at Oracle
erikj
parents: 53837
diff changeset
   639
    # gcc -Wl,-version output typically looks like:
49199
986249df86ce 8199403: Require binutils 2.18 or newer
ihse
parents: 49120
diff changeset
   640
    #   GNU ld (GNU Binutils for Ubuntu) 2.26.1
986249df86ce 8199403: Require binutils 2.18 or newer
ihse
parents: 49120
diff changeset
   641
    #   Copyright (C) 2015 Free Software Foundation, Inc.
986249df86ce 8199403: Require binutils 2.18 or newer
ihse
parents: 49120
diff changeset
   642
    #   This program is free software; [...]
54148
62e4ada7c4c8 8220093: Change to GCC 8.2 for building on Linux at Oracle
erikj
parents: 53837
diff changeset
   643
    # If using gold it will look like:
62e4ada7c4c8 8220093: Change to GCC 8.2 for building on Linux at Oracle
erikj
parents: 53837
diff changeset
   644
    #   GNU gold (GNU Binutils 2.30) 1.15
62e4ada7c4c8 8220093: Change to GCC 8.2 for building on Linux at Oracle
erikj
parents: 53837
diff changeset
   645
    LINKER_VERSION_STRING=`$LD -Wl,--version 2> /dev/null | $HEAD -n 1`
49199
986249df86ce 8199403: Require binutils 2.18 or newer
ihse
parents: 49120
diff changeset
   646
    # Extract version number
54148
62e4ada7c4c8 8220093: Change to GCC 8.2 for building on Linux at Oracle
erikj
parents: 53837
diff changeset
   647
    if [ [[ "$LINKER_VERSION_STRING" == *gold* ]] ]; then
62e4ada7c4c8 8220093: Change to GCC 8.2 for building on Linux at Oracle
erikj
parents: 53837
diff changeset
   648
      [ LINKER_VERSION_NUMBER=`$ECHO $LINKER_VERSION_STRING | \
62e4ada7c4c8 8220093: Change to GCC 8.2 for building on Linux at Oracle
erikj
parents: 53837
diff changeset
   649
          $SED -e 's/.* \([0-9][0-9]*\(\.[0-9][0-9]*\)*\).*) .*/\1/'` ]
62e4ada7c4c8 8220093: Change to GCC 8.2 for building on Linux at Oracle
erikj
parents: 53837
diff changeset
   650
    else
62e4ada7c4c8 8220093: Change to GCC 8.2 for building on Linux at Oracle
erikj
parents: 53837
diff changeset
   651
      [ LINKER_VERSION_NUMBER=`$ECHO $LINKER_VERSION_STRING | \
62e4ada7c4c8 8220093: Change to GCC 8.2 for building on Linux at Oracle
erikj
parents: 53837
diff changeset
   652
          $SED -e 's/.* \([0-9][0-9]*\(\.[0-9][0-9]*\)*\).*/\1/'` ]
62e4ada7c4c8 8220093: Change to GCC 8.2 for building on Linux at Oracle
erikj
parents: 53837
diff changeset
   653
    fi
49199
986249df86ce 8199403: Require binutils 2.18 or newer
ihse
parents: 49120
diff changeset
   654
  elif test  "x$TOOLCHAIN_TYPE" = xclang; then
986249df86ce 8199403: Require binutils 2.18 or newer
ihse
parents: 49120
diff changeset
   655
    # clang -Wl,-v output typically looks like
986249df86ce 8199403: Require binutils 2.18 or newer
ihse
parents: 49120
diff changeset
   656
    #   @(#)PROGRAM:ld  PROJECT:ld64-305
986249df86ce 8199403: Require binutils 2.18 or newer
ihse
parents: 49120
diff changeset
   657
    #   configured to support archs: armv6 armv7 armv7s arm64 i386 x86_64 x86_64h armv6m armv7k armv7m armv7em (tvOS)
986249df86ce 8199403: Require binutils 2.18 or newer
ihse
parents: 49120
diff changeset
   658
    #   Library search paths: [...]
986249df86ce 8199403: Require binutils 2.18 or newer
ihse
parents: 49120
diff changeset
   659
    # or
986249df86ce 8199403: Require binutils 2.18 or newer
ihse
parents: 49120
diff changeset
   660
    #   GNU ld (GNU Binutils for Ubuntu) 2.26.1
986249df86ce 8199403: Require binutils 2.18 or newer
ihse
parents: 49120
diff changeset
   661
986249df86ce 8199403: Require binutils 2.18 or newer
ihse
parents: 49120
diff changeset
   662
    LINKER_VERSION_STRING=`$LD -Wl,-v 2>&1 | $HEAD -n 1`
986249df86ce 8199403: Require binutils 2.18 or newer
ihse
parents: 49120
diff changeset
   663
    # Check if we're using the GNU ld
986249df86ce 8199403: Require binutils 2.18 or newer
ihse
parents: 49120
diff changeset
   664
    $ECHO "$LINKER_VERSION_STRING" | $GREP "GNU" > /dev/null
986249df86ce 8199403: Require binutils 2.18 or newer
ihse
parents: 49120
diff changeset
   665
    if test $? -eq 0; then
986249df86ce 8199403: Require binutils 2.18 or newer
ihse
parents: 49120
diff changeset
   666
      # Extract version number
986249df86ce 8199403: Require binutils 2.18 or newer
ihse
parents: 49120
diff changeset
   667
      [ LINKER_VERSION_NUMBER=`$ECHO $LINKER_VERSION_STRING | \
986249df86ce 8199403: Require binutils 2.18 or newer
ihse
parents: 49120
diff changeset
   668
          $SED -e 's/.* \([0-9][0-9]*\(\.[0-9][0-9]*\)*\).*/\1/'` ]
986249df86ce 8199403: Require binutils 2.18 or newer
ihse
parents: 49120
diff changeset
   669
    else
986249df86ce 8199403: Require binutils 2.18 or newer
ihse
parents: 49120
diff changeset
   670
      # Extract version number
986249df86ce 8199403: Require binutils 2.18 or newer
ihse
parents: 49120
diff changeset
   671
      [ LINKER_VERSION_NUMBER=`$ECHO $LINKER_VERSION_STRING | \
986249df86ce 8199403: Require binutils 2.18 or newer
ihse
parents: 49120
diff changeset
   672
          $SED -e 's/.*-\([0-9][0-9]*\)/\1/'` ]
986249df86ce 8199403: Require binutils 2.18 or newer
ihse
parents: 49120
diff changeset
   673
    fi
986249df86ce 8199403: Require binutils 2.18 or newer
ihse
parents: 49120
diff changeset
   674
  fi
986249df86ce 8199403: Require binutils 2.18 or newer
ihse
parents: 49120
diff changeset
   675
986249df86ce 8199403: Require binutils 2.18 or newer
ihse
parents: 49120
diff changeset
   676
  $1_VERSION_NUMBER="$LINKER_VERSION_NUMBER"
986249df86ce 8199403: Require binutils 2.18 or newer
ihse
parents: 49120
diff changeset
   677
  $1_VERSION_STRING="$LINKER_VERSION_STRING"
986249df86ce 8199403: Require binutils 2.18 or newer
ihse
parents: 49120
diff changeset
   678
986249df86ce 8199403: Require binutils 2.18 or newer
ihse
parents: 49120
diff changeset
   679
  AC_MSG_NOTICE([Using $TOOLCHAIN_TYPE $LINKER_NAME version $LINKER_VERSION_NUMBER @<:@$LINKER_VERSION_STRING@:>@])
986249df86ce 8199403: Require binutils 2.18 or newer
ihse
parents: 49120
diff changeset
   680
])
986249df86ce 8199403: Require binutils 2.18 or newer
ihse
parents: 49120
diff changeset
   681
24911
a039e17f8896 8032045: Enable compiler and linker safety switches for debug builds
mduigou
parents: 23429
diff changeset
   682
# Detect the core components of the toolchain, i.e. the compilers (CC and CXX),
a039e17f8896 8032045: Enable compiler and linker safety switches for debug builds
mduigou
parents: 23429
diff changeset
   683
# preprocessor (CPP and CXXCPP), the linker (LD), the assembler (AS) and the
a039e17f8896 8032045: Enable compiler and linker safety switches for debug builds
mduigou
parents: 23429
diff changeset
   684
# archiver (AR). Verify that the compilers are correct according to the
22721
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   685
# toolchain type.
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   686
AC_DEFUN_ONCE([TOOLCHAIN_DETECT_TOOLCHAIN_CORE],
14111
2a82ecb35fc7 8000992: Update new build-infra makefiles
ohair
parents: 13697
diff changeset
   687
[
22721
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   688
  #
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   689
  # Setup the compilers (CC and CXX)
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   690
  #
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   691
  TOOLCHAIN_FIND_COMPILER([CC], [C], $TOOLCHAIN_CC_BINARY)
20363
fa7663fc5d50 8001931: The new build system whitespace cleanup
ihse
parents: 20362
diff changeset
   692
  # Now that we have resolved CC ourself, let autoconf have its go at it
fa7663fc5d50 8001931: The new build system whitespace cleanup
ihse
parents: 20362
diff changeset
   693
  AC_PROG_CC([$CC])
14111
2a82ecb35fc7 8000992: Update new build-infra makefiles
ohair
parents: 13697
diff changeset
   694
22721
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   695
  TOOLCHAIN_FIND_COMPILER([CXX], [C++], $TOOLCHAIN_CXX_BINARY)
20363
fa7663fc5d50 8001931: The new build system whitespace cleanup
ihse
parents: 20362
diff changeset
   696
  # Now that we have resolved CXX ourself, let autoconf have its go at it
fa7663fc5d50 8001931: The new build system whitespace cleanup
ihse
parents: 20362
diff changeset
   697
  AC_PROG_CXX([$CXX])
14111
2a82ecb35fc7 8000992: Update new build-infra makefiles
ohair
parents: 13697
diff changeset
   698
35747
aeaa6d0101a8 8149647: Incremental enhancements from build-infra
ihse
parents: 35371
diff changeset
   699
  # This is the compiler version number on the form X.Y[.Z]
aeaa6d0101a8 8149647: Incremental enhancements from build-infra
ihse
parents: 35371
diff changeset
   700
  AC_SUBST(CC_VERSION_NUMBER)
aeaa6d0101a8 8149647: Incremental enhancements from build-infra
ihse
parents: 35371
diff changeset
   701
  AC_SUBST(CXX_VERSION_NUMBER)
aeaa6d0101a8 8149647: Incremental enhancements from build-infra
ihse
parents: 35371
diff changeset
   702
aeaa6d0101a8 8149647: Incremental enhancements from build-infra
ihse
parents: 35371
diff changeset
   703
  TOOLCHAIN_PREPARE_FOR_VERSION_COMPARISONS
aeaa6d0101a8 8149647: Incremental enhancements from build-infra
ihse
parents: 35371
diff changeset
   704
aeaa6d0101a8 8149647: Incremental enhancements from build-infra
ihse
parents: 35371
diff changeset
   705
  if test "x$TOOLCHAIN_MINIMUM_VERSION" != x; then
aeaa6d0101a8 8149647: Incremental enhancements from build-infra
ihse
parents: 35371
diff changeset
   706
    TOOLCHAIN_CHECK_COMPILER_VERSION(VERSION: $TOOLCHAIN_MINIMUM_VERSION,
aeaa6d0101a8 8149647: Incremental enhancements from build-infra
ihse
parents: 35371
diff changeset
   707
        IF_OLDER_THAN: [
aeaa6d0101a8 8149647: Incremental enhancements from build-infra
ihse
parents: 35371
diff changeset
   708
          AC_MSG_WARN([You are using $TOOLCHAIN_TYPE older than $TOOLCHAIN_MINIMUM_VERSION. This is not a supported configuration.])
aeaa6d0101a8 8149647: Incremental enhancements from build-infra
ihse
parents: 35371
diff changeset
   709
        ]
aeaa6d0101a8 8149647: Incremental enhancements from build-infra
ihse
parents: 35371
diff changeset
   710
    )
aeaa6d0101a8 8149647: Incremental enhancements from build-infra
ihse
parents: 35371
diff changeset
   711
  fi
aeaa6d0101a8 8149647: Incremental enhancements from build-infra
ihse
parents: 35371
diff changeset
   712
22721
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   713
  #
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   714
  # Setup the preprocessor (CPP and CXXCPP)
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   715
  #
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   716
  AC_PROG_CPP
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   717
  BASIC_FIXUP_EXECUTABLE(CPP)
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   718
  AC_PROG_CXXCPP
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   719
  BASIC_FIXUP_EXECUTABLE(CXXCPP)
13133
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
   720
22721
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   721
  #
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   722
  # Setup the linker (LD)
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   723
  #
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   724
  if test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   725
    # In the Microsoft toolchain we have a separate LD command "link".
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   726
    # Make sure we reject /usr/bin/link (as determined in CYGWIN_LINK), which is
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   727
    # a cygwin program for something completely different.
53110
50677f43ac3d 8215445: Enable building for Windows in WSL
erikj
parents: 51856
diff changeset
   728
    AC_CHECK_PROG([LD], [link$EXE_SUFFIX],[link$EXE_SUFFIX],,, [$CYGWIN_LINK])
22721
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   729
    BASIC_FIXUP_EXECUTABLE(LD)
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   730
    # Verify that we indeed succeeded with this trick.
13697
5262b00bc10c 7197849: Update new build-infra makefiles
ohair
parents: 13133
diff changeset
   731
    AC_MSG_CHECKING([if the found link.exe is actually the Visual Studio linker])
22721
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   732
    "$LD" --version > /dev/null
13697
5262b00bc10c 7197849: Update new build-infra makefiles
ohair
parents: 13133
diff changeset
   733
    if test $? -eq 0 ; then
5262b00bc10c 7197849: Update new build-infra makefiles
ohair
parents: 13133
diff changeset
   734
      AC_MSG_RESULT([no])
5262b00bc10c 7197849: Update new build-infra makefiles
ohair
parents: 13133
diff changeset
   735
      AC_MSG_ERROR([This is the Cygwin link tool. Please check your PATH and rerun configure.])
5262b00bc10c 7197849: Update new build-infra makefiles
ohair
parents: 13133
diff changeset
   736
    else
5262b00bc10c 7197849: Update new build-infra makefiles
ohair
parents: 13133
diff changeset
   737
      AC_MSG_RESULT([yes])
5262b00bc10c 7197849: Update new build-infra makefiles
ohair
parents: 13133
diff changeset
   738
    fi
22721
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   739
    LDCXX="$LD"
53460
65c813da7c65 8217613: [AOT] TEST_OPTS_AOT_MODULES doesn't work on mac
erikj
parents: 53110
diff changeset
   740
    # jaotc being a windows program expects the linker to be supplied with exe suffix.
65c813da7c65 8217613: [AOT] TEST_OPTS_AOT_MODULES doesn't work on mac
erikj
parents: 53110
diff changeset
   741
    LD_JAOTC="$LD$EXE_SUFFIX"
22721
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   742
  else
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   743
    # All other toolchains use the compiler to link.
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   744
    LD="$CC"
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   745
    LDCXX="$CXX"
53460
65c813da7c65 8217613: [AOT] TEST_OPTS_AOT_MODULES doesn't work on mac
erikj
parents: 53110
diff changeset
   746
    # jaotc expects 'ld' as the linker rather than the compiler.
65c813da7c65 8217613: [AOT] TEST_OPTS_AOT_MODULES doesn't work on mac
erikj
parents: 53110
diff changeset
   747
    BASIC_CHECK_TOOLS([LD_JAOTC], ld)
65c813da7c65 8217613: [AOT] TEST_OPTS_AOT_MODULES doesn't work on mac
erikj
parents: 53110
diff changeset
   748
    BASIC_FIXUP_EXECUTABLE(LD_JAOTC)
22721
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   749
  fi
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   750
  AC_SUBST(LD)
53460
65c813da7c65 8217613: [AOT] TEST_OPTS_AOT_MODULES doesn't work on mac
erikj
parents: 53110
diff changeset
   751
  AC_SUBST(LD_JAOTC)
22721
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   752
  # FIXME: it should be CXXLD, according to standard (cf CXXCPP)
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   753
  AC_SUBST(LDCXX)
13133
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
   754
49199
986249df86ce 8199403: Require binutils 2.18 or newer
ihse
parents: 49120
diff changeset
   755
  TOOLCHAIN_EXTRACT_LD_VERSION([LD], [linker])
986249df86ce 8199403: Require binutils 2.18 or newer
ihse
parents: 49120
diff changeset
   756
  TOOLCHAIN_PREPARE_FOR_LD_VERSION_COMPARISONS
986249df86ce 8199403: Require binutils 2.18 or newer
ihse
parents: 49120
diff changeset
   757
986249df86ce 8199403: Require binutils 2.18 or newer
ihse
parents: 49120
diff changeset
   758
  if test "x$TOOLCHAIN_MINIMUM_LD_VERSION" != x; then
986249df86ce 8199403: Require binutils 2.18 or newer
ihse
parents: 49120
diff changeset
   759
    TOOLCHAIN_CHECK_LINKER_VERSION(VERSION: $TOOLCHAIN_MINIMUM_LD_VERSION,
986249df86ce 8199403: Require binutils 2.18 or newer
ihse
parents: 49120
diff changeset
   760
        IF_OLDER_THAN: [
986249df86ce 8199403: Require binutils 2.18 or newer
ihse
parents: 49120
diff changeset
   761
          AC_MSG_WARN([You are using a linker older than $TOOLCHAIN_MINIMUM_LD_VERSION. This is not a supported configuration.])
986249df86ce 8199403: Require binutils 2.18 or newer
ihse
parents: 49120
diff changeset
   762
        ]
986249df86ce 8199403: Require binutils 2.18 or newer
ihse
parents: 49120
diff changeset
   763
    )
986249df86ce 8199403: Require binutils 2.18 or newer
ihse
parents: 49120
diff changeset
   764
  fi
986249df86ce 8199403: Require binutils 2.18 or newer
ihse
parents: 49120
diff changeset
   765
22721
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   766
  #
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   767
  # Setup the assembler (AS)
20363
fa7663fc5d50 8001931: The new build system whitespace cleanup
ihse
parents: 20362
diff changeset
   768
  #
fa7663fc5d50 8001931: The new build system whitespace cleanup
ihse
parents: 20362
diff changeset
   769
  if test "x$OPENJDK_TARGET_OS" = xsolaris; then
22475
777928354ad9 8031759: Improved tool overriding in configure
ihse
parents: 22473
diff changeset
   770
    BASIC_PATH_PROGS(AS, as)
14111
2a82ecb35fc7 8000992: Update new build-infra makefiles
ohair
parents: 13697
diff changeset
   771
    BASIC_FIXUP_EXECUTABLE(AS)
39115
1f71a5d2b20b 8081676: Verify that configure detects AS on Solaris and print help otherwise
tbell
parents: 38843
diff changeset
   772
    if test "x$AS" = x; then
1f71a5d2b20b 8081676: Verify that configure detects AS on Solaris and print help otherwise
tbell
parents: 38843
diff changeset
   773
      AC_MSG_ERROR([Solaris assembler (as) is required. Please install via "pkg install pkg:/developer/assembler".])
1f71a5d2b20b 8081676: Verify that configure detects AS on Solaris and print help otherwise
tbell
parents: 38843
diff changeset
   774
    fi
20363
fa7663fc5d50 8001931: The new build system whitespace cleanup
ihse
parents: 20362
diff changeset
   775
  else
22721
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   776
    # FIXME: is this correct for microsoft?
13133
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
   777
    AS="$CC -c"
20363
fa7663fc5d50 8001931: The new build system whitespace cleanup
ihse
parents: 20362
diff changeset
   778
  fi
fa7663fc5d50 8001931: The new build system whitespace cleanup
ihse
parents: 20362
diff changeset
   779
  AC_SUBST(AS)
13133
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
   780
22721
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   781
  #
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   782
  # Setup the archiver (AR)
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   783
  #
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   784
  if test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   785
    # The corresponding ar tool is lib.exe (used to create static libraries)
53110
50677f43ac3d 8215445: Enable building for Windows in WSL
erikj
parents: 51856
diff changeset
   786
    AC_CHECK_PROG([AR], [lib$EXE_SUFFIX],[lib$EXE_SUFFIX],,,)
34102
c0a98357f847 8143141: Bring in minor build changes from the jigsaw/jake forest
erikj
parents: 33568
diff changeset
   787
  elif test "x$TOOLCHAIN_TYPE" = xgcc; then
c0a98357f847 8143141: Bring in minor build changes from the jigsaw/jake forest
erikj
parents: 33568
diff changeset
   788
    BASIC_CHECK_TOOLS(AR, ar gcc-ar)
22721
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   789
  else
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   790
    BASIC_CHECK_TOOLS(AR, ar)
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   791
  fi
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   792
  BASIC_FIXUP_EXECUTABLE(AR)
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   793
])
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   794
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   795
# Setup additional tools that is considered a part of the toolchain, but not the
24911
a039e17f8896 8032045: Enable compiler and linker safety switches for debug builds
mduigou
parents: 23429
diff changeset
   796
# core part. Many of these are highly platform-specific and do not exist,
22721
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   797
# and/or are not needed on all platforms.
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   798
AC_DEFUN_ONCE([TOOLCHAIN_DETECT_TOOLCHAIN_EXTRA],
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   799
[
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   800
  if test "x$OPENJDK_TARGET_OS" = "xmacosx"; then
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   801
    BASIC_PATH_PROGS(LIPO, lipo)
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   802
    BASIC_FIXUP_EXECUTABLE(LIPO)
48032
9240097e2821 8139653: Freetype bundled on macosx, but not correctly linked
erikj
parents: 47258
diff changeset
   803
    BASIC_REQUIRE_PROGS(OTOOL, otool)
9240097e2821 8139653: Freetype bundled on macosx, but not correctly linked
erikj
parents: 47258
diff changeset
   804
    BASIC_FIXUP_EXECUTABLE(OTOOL)
9240097e2821 8139653: Freetype bundled on macosx, but not correctly linked
erikj
parents: 47258
diff changeset
   805
    BASIC_REQUIRE_PROGS(INSTALL_NAME_TOOL, install_name_tool)
9240097e2821 8139653: Freetype bundled on macosx, but not correctly linked
erikj
parents: 47258
diff changeset
   806
    BASIC_FIXUP_EXECUTABLE(INSTALL_NAME_TOOL)
22721
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   807
  fi
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   808
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   809
  if test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
53110
50677f43ac3d 8215445: Enable building for Windows in WSL
erikj
parents: 51856
diff changeset
   810
    AC_CHECK_PROG([MT], [mt$EXE_SUFFIX], [mt$EXE_SUFFIX],,, [/usr/bin/mt])
22721
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   811
    BASIC_FIXUP_EXECUTABLE(MT)
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   812
    # Setup the resource compiler (RC)
53110
50677f43ac3d 8215445: Enable building for Windows in WSL
erikj
parents: 51856
diff changeset
   813
    AC_CHECK_PROG([RC], [rc$EXE_SUFFIX], [rc$EXE_SUFFIX],,, [/usr/bin/rc])
22721
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   814
    BASIC_FIXUP_EXECUTABLE(RC)
53110
50677f43ac3d 8215445: Enable building for Windows in WSL
erikj
parents: 51856
diff changeset
   815
    AC_CHECK_PROG([DUMPBIN], [dumpbin$EXE_SUFFIX], [dumpbin$EXE_SUFFIX],,,)
22721
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   816
    BASIC_FIXUP_EXECUTABLE(DUMPBIN)
26400
4d6c6f2df610 8057538: Build the freetype library during configure on Windows
simonis
parents: 25034
diff changeset
   817
    # We need to check for 'msbuild.exe' because at the place where we expect to
4d6c6f2df610 8057538: Build the freetype library during configure on Windows
simonis
parents: 25034
diff changeset
   818
    # find 'msbuild.exe' there's also a directory called 'msbuild' and configure
4d6c6f2df610 8057538: Build the freetype library during configure on Windows
simonis
parents: 25034
diff changeset
   819
    # won't find the 'msbuild.exe' executable in that case (and the
4d6c6f2df610 8057538: Build the freetype library during configure on Windows
simonis
parents: 25034
diff changeset
   820
    # 'ac_executable_extensions' is unusable due to performance reasons).
4d6c6f2df610 8057538: Build the freetype library during configure on Windows
simonis
parents: 25034
diff changeset
   821
    # Notice that we intentionally don't fix up the path to MSBUILD because we
4d6c6f2df610 8057538: Build the freetype library during configure on Windows
simonis
parents: 25034
diff changeset
   822
    # will call it in a DOS shell during freetype detection on Windows (see
4d6c6f2df610 8057538: Build the freetype library during configure on Windows
simonis
parents: 25034
diff changeset
   823
    # 'LIB_SETUP_FREETYPE' in "libraries.m4"
53110
50677f43ac3d 8215445: Enable building for Windows in WSL
erikj
parents: 51856
diff changeset
   824
    AC_CHECK_PROG([MSBUILD], [msbuild$EXE_SUFFIX], [msbuild$EXE_SUFFIX],,,)
22721
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   825
  fi
24911
a039e17f8896 8032045: Enable compiler and linker safety switches for debug builds
mduigou
parents: 23429
diff changeset
   826
20363
fa7663fc5d50 8001931: The new build system whitespace cleanup
ihse
parents: 20362
diff changeset
   827
  if test "x$OPENJDK_TARGET_OS" = xsolaris; then
22721
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   828
    BASIC_PATH_PROGS(STRIP, strip)
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   829
    BASIC_FIXUP_EXECUTABLE(STRIP)
22475
777928354ad9 8031759: Improved tool overriding in configure
ihse
parents: 22473
diff changeset
   830
    BASIC_PATH_PROGS(NM, nm)
14111
2a82ecb35fc7 8000992: Update new build-infra makefiles
ohair
parents: 13697
diff changeset
   831
    BASIC_FIXUP_EXECUTABLE(NM)
22475
777928354ad9 8031759: Improved tool overriding in configure
ihse
parents: 22473
diff changeset
   832
    BASIC_PATH_PROGS(GNM, gnm)
16582
61f0b8f48036 8006288: build-infra: Use solaris nm and not gnm on solaris
erikj
parents: 15912
diff changeset
   833
    BASIC_FIXUP_EXECUTABLE(GNM)
20363
fa7663fc5d50 8001931: The new build system whitespace cleanup
ihse
parents: 20362
diff changeset
   834
  elif test "x$OPENJDK_TARGET_OS" != xwindows; then
22721
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   835
    # FIXME: we should unify this with the solaris case above.
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   836
    BASIC_CHECK_TOOLS(STRIP, strip)
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   837
    BASIC_FIXUP_EXECUTABLE(STRIP)
34102
c0a98357f847 8143141: Bring in minor build changes from the jigsaw/jake forest
erikj
parents: 33568
diff changeset
   838
    if test "x$TOOLCHAIN_TYPE" = xgcc; then
c0a98357f847 8143141: Bring in minor build changes from the jigsaw/jake forest
erikj
parents: 33568
diff changeset
   839
      BASIC_CHECK_TOOLS(NM, nm gcc-nm)
c0a98357f847 8143141: Bring in minor build changes from the jigsaw/jake forest
erikj
parents: 33568
diff changeset
   840
    else
c0a98357f847 8143141: Bring in minor build changes from the jigsaw/jake forest
erikj
parents: 33568
diff changeset
   841
      BASIC_CHECK_TOOLS(NM, nm)
c0a98357f847 8143141: Bring in minor build changes from the jigsaw/jake forest
erikj
parents: 33568
diff changeset
   842
    fi
14111
2a82ecb35fc7 8000992: Update new build-infra makefiles
ohair
parents: 13697
diff changeset
   843
    BASIC_FIXUP_EXECUTABLE(NM)
16582
61f0b8f48036 8006288: build-infra: Use solaris nm and not gnm on solaris
erikj
parents: 15912
diff changeset
   844
    GNM="$NM"
61f0b8f48036 8006288: build-infra: Use solaris nm and not gnm on solaris
erikj
parents: 15912
diff changeset
   845
    AC_SUBST(GNM)
20363
fa7663fc5d50 8001931: The new build system whitespace cleanup
ihse
parents: 20362
diff changeset
   846
  fi
13133
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
   847
20363
fa7663fc5d50 8001931: The new build system whitespace cleanup
ihse
parents: 20362
diff changeset
   848
  # objcopy is used for moving debug symbols to separate files when
fa7663fc5d50 8001931: The new build system whitespace cleanup
ihse
parents: 20362
diff changeset
   849
  # full debug symbols are enabled.
fa7663fc5d50 8001931: The new build system whitespace cleanup
ihse
parents: 20362
diff changeset
   850
  if test "x$OPENJDK_TARGET_OS" = xsolaris || test "x$OPENJDK_TARGET_OS" = xlinux; then
22475
777928354ad9 8031759: Improved tool overriding in configure
ihse
parents: 22473
diff changeset
   851
    BASIC_CHECK_TOOLS(OBJCOPY, [gobjcopy objcopy])
14464
b82a851468d0 8003300: build-infra: fails on solaris when objcopy is not found
tbell
parents: 14112
diff changeset
   852
    # Only call fixup if objcopy was found.
b82a851468d0 8003300: build-infra: fails on solaris when objcopy is not found
tbell
parents: 14112
diff changeset
   853
    if test -n "$OBJCOPY"; then
20363
fa7663fc5d50 8001931: The new build system whitespace cleanup
ihse
parents: 20362
diff changeset
   854
      BASIC_FIXUP_EXECUTABLE(OBJCOPY)
32462
f236112ab3d0 8064808: Disable use of broken objcopy on Solaris, remove adhoc helper tools
ihse
parents: 30096
diff changeset
   855
      if test "x$OPENJDK_BUILD_OS" = xsolaris; then
f236112ab3d0 8064808: Disable use of broken objcopy on Solaris, remove adhoc helper tools
ihse
parents: 30096
diff changeset
   856
        # objcopy prior to 2.21.1 on solaris is broken and is not usable.
f236112ab3d0 8064808: Disable use of broken objcopy on Solaris, remove adhoc helper tools
ihse
parents: 30096
diff changeset
   857
        # Rewrite objcopy version output to VALID_VERSION or BAD_VERSION.
f236112ab3d0 8064808: Disable use of broken objcopy on Solaris, remove adhoc helper tools
ihse
parents: 30096
diff changeset
   858
        # - version number is last blank separate word on first line
f236112ab3d0 8064808: Disable use of broken objcopy on Solaris, remove adhoc helper tools
ihse
parents: 30096
diff changeset
   859
        # - version number formats that have been seen:
f236112ab3d0 8064808: Disable use of broken objcopy on Solaris, remove adhoc helper tools
ihse
parents: 30096
diff changeset
   860
        #   - <major>.<minor>
f236112ab3d0 8064808: Disable use of broken objcopy on Solaris, remove adhoc helper tools
ihse
parents: 30096
diff changeset
   861
        #   - <major>.<minor>.<micro>
f236112ab3d0 8064808: Disable use of broken objcopy on Solaris, remove adhoc helper tools
ihse
parents: 30096
diff changeset
   862
        OBJCOPY_VERSION=`$OBJCOPY --version | $HEAD -n 1`
f236112ab3d0 8064808: Disable use of broken objcopy on Solaris, remove adhoc helper tools
ihse
parents: 30096
diff changeset
   863
        # The outer [ ] is to prevent m4 from eating the [] in the sed expression.
f236112ab3d0 8064808: Disable use of broken objcopy on Solaris, remove adhoc helper tools
ihse
parents: 30096
diff changeset
   864
        [ OBJCOPY_VERSION_CHECK=`$ECHO $OBJCOPY_VERSION | $SED -n \
f236112ab3d0 8064808: Disable use of broken objcopy on Solaris, remove adhoc helper tools
ihse
parents: 30096
diff changeset
   865
              -e 's/.* //' \
f236112ab3d0 8064808: Disable use of broken objcopy on Solaris, remove adhoc helper tools
ihse
parents: 30096
diff changeset
   866
              -e '/^[01]\./b bad' \
f236112ab3d0 8064808: Disable use of broken objcopy on Solaris, remove adhoc helper tools
ihse
parents: 30096
diff changeset
   867
              -e '/^2\./{' \
f236112ab3d0 8064808: Disable use of broken objcopy on Solaris, remove adhoc helper tools
ihse
parents: 30096
diff changeset
   868
              -e '  s/^2\.//' \
f236112ab3d0 8064808: Disable use of broken objcopy on Solaris, remove adhoc helper tools
ihse
parents: 30096
diff changeset
   869
              -e '  /^[0-9]$/b bad' \
f236112ab3d0 8064808: Disable use of broken objcopy on Solaris, remove adhoc helper tools
ihse
parents: 30096
diff changeset
   870
              -e '  /^[0-9]\./b bad' \
f236112ab3d0 8064808: Disable use of broken objcopy on Solaris, remove adhoc helper tools
ihse
parents: 30096
diff changeset
   871
              -e '  /^1[0-9]$/b bad' \
f236112ab3d0 8064808: Disable use of broken objcopy on Solaris, remove adhoc helper tools
ihse
parents: 30096
diff changeset
   872
              -e '  /^1[0-9]\./b bad' \
f236112ab3d0 8064808: Disable use of broken objcopy on Solaris, remove adhoc helper tools
ihse
parents: 30096
diff changeset
   873
              -e '  /^20\./b bad' \
f236112ab3d0 8064808: Disable use of broken objcopy on Solaris, remove adhoc helper tools
ihse
parents: 30096
diff changeset
   874
              -e '  /^21\.0$/b bad' \
f236112ab3d0 8064808: Disable use of broken objcopy on Solaris, remove adhoc helper tools
ihse
parents: 30096
diff changeset
   875
              -e '  /^21\.0\./b bad' \
f236112ab3d0 8064808: Disable use of broken objcopy on Solaris, remove adhoc helper tools
ihse
parents: 30096
diff changeset
   876
              -e '}' \
f236112ab3d0 8064808: Disable use of broken objcopy on Solaris, remove adhoc helper tools
ihse
parents: 30096
diff changeset
   877
              -e ':good' \
f236112ab3d0 8064808: Disable use of broken objcopy on Solaris, remove adhoc helper tools
ihse
parents: 30096
diff changeset
   878
              -e 's/.*/VALID_VERSION/p' \
f236112ab3d0 8064808: Disable use of broken objcopy on Solaris, remove adhoc helper tools
ihse
parents: 30096
diff changeset
   879
              -e 'q' \
f236112ab3d0 8064808: Disable use of broken objcopy on Solaris, remove adhoc helper tools
ihse
parents: 30096
diff changeset
   880
              -e ':bad' \
f236112ab3d0 8064808: Disable use of broken objcopy on Solaris, remove adhoc helper tools
ihse
parents: 30096
diff changeset
   881
              -e 's/.*/BAD_VERSION/p' \
f236112ab3d0 8064808: Disable use of broken objcopy on Solaris, remove adhoc helper tools
ihse
parents: 30096
diff changeset
   882
              -e 'q'` ]
f236112ab3d0 8064808: Disable use of broken objcopy on Solaris, remove adhoc helper tools
ihse
parents: 30096
diff changeset
   883
        if test "x$OBJCOPY_VERSION_CHECK" = xBAD_VERSION; then
f236112ab3d0 8064808: Disable use of broken objcopy on Solaris, remove adhoc helper tools
ihse
parents: 30096
diff changeset
   884
          OBJCOPY=
f236112ab3d0 8064808: Disable use of broken objcopy on Solaris, remove adhoc helper tools
ihse
parents: 30096
diff changeset
   885
          AC_MSG_WARN([Ignoring found objcopy since it is broken (prior to 2.21.1). No debug symbols will be generated.])
f236112ab3d0 8064808: Disable use of broken objcopy on Solaris, remove adhoc helper tools
ihse
parents: 30096
diff changeset
   886
          AC_MSG_NOTICE([objcopy reports version $OBJCOPY_VERSION])
f236112ab3d0 8064808: Disable use of broken objcopy on Solaris, remove adhoc helper tools
ihse
parents: 30096
diff changeset
   887
          AC_MSG_NOTICE([Note: patch 149063-01 or newer contains the correct Solaris 10 SPARC version])
f236112ab3d0 8064808: Disable use of broken objcopy on Solaris, remove adhoc helper tools
ihse
parents: 30096
diff changeset
   888
          AC_MSG_NOTICE([Note: patch 149064-01 or newer contains the correct Solaris 10 X86 version])
f236112ab3d0 8064808: Disable use of broken objcopy on Solaris, remove adhoc helper tools
ihse
parents: 30096
diff changeset
   889
          AC_MSG_NOTICE([Note: Solaris 11 Update 1 contains the correct version])
f236112ab3d0 8064808: Disable use of broken objcopy on Solaris, remove adhoc helper tools
ihse
parents: 30096
diff changeset
   890
        fi
f236112ab3d0 8064808: Disable use of broken objcopy on Solaris, remove adhoc helper tools
ihse
parents: 30096
diff changeset
   891
      fi
14464
b82a851468d0 8003300: build-infra: fails on solaris when objcopy is not found
tbell
parents: 14112
diff changeset
   892
    fi
20363
fa7663fc5d50 8001931: The new build system whitespace cleanup
ihse
parents: 20362
diff changeset
   893
  fi
14111
2a82ecb35fc7 8000992: Update new build-infra makefiles
ohair
parents: 13697
diff changeset
   894
22475
777928354ad9 8031759: Improved tool overriding in configure
ihse
parents: 22473
diff changeset
   895
  BASIC_CHECK_TOOLS(OBJDUMP, [gobjdump objdump])
20363
fa7663fc5d50 8001931: The new build system whitespace cleanup
ihse
parents: 20362
diff changeset
   896
  if test "x$OBJDUMP" != x; then
22721
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   897
    # Only used for compare.sh; we can live without it. BASIC_FIXUP_EXECUTABLE
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   898
    # bails if argument is missing.
20363
fa7663fc5d50 8001931: The new build system whitespace cleanup
ihse
parents: 20362
diff changeset
   899
    BASIC_FIXUP_EXECUTABLE(OBJDUMP)
fa7663fc5d50 8001931: The new build system whitespace cleanup
ihse
parents: 20362
diff changeset
   900
  fi
49357
aaedb8343784 8198243: Add build time check for global operator new/delete in object files
erikj
parents: 48678
diff changeset
   901
aaedb8343784 8198243: Add build time check for global operator new/delete in object files
erikj
parents: 48678
diff changeset
   902
  case $TOOLCHAIN_TYPE in
aaedb8343784 8198243: Add build time check for global operator new/delete in object files
erikj
parents: 48678
diff changeset
   903
    gcc|clang|solstudio)
aaedb8343784 8198243: Add build time check for global operator new/delete in object files
erikj
parents: 48678
diff changeset
   904
      BASIC_CHECK_TOOLS(CXXFILT, [c++filt])
aaedb8343784 8198243: Add build time check for global operator new/delete in object files
erikj
parents: 48678
diff changeset
   905
      BASIC_CHECK_NONEMPTY(CXXFILT)
aaedb8343784 8198243: Add build time check for global operator new/delete in object files
erikj
parents: 48678
diff changeset
   906
      BASIC_FIXUP_EXECUTABLE(CXXFILT)
aaedb8343784 8198243: Add build time check for global operator new/delete in object files
erikj
parents: 48678
diff changeset
   907
      ;;
aaedb8343784 8198243: Add build time check for global operator new/delete in object files
erikj
parents: 48678
diff changeset
   908
  esac
22721
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   909
])
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   910
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   911
# Setup the build tools (i.e, the compiler and linker used to build programs
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   912
# that should be run on the build platform, not the target platform, as a build
24911
a039e17f8896 8032045: Enable compiler and linker safety switches for debug builds
mduigou
parents: 23429
diff changeset
   913
# helper). Since the non-cross-compile case uses the normal, target compilers
22721
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   914
# for this, we can only do this after these have been setup.
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   915
AC_DEFUN_ONCE([TOOLCHAIN_SETUP_BUILD_COMPILERS],
24911
a039e17f8896 8032045: Enable compiler and linker safety switches for debug builds
mduigou
parents: 23429
diff changeset
   916
[
22721
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   917
  if test "x$COMPILE_TYPE" = "xcross"; then
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   918
    # Now we need to find a C/C++ compiler that can build executables for the
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   919
    # build platform. We can't use the AC_PROG_CC macro, since it can only be
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   920
    # used once. Also, we need to do this without adding a tools dir to the
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   921
    # path, otherwise we might pick up cross-compilers which don't use standard
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   922
    # naming.
24911
a039e17f8896 8032045: Enable compiler and linker safety switches for debug builds
mduigou
parents: 23429
diff changeset
   923
33395
5907d5b1287c 8140593: Add configure parameter for devkit for the build compiler
erikj
parents: 32810
diff changeset
   924
    OLDPATH="$PATH"
5907d5b1287c 8140593: Add configure parameter for devkit for the build compiler
erikj
parents: 32810
diff changeset
   925
5907d5b1287c 8140593: Add configure parameter for devkit for the build compiler
erikj
parents: 32810
diff changeset
   926
    AC_ARG_WITH(build-devkit, [AS_HELP_STRING([--with-build-devkit],
5907d5b1287c 8140593: Add configure parameter for devkit for the build compiler
erikj
parents: 32810
diff changeset
   927
        [Devkit to use for the build platform toolchain])])
5907d5b1287c 8140593: Add configure parameter for devkit for the build compiler
erikj
parents: 32810
diff changeset
   928
    if test "x$with_build_devkit" = "xyes"; then
5907d5b1287c 8140593: Add configure parameter for devkit for the build compiler
erikj
parents: 32810
diff changeset
   929
      AC_MSG_ERROR([--with-build-devkit must have a value])
5907d5b1287c 8140593: Add configure parameter for devkit for the build compiler
erikj
parents: 32810
diff changeset
   930
    elif test -n "$with_build_devkit"; then
5907d5b1287c 8140593: Add configure parameter for devkit for the build compiler
erikj
parents: 32810
diff changeset
   931
      if test ! -d "$with_build_devkit"; then
5907d5b1287c 8140593: Add configure parameter for devkit for the build compiler
erikj
parents: 32810
diff changeset
   932
        AC_MSG_ERROR([--with-build-devkit points to non existing dir: $with_build_devkit])
5907d5b1287c 8140593: Add configure parameter for devkit for the build compiler
erikj
parents: 32810
diff changeset
   933
      else
5907d5b1287c 8140593: Add configure parameter for devkit for the build compiler
erikj
parents: 32810
diff changeset
   934
        BASIC_FIXUP_PATH([with_build_devkit])
5907d5b1287c 8140593: Add configure parameter for devkit for the build compiler
erikj
parents: 32810
diff changeset
   935
        BUILD_DEVKIT_ROOT="$with_build_devkit"
5907d5b1287c 8140593: Add configure parameter for devkit for the build compiler
erikj
parents: 32810
diff changeset
   936
        # Check for a meta data info file in the root of the devkit
5907d5b1287c 8140593: Add configure parameter for devkit for the build compiler
erikj
parents: 32810
diff changeset
   937
        if test -f "$BUILD_DEVKIT_ROOT/devkit.info"; then
5907d5b1287c 8140593: Add configure parameter for devkit for the build compiler
erikj
parents: 32810
diff changeset
   938
          # Process devkit.info so that existing devkit variables are not
5907d5b1287c 8140593: Add configure parameter for devkit for the build compiler
erikj
parents: 32810
diff changeset
   939
          # modified by this
5907d5b1287c 8140593: Add configure parameter for devkit for the build compiler
erikj
parents: 32810
diff changeset
   940
          $SED -e "s/^DEVKIT_/BUILD_DEVKIT_/g" \
5907d5b1287c 8140593: Add configure parameter for devkit for the build compiler
erikj
parents: 32810
diff changeset
   941
              -e "s/\$DEVKIT_ROOT/\$BUILD_DEVKIT_ROOT/g" \
5907d5b1287c 8140593: Add configure parameter for devkit for the build compiler
erikj
parents: 32810
diff changeset
   942
              -e "s/\$host/\$build/g" \
5907d5b1287c 8140593: Add configure parameter for devkit for the build compiler
erikj
parents: 32810
diff changeset
   943
              $BUILD_DEVKIT_ROOT/devkit.info \
5907d5b1287c 8140593: Add configure parameter for devkit for the build compiler
erikj
parents: 32810
diff changeset
   944
              > $CONFIGURESUPPORT_OUTPUTDIR/build-devkit.info
5907d5b1287c 8140593: Add configure parameter for devkit for the build compiler
erikj
parents: 32810
diff changeset
   945
          . $CONFIGURESUPPORT_OUTPUTDIR/build-devkit.info
5907d5b1287c 8140593: Add configure parameter for devkit for the build compiler
erikj
parents: 32810
diff changeset
   946
          # This potentially sets the following:
5907d5b1287c 8140593: Add configure parameter for devkit for the build compiler
erikj
parents: 32810
diff changeset
   947
          # A descriptive name of the devkit
5907d5b1287c 8140593: Add configure parameter for devkit for the build compiler
erikj
parents: 32810
diff changeset
   948
          BASIC_EVAL_DEVKIT_VARIABLE([BUILD_DEVKIT_NAME])
5907d5b1287c 8140593: Add configure parameter for devkit for the build compiler
erikj
parents: 32810
diff changeset
   949
          # Corresponds to --with-extra-path
5907d5b1287c 8140593: Add configure parameter for devkit for the build compiler
erikj
parents: 32810
diff changeset
   950
          BASIC_EVAL_DEVKIT_VARIABLE([BUILD_DEVKIT_EXTRA_PATH])
5907d5b1287c 8140593: Add configure parameter for devkit for the build compiler
erikj
parents: 32810
diff changeset
   951
          # Corresponds to --with-toolchain-path
5907d5b1287c 8140593: Add configure parameter for devkit for the build compiler
erikj
parents: 32810
diff changeset
   952
          BASIC_EVAL_DEVKIT_VARIABLE([BUILD_DEVKIT_TOOLCHAIN_PATH])
5907d5b1287c 8140593: Add configure parameter for devkit for the build compiler
erikj
parents: 32810
diff changeset
   953
          # Corresponds to --with-sysroot
5907d5b1287c 8140593: Add configure parameter for devkit for the build compiler
erikj
parents: 32810
diff changeset
   954
          BASIC_EVAL_DEVKIT_VARIABLE([BUILD_DEVKIT_SYSROOT])
5907d5b1287c 8140593: Add configure parameter for devkit for the build compiler
erikj
parents: 32810
diff changeset
   955
          # Skip the Window specific parts
5907d5b1287c 8140593: Add configure parameter for devkit for the build compiler
erikj
parents: 32810
diff changeset
   956
        fi
5907d5b1287c 8140593: Add configure parameter for devkit for the build compiler
erikj
parents: 32810
diff changeset
   957
5907d5b1287c 8140593: Add configure parameter for devkit for the build compiler
erikj
parents: 32810
diff changeset
   958
        AC_MSG_CHECKING([for build platform devkit])
5907d5b1287c 8140593: Add configure parameter for devkit for the build compiler
erikj
parents: 32810
diff changeset
   959
        if test "x$BUILD_DEVKIT_NAME" != x; then
5907d5b1287c 8140593: Add configure parameter for devkit for the build compiler
erikj
parents: 32810
diff changeset
   960
          AC_MSG_RESULT([$BUILD_DEVKIT_NAME in $BUILD_DEVKIT_ROOT])
5907d5b1287c 8140593: Add configure parameter for devkit for the build compiler
erikj
parents: 32810
diff changeset
   961
        else
5907d5b1287c 8140593: Add configure parameter for devkit for the build compiler
erikj
parents: 32810
diff changeset
   962
          AC_MSG_RESULT([$BUILD_DEVKIT_ROOT])
5907d5b1287c 8140593: Add configure parameter for devkit for the build compiler
erikj
parents: 32810
diff changeset
   963
        fi
5907d5b1287c 8140593: Add configure parameter for devkit for the build compiler
erikj
parents: 32810
diff changeset
   964
5907d5b1287c 8140593: Add configure parameter for devkit for the build compiler
erikj
parents: 32810
diff changeset
   965
        BUILD_SYSROOT="$BUILD_DEVKIT_SYSROOT"
5907d5b1287c 8140593: Add configure parameter for devkit for the build compiler
erikj
parents: 32810
diff changeset
   966
5907d5b1287c 8140593: Add configure parameter for devkit for the build compiler
erikj
parents: 32810
diff changeset
   967
         # Fallback default of just /bin if DEVKIT_PATH is not defined
5907d5b1287c 8140593: Add configure parameter for devkit for the build compiler
erikj
parents: 32810
diff changeset
   968
        if test "x$BUILD_DEVKIT_TOOLCHAIN_PATH" = x; then
5907d5b1287c 8140593: Add configure parameter for devkit for the build compiler
erikj
parents: 32810
diff changeset
   969
          BUILD_DEVKIT_TOOLCHAIN_PATH="$BUILD_DEVKIT_ROOT/bin"
5907d5b1287c 8140593: Add configure parameter for devkit for the build compiler
erikj
parents: 32810
diff changeset
   970
        fi
5907d5b1287c 8140593: Add configure parameter for devkit for the build compiler
erikj
parents: 32810
diff changeset
   971
        PATH="$BUILD_DEVKIT_TOOLCHAIN_PATH:$BUILD_DEVKIT_EXTRA_PATH"
5907d5b1287c 8140593: Add configure parameter for devkit for the build compiler
erikj
parents: 32810
diff changeset
   972
      fi
5907d5b1287c 8140593: Add configure parameter for devkit for the build compiler
erikj
parents: 32810
diff changeset
   973
    fi
5907d5b1287c 8140593: Add configure parameter for devkit for the build compiler
erikj
parents: 32810
diff changeset
   974
22721
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   975
    # FIXME: we should list the discovered compilers as an exclude pattern!
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   976
    # If we do that, we can do this detection before POST_DETECTION, and still
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   977
    # find the build compilers in the tools dir, if needed.
33395
5907d5b1287c 8140593: Add configure parameter for devkit for the build compiler
erikj
parents: 32810
diff changeset
   978
    BASIC_REQUIRE_PROGS(BUILD_CC, [cl cc gcc])
22721
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   979
    BASIC_FIXUP_EXECUTABLE(BUILD_CC)
33395
5907d5b1287c 8140593: Add configure parameter for devkit for the build compiler
erikj
parents: 32810
diff changeset
   980
    BASIC_REQUIRE_PROGS(BUILD_CXX, [cl CC g++])
22721
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   981
    BASIC_FIXUP_EXECUTABLE(BUILD_CXX)
34102
c0a98357f847 8143141: Bring in minor build changes from the jigsaw/jake forest
erikj
parents: 33568
diff changeset
   982
    BASIC_PATH_PROGS(BUILD_NM, nm gcc-nm)
c0a98357f847 8143141: Bring in minor build changes from the jigsaw/jake forest
erikj
parents: 33568
diff changeset
   983
    BASIC_FIXUP_EXECUTABLE(BUILD_NM)
c0a98357f847 8143141: Bring in minor build changes from the jigsaw/jake forest
erikj
parents: 33568
diff changeset
   984
    BASIC_PATH_PROGS(BUILD_AR, ar gcc-ar)
c0a98357f847 8143141: Bring in minor build changes from the jigsaw/jake forest
erikj
parents: 33568
diff changeset
   985
    BASIC_FIXUP_EXECUTABLE(BUILD_AR)
36506
17612cee3530 8142968: Module System implementation
alanb
parents: 35747
diff changeset
   986
    BASIC_PATH_PROGS(BUILD_OBJCOPY, objcopy)
17612cee3530 8142968: Module System implementation
alanb
parents: 35747
diff changeset
   987
    BASIC_FIXUP_EXECUTABLE(BUILD_OBJCOPY)
17612cee3530 8142968: Module System implementation
alanb
parents: 35747
diff changeset
   988
    BASIC_PATH_PROGS(BUILD_STRIP, strip)
17612cee3530 8142968: Module System implementation
alanb
parents: 35747
diff changeset
   989
    BASIC_FIXUP_EXECUTABLE(BUILD_STRIP)
34102
c0a98357f847 8143141: Bring in minor build changes from the jigsaw/jake forest
erikj
parents: 33568
diff changeset
   990
    # Assume the C compiler is the assembler
c0a98357f847 8143141: Bring in minor build changes from the jigsaw/jake forest
erikj
parents: 33568
diff changeset
   991
    BUILD_AS="$BUILD_CC -c"
c0a98357f847 8143141: Bring in minor build changes from the jigsaw/jake forest
erikj
parents: 33568
diff changeset
   992
    # Just like for the target compiler, use the compiler as linker
33395
5907d5b1287c 8140593: Add configure parameter for devkit for the build compiler
erikj
parents: 32810
diff changeset
   993
    BUILD_LD="$BUILD_CC"
34596
e8328ce5b64e 8142907: Integration of minor fixes from the build-infra project
ihse
parents: 34102
diff changeset
   994
    BUILD_LDCXX="$BUILD_CXX"
33395
5907d5b1287c 8140593: Add configure parameter for devkit for the build compiler
erikj
parents: 32810
diff changeset
   995
5907d5b1287c 8140593: Add configure parameter for devkit for the build compiler
erikj
parents: 32810
diff changeset
   996
    PATH="$OLDPATH"
37864
5284b5a9fdc7 8155587: Cross compilation may cause compiler warnings for "build" compiler
erikj
parents: 37402
diff changeset
   997
5284b5a9fdc7 8155587: Cross compilation may cause compiler warnings for "build" compiler
erikj
parents: 37402
diff changeset
   998
    TOOLCHAIN_EXTRACT_COMPILER_VERSION(BUILD_CC, [BuildC])
5284b5a9fdc7 8155587: Cross compilation may cause compiler warnings for "build" compiler
erikj
parents: 37402
diff changeset
   999
    TOOLCHAIN_EXTRACT_COMPILER_VERSION(BUILD_CXX, [BuildC++])
5284b5a9fdc7 8155587: Cross compilation may cause compiler warnings for "build" compiler
erikj
parents: 37402
diff changeset
  1000
    TOOLCHAIN_PREPARE_FOR_VERSION_COMPARISONS([BUILD_], [OPENJDK_BUILD_])
49199
986249df86ce 8199403: Require binutils 2.18 or newer
ihse
parents: 49120
diff changeset
  1001
    TOOLCHAIN_EXTRACT_LD_VERSION(BUILD_LD, [build linker])
986249df86ce 8199403: Require binutils 2.18 or newer
ihse
parents: 49120
diff changeset
  1002
    TOOLCHAIN_PREPARE_FOR_LD_VERSION_COMPARISONS([BUILD_], [OPENJDK_BUILD_])
22721
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
  1003
  else
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
  1004
    # If we are not cross compiling, use the normal target compilers for
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
  1005
    # building the build platform executables.
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
  1006
    BUILD_CC="$CC"
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
  1007
    BUILD_CXX="$CXX"
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
  1008
    BUILD_LD="$LD"
34596
e8328ce5b64e 8142907: Integration of minor fixes from the build-infra project
ihse
parents: 34102
diff changeset
  1009
    BUILD_LDCXX="$LDCXX"
34102
c0a98357f847 8143141: Bring in minor build changes from the jigsaw/jake forest
erikj
parents: 33568
diff changeset
  1010
    BUILD_NM="$NM"
c0a98357f847 8143141: Bring in minor build changes from the jigsaw/jake forest
erikj
parents: 33568
diff changeset
  1011
    BUILD_AS="$AS"
36506
17612cee3530 8142968: Module System implementation
alanb
parents: 35747
diff changeset
  1012
    BUILD_OBJCOPY="$OBJCOPY"
17612cee3530 8142968: Module System implementation
alanb
parents: 35747
diff changeset
  1013
    BUILD_STRIP="$STRIP"
34102
c0a98357f847 8143141: Bring in minor build changes from the jigsaw/jake forest
erikj
parents: 33568
diff changeset
  1014
    BUILD_AR="$AR"
42296
671fe155ec14 8170651: Remove legacy hotspot compiler setup
ihse
parents: 42294
diff changeset
  1015
39936
552923792fd8 8156980: Hotspot build doesn't have -std=gnu++98 gcc option
andrew
parents: 39115
diff changeset
  1016
    TOOLCHAIN_PREPARE_FOR_VERSION_COMPARISONS([], [OPENJDK_BUILD_])
49199
986249df86ce 8199403: Require binutils 2.18 or newer
ihse
parents: 49120
diff changeset
  1017
    TOOLCHAIN_PREPARE_FOR_LD_VERSION_COMPARISONS([BUILD_], [OPENJDK_BUILD_])
22721
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
  1018
  fi
13133
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
  1019
22721
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
  1020
  AC_SUBST(BUILD_CC)
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
  1021
  AC_SUBST(BUILD_CXX)
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
  1022
  AC_SUBST(BUILD_LD)
34596
e8328ce5b64e 8142907: Integration of minor fixes from the build-infra project
ihse
parents: 34102
diff changeset
  1023
  AC_SUBST(BUILD_LDCXX)
34102
c0a98357f847 8143141: Bring in minor build changes from the jigsaw/jake forest
erikj
parents: 33568
diff changeset
  1024
  AC_SUBST(BUILD_NM)
c0a98357f847 8143141: Bring in minor build changes from the jigsaw/jake forest
erikj
parents: 33568
diff changeset
  1025
  AC_SUBST(BUILD_AS)
c0a98357f847 8143141: Bring in minor build changes from the jigsaw/jake forest
erikj
parents: 33568
diff changeset
  1026
  AC_SUBST(BUILD_AR)
13133
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
  1027
])
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
  1028
22721
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
  1029
# Do some additional checks on the detected tools.
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
  1030
AC_DEFUN_ONCE([TOOLCHAIN_MISC_CHECKS],
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
  1031
[
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
  1032
  # Check for extra potential brokenness.
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
  1033
  if test  "x$TOOLCHAIN_TYPE" = xmicrosoft; then
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
  1034
    # On Windows, double-check that we got the right compiler.
53110
50677f43ac3d 8215445: Enable building for Windows in WSL
erikj
parents: 51856
diff changeset
  1035
    CC_VERSION_OUTPUT=`$CC 2>&1 | $GREP -v 'ERROR.*UtilTranslatePathList' | $HEAD -n 1 | $TR -d '\r'`
22721
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
  1036
    COMPILER_CPU_TEST=`$ECHO $CC_VERSION_OUTPUT | $SED -n "s/^.* \(.*\)$/\1/p"`
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
  1037
    if test "x$OPENJDK_TARGET_CPU" = "xx86"; then
28901
5acc0ec03d06 8042707: Source changes needed to build JDK 9 with Visual Studio 2013 (VS2013)
erikj
parents: 27594
diff changeset
  1038
      if test "x$COMPILER_CPU_TEST" != "x80x86" -a "x$COMPILER_CPU_TEST" != "xx86"; then
5acc0ec03d06 8042707: Source changes needed to build JDK 9 with Visual Studio 2013 (VS2013)
erikj
parents: 27594
diff changeset
  1039
        AC_MSG_ERROR([Target CPU mismatch. We are building for $OPENJDK_TARGET_CPU but CL is for "$COMPILER_CPU_TEST"; expected "80x86" or "x86".])
22721
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
  1040
      fi
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
  1041
    elif test "x$OPENJDK_TARGET_CPU" = "xx86_64"; then
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
  1042
      if test "x$COMPILER_CPU_TEST" != "xx64"; then
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
  1043
        AC_MSG_ERROR([Target CPU mismatch. We are building for $OPENJDK_TARGET_CPU but CL is for "$COMPILER_CPU_TEST"; expected "x64".])
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
  1044
      fi
13133
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
  1045
    fi
20363
fa7663fc5d50 8001931: The new build system whitespace cleanup
ihse
parents: 20362
diff changeset
  1046
  fi
13133
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
  1047
22721
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
  1048
  if test "x$TOOLCHAIN_TYPE" = xgcc; then
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
  1049
    # If this is a --hash-style=gnu system, use --hash-style=both, why?
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
  1050
    HAS_GNU_HASH=`$CC -dumpspecs 2>/dev/null | $GREP 'hash-style=gnu'`
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
  1051
    # This is later checked when setting flags.
20363
fa7663fc5d50 8001931: The new build system whitespace cleanup
ihse
parents: 20362
diff changeset
  1052
  fi
13133
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
  1053
51805
eb2adb0a9b09 8209817: stack is executable when building with Clang on Linux
martin
parents: 51780
diff changeset
  1054
  if test "x$TOOLCHAIN_TYPE" = xgcc || test "x$TOOLCHAIN_TYPE" = xclang; then
eb2adb0a9b09 8209817: stack is executable when building with Clang on Linux
martin
parents: 51780
diff changeset
  1055
    # Check if linker has -z noexecstack.
eb2adb0a9b09 8209817: stack is executable when building with Clang on Linux
martin
parents: 51780
diff changeset
  1056
    HAS_NOEXECSTACK=`$CC -Wl,--help 2>/dev/null | $GREP 'z noexecstack'`
eb2adb0a9b09 8209817: stack is executable when building with Clang on Linux
martin
parents: 51780
diff changeset
  1057
    # This is later checked when setting flags.
eb2adb0a9b09 8209817: stack is executable when building with Clang on Linux
martin
parents: 51780
diff changeset
  1058
  fi
eb2adb0a9b09 8209817: stack is executable when building with Clang on Linux
martin
parents: 51780
diff changeset
  1059
37402
62b5f067032e 8152666: The new Hotspot Build System
erikj
parents: 36541
diff changeset
  1060
  # Setup hotspot lecagy names for toolchains
62b5f067032e 8152666: The new Hotspot Build System
erikj
parents: 36541
diff changeset
  1061
  HOTSPOT_TOOLCHAIN_TYPE=$TOOLCHAIN_TYPE
62b5f067032e 8152666: The new Hotspot Build System
erikj
parents: 36541
diff changeset
  1062
  if test "x$TOOLCHAIN_TYPE" = xclang; then
62b5f067032e 8152666: The new Hotspot Build System
erikj
parents: 36541
diff changeset
  1063
    HOTSPOT_TOOLCHAIN_TYPE=gcc
62b5f067032e 8152666: The new Hotspot Build System
erikj
parents: 36541
diff changeset
  1064
  elif test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
62b5f067032e 8152666: The new Hotspot Build System
erikj
parents: 36541
diff changeset
  1065
    HOTSPOT_TOOLCHAIN_TYPE=visCPP
62b5f067032e 8152666: The new Hotspot Build System
erikj
parents: 36541
diff changeset
  1066
  fi
62b5f067032e 8152666: The new Hotspot Build System
erikj
parents: 36541
diff changeset
  1067
  AC_SUBST(HOTSPOT_TOOLCHAIN_TYPE)
16987
19305cbf4362 8013786: JDK-8013480 broke configure on solaris
erikj
parents: 16582
diff changeset
  1068
])
17593
de6741d8a142 8007129: build-infra Add configure --with-jtreg option for location of JTREG
erikj
parents: 16988
diff changeset
  1069
22721
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
  1070
# Setup the JTReg Regression Test Harness.
17664
2cb42641740b 8015510: (s) Improve JTReg location detection and provide location to test/Makefile
mduigou
parents: 17593
diff changeset
  1071
AC_DEFUN_ONCE([TOOLCHAIN_SETUP_JTREG],
2cb42641740b 8015510: (s) Improve JTReg location detection and provide location to test/Makefile
mduigou
parents: 17593
diff changeset
  1072
[
2cb42641740b 8015510: (s) Improve JTReg location detection and provide location to test/Makefile
mduigou
parents: 17593
diff changeset
  1073
  AC_ARG_WITH(jtreg, [AS_HELP_STRING([--with-jtreg],
45104
b8a6cd8674d1 8180281: --with-jtreg is broken for many use cases
ihse
parents: 43918
diff changeset
  1074
      [Regression Test Harness @<:@probed@:>@])])
17664
2cb42641740b 8015510: (s) Improve JTReg location detection and provide location to test/Makefile
mduigou
parents: 17593
diff changeset
  1075
2cb42641740b 8015510: (s) Improve JTReg location detection and provide location to test/Makefile
mduigou
parents: 17593
diff changeset
  1076
  if test "x$with_jtreg" = xno; then
2cb42641740b 8015510: (s) Improve JTReg location detection and provide location to test/Makefile
mduigou
parents: 17593
diff changeset
  1077
    # jtreg disabled
45104
b8a6cd8674d1 8180281: --with-jtreg is broken for many use cases
ihse
parents: 43918
diff changeset
  1078
    AC_MSG_CHECKING([for jtreg test harness])
b8a6cd8674d1 8180281: --with-jtreg is broken for many use cases
ihse
parents: 43918
diff changeset
  1079
    AC_MSG_RESULT([no, disabled])
b8a6cd8674d1 8180281: --with-jtreg is broken for many use cases
ihse
parents: 43918
diff changeset
  1080
  elif test "x$with_jtreg" != xyes && test "x$with_jtreg" != x; then
b8a6cd8674d1 8180281: --with-jtreg is broken for many use cases
ihse
parents: 43918
diff changeset
  1081
    # An explicit path is specified, use it.
b8a6cd8674d1 8180281: --with-jtreg is broken for many use cases
ihse
parents: 43918
diff changeset
  1082
    JT_HOME="$with_jtreg"
47258
4bfce39946ba 8180897: Explicit --with-jtreg path not expanded
ihse
parents: 47216
diff changeset
  1083
    BASIC_FIXUP_PATH([JT_HOME])
45104
b8a6cd8674d1 8180281: --with-jtreg is broken for many use cases
ihse
parents: 43918
diff changeset
  1084
    if test ! -d "$JT_HOME"; then
b8a6cd8674d1 8180281: --with-jtreg is broken for many use cases
ihse
parents: 43918
diff changeset
  1085
      AC_MSG_ERROR([jtreg home directory from --with-jtreg=$with_jtreg does not exist])
b8a6cd8674d1 8180281: --with-jtreg is broken for many use cases
ihse
parents: 43918
diff changeset
  1086
    fi
b8a6cd8674d1 8180281: --with-jtreg is broken for many use cases
ihse
parents: 43918
diff changeset
  1087
b8a6cd8674d1 8180281: --with-jtreg is broken for many use cases
ihse
parents: 43918
diff changeset
  1088
    if test ! -e "$JT_HOME/lib/jtreg.jar"; then
b8a6cd8674d1 8180281: --with-jtreg is broken for many use cases
ihse
parents: 43918
diff changeset
  1089
      AC_MSG_ERROR([jtreg home directory from --with-jtreg=$with_jtreg is not a valid jtreg home])
b8a6cd8674d1 8180281: --with-jtreg is broken for many use cases
ihse
parents: 43918
diff changeset
  1090
    fi
b8a6cd8674d1 8180281: --with-jtreg is broken for many use cases
ihse
parents: 43918
diff changeset
  1091
b8a6cd8674d1 8180281: --with-jtreg is broken for many use cases
ihse
parents: 43918
diff changeset
  1092
    JTREGEXE="$JT_HOME/bin/jtreg"
b8a6cd8674d1 8180281: --with-jtreg is broken for many use cases
ihse
parents: 43918
diff changeset
  1093
    if test ! -x "$JTREGEXE"; then
b8a6cd8674d1 8180281: --with-jtreg is broken for many use cases
ihse
parents: 43918
diff changeset
  1094
      AC_MSG_ERROR([jtreg home directory from --with-jtreg=$with_jtreg does not contain valid jtreg executable])
17593
de6741d8a142 8007129: build-infra Add configure --with-jtreg option for location of JTREG
erikj
parents: 16988
diff changeset
  1095
    fi
17664
2cb42641740b 8015510: (s) Improve JTReg location detection and provide location to test/Makefile
mduigou
parents: 17593
diff changeset
  1096
45104
b8a6cd8674d1 8180281: --with-jtreg is broken for many use cases
ihse
parents: 43918
diff changeset
  1097
    AC_MSG_CHECKING([for jtreg test harness])
b8a6cd8674d1 8180281: --with-jtreg is broken for many use cases
ihse
parents: 43918
diff changeset
  1098
    AC_MSG_RESULT([$JT_HOME])
b8a6cd8674d1 8180281: --with-jtreg is broken for many use cases
ihse
parents: 43918
diff changeset
  1099
  else
b8a6cd8674d1 8180281: --with-jtreg is broken for many use cases
ihse
parents: 43918
diff changeset
  1100
    # Try to locate jtreg
17664
2cb42641740b 8015510: (s) Improve JTReg location detection and provide location to test/Makefile
mduigou
parents: 17593
diff changeset
  1101
    if test "x$JT_HOME" != x; then
45104
b8a6cd8674d1 8180281: --with-jtreg is broken for many use cases
ihse
parents: 43918
diff changeset
  1102
      # JT_HOME set in environment, use it
b8a6cd8674d1 8180281: --with-jtreg is broken for many use cases
ihse
parents: 43918
diff changeset
  1103
      if test ! -d "$JT_HOME"; then
b8a6cd8674d1 8180281: --with-jtreg is broken for many use cases
ihse
parents: 43918
diff changeset
  1104
        AC_MSG_WARN([Ignoring JT_HOME pointing to invalid directory: $JT_HOME])
b8a6cd8674d1 8180281: --with-jtreg is broken for many use cases
ihse
parents: 43918
diff changeset
  1105
        JT_HOME=
b8a6cd8674d1 8180281: --with-jtreg is broken for many use cases
ihse
parents: 43918
diff changeset
  1106
      else
b8a6cd8674d1 8180281: --with-jtreg is broken for many use cases
ihse
parents: 43918
diff changeset
  1107
        if test ! -e "$JT_HOME/lib/jtreg.jar"; then
b8a6cd8674d1 8180281: --with-jtreg is broken for many use cases
ihse
parents: 43918
diff changeset
  1108
          AC_MSG_WARN([Ignoring JT_HOME which is not a valid jtreg home: $JT_HOME])
b8a6cd8674d1 8180281: --with-jtreg is broken for many use cases
ihse
parents: 43918
diff changeset
  1109
          JT_HOME=
b8a6cd8674d1 8180281: --with-jtreg is broken for many use cases
ihse
parents: 43918
diff changeset
  1110
        elif test ! -x "$JT_HOME/bin/jtreg"; then
b8a6cd8674d1 8180281: --with-jtreg is broken for many use cases
ihse
parents: 43918
diff changeset
  1111
          AC_MSG_WARN([Ignoring JT_HOME which does not contain valid jtreg executable: $JT_HOME])
b8a6cd8674d1 8180281: --with-jtreg is broken for many use cases
ihse
parents: 43918
diff changeset
  1112
          JT_HOME=
b8a6cd8674d1 8180281: --with-jtreg is broken for many use cases
ihse
parents: 43918
diff changeset
  1113
        else
b8a6cd8674d1 8180281: --with-jtreg is broken for many use cases
ihse
parents: 43918
diff changeset
  1114
          JTREGEXE="$JT_HOME/bin/jtreg"
b8a6cd8674d1 8180281: --with-jtreg is broken for many use cases
ihse
parents: 43918
diff changeset
  1115
          AC_MSG_NOTICE([Located jtreg using JT_HOME from environment])
b8a6cd8674d1 8180281: --with-jtreg is broken for many use cases
ihse
parents: 43918
diff changeset
  1116
        fi
b8a6cd8674d1 8180281: --with-jtreg is broken for many use cases
ihse
parents: 43918
diff changeset
  1117
      fi
b8a6cd8674d1 8180281: --with-jtreg is broken for many use cases
ihse
parents: 43918
diff changeset
  1118
    fi
17664
2cb42641740b 8015510: (s) Improve JTReg location detection and provide location to test/Makefile
mduigou
parents: 17593
diff changeset
  1119
45104
b8a6cd8674d1 8180281: --with-jtreg is broken for many use cases
ihse
parents: 43918
diff changeset
  1120
    if test "x$JT_HOME" = x; then
b8a6cd8674d1 8180281: --with-jtreg is broken for many use cases
ihse
parents: 43918
diff changeset
  1121
      # JT_HOME is not set in environment, or was deemed invalid.
b8a6cd8674d1 8180281: --with-jtreg is broken for many use cases
ihse
parents: 43918
diff changeset
  1122
      # Try to find jtreg on path
b8a6cd8674d1 8180281: --with-jtreg is broken for many use cases
ihse
parents: 43918
diff changeset
  1123
      BASIC_PATH_PROGS(JTREGEXE, jtreg)
b8a6cd8674d1 8180281: --with-jtreg is broken for many use cases
ihse
parents: 43918
diff changeset
  1124
      if test "x$JTREGEXE" != x; then
b8a6cd8674d1 8180281: --with-jtreg is broken for many use cases
ihse
parents: 43918
diff changeset
  1125
        # That's good, now try to derive JT_HOME
b8a6cd8674d1 8180281: --with-jtreg is broken for many use cases
ihse
parents: 43918
diff changeset
  1126
        JT_HOME=`(cd $($DIRNAME $JTREGEXE)/.. && pwd)`
b8a6cd8674d1 8180281: --with-jtreg is broken for many use cases
ihse
parents: 43918
diff changeset
  1127
        if test ! -e "$JT_HOME/lib/jtreg.jar"; then
b8a6cd8674d1 8180281: --with-jtreg is broken for many use cases
ihse
parents: 43918
diff changeset
  1128
          AC_MSG_WARN([Ignoring jtreg from path since a valid jtreg home cannot be found])
b8a6cd8674d1 8180281: --with-jtreg is broken for many use cases
ihse
parents: 43918
diff changeset
  1129
          JT_HOME=
b8a6cd8674d1 8180281: --with-jtreg is broken for many use cases
ihse
parents: 43918
diff changeset
  1130
          JTREGEXE=
b8a6cd8674d1 8180281: --with-jtreg is broken for many use cases
ihse
parents: 43918
diff changeset
  1131
        else
b8a6cd8674d1 8180281: --with-jtreg is broken for many use cases
ihse
parents: 43918
diff changeset
  1132
          AC_MSG_NOTICE([Located jtreg using jtreg executable in path])
b8a6cd8674d1 8180281: --with-jtreg is broken for many use cases
ihse
parents: 43918
diff changeset
  1133
        fi
17664
2cb42641740b 8015510: (s) Improve JTReg location detection and provide location to test/Makefile
mduigou
parents: 17593
diff changeset
  1134
      fi
45104
b8a6cd8674d1 8180281: --with-jtreg is broken for many use cases
ihse
parents: 43918
diff changeset
  1135
    fi
17664
2cb42641740b 8015510: (s) Improve JTReg location detection and provide location to test/Makefile
mduigou
parents: 17593
diff changeset
  1136
45104
b8a6cd8674d1 8180281: --with-jtreg is broken for many use cases
ihse
parents: 43918
diff changeset
  1137
    AC_MSG_CHECKING([for jtreg test harness])
b8a6cd8674d1 8180281: --with-jtreg is broken for many use cases
ihse
parents: 43918
diff changeset
  1138
    if test "x$JT_HOME" != x; then
b8a6cd8674d1 8180281: --with-jtreg is broken for many use cases
ihse
parents: 43918
diff changeset
  1139
      AC_MSG_RESULT([$JT_HOME])
17664
2cb42641740b 8015510: (s) Improve JTReg location detection and provide location to test/Makefile
mduigou
parents: 17593
diff changeset
  1140
    else
45104
b8a6cd8674d1 8180281: --with-jtreg is broken for many use cases
ihse
parents: 43918
diff changeset
  1141
      AC_MSG_RESULT([no, not found])
b8a6cd8674d1 8180281: --with-jtreg is broken for many use cases
ihse
parents: 43918
diff changeset
  1142
b8a6cd8674d1 8180281: --with-jtreg is broken for many use cases
ihse
parents: 43918
diff changeset
  1143
      if test "x$with_jtreg" = xyes; then
b8a6cd8674d1 8180281: --with-jtreg is broken for many use cases
ihse
parents: 43918
diff changeset
  1144
        AC_MSG_ERROR([--with-jtreg was specified, but no jtreg found.])
b8a6cd8674d1 8180281: --with-jtreg is broken for many use cases
ihse
parents: 43918
diff changeset
  1145
      fi
17664
2cb42641740b 8015510: (s) Improve JTReg location detection and provide location to test/Makefile
mduigou
parents: 17593
diff changeset
  1146
    fi
2cb42641740b 8015510: (s) Improve JTReg location detection and provide location to test/Makefile
mduigou
parents: 17593
diff changeset
  1147
  fi
2cb42641740b 8015510: (s) Improve JTReg location detection and provide location to test/Makefile
mduigou
parents: 17593
diff changeset
  1148
45106
c74e98882464 8180342: Fixup path for jtreg
ihse
parents: 45104
diff changeset
  1149
  BASIC_FIXUP_EXECUTABLE(JTREGEXE)
c74e98882464 8180342: Fixup path for jtreg
ihse
parents: 45104
diff changeset
  1150
  BASIC_FIXUP_PATH(JT_HOME)
17664
2cb42641740b 8015510: (s) Improve JTReg location detection and provide location to test/Makefile
mduigou
parents: 17593
diff changeset
  1151
  AC_SUBST(JT_HOME)
2cb42641740b 8015510: (s) Improve JTReg location detection and provide location to test/Makefile
mduigou
parents: 17593
diff changeset
  1152
  AC_SUBST(JTREGEXE)
17593
de6741d8a142 8007129: build-infra Add configure --with-jtreg option for location of JTREG
erikj
parents: 16988
diff changeset
  1153
])
46196
822ca950ddaa 8175300: Enable artifact resolution for jtreg tests
ctornqvi
parents: 42297
diff changeset
  1154
822ca950ddaa 8175300: Enable artifact resolution for jtreg tests
ctornqvi
parents: 42297
diff changeset
  1155
# Setup the JIB dependency resolver
822ca950ddaa 8175300: Enable artifact resolution for jtreg tests
ctornqvi
parents: 42297
diff changeset
  1156
AC_DEFUN_ONCE([TOOLCHAIN_SETUP_JIB],
822ca950ddaa 8175300: Enable artifact resolution for jtreg tests
ctornqvi
parents: 42297
diff changeset
  1157
[
822ca950ddaa 8175300: Enable artifact resolution for jtreg tests
ctornqvi
parents: 42297
diff changeset
  1158
  AC_ARG_WITH(jib, [AS_HELP_STRING([--with-jib],
822ca950ddaa 8175300: Enable artifact resolution for jtreg tests
ctornqvi
parents: 42297
diff changeset
  1159
      [Jib dependency management tool @<:@not used@:>@])])
822ca950ddaa 8175300: Enable artifact resolution for jtreg tests
ctornqvi
parents: 42297
diff changeset
  1160
822ca950ddaa 8175300: Enable artifact resolution for jtreg tests
ctornqvi
parents: 42297
diff changeset
  1161
  if test "x$with_jib" = xno || test "x$with_jib" = x; then
822ca950ddaa 8175300: Enable artifact resolution for jtreg tests
ctornqvi
parents: 42297
diff changeset
  1162
    # jib disabled
822ca950ddaa 8175300: Enable artifact resolution for jtreg tests
ctornqvi
parents: 42297
diff changeset
  1163
    AC_MSG_CHECKING([for jib])
822ca950ddaa 8175300: Enable artifact resolution for jtreg tests
ctornqvi
parents: 42297
diff changeset
  1164
    AC_MSG_RESULT(no)
822ca950ddaa 8175300: Enable artifact resolution for jtreg tests
ctornqvi
parents: 42297
diff changeset
  1165
  elif test "x$with_jib" = xyes; then
822ca950ddaa 8175300: Enable artifact resolution for jtreg tests
ctornqvi
parents: 42297
diff changeset
  1166
    AC_MSG_ERROR([Must supply a value to --with-jib])
822ca950ddaa 8175300: Enable artifact resolution for jtreg tests
ctornqvi
parents: 42297
diff changeset
  1167
  else
822ca950ddaa 8175300: Enable artifact resolution for jtreg tests
ctornqvi
parents: 42297
diff changeset
  1168
    JIB_HOME="${with_jib}"
822ca950ddaa 8175300: Enable artifact resolution for jtreg tests
ctornqvi
parents: 42297
diff changeset
  1169
    AC_MSG_CHECKING([for jib])
822ca950ddaa 8175300: Enable artifact resolution for jtreg tests
ctornqvi
parents: 42297
diff changeset
  1170
    AC_MSG_RESULT(${JIB_HOME})
822ca950ddaa 8175300: Enable artifact resolution for jtreg tests
ctornqvi
parents: 42297
diff changeset
  1171
    if test ! -d "${JIB_HOME}"; then
822ca950ddaa 8175300: Enable artifact resolution for jtreg tests
ctornqvi
parents: 42297
diff changeset
  1172
      AC_MSG_ERROR([--with-jib must be a directory])
822ca950ddaa 8175300: Enable artifact resolution for jtreg tests
ctornqvi
parents: 42297
diff changeset
  1173
    fi
822ca950ddaa 8175300: Enable artifact resolution for jtreg tests
ctornqvi
parents: 42297
diff changeset
  1174
    JIB_JAR=$(ls ${JIB_HOME}/lib/jib-*.jar)
822ca950ddaa 8175300: Enable artifact resolution for jtreg tests
ctornqvi
parents: 42297
diff changeset
  1175
    if test ! -f "${JIB_JAR}"; then
822ca950ddaa 8175300: Enable artifact resolution for jtreg tests
ctornqvi
parents: 42297
diff changeset
  1176
      AC_MSG_ERROR([Could not find jib jar file in ${JIB_HOME}])
822ca950ddaa 8175300: Enable artifact resolution for jtreg tests
ctornqvi
parents: 42297
diff changeset
  1177
    fi
822ca950ddaa 8175300: Enable artifact resolution for jtreg tests
ctornqvi
parents: 42297
diff changeset
  1178
  fi
822ca950ddaa 8175300: Enable artifact resolution for jtreg tests
ctornqvi
parents: 42297
diff changeset
  1179
51856
11b9d3a6f31c 8211037: Load jib jars dynamically from JibArtifactManager
erikj
parents: 51811
diff changeset
  1180
  AC_SUBST(JIB_HOME)
46196
822ca950ddaa 8175300: Enable artifact resolution for jtreg tests
ctornqvi
parents: 42297
diff changeset
  1181
])