make/autoconf/flags-cflags.m4
author cgo
Tue, 26 Nov 2019 10:00:33 +0100
changeset 59281 eef0bf57357c
parent 58909 66f7d2494d4e
child 59287 c04fa10636fd
permissions -rw-r--r--
8234535: Cross compilation fails due to missing CFLAGS for the BUILD_CC Reviewed-by: erikj
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
49120
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
     1
#
54490
bf07e140c49c 8221851: Use of THIS_FILE in hotspot invalidates precompiled header on Linux/GCC
erikj
parents: 53837
diff changeset
     2
# Copyright (c) 2011, 2019, Oracle and/or its affiliates. All rights reserved.
49120
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
     3
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
     4
#
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
     5
# This code is free software; you can redistribute it and/or modify it
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
     6
# under the terms of the GNU General Public License version 2 only, as
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
     7
# published by the Free Software Foundation.  Oracle designates this
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
     8
# particular file as subject to the "Classpath" exception as provided
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
     9
# by Oracle in the LICENSE file that accompanied this code.
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
    10
#
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
    11
# This code is distributed in the hope that it will be useful, but WITHOUT
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
    12
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
    13
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
    14
# version 2 for more details (a copy is included in the LICENSE file that
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
    15
# accompanied this code).
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
    16
#
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
    17
# You should have received a copy of the GNU General Public License version
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
    18
# 2 along with this work; if not, write to the Free Software Foundation,
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
    19
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
    20
#
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
    21
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
    22
# or visit www.oracle.com if you need additional information or have any
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
    23
# questions.
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
    24
#
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
    25
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
    26
################################################################################
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
    27
#
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
    28
# Setup flags for C/C++ compiler
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
    29
#
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
    30
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
    31
###############################################################################
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
    32
#
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
    33
# How to compile shared libraries.
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
    34
#
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
    35
AC_DEFUN([FLAGS_SETUP_SHARED_LIBS],
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
    36
[
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
    37
  if test "x$TOOLCHAIN_TYPE" = xgcc; then
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
    38
    C_FLAG_REORDER=''
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
    39
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
    40
    # Default works for linux, might work on other platforms as well.
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
    41
    SHARED_LIBRARY_FLAGS='-shared'
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
    42
    SET_EXECUTABLE_ORIGIN='-Wl,-rpath,\$$ORIGIN[$]1'
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
    43
    SET_SHARED_LIBRARY_ORIGIN="-Wl,-z,origin $SET_EXECUTABLE_ORIGIN"
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
    44
    SET_SHARED_LIBRARY_NAME='-Wl,-soname=[$]1'
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
    45
    SET_SHARED_LIBRARY_MAPFILE='-Wl,-version-script=[$]1'
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
    46
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
    47
  elif test "x$TOOLCHAIN_TYPE" = xclang; then
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
    48
    C_FLAG_REORDER=''
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
    49
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
    50
    if test "x$OPENJDK_TARGET_OS" = xmacosx; then
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
    51
      # Linking is different on MacOSX
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
    52
      SHARED_LIBRARY_FLAGS="-dynamiclib -compatibility_version 1.0.0 -current_version 1.0.0"
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
    53
      SET_EXECUTABLE_ORIGIN='-Wl,-rpath,@loader_path$(or [$]1,/.)'
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
    54
      SET_SHARED_LIBRARY_ORIGIN="$SET_EXECUTABLE_ORIGIN"
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
    55
      SET_SHARED_LIBRARY_NAME='-Wl,-install_name,@rpath/[$]1'
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
    56
      SET_SHARED_LIBRARY_MAPFILE='-Wl,-exported_symbols_list,[$]1'
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
    57
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
    58
    else
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
    59
      # Default works for linux, might work on other platforms as well.
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
    60
      SHARED_LIBRARY_FLAGS='-shared'
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
    61
      SET_EXECUTABLE_ORIGIN='-Wl,-rpath,\$$ORIGIN[$]1'
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
    62
      SET_SHARED_LIBRARY_NAME='-Wl,-soname=[$]1'
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
    63
      SET_SHARED_LIBRARY_MAPFILE='-Wl,-version-script=[$]1'
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
    64
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
    65
      # arm specific settings
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
    66
      if test "x$OPENJDK_TARGET_CPU" = "xarm"; then
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
    67
        # '-Wl,-z,origin' isn't used on arm.
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
    68
        SET_SHARED_LIBRARY_ORIGIN='-Wl,-rpath,\$$$$ORIGIN[$]1'
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
    69
      else
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
    70
        SET_SHARED_LIBRARY_ORIGIN="-Wl,-z,origin $SET_EXECUTABLE_ORIGIN"
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
    71
      fi
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
    72
    fi
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
    73
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
    74
  elif test "x$TOOLCHAIN_TYPE" = xsolstudio; then
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
    75
    C_FLAG_REORDER='-xF'
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
    76
    SHARED_LIBRARY_FLAGS="-G"
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
    77
    SET_EXECUTABLE_ORIGIN='-R\$$ORIGIN[$]1'
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
    78
    SET_SHARED_LIBRARY_ORIGIN="$SET_EXECUTABLE_ORIGIN"
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
    79
    SET_SHARED_LIBRARY_NAME='-h [$]1'
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
    80
    SET_SHARED_LIBRARY_MAPFILE='-M[$]1'
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
    81
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
    82
  elif test "x$TOOLCHAIN_TYPE" = xxlc; then
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
    83
    C_FLAG_REORDER=''
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
    84
    SHARED_LIBRARY_FLAGS="-qmkshrobj -bM:SRE -bnoentry"
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
    85
    SET_EXECUTABLE_ORIGIN=""
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
    86
    SET_SHARED_LIBRARY_ORIGIN=''
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
    87
    SET_SHARED_LIBRARY_NAME=''
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
    88
    SET_SHARED_LIBRARY_MAPFILE=''
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
    89
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
    90
  elif test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
    91
    C_FLAG_REORDER=''
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
    92
    SHARED_LIBRARY_FLAGS="-dll"
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
    93
    SET_EXECUTABLE_ORIGIN=''
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
    94
    SET_SHARED_LIBRARY_ORIGIN=''
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
    95
    SET_SHARED_LIBRARY_NAME=''
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
    96
    SET_SHARED_LIBRARY_MAPFILE='-def:[$]1'
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
    97
  fi
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
    98
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
    99
  AC_SUBST(C_FLAG_REORDER)
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   100
  AC_SUBST(SET_EXECUTABLE_ORIGIN)
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   101
  AC_SUBST(SET_SHARED_LIBRARY_ORIGIN)
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   102
  AC_SUBST(SET_SHARED_LIBRARY_NAME)
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   103
  AC_SUBST(SET_SHARED_LIBRARY_MAPFILE)
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   104
  AC_SUBST(SHARED_LIBRARY_FLAGS)
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   105
])
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   106
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   107
AC_DEFUN([FLAGS_SETUP_DEBUG_SYMBOLS],
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   108
[
51095
a8ee31fb99e1 8207057: No debug info for assembler files
sgehwolf
parents: 50781
diff changeset
   109
  # By default don't set any specific assembler debug
a8ee31fb99e1 8207057: No debug info for assembler files
sgehwolf
parents: 50781
diff changeset
   110
  # info flags for toolchains unless we know they work.
a8ee31fb99e1 8207057: No debug info for assembler files
sgehwolf
parents: 50781
diff changeset
   111
  # See JDK-8207057.
a8ee31fb99e1 8207057: No debug info for assembler files
sgehwolf
parents: 50781
diff changeset
   112
  ASFLAGS_DEBUG_SYMBOLS=""
49120
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   113
  # Debug symbols
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   114
  if test "x$TOOLCHAIN_TYPE" = xgcc; then
49156
6aaf3aef2d67 8199331: Don't limit debug information for fastdebug JDK native libraries
ihse
parents: 49155
diff changeset
   115
    CFLAGS_DEBUG_SYMBOLS="-g"
51095
a8ee31fb99e1 8207057: No debug info for assembler files
sgehwolf
parents: 50781
diff changeset
   116
    ASFLAGS_DEBUG_SYMBOLS="-g"
49120
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   117
  elif test "x$TOOLCHAIN_TYPE" = xclang; then
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   118
    CFLAGS_DEBUG_SYMBOLS="-g"
51095
a8ee31fb99e1 8207057: No debug info for assembler files
sgehwolf
parents: 50781
diff changeset
   119
    ASFLAGS_DEBUG_SYMBOLS="-g"
49120
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   120
  elif test "x$TOOLCHAIN_TYPE" = xsolstudio; then
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   121
    # -g0 enables debug symbols without disabling inlining.
49155
7cd937277d5e 8199338: Use -g0 on solstudio also for compiling C programs
ihse
parents: 49120
diff changeset
   122
    CFLAGS_DEBUG_SYMBOLS="-g0 -xs"
49120
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   123
  elif test "x$TOOLCHAIN_TYPE" = xxlc; then
57975
a333fdeb8de0 8224214: [AIX] Remove support for legacy xlc compiler
mbaesken
parents: 57481
diff changeset
   124
    CFLAGS_DEBUG_SYMBOLS="-g1"
49120
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   125
  elif test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
49160
cefb7b496d17 8199347: Always use -Z7 for debug symbols when compiling on Windows
ihse
parents: 49156
diff changeset
   126
    CFLAGS_DEBUG_SYMBOLS="-Z7 -d2Zi+"
49120
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   127
  fi
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   128
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   129
  AC_SUBST(CFLAGS_DEBUG_SYMBOLS)
51095
a8ee31fb99e1 8207057: No debug info for assembler files
sgehwolf
parents: 50781
diff changeset
   130
  AC_SUBST(ASFLAGS_DEBUG_SYMBOLS)
49120
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   131
])
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   132
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   133
AC_DEFUN([FLAGS_SETUP_WARNINGS],
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   134
[
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   135
  AC_ARG_ENABLE([warnings-as-errors], [AS_HELP_STRING([--disable-warnings-as-errors],
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   136
      [do not consider native warnings to be an error @<:@enabled@:>@])])
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   137
49907
1ca3406a2101 8202325: [aix] disable warnings-as-errors by default
stuefe
parents: 49726
diff changeset
   138
  # Set default value.
1ca3406a2101 8202325: [aix] disable warnings-as-errors by default
stuefe
parents: 49726
diff changeset
   139
  if test "x$TOOLCHAIN_TYPE" = xxlc; then
1ca3406a2101 8202325: [aix] disable warnings-as-errors by default
stuefe
parents: 49726
diff changeset
   140
    WARNINGS_AS_ERRORS=false
1ca3406a2101 8202325: [aix] disable warnings-as-errors by default
stuefe
parents: 49726
diff changeset
   141
  else
1ca3406a2101 8202325: [aix] disable warnings-as-errors by default
stuefe
parents: 49726
diff changeset
   142
    WARNINGS_AS_ERRORS=true
1ca3406a2101 8202325: [aix] disable warnings-as-errors by default
stuefe
parents: 49726
diff changeset
   143
  fi
1ca3406a2101 8202325: [aix] disable warnings-as-errors by default
stuefe
parents: 49726
diff changeset
   144
49120
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   145
  AC_MSG_CHECKING([if native warnings are errors])
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   146
  if test "x$enable_warnings_as_errors" = "xyes"; then
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   147
    AC_MSG_RESULT([yes (explicitly set)])
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   148
    WARNINGS_AS_ERRORS=true
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   149
  elif test "x$enable_warnings_as_errors" = "xno"; then
49907
1ca3406a2101 8202325: [aix] disable warnings-as-errors by default
stuefe
parents: 49726
diff changeset
   150
    AC_MSG_RESULT([no (explicitly set)])
49120
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   151
    WARNINGS_AS_ERRORS=false
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   152
  elif test "x$enable_warnings_as_errors" = "x"; then
49907
1ca3406a2101 8202325: [aix] disable warnings-as-errors by default
stuefe
parents: 49726
diff changeset
   153
    AC_MSG_RESULT([${WARNINGS_AS_ERRORS} (default)])
49120
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   154
  else
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   155
    AC_MSG_ERROR([--enable-warnings-as-errors accepts no argument])
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   156
  fi
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   157
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   158
  AC_SUBST(WARNINGS_AS_ERRORS)
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   159
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   160
  case "${TOOLCHAIN_TYPE}" in
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   161
    microsoft)
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   162
      DISABLE_WARNING_PREFIX="-wd"
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   163
      CFLAGS_WARNINGS_ARE_ERRORS="-WX"
51839
ab54a4d61d7f 8210988: Improved handling of compiler warnings in the build
ihse
parents: 51814
diff changeset
   164
ab54a4d61d7f 8210988: Improved handling of compiler warnings in the build
ihse
parents: 51814
diff changeset
   165
      WARNINGS_ENABLE_ALL="-W3"
ab54a4d61d7f 8210988: Improved handling of compiler warnings in the build
ihse
parents: 51814
diff changeset
   166
      DISABLED_WARNINGS="4800"
49120
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   167
      ;;
51839
ab54a4d61d7f 8210988: Improved handling of compiler warnings in the build
ihse
parents: 51814
diff changeset
   168
49120
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   169
    solstudio)
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   170
      DISABLE_WARNING_PREFIX="-erroff="
51839
ab54a4d61d7f 8210988: Improved handling of compiler warnings in the build
ihse
parents: 51814
diff changeset
   171
      CFLAGS_WARNINGS_ARE_ERRORS="-errwarn=%all"
ab54a4d61d7f 8210988: Improved handling of compiler warnings in the build
ihse
parents: 51814
diff changeset
   172
58747
c6fd655677ec 8232770: Enable more warnings on solaris studio
ihse
parents: 57975
diff changeset
   173
      WARNINGS_ENABLE_ALL_CFLAGS="-v -fd -xtransition"
c6fd655677ec 8232770: Enable more warnings on solaris studio
ihse
parents: 57975
diff changeset
   174
      WARNINGS_ENABLE_ALL_CXXFLAGS="+w +w2"
51839
ab54a4d61d7f 8210988: Improved handling of compiler warnings in the build
ihse
parents: 51814
diff changeset
   175
58747
c6fd655677ec 8232770: Enable more warnings on solaris studio
ihse
parents: 57975
diff changeset
   176
      DISABLED_WARNINGS_C="E_OLD_STYLE_FUNC_DECL E_OLD_STYLE_FUNC_DEF E_SEMANTICS_OF_OP_CHG_IN_ANSI_C E_NO_REPLACEMENT_IN_STRING E_DECLARATION_IN_CODE"
c6fd655677ec 8232770: Enable more warnings on solaris studio
ihse
parents: 57975
diff changeset
   177
      DISABLED_WARNINGS_CXX="inllargeuse inllargeint notused wemptydecl notemsource"
49120
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   178
      ;;
51839
ab54a4d61d7f 8210988: Improved handling of compiler warnings in the build
ihse
parents: 51814
diff changeset
   179
49120
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   180
    gcc)
49200
a19a6228cdb2 8199405: Bump lowest supported gcc to 4.8
ihse
parents: 49160
diff changeset
   181
      DISABLE_WARNING_PREFIX="-Wno-"
49120
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   182
      CFLAGS_WARNINGS_ARE_ERRORS="-Werror"
51839
ab54a4d61d7f 8210988: Improved handling of compiler warnings in the build
ihse
parents: 51814
diff changeset
   183
51853
ec62d6cab037 8211029: Have a common set of enabled warnings for all native libraries
ihse
parents: 51839
diff changeset
   184
      # Additional warnings that are not activated by -Wall and -Wextra
ec62d6cab037 8211029: Have a common set of enabled warnings for all native libraries
ihse
parents: 51839
diff changeset
   185
      WARNINGS_ENABLE_ADDITIONAL="-Wpointer-arith -Wsign-compare \
53174
8970b75f0d37 8215400: Warn on usage of trampolines with gcc
erikj
parents: 52351
diff changeset
   186
          -Wunused-function -Wundef -Wunused-value -Wreturn-type \
8970b75f0d37 8215400: Warn on usage of trampolines with gcc
erikj
parents: 52351
diff changeset
   187
          -Wtrampolines"
51853
ec62d6cab037 8211029: Have a common set of enabled warnings for all native libraries
ihse
parents: 51839
diff changeset
   188
      WARNINGS_ENABLE_ADDITIONAL_CXX="-Woverloaded-virtual -Wreorder"
ec62d6cab037 8211029: Have a common set of enabled warnings for all native libraries
ihse
parents: 51839
diff changeset
   189
      WARNINGS_ENABLE_ALL_CFLAGS="-Wall -Wextra -Wformat=2 $WARNINGS_ENABLE_ADDITIONAL"
ec62d6cab037 8211029: Have a common set of enabled warnings for all native libraries
ihse
parents: 51839
diff changeset
   190
      WARNINGS_ENABLE_ALL_CXXFLAGS="$WARNINGS_ENABLE_ALL_CFLAGS $WARNINGS_ENABLE_ADDITIONAL_CXX"
51839
ab54a4d61d7f 8210988: Improved handling of compiler warnings in the build
ihse
parents: 51814
diff changeset
   191
ab54a4d61d7f 8210988: Improved handling of compiler warnings in the build
ihse
parents: 51814
diff changeset
   192
      DISABLED_WARNINGS="unused-parameter unused"
49200
a19a6228cdb2 8199405: Bump lowest supported gcc to 4.8
ihse
parents: 49160
diff changeset
   193
      BUILD_CC_DISABLE_WARNING_PREFIX="-Wno-"
49120
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   194
      ;;
51839
ab54a4d61d7f 8210988: Improved handling of compiler warnings in the build
ihse
parents: 51814
diff changeset
   195
49120
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   196
    clang)
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   197
      DISABLE_WARNING_PREFIX="-Wno-"
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   198
      CFLAGS_WARNINGS_ARE_ERRORS="-Werror"
51839
ab54a4d61d7f 8210988: Improved handling of compiler warnings in the build
ihse
parents: 51814
diff changeset
   199
51853
ec62d6cab037 8211029: Have a common set of enabled warnings for all native libraries
ihse
parents: 51839
diff changeset
   200
      # Additional warnings that are not activated by -Wall and -Wextra
ec62d6cab037 8211029: Have a common set of enabled warnings for all native libraries
ihse
parents: 51839
diff changeset
   201
      WARNINGS_ENABLE_ADDITIONAL="-Wpointer-arith -Wsign-compare -Wreorder \
ec62d6cab037 8211029: Have a common set of enabled warnings for all native libraries
ihse
parents: 51839
diff changeset
   202
          -Wunused-function -Wundef -Wunused-value -Woverloaded-virtual"
ec62d6cab037 8211029: Have a common set of enabled warnings for all native libraries
ihse
parents: 51839
diff changeset
   203
      WARNINGS_ENABLE_ALL="-Wall -Wextra -Wformat=2 $WARNINGS_ENABLE_ADDITIONAL"
51839
ab54a4d61d7f 8210988: Improved handling of compiler warnings in the build
ihse
parents: 51814
diff changeset
   204
54711
297ddf282627 8223309: test failing due to self-assign-overloaded
erikj
parents: 54646
diff changeset
   205
      DISABLED_WARNINGS="unknown-warning-option unused-parameter unused"
51853
ec62d6cab037 8211029: Have a common set of enabled warnings for all native libraries
ihse
parents: 51839
diff changeset
   206
ec62d6cab037 8211029: Have a common set of enabled warnings for all native libraries
ihse
parents: 51839
diff changeset
   207
      if test "x$OPENJDK_TARGET_OS" = xmacosx; then
ec62d6cab037 8211029: Have a common set of enabled warnings for all native libraries
ihse
parents: 51839
diff changeset
   208
        # missing-method-return-type triggers in JavaNativeFoundation framework
ec62d6cab037 8211029: Have a common set of enabled warnings for all native libraries
ihse
parents: 51839
diff changeset
   209
        DISABLED_WARNINGS="$DISABLED_WARNINGS missing-method-return-type"
ec62d6cab037 8211029: Have a common set of enabled warnings for all native libraries
ihse
parents: 51839
diff changeset
   210
      fi
ec62d6cab037 8211029: Have a common set of enabled warnings for all native libraries
ihse
parents: 51839
diff changeset
   211
49120
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   212
      ;;
51839
ab54a4d61d7f 8210988: Improved handling of compiler warnings in the build
ihse
parents: 51814
diff changeset
   213
49120
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   214
    xlc)
57481
aaa83519e723 8228426: xlc: switch to clang-style warning disabling
mbaesken
parents: 55623
diff changeset
   215
      DISABLE_WARNING_PREFIX="-Wno-"
49120
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   216
      CFLAGS_WARNINGS_ARE_ERRORS="-qhalt=w"
51839
ab54a4d61d7f 8210988: Improved handling of compiler warnings in the build
ihse
parents: 51814
diff changeset
   217
ab54a4d61d7f 8210988: Improved handling of compiler warnings in the build
ihse
parents: 51814
diff changeset
   218
      # Possibly a better subset than "all" is "lan:trx:ret:zea:cmp:ret"
ab54a4d61d7f 8210988: Improved handling of compiler warnings in the build
ihse
parents: 51814
diff changeset
   219
      WARNINGS_ENABLE_ALL="-qinfo=all -qformat=all"
ab54a4d61d7f 8210988: Improved handling of compiler warnings in the build
ihse
parents: 51814
diff changeset
   220
      DISABLED_WARNINGS=""
49120
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   221
      ;;
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   222
  esac
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   223
  AC_SUBST(DISABLE_WARNING_PREFIX)
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   224
  AC_SUBST(BUILD_CC_DISABLE_WARNING_PREFIX)
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   225
  AC_SUBST(CFLAGS_WARNINGS_ARE_ERRORS)
51839
ab54a4d61d7f 8210988: Improved handling of compiler warnings in the build
ihse
parents: 51814
diff changeset
   226
  AC_SUBST(DISABLED_WARNINGS)
ab54a4d61d7f 8210988: Improved handling of compiler warnings in the build
ihse
parents: 51814
diff changeset
   227
  AC_SUBST(DISABLED_WARNINGS_C)
ab54a4d61d7f 8210988: Improved handling of compiler warnings in the build
ihse
parents: 51814
diff changeset
   228
  AC_SUBST(DISABLED_WARNINGS_CXX)
49120
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   229
])
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   230
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   231
AC_DEFUN([FLAGS_SETUP_QUALITY_CHECKS],
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   232
[
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   233
  # bounds, memory and behavior checking options
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   234
  if test "x$TOOLCHAIN_TYPE" = xgcc; then
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   235
    case $DEBUG_LEVEL in
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   236
    release )
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   237
      # no adjustment
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   238
      ;;
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   239
    fastdebug )
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   240
      # no adjustment
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   241
      ;;
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   242
    slowdebug )
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   243
      # FIXME: By adding this to C(XX)FLAGS_DEBUG_OPTIONS/JVM_CFLAGS_SYMBOLS it
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   244
      # get's added conditionally on whether we produce debug symbols or not.
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   245
      # This is most likely not really correct.
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   246
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   247
      # Add runtime stack smashing and undefined behavior checks.
49200
a19a6228cdb2 8199405: Bump lowest supported gcc to 4.8
ihse
parents: 49160
diff changeset
   248
      CFLAGS_DEBUG_OPTIONS="-fstack-protector-all --param ssp-buffer-size=1"
a19a6228cdb2 8199405: Bump lowest supported gcc to 4.8
ihse
parents: 49160
diff changeset
   249
      CXXFLAGS_DEBUG_OPTIONS="-fstack-protector-all --param ssp-buffer-size=1"
49120
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   250
49200
a19a6228cdb2 8199405: Bump lowest supported gcc to 4.8
ihse
parents: 49160
diff changeset
   251
      JVM_CFLAGS_SYMBOLS="$JVM_CFLAGS_SYMBOLS -fstack-protector-all --param ssp-buffer-size=1"
49120
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   252
      ;;
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   253
    esac
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   254
  fi
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   255
])
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   256
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   257
AC_DEFUN([FLAGS_SETUP_OPTIMIZATION],
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   258
[
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   259
  if test "x$TOOLCHAIN_TYPE" = xsolstudio; then
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   260
    CC_HIGHEST="-fns -fsimple -fsingle -xbuiltin=%all -xdepend -xrestrict -xlibmil"
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   261
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   262
    C_O_FLAG_HIGHEST_JVM="-xO4"
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   263
    C_O_FLAG_DEBUG_JVM=""
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   264
    C_O_FLAG_SIZE=""
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   265
    C_O_FLAG_DEBUG=""
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   266
    C_O_FLAG_NONE=""
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   267
    if test "x$OPENJDK_TARGET_CPU_ARCH" = "xx86"; then
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   268
      C_O_FLAG_HIGHEST="-xO4 -Wu,-O4~yz $CC_HIGHEST"
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   269
      C_O_FLAG_HI="-xO4 -Wu,-O4~yz"
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   270
      C_O_FLAG_NORM="-xO2 -Wu,-O2~yz"
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   271
    elif test "x$OPENJDK_TARGET_CPU_ARCH" = "xsparc"; then
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   272
      C_O_FLAG_HIGHEST="-xO4 -Wc,-Qrm-s -Wc,-Qiselect-T0 \
50645
9cdde9293187 8205110: Fix xchip warnings with new Solaris toolchain
gadams
parents: 50550
diff changeset
   273
          -xprefetch=auto,explicit $CC_HIGHEST"
49120
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   274
      C_O_FLAG_HI="-xO4 -Wc,-Qrm-s -Wc,-Qiselect-T0"
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   275
      C_O_FLAG_NORM="-xO2 -Wc,-Qrm-s -Wc,-Qiselect-T0"
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   276
    fi
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   277
  elif test "x$TOOLCHAIN_TYPE" = xgcc; then
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   278
    C_O_FLAG_HIGHEST_JVM="-O3"
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   279
    C_O_FLAG_HIGHEST="-O3"
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   280
    C_O_FLAG_HI="-O3"
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   281
    C_O_FLAG_NORM="-O2"
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   282
    C_O_FLAG_SIZE="-Os"
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   283
    C_O_FLAG_DEBUG="-O0"
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   284
    C_O_FLAG_DEBUG_JVM="-O0"
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   285
    C_O_FLAG_NONE="-O0"
54937
7e5e0b326ed7 8130017: use _FORTIFY_SOURCE in gcc fastdebug builds
mbaesken
parents: 54711
diff changeset
   286
    # -D_FORTIFY_SOURCE=2 hardening option needs optimization (at least -O1) enabled
7e5e0b326ed7 8130017: use _FORTIFY_SOURCE in gcc fastdebug builds
mbaesken
parents: 54711
diff changeset
   287
    # set for lower O-levels -U_FORTIFY_SOURCE to overwrite previous settings
7e5e0b326ed7 8130017: use _FORTIFY_SOURCE in gcc fastdebug builds
mbaesken
parents: 54711
diff changeset
   288
    if test "x$OPENJDK_TARGET_OS" = xlinux -a "x$DEBUG_LEVEL" = "xfastdebug"; then
7e5e0b326ed7 8130017: use _FORTIFY_SOURCE in gcc fastdebug builds
mbaesken
parents: 54711
diff changeset
   289
      ENABLE_FORTIFY_CFLAGS="-D_FORTIFY_SOURCE=2"
7e5e0b326ed7 8130017: use _FORTIFY_SOURCE in gcc fastdebug builds
mbaesken
parents: 54711
diff changeset
   290
      DISABLE_FORTIFY_CFLAGS="-U_FORTIFY_SOURCE"
7e5e0b326ed7 8130017: use _FORTIFY_SOURCE in gcc fastdebug builds
mbaesken
parents: 54711
diff changeset
   291
      C_O_FLAG_HIGHEST_JVM="${C_O_FLAG_HIGHEST_JVM} ${ENABLE_FORTIFY_CFLAGS}"
7e5e0b326ed7 8130017: use _FORTIFY_SOURCE in gcc fastdebug builds
mbaesken
parents: 54711
diff changeset
   292
      C_O_FLAG_HIGHEST="${C_O_FLAG_HIGHEST} ${ENABLE_FORTIFY_CFLAGS}"
7e5e0b326ed7 8130017: use _FORTIFY_SOURCE in gcc fastdebug builds
mbaesken
parents: 54711
diff changeset
   293
      C_O_FLAG_HI="${C_O_FLAG_HI} ${ENABLE_FORTIFY_CFLAGS}"
7e5e0b326ed7 8130017: use _FORTIFY_SOURCE in gcc fastdebug builds
mbaesken
parents: 54711
diff changeset
   294
      C_O_FLAG_NORM="${C_O_FLAG_NORM} ${ENABLE_FORTIFY_CFLAGS}"
7e5e0b326ed7 8130017: use _FORTIFY_SOURCE in gcc fastdebug builds
mbaesken
parents: 54711
diff changeset
   295
      C_O_FLAG_SIZE="${C_O_FLAG_SIZE} ${DISABLE_FORTIFY_CFLAGS}"
7e5e0b326ed7 8130017: use _FORTIFY_SOURCE in gcc fastdebug builds
mbaesken
parents: 54711
diff changeset
   296
      C_O_FLAG_DEBUG="${C_O_FLAG_DEBUG} ${DISABLE_FORTIFY_CFLAGS}"
7e5e0b326ed7 8130017: use _FORTIFY_SOURCE in gcc fastdebug builds
mbaesken
parents: 54711
diff changeset
   297
      C_O_FLAG_DEBUG_JVM="${C_O_FLAG_DEBUG_JVM} ${DISABLE_FORTIFY_CFLAGS}"
7e5e0b326ed7 8130017: use _FORTIFY_SOURCE in gcc fastdebug builds
mbaesken
parents: 54711
diff changeset
   298
      C_O_FLAG_NONE="${C_O_FLAG_NONE} ${DISABLE_FORTIFY_CFLAGS}"
7e5e0b326ed7 8130017: use _FORTIFY_SOURCE in gcc fastdebug builds
mbaesken
parents: 54711
diff changeset
   299
    fi
49120
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   300
  elif test "x$TOOLCHAIN_TYPE" = xclang; then
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   301
    if test "x$OPENJDK_TARGET_OS" = xmacosx; then
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   302
      # On MacOSX we optimize for size, something
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   303
      # we should do for all platforms?
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   304
      C_O_FLAG_HIGHEST_JVM="-Os"
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   305
      C_O_FLAG_HIGHEST="-Os"
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   306
      C_O_FLAG_HI="-Os"
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   307
      C_O_FLAG_NORM="-Os"
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   308
      C_O_FLAG_DEBUG_JVM=""
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   309
    else
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   310
      C_O_FLAG_HIGHEST_JVM="-O3"
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   311
      C_O_FLAG_HIGHEST="-O3"
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   312
      C_O_FLAG_HI="-O3"
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   313
      C_O_FLAG_NORM="-O2"
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   314
      C_O_FLAG_DEBUG_JVM="-O0"
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   315
    fi
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   316
    C_O_FLAG_SIZE="-Os"
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   317
    C_O_FLAG_DEBUG="-O0"
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   318
    C_O_FLAG_NONE="-O0"
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   319
  elif test "x$TOOLCHAIN_TYPE" = xxlc; then
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   320
    C_O_FLAG_HIGHEST_JVM="-O3 -qhot=level=1 -qinline -qinlglue"
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   321
    C_O_FLAG_HIGHEST="-O3 -qhot=level=1 -qinline -qinlglue"
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   322
    C_O_FLAG_HI="-O3 -qinline -qinlglue"
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   323
    C_O_FLAG_NORM="-O2"
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   324
    C_O_FLAG_DEBUG="-qnoopt"
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   325
    # FIXME: Value below not verified.
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   326
    C_O_FLAG_DEBUG_JVM=""
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   327
    C_O_FLAG_NONE="-qnoopt"
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   328
  elif test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   329
    C_O_FLAG_HIGHEST_JVM="-O2 -Oy-"
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   330
    C_O_FLAG_HIGHEST="-O2"
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   331
    C_O_FLAG_HI="-O1"
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   332
    C_O_FLAG_NORM="-O1"
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   333
    C_O_FLAG_DEBUG="-Od"
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   334
    C_O_FLAG_DEBUG_JVM=""
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   335
    C_O_FLAG_NONE="-Od"
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   336
    C_O_FLAG_SIZE="-Os"
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   337
  fi
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   338
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   339
  # Now copy to C++ flags
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   340
  CXX_O_FLAG_HIGHEST_JVM="$C_O_FLAG_HIGHEST_JVM"
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   341
  CXX_O_FLAG_HIGHEST="$C_O_FLAG_HIGHEST"
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   342
  CXX_O_FLAG_HI="$C_O_FLAG_HI"
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   343
  CXX_O_FLAG_NORM="$C_O_FLAG_NORM"
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   344
  CXX_O_FLAG_DEBUG="$C_O_FLAG_DEBUG"
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   345
  CXX_O_FLAG_DEBUG_JVM="$C_O_FLAG_DEBUG_JVM"
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   346
  CXX_O_FLAG_NONE="$C_O_FLAG_NONE"
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   347
  CXX_O_FLAG_SIZE="$C_O_FLAG_SIZE"
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   348
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   349
  if test "x$TOOLCHAIN_TYPE" = xsolstudio; then
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   350
    # In solstudio, also add this to C (but not C++) flags...
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   351
    C_O_FLAG_HIGHEST="$C_O_FLAG_HIGHEST -xalias_level=basic"
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   352
  fi
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   353
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   354
  # Adjust optimization flags according to debug level.
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   355
  case $DEBUG_LEVEL in
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   356
    release )
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   357
      # no adjustment
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   358
      ;;
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   359
    fastdebug )
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   360
      # Not quite so much optimization
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   361
      C_O_FLAG_HI="$C_O_FLAG_NORM"
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   362
      CXX_O_FLAG_HI="$CXX_O_FLAG_NORM"
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   363
      ;;
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   364
    slowdebug )
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   365
      # Disable optimization
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   366
      C_O_FLAG_HIGHEST_JVM="$C_O_FLAG_DEBUG_JVM"
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   367
      C_O_FLAG_HIGHEST="$C_O_FLAG_DEBUG"
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   368
      C_O_FLAG_HI="$C_O_FLAG_DEBUG"
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   369
      C_O_FLAG_NORM="$C_O_FLAG_DEBUG"
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   370
      C_O_FLAG_SIZE="$C_O_FLAG_DEBUG"
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   371
      CXX_O_FLAG_HIGHEST_JVM="$CXX_O_FLAG_DEBUG_JVM"
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   372
      CXX_O_FLAG_HIGHEST="$CXX_O_FLAG_DEBUG"
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   373
      CXX_O_FLAG_HI="$CXX_O_FLAG_DEBUG"
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   374
      CXX_O_FLAG_NORM="$CXX_O_FLAG_DEBUG"
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   375
      CXX_O_FLAG_SIZE="$CXX_O_FLAG_DEBUG"
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   376
      ;;
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   377
  esac
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   378
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   379
  AC_SUBST(C_O_FLAG_HIGHEST_JVM)
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   380
  AC_SUBST(C_O_FLAG_HIGHEST)
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   381
  AC_SUBST(C_O_FLAG_HI)
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   382
  AC_SUBST(C_O_FLAG_NORM)
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   383
  AC_SUBST(C_O_FLAG_NONE)
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   384
  AC_SUBST(C_O_FLAG_SIZE)
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   385
  AC_SUBST(CXX_O_FLAG_HIGHEST_JVM)
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   386
  AC_SUBST(CXX_O_FLAG_HIGHEST)
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   387
  AC_SUBST(CXX_O_FLAG_HI)
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   388
  AC_SUBST(CXX_O_FLAG_NORM)
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   389
  AC_SUBST(CXX_O_FLAG_NONE)
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   390
  AC_SUBST(CXX_O_FLAG_SIZE)
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   391
])
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   392
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   393
AC_DEFUN([FLAGS_SETUP_CFLAGS],
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   394
[
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   395
  ### CFLAGS
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   396
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   397
  FLAGS_SETUP_CFLAGS_HELPER
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   398
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   399
  FLAGS_OS=$OPENJDK_TARGET_OS
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   400
  FLAGS_OS_TYPE=$OPENJDK_TARGET_OS_TYPE
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   401
  FLAGS_CPU=$OPENJDK_TARGET_CPU
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   402
  FLAGS_CPU_ARCH=$OPENJDK_TARGET_CPU_ARCH
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   403
  FLAGS_CPU_BITS=$OPENJDK_TARGET_CPU_BITS
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   404
  FLAGS_CPU_ENDIAN=$OPENJDK_TARGET_CPU_ENDIAN
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   405
  FLAGS_CPU_LEGACY=$OPENJDK_TARGET_CPU_LEGACY
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   406
  FLAGS_CPU_LEGACY_LIB=$OPENJDK_TARGET_CPU_LEGACY_LIB
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   407
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   408
  FLAGS_SETUP_CFLAGS_CPU_DEP([TARGET])
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   409
59281
eef0bf57357c 8234535: Cross compilation fails due to missing CFLAGS for the BUILD_CC
cgo
parents: 58909
diff changeset
   410
  # Repeat the check for the BUILD_CC and BUILD_CXX. Need to also reset CFLAGS
eef0bf57357c 8234535: Cross compilation fails due to missing CFLAGS for the BUILD_CC
cgo
parents: 58909
diff changeset
   411
  # since any target specific flags will likely not work with the build compiler.
eef0bf57357c 8234535: Cross compilation fails due to missing CFLAGS for the BUILD_CC
cgo
parents: 58909
diff changeset
   412
  CC_OLD="$CC"
eef0bf57357c 8234535: Cross compilation fails due to missing CFLAGS for the BUILD_CC
cgo
parents: 58909
diff changeset
   413
  CXX_OLD="$CXX"
eef0bf57357c 8234535: Cross compilation fails due to missing CFLAGS for the BUILD_CC
cgo
parents: 58909
diff changeset
   414
  CFLAGS_OLD="$CFLAGS"
eef0bf57357c 8234535: Cross compilation fails due to missing CFLAGS for the BUILD_CC
cgo
parents: 58909
diff changeset
   415
  CXXFLAGS_OLD="$CXXFLAGS"
eef0bf57357c 8234535: Cross compilation fails due to missing CFLAGS for the BUILD_CC
cgo
parents: 58909
diff changeset
   416
  CC="$BUILD_CC"
eef0bf57357c 8234535: Cross compilation fails due to missing CFLAGS for the BUILD_CC
cgo
parents: 58909
diff changeset
   417
  CXX="$BUILD_CXX"
eef0bf57357c 8234535: Cross compilation fails due to missing CFLAGS for the BUILD_CC
cgo
parents: 58909
diff changeset
   418
  CFLAGS=""
eef0bf57357c 8234535: Cross compilation fails due to missing CFLAGS for the BUILD_CC
cgo
parents: 58909
diff changeset
   419
  CXXFLAGS=""
eef0bf57357c 8234535: Cross compilation fails due to missing CFLAGS for the BUILD_CC
cgo
parents: 58909
diff changeset
   420
49120
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   421
  FLAGS_OS=$OPENJDK_BUILD_OS
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   422
  FLAGS_OS_TYPE=$OPENJDK_BUILD_OS_TYPE
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   423
  FLAGS_CPU=$OPENJDK_BUILD_CPU
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   424
  FLAGS_CPU_ARCH=$OPENJDK_BUILD_CPU_ARCH
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   425
  FLAGS_CPU_BITS=$OPENJDK_BUILD_CPU_BITS
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   426
  FLAGS_CPU_ENDIAN=$OPENJDK_BUILD_CPU_ENDIAN
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   427
  FLAGS_CPU_LEGACY=$OPENJDK_BUILD_CPU_LEGACY
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   428
  FLAGS_CPU_LEGACY_LIB=$OPENJDK_BUILD_CPU_LEGACY_LIB
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   429
53643
1126811a5124 8160926: FLAGS_COMPILER_CHECK_ARGUMENTS doesn't handle cross-compilation
erikj
parents: 53366
diff changeset
   430
  FLAGS_SETUP_CFLAGS_CPU_DEP([BUILD], [OPENJDK_BUILD_], [BUILD_])
59281
eef0bf57357c 8234535: Cross compilation fails due to missing CFLAGS for the BUILD_CC
cgo
parents: 58909
diff changeset
   431
eef0bf57357c 8234535: Cross compilation fails due to missing CFLAGS for the BUILD_CC
cgo
parents: 58909
diff changeset
   432
  CC="$CC_OLD"
eef0bf57357c 8234535: Cross compilation fails due to missing CFLAGS for the BUILD_CC
cgo
parents: 58909
diff changeset
   433
  CXX="$CXX_OLD"
eef0bf57357c 8234535: Cross compilation fails due to missing CFLAGS for the BUILD_CC
cgo
parents: 58909
diff changeset
   434
  CFLAGS="$CFLAGS_OLD"
eef0bf57357c 8234535: Cross compilation fails due to missing CFLAGS for the BUILD_CC
cgo
parents: 58909
diff changeset
   435
  CXXFLAGS="$CXXFLAGS_OLD"
49120
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   436
])
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   437
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   438
################################################################################
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   439
# platform independent
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   440
AC_DEFUN([FLAGS_SETUP_CFLAGS_HELPER],
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   441
[
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   442
  #### OS DEFINES, these should be independent on toolchain
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   443
  if test "x$OPENJDK_TARGET_OS" = xlinux; then
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   444
    CFLAGS_OS_DEF_JVM="-DLINUX"
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   445
    CFLAGS_OS_DEF_JDK="-D_GNU_SOURCE -D_REENTRANT -D_LARGEFILE64_SOURCE"
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   446
  elif test "x$OPENJDK_TARGET_OS" = xsolaris; then
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   447
    CFLAGS_OS_DEF_JVM="-DSOLARIS"
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   448
    CFLAGS_OS_DEF_JDK="-D__solaris__"
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   449
  elif test "x$OPENJDK_TARGET_OS" = xmacosx; then
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   450
    CFLAGS_OS_DEF_JVM="-D_ALLBSD_SOURCE -D_DARWIN_C_SOURCE -D_XOPEN_SOURCE"
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   451
    CFLAGS_OS_DEF_JDK="-D_ALLBSD_SOURCE -D_DARWIN_UNLIMITED_SELECT"
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   452
  elif test "x$OPENJDK_TARGET_OS" = xaix; then
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   453
    CFLAGS_OS_DEF_JVM="-DAIX"
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   454
  elif test "x$OPENJDK_TARGET_OS" = xbsd; then
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   455
    CFLAGS_OS_DEF_JDK="-D_ALLBSD_SOURCE"
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   456
  elif test "x$OPENJDK_TARGET_OS" = xwindows; then
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   457
    CFLAGS_OS_DEF_JVM="-D_WINDOWS -DWIN32 -D_JNI_IMPLEMENTATION_"
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   458
  fi
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   459
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   460
  CFLAGS_OS_DEF_JDK="$CFLAGS_OS_DEF_JDK -D$OPENJDK_TARGET_OS_UPPERCASE"
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   461
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   462
  #### GLOBAL DEFINES
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   463
  # Set some common defines. These works for all compilers, but assume
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   464
  # -D is universally accepted.
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   465
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   466
  # Always enable optional macros for VM.
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   467
  ALWAYS_CFLAGS_JVM="-D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS"
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   468
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   469
  # Setup some hard coded includes
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   470
  ALWAYS_CFLAGS_JDK=" \
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   471
      -I\$(SUPPORT_OUTPUTDIR)/modules_include/java.base \
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   472
      -I\$(SUPPORT_OUTPUTDIR)/modules_include/java.base/\$(OPENJDK_TARGET_OS_INCLUDE_SUBDIR) \
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   473
      -I${TOPDIR}/src/java.base/share/native/libjava \
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   474
      -I${TOPDIR}/src/java.base/$OPENJDK_TARGET_OS_TYPE/native/libjava \
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   475
      -I${TOPDIR}/src/hotspot/share/include \
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   476
      -I${TOPDIR}/src/hotspot/os/${HOTSPOT_TARGET_OS_TYPE}/include"
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   477
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   478
  ###############################################################################
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   479
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   480
  # Adjust flags according to debug level.
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   481
  # Setup debug/release defines
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   482
  if test "x$DEBUG_LEVEL" = xrelease; then
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   483
    DEBUG_CFLAGS_JDK="-DNDEBUG"
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   484
    if test "x$OPENJDK_TARGET_OS" = xsolaris; then
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   485
      DEBUG_CFLAGS_JDK="$DEBUG_CFLAGS_JDK -DTRIMMED"
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   486
    fi
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   487
  else
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   488
    DEBUG_CFLAGS_JDK="-DDEBUG"
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   489
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   490
    if test "x$TOOLCHAIN_TYPE" = xxlc; then
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   491
      # We need '-qminimaltoc' or '-qpic=large -bbigtoc' if the TOC overflows.
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   492
      # Hotspot now overflows its 64K TOC (currently only for debug),
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   493
      # so for debug we build with '-qpic=large -bbigtoc'.
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   494
      DEBUG_CFLAGS_JVM="-qpic=large"
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   495
    fi
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   496
  fi
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   497
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   498
  if test "x$DEBUG_LEVEL" != xrelease; then
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   499
    DEBUG_OPTIONS_FLAGS_JDK="$CFLAGS_DEBUG_OPTIONS"
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   500
    DEBUG_SYMBOLS_CFLAGS_JDK="$CFLAGS_DEBUG_SYMBOLS"
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   501
  fi
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   502
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   503
  #### TOOLCHAIN DEFINES
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   504
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   505
  if test "x$TOOLCHAIN_TYPE" = xgcc; then
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   506
    ALWAYS_DEFINES_JVM="-D_GNU_SOURCE -D_REENTRANT"
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   507
  elif test "x$TOOLCHAIN_TYPE" = xclang; then
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   508
    ALWAYS_DEFINES_JVM="-D_GNU_SOURCE"
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   509
  elif test "x$TOOLCHAIN_TYPE" = xsolstudio; then
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   510
    ALWAYS_DEFINES_JVM="-DSPARC_WORKS -D_Crun_inline_placement"
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   511
    ALWAYS_DEFINES_JDK="-DTRACING -DMACRO_MEMSYS_OPS -DBREAKPTS"
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   512
    ALWAYS_DEFINES_JDK_CXXONLY="-DCC_NOEX"
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   513
  elif test "x$TOOLCHAIN_TYPE" = xxlc; then
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   514
    ALWAYS_DEFINES_JVM="-D_REENTRANT"
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   515
    ALWAYS_DEFINES_JDK="-D_GNU_SOURCE -D_REENTRANT -D_LARGEFILE64_SOURCE -DSTDC"
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   516
  elif test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   517
    ALWAYS_DEFINES_JDK="-DWIN32_LEAN_AND_MEAN -D_CRT_SECURE_NO_DEPRECATE \
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   518
        -D_CRT_NONSTDC_NO_DEPRECATE -DWIN32 -DIAL"
49726
4ae63fcabe2e 8199736: Define WIN32_LEAN_AND_MEAN before including windows.h
rwestberg
parents: 49679
diff changeset
   519
    ALWAYS_DEFINES_JVM="-DNOMINMAX -DWIN32_LEAN_AND_MEAN"
49120
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   520
  fi
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   521
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   522
  ###############################################################################
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   523
  #
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   524
  #
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   525
  # CFLAGS BASIC
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   526
  if test "x$TOOLCHAIN_TYPE" = xgcc || test "x$TOOLCHAIN_TYPE" = xclang; then
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   527
    # COMMON to gcc and clang
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   528
    TOOLCHAIN_CFLAGS_JVM="-pipe -fno-rtti -fno-exceptions \
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   529
        -fvisibility=hidden -fno-strict-aliasing -fno-omit-frame-pointer"
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   530
  fi
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   531
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   532
  if test "x$TOOLCHAIN_TYPE" = xgcc; then
53332
ab474ef0a0ac 8199552: Update to build scripts
jwilhelm
parents: 52351
diff changeset
   533
    TOOLCHAIN_CFLAGS_JVM="$TOOLCHAIN_CFLAGS_JVM -fcheck-new -fstack-protector"
ab474ef0a0ac 8199552: Update to build scripts
jwilhelm
parents: 52351
diff changeset
   534
    TOOLCHAIN_CFLAGS_JDK="-pipe -fstack-protector"
53643
1126811a5124 8160926: FLAGS_COMPILER_CHECK_ARGUMENTS doesn't handle cross-compilation
erikj
parents: 53366
diff changeset
   535
    # technically NOT for CXX (but since this gives *worse* performance, use
1126811a5124 8160926: FLAGS_COMPILER_CHECK_ARGUMENTS doesn't handle cross-compilation
erikj
parents: 53366
diff changeset
   536
    # no-strict-aliasing everywhere!)
1126811a5124 8160926: FLAGS_COMPILER_CHECK_ARGUMENTS doesn't handle cross-compilation
erikj
parents: 53366
diff changeset
   537
    TOOLCHAIN_CFLAGS_JDK_CONLY="-fno-strict-aliasing"
49120
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   538
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   539
  elif test "x$TOOLCHAIN_TYPE" = xclang; then
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   540
    # Restrict the debug information created by Clang to avoid
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   541
    # too big object files and speed the build up a little bit
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   542
    # (see http://llvm.org/bugs/show_bug.cgi?id=7554)
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   543
    TOOLCHAIN_CFLAGS_JVM="$TOOLCHAIN_CFLAGS_JVM -flimit-debug-info"
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   544
50781
9f781ce22e7d 8205649: Make clang stack flags independent of OS
martin
parents: 50678
diff changeset
   545
    # In principle the stack alignment below is cpu- and ABI-dependent and
9f781ce22e7d 8205649: Make clang stack flags independent of OS
martin
parents: 50678
diff changeset
   546
    # should agree with values of StackAlignmentInBytes in various
9f781ce22e7d 8205649: Make clang stack flags independent of OS
martin
parents: 50678
diff changeset
   547
    # src/hotspot/cpu/*/globalDefinitions_*.hpp files, but this value currently
9f781ce22e7d 8205649: Make clang stack flags independent of OS
martin
parents: 50678
diff changeset
   548
    # works for all platforms.
9f781ce22e7d 8205649: Make clang stack flags independent of OS
martin
parents: 50678
diff changeset
   549
    TOOLCHAIN_CFLAGS_JVM="$TOOLCHAIN_CFLAGS_JVM -mno-omit-leaf-frame-pointer -mstack-alignment=16"
9f781ce22e7d 8205649: Make clang stack flags independent of OS
martin
parents: 50678
diff changeset
   550
49120
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   551
    if test "x$OPENJDK_TARGET_OS" = xlinux; then
54646
5b1eec609909 8220388: Increase -inlinehint-threshold for Clang to avoid G1 pause time regression
manc
parents: 54490
diff changeset
   552
      if test "x$DEBUG_LEVEL" = xrelease; then
5b1eec609909 8220388: Increase -inlinehint-threshold for Clang to avoid G1 pause time regression
manc
parents: 54490
diff changeset
   553
        # Clang does not inline as much as GCC does for functions with "inline" keyword by default.
5b1eec609909 8220388: Increase -inlinehint-threshold for Clang to avoid G1 pause time regression
manc
parents: 54490
diff changeset
   554
        # This causes noticeable slowdown in pause time for G1, and possibly in other areas.
5b1eec609909 8220388: Increase -inlinehint-threshold for Clang to avoid G1 pause time regression
manc
parents: 54490
diff changeset
   555
        # Increasing the inline hint threshold avoids the slowdown for Clang-built JVM.
5b1eec609909 8220388: Increase -inlinehint-threshold for Clang to avoid G1 pause time regression
manc
parents: 54490
diff changeset
   556
        TOOLCHAIN_CFLAGS_JVM="$TOOLCHAIN_CFLAGS_JVM -mllvm -inlinehint-threshold=100000"
5b1eec609909 8220388: Increase -inlinehint-threshold for Clang to avoid G1 pause time regression
manc
parents: 54490
diff changeset
   557
      fi
49120
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   558
      TOOLCHAIN_CFLAGS_JDK="-pipe"
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   559
      TOOLCHAIN_CFLAGS_JDK_CONLY="-fno-strict-aliasing" # technically NOT for CXX
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   560
    fi
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   561
  elif test "x$TOOLCHAIN_TYPE" = xsolstudio; then
51839
ab54a4d61d7f 8210988: Improved handling of compiler warnings in the build
ihse
parents: 51814
diff changeset
   562
    TOOLCHAIN_FLAGS="-errtags -errfmt"
ab54a4d61d7f 8210988: Improved handling of compiler warnings in the build
ihse
parents: 51814
diff changeset
   563
    TOOLCHAIN_CFLAGS="-errshort=tags"
ab54a4d61d7f 8210988: Improved handling of compiler warnings in the build
ihse
parents: 51814
diff changeset
   564
ab54a4d61d7f 8210988: Improved handling of compiler warnings in the build
ihse
parents: 51814
diff changeset
   565
    TOOLCHAIN_CFLAGS_JDK="-mt $TOOLCHAIN_FLAGS"
54999
98ed47cd114a 8224087: Compile C code for at least C99 Standard compliance
dholmes
parents: 54937
diff changeset
   566
    TOOLCHAIN_CFLAGS_JDK_CONLY="-W0,-noglobal $TOOLCHAIN_CFLAGS" # C only
49120
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   567
    TOOLCHAIN_CFLAGS_JDK_CXXONLY="-features=no%except -norunpath -xnolib" # CXX only
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   568
    TOOLCHAIN_CFLAGS_JVM="-template=no%extdef -features=no%split_init \
51839
ab54a4d61d7f 8210988: Improved handling of compiler warnings in the build
ihse
parents: 51814
diff changeset
   569
        -library=stlport4 -mt -features=no%except $TOOLCHAIN_FLAGS"
49155
7cd937277d5e 8199338: Use -g0 on solstudio also for compiling C programs
ihse
parents: 49120
diff changeset
   570
    if test "x$DEBUG_LEVEL" = xslowdebug; then
7cd937277d5e 8199338: Use -g0 on solstudio also for compiling C programs
ihse
parents: 49120
diff changeset
   571
      # Previously -g was used instead of -g0 for slowdebug; this is equivalent
7cd937277d5e 8199338: Use -g0 on solstudio also for compiling C programs
ihse
parents: 49120
diff changeset
   572
      # to setting +d.
7cd937277d5e 8199338: Use -g0 on solstudio also for compiling C programs
ihse
parents: 49120
diff changeset
   573
      TOOLCHAIN_CFLAGS_JVM="$TOOLCHAIN_CFLAGS_JVM +d"
7cd937277d5e 8199338: Use -g0 on solstudio also for compiling C programs
ihse
parents: 49120
diff changeset
   574
    fi
7cd937277d5e 8199338: Use -g0 on solstudio also for compiling C programs
ihse
parents: 49120
diff changeset
   575
49120
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   576
  elif test "x$TOOLCHAIN_TYPE" = xxlc; then
51839
ab54a4d61d7f 8210988: Improved handling of compiler warnings in the build
ihse
parents: 51814
diff changeset
   577
    # Suggested additions: -qsrcmsg to get improved error reporting
55584
ef032c55234c 8227171: provide function names in native stack trace on aix with xlc16
mbaesken
parents: 54999
diff changeset
   578
    # set -qtbtable=full for a better traceback table/better stacks in hs_err when xlc16 is used
ef032c55234c 8227171: provide function names in native stack trace on aix with xlc16
mbaesken
parents: 54999
diff changeset
   579
    TOOLCHAIN_CFLAGS_JDK="-qtbtable=full -qchars=signed -qfullpath -qsaveopt -qstackprotect"  # add on both CFLAGS
ef032c55234c 8227171: provide function names in native stack trace on aix with xlc16
mbaesken
parents: 54999
diff changeset
   580
    TOOLCHAIN_CFLAGS_JVM="-qtbtable=full -qtune=balanced \
55623
c589ba4b823c 8227389: Remove unsupported xlc16 compile options on aix
mbaesken
parents: 55584
diff changeset
   581
        -qalias=noansi -qstrict -qtls=default -qnortti -qnoeh -qignerrno -qstackprotect"
49120
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   582
  elif test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   583
    TOOLCHAIN_CFLAGS_JVM="-nologo -MD -MP"
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   584
    TOOLCHAIN_CFLAGS_JDK="-nologo -MD -Zc:wchar_t-"
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   585
  fi
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   586
54999
98ed47cd114a 8224087: Compile C code for at least C99 Standard compliance
dholmes
parents: 54937
diff changeset
   587
  # CFLAGS C language level for JDK sources (hotspot only uses C++)
98ed47cd114a 8224087: Compile C code for at least C99 Standard compliance
dholmes
parents: 54937
diff changeset
   588
  # Ideally we would have a common level across all toolchains so that all sources
98ed47cd114a 8224087: Compile C code for at least C99 Standard compliance
dholmes
parents: 54937
diff changeset
   589
  # are sure to conform to the same standard. Unfortunately neither our sources nor
98ed47cd114a 8224087: Compile C code for at least C99 Standard compliance
dholmes
parents: 54937
diff changeset
   590
  # our toolchains are in a condition to support that. But what we loosely aim for is
98ed47cd114a 8224087: Compile C code for at least C99 Standard compliance
dholmes
parents: 54937
diff changeset
   591
  # C99 level.
98ed47cd114a 8224087: Compile C code for at least C99 Standard compliance
dholmes
parents: 54937
diff changeset
   592
  if test "x$TOOLCHAIN_TYPE" = xgcc || test "x$TOOLCHAIN_TYPE" = xclang || test "x$TOOLCHAIN_TYPE" = xxlc; then
98ed47cd114a 8224087: Compile C code for at least C99 Standard compliance
dholmes
parents: 54937
diff changeset
   593
    # This raises the language level for older 4.8 gcc, while lowering it for later
98ed47cd114a 8224087: Compile C code for at least C99 Standard compliance
dholmes
parents: 54937
diff changeset
   594
    # versions. clang and xlclang support the same flag.
98ed47cd114a 8224087: Compile C code for at least C99 Standard compliance
dholmes
parents: 54937
diff changeset
   595
    LANGSTD_CFLAGS="-std=c99"
98ed47cd114a 8224087: Compile C code for at least C99 Standard compliance
dholmes
parents: 54937
diff changeset
   596
  elif test "x$TOOLCHAIN_TYPE" = xsolstudio; then
98ed47cd114a 8224087: Compile C code for at least C99 Standard compliance
dholmes
parents: 54937
diff changeset
   597
    # We can't turn on -std=c99 without breaking compilation of the splashscreen/png
98ed47cd114a 8224087: Compile C code for at least C99 Standard compliance
dholmes
parents: 54937
diff changeset
   598
    # utilities. But we can enable c99 as below (previously achieved by using -Xa).
98ed47cd114a 8224087: Compile C code for at least C99 Standard compliance
dholmes
parents: 54937
diff changeset
   599
    # It is the no_lib that makes the difference.
98ed47cd114a 8224087: Compile C code for at least C99 Standard compliance
dholmes
parents: 54937
diff changeset
   600
    LANGSTD_CFLAGS="-xc99=all,no_lib"
98ed47cd114a 8224087: Compile C code for at least C99 Standard compliance
dholmes
parents: 54937
diff changeset
   601
  elif test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
98ed47cd114a 8224087: Compile C code for at least C99 Standard compliance
dholmes
parents: 54937
diff changeset
   602
    # MSVC doesn't support C99/C11 explicitly, unless you compile as C++:
58909
66f7d2494d4e 8233383: Various minor fixes
ihse
parents: 58846
diff changeset
   603
    # LANGSTD_CFLAGS="-TP"
54999
98ed47cd114a 8224087: Compile C code for at least C99 Standard compliance
dholmes
parents: 54937
diff changeset
   604
    # but that requires numerous changes to the sources files. So we are limited
98ed47cd114a 8224087: Compile C code for at least C99 Standard compliance
dholmes
parents: 54937
diff changeset
   605
    # to C89/C90 plus whatever extensions Visual Studio has decided to implement.
98ed47cd114a 8224087: Compile C code for at least C99 Standard compliance
dholmes
parents: 54937
diff changeset
   606
    # This is the lowest bar for shared code.
98ed47cd114a 8224087: Compile C code for at least C99 Standard compliance
dholmes
parents: 54937
diff changeset
   607
    LANGSTD_CFLAGS=""
98ed47cd114a 8224087: Compile C code for at least C99 Standard compliance
dholmes
parents: 54937
diff changeset
   608
  fi
98ed47cd114a 8224087: Compile C code for at least C99 Standard compliance
dholmes
parents: 54937
diff changeset
   609
  TOOLCHAIN_CFLAGS_JDK_CONLY="$LANGSTD_CFLAGS $TOOLCHAIN_CFLAGS_JDK_CONLY"
98ed47cd114a 8224087: Compile C code for at least C99 Standard compliance
dholmes
parents: 54937
diff changeset
   610
49120
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   611
  # CFLAGS WARNINGS STUFF
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   612
  # Set JVM_CFLAGS warning handling
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   613
  if test "x$TOOLCHAIN_TYPE" = xgcc; then
51853
ec62d6cab037 8211029: Have a common set of enabled warnings for all native libraries
ihse
parents: 51839
diff changeset
   614
    WARNING_CFLAGS_JDK_CONLY="$WARNINGS_ENABLE_ALL_CFLAGS"
ec62d6cab037 8211029: Have a common set of enabled warnings for all native libraries
ihse
parents: 51839
diff changeset
   615
    WARNING_CFLAGS_JDK_CXXONLY="$WARNINGS_ENABLE_ALL_CXXFLAGS"
ec62d6cab037 8211029: Have a common set of enabled warnings for all native libraries
ihse
parents: 51839
diff changeset
   616
    WARNING_CFLAGS_JVM="$WARNINGS_ENABLE_ALL_CXXFLAGS"
49120
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   617
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   618
  elif test "x$TOOLCHAIN_TYPE" = xclang; then
51853
ec62d6cab037 8211029: Have a common set of enabled warnings for all native libraries
ihse
parents: 51839
diff changeset
   619
    WARNING_CFLAGS="$WARNINGS_ENABLE_ALL"
51839
ab54a4d61d7f 8210988: Improved handling of compiler warnings in the build
ihse
parents: 51814
diff changeset
   620
49120
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   621
  elif test "x$TOOLCHAIN_TYPE" = xsolstudio; then
51839
ab54a4d61d7f 8210988: Improved handling of compiler warnings in the build
ihse
parents: 51814
diff changeset
   622
    WARNING_CFLAGS_JDK_CONLY="$WARNINGS_ENABLE_ALL_CFLAGS"
ab54a4d61d7f 8210988: Improved handling of compiler warnings in the build
ihse
parents: 51814
diff changeset
   623
    WARNING_CFLAGS_JDK_CXXONLY="$WARNINGS_ENABLE_ALL_CXXFLAGS"
51853
ec62d6cab037 8211029: Have a common set of enabled warnings for all native libraries
ihse
parents: 51839
diff changeset
   624
    WARNING_CFLAGS_JVM="$WARNINGS_ENABLE_ALL_CXXFLAGS"
ec62d6cab037 8211029: Have a common set of enabled warnings for all native libraries
ihse
parents: 51839
diff changeset
   625
49120
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   626
  elif test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
51839
ab54a4d61d7f 8210988: Improved handling of compiler warnings in the build
ihse
parents: 51814
diff changeset
   627
    WARNING_CFLAGS="$WARNINGS_ENABLE_ALL"
51853
ec62d6cab037 8211029: Have a common set of enabled warnings for all native libraries
ihse
parents: 51839
diff changeset
   628
51839
ab54a4d61d7f 8210988: Improved handling of compiler warnings in the build
ihse
parents: 51814
diff changeset
   629
  elif test "x$TOOLCHAIN_TYPE" = xxlc; then
ab54a4d61d7f 8210988: Improved handling of compiler warnings in the build
ihse
parents: 51814
diff changeset
   630
    WARNING_CFLAGS=""  # currently left empty
49120
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   631
  fi
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   632
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   633
  # Set some additional per-OS defines.
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   634
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   635
  # Additional macosx handling
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   636
  if test "x$OPENJDK_TARGET_OS" = xmacosx; then
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   637
    OS_CFLAGS="-DMAC_OS_X_VERSION_MIN_REQUIRED=$MACOSX_VERSION_MIN_NODOTS \
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   638
        -mmacosx-version-min=$MACOSX_VERSION_MIN"
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   639
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   640
    if test -n "$MACOSX_VERSION_MAX"; then
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   641
        OS_CFLAGS="$OS_CFLAGS \
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   642
            -DMAC_OS_X_VERSION_MAX_ALLOWED=$MACOSX_VERSION_MAX_NODOTS"
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   643
    fi
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   644
  fi
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   645
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   646
  # Where does this really belong??
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   647
  if test "x$TOOLCHAIN_TYPE" = xgcc || test "x$TOOLCHAIN_TYPE" = xclang; then
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   648
    PICFLAG="-fPIC"
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   649
  elif test "x$TOOLCHAIN_TYPE" = xsolstudio; then
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   650
    PICFLAG="-KPIC"
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   651
  elif test "x$TOOLCHAIN_TYPE" = xxlc; then
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   652
    # '-qpic' defaults to 'qpic=small'. This means that the compiler generates only
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   653
    # one instruction for accessing the TOC. If the TOC grows larger than 64K, the linker
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   654
    # will have to patch this single instruction with a call to some out-of-order code which
50550
41ff671ed8cf 8204935: [aix] TOC overflow in libjvm.so (release build)
stuefe
parents: 49907
diff changeset
   655
    # does the load from the TOC. This is of course slower, and we also would have
49120
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   656
    # to use '-bbigtoc' for linking anyway so we could also change the PICFLAG to 'qpic=large'.
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   657
    # With 'qpic=large' the compiler will by default generate a two-instruction sequence which
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   658
    # can be patched directly by the linker and does not require a jump to out-of-order code.
50550
41ff671ed8cf 8204935: [aix] TOC overflow in libjvm.so (release build)
stuefe
parents: 49907
diff changeset
   659
    #
41ff671ed8cf 8204935: [aix] TOC overflow in libjvm.so (release build)
stuefe
parents: 49907
diff changeset
   660
    # Since large TOC causes perf. overhead, only pay it where we must. Currently this is
41ff671ed8cf 8204935: [aix] TOC overflow in libjvm.so (release build)
stuefe
parents: 49907
diff changeset
   661
    # for all libjvm variants (both gtest and normal) but no other binaries. So, build
41ff671ed8cf 8204935: [aix] TOC overflow in libjvm.so (release build)
stuefe
parents: 49907
diff changeset
   662
    # libjvm with -qpic=large and link with -bbigtoc.
41ff671ed8cf 8204935: [aix] TOC overflow in libjvm.so (release build)
stuefe
parents: 49907
diff changeset
   663
    JVM_PICFLAG="-qpic=large"
41ff671ed8cf 8204935: [aix] TOC overflow in libjvm.so (release build)
stuefe
parents: 49907
diff changeset
   664
    JDK_PICFLAG="-qpic"
49120
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   665
  elif test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   666
    PICFLAG=""
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   667
  fi
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   668
50550
41ff671ed8cf 8204935: [aix] TOC overflow in libjvm.so (release build)
stuefe
parents: 49907
diff changeset
   669
  if test "x$TOOLCHAIN_TYPE" != xxlc; then
41ff671ed8cf 8204935: [aix] TOC overflow in libjvm.so (release build)
stuefe
parents: 49907
diff changeset
   670
    JVM_PICFLAG="$PICFLAG"
41ff671ed8cf 8204935: [aix] TOC overflow in libjvm.so (release build)
stuefe
parents: 49907
diff changeset
   671
    JDK_PICFLAG="$PICFLAG"
41ff671ed8cf 8204935: [aix] TOC overflow in libjvm.so (release build)
stuefe
parents: 49907
diff changeset
   672
  fi
49120
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   673
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   674
  if test "x$OPENJDK_TARGET_OS" = xmacosx; then
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   675
    # Linking is different on MacOSX
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   676
    JDK_PICFLAG=''
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   677
    if test "x$STATIC_BUILD" = xtrue; then
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   678
      JVM_PICFLAG=""
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   679
    fi
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   680
  fi
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   681
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   682
  # Optional POSIX functionality needed by the JVM
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   683
  #
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   684
  # Check if clock_gettime is available and in which library. This indicates
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   685
  # availability of CLOCK_MONOTONIC for hotspot. But we don't need to link, so
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   686
  # don't let it update LIBS.
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   687
  save_LIBS="$LIBS"
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   688
  AC_SEARCH_LIBS(clock_gettime, rt, [HAS_CLOCK_GETTIME=true], [])
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   689
  if test "x$LIBS" = "x-lrt "; then
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   690
    CLOCK_GETTIME_IN_LIBRT=true
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   691
  fi
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   692
  LIBS="$save_LIBS"
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   693
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   694
  if test "x$HAS_CLOCK_GETTIME" = "xtrue"; then
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   695
    OS_CFLAGS_JVM="$OS_CFLAGS_JVM -DSUPPORTS_CLOCK_MONOTONIC"
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   696
    if test "x$CLOCK_GETTIME_IN_LIBRT" = "xtrue"; then
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   697
      OS_CFLAGS_JVM="$OS_CFLAGS_JVM -DNEEDS_LIBRT"
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   698
    fi
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   699
  fi
58846
f9ac726ab347 8232748: Build static versions of certain JDK libraries
erikj
parents: 58747
diff changeset
   700
f9ac726ab347 8232748: Build static versions of certain JDK libraries
erikj
parents: 58747
diff changeset
   701
  # Extra flags needed when building optional static versions of certain
f9ac726ab347 8232748: Build static versions of certain JDK libraries
erikj
parents: 58747
diff changeset
   702
  # JDK libraries.
f9ac726ab347 8232748: Build static versions of certain JDK libraries
erikj
parents: 58747
diff changeset
   703
  STATIC_LIBS_CFLAGS="-DSTATIC_BUILD=1"
f9ac726ab347 8232748: Build static versions of certain JDK libraries
erikj
parents: 58747
diff changeset
   704
  if test "x$TOOLCHAIN_TYPE" = xgcc || test "x$TOOLCHAIN_TYPE" = xclang; then
f9ac726ab347 8232748: Build static versions of certain JDK libraries
erikj
parents: 58747
diff changeset
   705
    STATIC_LIBS_CFLAGS="$STATIC_LIBS_CFLAGS -ffunction-sections -fdata-sections"
f9ac726ab347 8232748: Build static versions of certain JDK libraries
erikj
parents: 58747
diff changeset
   706
  fi
f9ac726ab347 8232748: Build static versions of certain JDK libraries
erikj
parents: 58747
diff changeset
   707
  if test "x$TOOLCHAIN_TYPE" = xgcc; then
f9ac726ab347 8232748: Build static versions of certain JDK libraries
erikj
parents: 58747
diff changeset
   708
    # Disable relax-relocation to enable compatibility with older linkers
f9ac726ab347 8232748: Build static versions of certain JDK libraries
erikj
parents: 58747
diff changeset
   709
    RELAX_RELOCATIONS_FLAG="-Xassembler -mrelax-relocations=no"
f9ac726ab347 8232748: Build static versions of certain JDK libraries
erikj
parents: 58747
diff changeset
   710
    FLAGS_COMPILER_CHECK_ARGUMENTS(ARGUMENT: [${RELAX_RELOCATIONS_FLAG}],
f9ac726ab347 8232748: Build static versions of certain JDK libraries
erikj
parents: 58747
diff changeset
   711
        IF_TRUE: [STATIC_LIBS_CFLAGS="$STATIC_LIBS_CFLAGS ${RELAX_RELOCATIONS_FLAG}"])
f9ac726ab347 8232748: Build static versions of certain JDK libraries
erikj
parents: 58747
diff changeset
   712
  fi
f9ac726ab347 8232748: Build static versions of certain JDK libraries
erikj
parents: 58747
diff changeset
   713
  AC_SUBST(STATIC_LIBS_CFLAGS)
49120
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   714
])
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   715
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   716
################################################################################
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   717
# $1 - Either BUILD or TARGET to pick the correct OS/CPU variables to check
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   718
#      conditionals against.
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   719
# $2 - Optional prefix for each variable defined.
53643
1126811a5124 8160926: FLAGS_COMPILER_CHECK_ARGUMENTS doesn't handle cross-compilation
erikj
parents: 53366
diff changeset
   720
# $3 - Optional prefix for compiler variables (either BUILD_ or nothing).
49120
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   721
AC_DEFUN([FLAGS_SETUP_CFLAGS_CPU_DEP],
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   722
[
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   723
  #### CPU DEFINES, these should (in theory) be independent on toolchain
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   724
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   725
  # Setup target CPU
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   726
  # Setup endianness
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   727
  if test "x$FLAGS_CPU_ENDIAN" = xlittle; then
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   728
    $1_DEFINES_CPU_JVM="-DVM_LITTLE_ENDIAN"
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   729
  fi
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   730
  if test "x$TOOLCHAIN_TYPE" = xsolstudio; then
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   731
    # The macro _LITTLE_ENDIAN needs to be defined the same to avoid the
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   732
    #   Sun C compiler warning message: warning: macro redefined: _LITTLE_ENDIAN
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   733
    if test "x$FLAGS_CPU_ENDIAN" = xlittle; then
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   734
      $1_DEFINES_CPU_JDK="-D_LITTLE_ENDIAN="
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   735
    else
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   736
      $1_DEFINES_CPU_JDK="-D_BIG_ENDIAN="
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   737
    fi
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   738
  else
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   739
    if test "x$FLAGS_CPU_ENDIAN" = xlittle; then
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   740
      $1_DEFINES_CPU_JDK="-D_LITTLE_ENDIAN"
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   741
    else
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   742
      $1_DEFINES_CPU_JDK="-D_BIG_ENDIAN"
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   743
    fi
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   744
  fi
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   745
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   746
  # setup CPU bit size
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   747
  $1_DEFINES_CPU_JDK="${$1_DEFINES_CPU_JDK} -DARCH='\"$FLAGS_CPU_LEGACY\"' \
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   748
      -D$FLAGS_CPU_LEGACY"
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   749
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   750
  if test "x$FLAGS_CPU_BITS" = x64; then
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   751
    # -D_LP64=1 is only set on linux and mac. Setting on windows causes diff in
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   752
    # unpack200.exe.
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   753
    if test "x$FLAGS_OS" = xlinux || test "x$FLAGS_OS" = xmacosx; then
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   754
      $1_DEFINES_CPU_JDK="${$1_DEFINES_CPU_JDK} -D_LP64=1"
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   755
    fi
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   756
    if test "x$FLAGS_OS" != xsolaris && test "x$FLAGS_OS" != xaix; then
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   757
      # Solaris does not have _LP64=1 in the old build.
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   758
      # xlc on AIX defines _LP64=1 by default and issues a warning if we redefine it.
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   759
      $1_DEFINES_CPU_JVM="${$1_DEFINES_CPU_JVM} -D_LP64=1"
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   760
    fi
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   761
  fi
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   762
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   763
  # toolchain dependend, per-cpu
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   764
  if test "x$TOOLCHAIN_TYPE" = xsolstudio; then
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   765
    if test "x$FLAGS_CPU_ARCH" = xx86; then
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   766
      $1_DEFINES_CPU_JDK="${$1_DEFINES_CPU_JDK} -DcpuIntel -Di586 -D$FLAGS_CPU_LEGACY_LIB"
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   767
    fi
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   768
  elif test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   769
    if test "x$FLAGS_CPU" = xx86_64; then
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   770
      $1_DEFINES_CPU_JDK="${$1_DEFINES_CPU_JDK} -D_AMD64_ -Damd64"
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   771
    else
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   772
      $1_DEFINES_CPU_JDK="${$1_DEFINES_CPU_JDK} -D_X86_ -Dx86"
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   773
    fi
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   774
  fi
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   775
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   776
  # CFLAGS PER CPU
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   777
  if test "x$TOOLCHAIN_TYPE" = xgcc || test "x$TOOLCHAIN_TYPE" = xclang; then
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   778
    # COMMON to gcc and clang
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   779
    if test "x$FLAGS_CPU" = xx86; then
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   780
      # Force compatibility with i586 on 32 bit intel platforms.
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   781
      $1_CFLAGS_CPU="-march=i586"
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   782
    fi
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   783
  fi
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   784
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   785
  if test "x$TOOLCHAIN_TYPE" = xgcc; then
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   786
    if test "x$FLAGS_CPU" = xarm; then
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   787
      # -Wno-psabi to get rid of annoying "note: the mangling of 'va_list' has changed in GCC 4.4"
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   788
      $1_CFLAGS_CPU="-fsigned-char -Wno-psabi $ARM_ARCH_TYPE_FLAGS $ARM_FLOAT_TYPE_FLAGS -DJDK_ARCH_ABI_PROP_NAME='\"\$(JDK_ARCH_ABI_PROP_NAME)\"'"
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   789
      $1_CFLAGS_CPU_JVM="-DARM"
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   790
    elif test "x$FLAGS_CPU_ARCH" = xppc; then
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   791
      $1_CFLAGS_CPU_JVM="-minsert-sched-nops=regroup_exact -mno-multiple -mno-string"
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   792
      if test "x$FLAGS_CPU" = xppc64; then
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   793
        # -mminimal-toc fixes `relocation truncated to fit' error for gcc 4.1.
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   794
        # Use ppc64 instructions, but schedule for power5
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   795
        $1_CFLAGS_CPU_JVM="${$1_CFLAGS_CPU_JVM} -mminimal-toc -mcpu=powerpc64 -mtune=power5"
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   796
      elif test "x$FLAGS_CPU" = xppc64le; then
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   797
        # Little endian machine uses ELFv2 ABI.
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   798
        # Use Power8, this is the first CPU to support PPC64 LE with ELFv2 ABI.
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   799
        $1_CFLAGS_CPU_JVM="${$1_CFLAGS_CPU_JVM} -DABI_ELFv2 -mcpu=power8 -mtune=power8"
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   800
      fi
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   801
    elif test "x$FLAGS_CPU" = xs390x; then
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   802
      $1_CFLAGS_CPU="-mbackchain -march=z10"
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   803
    fi
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   804
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   805
    if test "x$FLAGS_CPU_ARCH" != xarm &&  test "x$FLAGS_CPU_ARCH" != xppc; then
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   806
      # for all archs except arm and ppc, prevent gcc to omit frame pointer
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   807
      $1_CFLAGS_CPU_JDK="${$1_CFLAGS_CPU_JDK} -fno-omit-frame-pointer"
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   808
    fi
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   809
53643
1126811a5124 8160926: FLAGS_COMPILER_CHECK_ARGUMENTS doesn't handle cross-compilation
erikj
parents: 53366
diff changeset
   810
    $1_CXXSTD_CXXFLAG="-std=gnu++98"
1126811a5124 8160926: FLAGS_COMPILER_CHECK_ARGUMENTS doesn't handle cross-compilation
erikj
parents: 53366
diff changeset
   811
    FLAGS_CXX_COMPILER_CHECK_ARGUMENTS(ARGUMENT: [${$1_CXXSTD_CXXFLAG} -Werror],
1126811a5124 8160926: FLAGS_COMPILER_CHECK_ARGUMENTS doesn't handle cross-compilation
erikj
parents: 53366
diff changeset
   812
        PREFIX: $3, IF_FALSE: [$1_CXXSTD_CXXFLAG=""])
1126811a5124 8160926: FLAGS_COMPILER_CHECK_ARGUMENTS doesn't handle cross-compilation
erikj
parents: 53366
diff changeset
   813
    $1_TOOLCHAIN_CFLAGS_JDK_CXXONLY="${$1_CXXSTD_CXXFLAG}"
1126811a5124 8160926: FLAGS_COMPILER_CHECK_ARGUMENTS doesn't handle cross-compilation
erikj
parents: 53366
diff changeset
   814
    $1_TOOLCHAIN_CFLAGS_JVM="${$1_TOOLCHAIN_CFLAGS_JVM} ${$1_CXXSTD_CXXFLAG}"
1126811a5124 8160926: FLAGS_COMPILER_CHECK_ARGUMENTS doesn't handle cross-compilation
erikj
parents: 53366
diff changeset
   815
    $2ADLC_CXXFLAG="${$1_CXXSTD_CXXFLAG}"
1126811a5124 8160926: FLAGS_COMPILER_CHECK_ARGUMENTS doesn't handle cross-compilation
erikj
parents: 53366
diff changeset
   816
49120
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   817
  elif test "x$TOOLCHAIN_TYPE" = xclang; then
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   818
    if test "x$FLAGS_OS" = xlinux; then
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   819
      # ppc test not really needed for clang
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   820
      if test "x$FLAGS_CPU_ARCH" != xarm &&  test "x$FLAGS_CPU_ARCH" != xppc; then
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   821
        # for all archs except arm and ppc, prevent gcc to omit frame pointer
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   822
        $1_CFLAGS_CPU_JDK="${$1_CFLAGS_CPU_JDK} -fno-omit-frame-pointer"
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   823
      fi
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   824
    fi
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   825
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   826
  elif test "x$TOOLCHAIN_TYPE" = xsolstudio; then
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   827
    if test "x$FLAGS_CPU" = xx86_64; then
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   828
      # NOTE: -xregs=no%frameptr is supposed to be default on x64
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   829
      $1_CFLAGS_CPU_JDK="-xregs=no%frameptr"
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   830
    elif test "x$FLAGS_CPU" = xsparcv9; then
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   831
      $1_CFLAGS_CPU_JVM="-xarch=sparc"
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   832
      $1_CFLAGS_CPU_JDK_LIBONLY="-xregs=no%appl"
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   833
    fi
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   834
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   835
  elif test "x$TOOLCHAIN_TYPE" = xxlc; then
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   836
    if test "x$FLAGS_CPU" = xppc64; then
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   837
      $1_CFLAGS_CPU_JVM="-qarch=ppc64"
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   838
    fi
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   839
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   840
  elif test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   841
    if test "x$FLAGS_CPU" = xx86; then
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   842
      $1_CFLAGS_CPU_JVM="-arch:IA32"
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   843
    elif test "x$OPENJDK_TARGET_CPU" = xx86_64; then
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   844
      if test "x$DEBUG_LEVEL" != xrelease; then
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   845
        # NOTE: This is probably redundant; -homeparams is default on
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   846
        # non-release builds.
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   847
        $1_CFLAGS_CPU_JVM="-homeparams"
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   848
      fi
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   849
    fi
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   850
  fi
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   851
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   852
  if test "x$TOOLCHAIN_TYPE" = xgcc; then
53643
1126811a5124 8160926: FLAGS_COMPILER_CHECK_ARGUMENTS doesn't handle cross-compilation
erikj
parents: 53366
diff changeset
   853
    FLAGS_SETUP_GCC6_COMPILER_FLAGS($1, $3)
49120
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   854
    $1_TOOLCHAIN_CFLAGS="${$1_GCC6_CFLAGS}"
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   855
49200
a19a6228cdb2 8199405: Bump lowest supported gcc to 4.8
ihse
parents: 49160
diff changeset
   856
    $1_WARNING_CFLAGS_JVM="-Wno-format-zero-length -Wtype-limits -Wuninitialized"
49120
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   857
  fi
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   858
54490
bf07e140c49c 8221851: Use of THIS_FILE in hotspot invalidates precompiled header on Linux/GCC
erikj
parents: 53837
diff changeset
   859
  if test "x$TOOLCHAIN_TYPE" = xgcc || test "x$TOOLCHAIN_TYPE" = xclang; then
bf07e140c49c 8221851: Use of THIS_FILE in hotspot invalidates precompiled header on Linux/GCC
erikj
parents: 53837
diff changeset
   860
    # Check if compiler supports -fmacro-prefix-map. If so, use that to make
bf07e140c49c 8221851: Use of THIS_FILE in hotspot invalidates precompiled header on Linux/GCC
erikj
parents: 53837
diff changeset
   861
    # the __FILE__ macro resolve to paths relative to the workspace root.
bf07e140c49c 8221851: Use of THIS_FILE in hotspot invalidates precompiled header on Linux/GCC
erikj
parents: 53837
diff changeset
   862
    workspace_root_trailing_slash="${WORKSPACE_ROOT%/}/"
bf07e140c49c 8221851: Use of THIS_FILE in hotspot invalidates precompiled header on Linux/GCC
erikj
parents: 53837
diff changeset
   863
    FILE_MACRO_CFLAGS="-fmacro-prefix-map=${workspace_root_trailing_slash}="
bf07e140c49c 8221851: Use of THIS_FILE in hotspot invalidates precompiled header on Linux/GCC
erikj
parents: 53837
diff changeset
   864
    FLAGS_COMPILER_CHECK_ARGUMENTS(ARGUMENT: [${FILE_MACRO_CFLAGS}],
bf07e140c49c 8221851: Use of THIS_FILE in hotspot invalidates precompiled header on Linux/GCC
erikj
parents: 53837
diff changeset
   865
        PREFIX: $3,
bf07e140c49c 8221851: Use of THIS_FILE in hotspot invalidates precompiled header on Linux/GCC
erikj
parents: 53837
diff changeset
   866
        IF_FALSE: [
bf07e140c49c 8221851: Use of THIS_FILE in hotspot invalidates precompiled header on Linux/GCC
erikj
parents: 53837
diff changeset
   867
            FILE_MACRO_CFLAGS=
bf07e140c49c 8221851: Use of THIS_FILE in hotspot invalidates precompiled header on Linux/GCC
erikj
parents: 53837
diff changeset
   868
        ]
bf07e140c49c 8221851: Use of THIS_FILE in hotspot invalidates precompiled header on Linux/GCC
erikj
parents: 53837
diff changeset
   869
    )
bf07e140c49c 8221851: Use of THIS_FILE in hotspot invalidates precompiled header on Linux/GCC
erikj
parents: 53837
diff changeset
   870
  fi
bf07e140c49c 8221851: Use of THIS_FILE in hotspot invalidates precompiled header on Linux/GCC
erikj
parents: 53837
diff changeset
   871
49120
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   872
  # EXPORT to API
53643
1126811a5124 8160926: FLAGS_COMPILER_CHECK_ARGUMENTS doesn't handle cross-compilation
erikj
parents: 53366
diff changeset
   873
  CFLAGS_JVM_COMMON="$ALWAYS_CFLAGS_JVM $ALWAYS_DEFINES_JVM \
1126811a5124 8160926: FLAGS_COMPILER_CHECK_ARGUMENTS doesn't handle cross-compilation
erikj
parents: 53366
diff changeset
   874
      $TOOLCHAIN_CFLAGS_JVM ${$1_TOOLCHAIN_CFLAGS_JVM} \
49120
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   875
      $OS_CFLAGS $OS_CFLAGS_JVM $CFLAGS_OS_DEF_JVM $DEBUG_CFLAGS_JVM \
54490
bf07e140c49c 8221851: Use of THIS_FILE in hotspot invalidates precompiled header on Linux/GCC
erikj
parents: 53837
diff changeset
   876
      $WARNING_CFLAGS $WARNING_CFLAGS_JVM $JVM_PICFLAG $FILE_MACRO_CFLAGS"
49120
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   877
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   878
  CFLAGS_JDK_COMMON="$ALWAYS_CFLAGS_JDK $ALWAYS_DEFINES_JDK $TOOLCHAIN_CFLAGS_JDK \
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   879
      $OS_CFLAGS $CFLAGS_OS_DEF_JDK $DEBUG_CFLAGS_JDK $DEBUG_OPTIONS_FLAGS_JDK \
54490
bf07e140c49c 8221851: Use of THIS_FILE in hotspot invalidates precompiled header on Linux/GCC
erikj
parents: 53837
diff changeset
   880
      $WARNING_CFLAGS $WARNING_CFLAGS_JDK $DEBUG_SYMBOLS_CFLAGS_JDK \
bf07e140c49c 8221851: Use of THIS_FILE in hotspot invalidates precompiled header on Linux/GCC
erikj
parents: 53837
diff changeset
   881
      $FILE_MACRO_CFLAGS"
49120
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   882
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   883
  # Use ${$2EXTRA_CFLAGS} to block EXTRA_CFLAGS to be added to build flags.
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   884
  # (Currently we don't have any OPENJDK_BUILD_EXTRA_CFLAGS, but that might
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   885
  # change in the future.)
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   886
49155
7cd937277d5e 8199338: Use -g0 on solstudio also for compiling C programs
ihse
parents: 49120
diff changeset
   887
  CFLAGS_JDK_COMMON_CONLY="$TOOLCHAIN_CFLAGS_JDK_CONLY  \
49120
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   888
      $WARNING_CFLAGS_JDK_CONLY ${$2EXTRA_CFLAGS}"
53643
1126811a5124 8160926: FLAGS_COMPILER_CHECK_ARGUMENTS doesn't handle cross-compilation
erikj
parents: 53366
diff changeset
   889
  CFLAGS_JDK_COMMON_CXXONLY="$ALWAYS_DEFINES_JDK_CXXONLY \
1126811a5124 8160926: FLAGS_COMPILER_CHECK_ARGUMENTS doesn't handle cross-compilation
erikj
parents: 53366
diff changeset
   890
      $TOOLCHAIN_CFLAGS_JDK_CXXONLY \
1126811a5124 8160926: FLAGS_COMPILER_CHECK_ARGUMENTS doesn't handle cross-compilation
erikj
parents: 53366
diff changeset
   891
      ${$1_TOOLCHAIN_CFLAGS_JDK_CXXONLY} \
49155
7cd937277d5e 8199338: Use -g0 on solstudio also for compiling C programs
ihse
parents: 49120
diff changeset
   892
      $WARNING_CFLAGS_JDK_CXXONLY ${$2EXTRA_CXXFLAGS}"
49120
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   893
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   894
  $1_CFLAGS_JVM="${$1_DEFINES_CPU_JVM} ${$1_CFLAGS_CPU} ${$1_CFLAGS_CPU_JVM} ${$1_TOOLCHAIN_CFLAGS} ${$1_WARNING_CFLAGS_JVM}"
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   895
  $1_CFLAGS_JDK="${$1_DEFINES_CPU_JDK} ${$1_CFLAGS_CPU} ${$1_CFLAGS_CPU_JDK} ${$1_TOOLCHAIN_CFLAGS}"
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   896
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   897
  $2JVM_CFLAGS="$CFLAGS_JVM_COMMON ${$1_CFLAGS_JVM} ${$2EXTRA_CXXFLAGS}"
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   898
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   899
  $2CFLAGS_JDKEXE="$CFLAGS_JDK_COMMON $CFLAGS_JDK_COMMON_CONLY ${$1_CFLAGS_JDK}"
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   900
  $2CXXFLAGS_JDKEXE="$CFLAGS_JDK_COMMON $CFLAGS_JDK_COMMON_CXXONLY ${$1_CFLAGS_JDK}"
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   901
  $2CFLAGS_JDKLIB="${$2CFLAGS_JDKEXE} $JDK_PICFLAG ${$1_CFLAGS_CPU_JDK_LIBONLY}"
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   902
  $2CXXFLAGS_JDKLIB="${$2CXXFLAGS_JDKEXE} $JDK_PICFLAG ${$1_CFLAGS_CPU_JDK_LIBONLY}"
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   903
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   904
  AC_SUBST($2JVM_CFLAGS)
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   905
  AC_SUBST($2CFLAGS_JDKLIB)
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   906
  AC_SUBST($2CFLAGS_JDKEXE)
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   907
  AC_SUBST($2CXXFLAGS_JDKLIB)
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   908
  AC_SUBST($2CXXFLAGS_JDKEXE)
53643
1126811a5124 8160926: FLAGS_COMPILER_CHECK_ARGUMENTS doesn't handle cross-compilation
erikj
parents: 53366
diff changeset
   909
  AC_SUBST($2ADLC_CXXFLAG)
1126811a5124 8160926: FLAGS_COMPILER_CHECK_ARGUMENTS doesn't handle cross-compilation
erikj
parents: 53366
diff changeset
   910
1126811a5124 8160926: FLAGS_COMPILER_CHECK_ARGUMENTS doesn't handle cross-compilation
erikj
parents: 53366
diff changeset
   911
  COMPILER_FP_CONTRACT_OFF_FLAG="-ffp-contract=off"
1126811a5124 8160926: FLAGS_COMPILER_CHECK_ARGUMENTS doesn't handle cross-compilation
erikj
parents: 53366
diff changeset
   912
  # Check that the compiler supports -ffp-contract=off flag
1126811a5124 8160926: FLAGS_COMPILER_CHECK_ARGUMENTS doesn't handle cross-compilation
erikj
parents: 53366
diff changeset
   913
  # Set FDLIBM_CFLAGS to -ffp-contract=off if it does. Empty
1126811a5124 8160926: FLAGS_COMPILER_CHECK_ARGUMENTS doesn't handle cross-compilation
erikj
parents: 53366
diff changeset
   914
  # otherwise.
1126811a5124 8160926: FLAGS_COMPILER_CHECK_ARGUMENTS doesn't handle cross-compilation
erikj
parents: 53366
diff changeset
   915
  # These flags are required for GCC-based builds of
1126811a5124 8160926: FLAGS_COMPILER_CHECK_ARGUMENTS doesn't handle cross-compilation
erikj
parents: 53366
diff changeset
   916
  # fdlibm with optimization without losing precision.
1126811a5124 8160926: FLAGS_COMPILER_CHECK_ARGUMENTS doesn't handle cross-compilation
erikj
parents: 53366
diff changeset
   917
  # Notably, -ffp-contract=off needs to be added for GCC >= 4.6.
1126811a5124 8160926: FLAGS_COMPILER_CHECK_ARGUMENTS doesn't handle cross-compilation
erikj
parents: 53366
diff changeset
   918
  if test "x$TOOLCHAIN_TYPE" = xgcc || test "x$TOOLCHAIN_TYPE" = xclang; then
1126811a5124 8160926: FLAGS_COMPILER_CHECK_ARGUMENTS doesn't handle cross-compilation
erikj
parents: 53366
diff changeset
   919
    FLAGS_COMPILER_CHECK_ARGUMENTS(ARGUMENT: [${COMPILER_FP_CONTRACT_OFF_FLAG}],
1126811a5124 8160926: FLAGS_COMPILER_CHECK_ARGUMENTS doesn't handle cross-compilation
erikj
parents: 53366
diff changeset
   920
        PREFIX: $3,
1126811a5124 8160926: FLAGS_COMPILER_CHECK_ARGUMENTS doesn't handle cross-compilation
erikj
parents: 53366
diff changeset
   921
        IF_TRUE: [$2FDLIBM_CFLAGS=${COMPILER_FP_CONTRACT_OFF_FLAG}],
1126811a5124 8160926: FLAGS_COMPILER_CHECK_ARGUMENTS doesn't handle cross-compilation
erikj
parents: 53366
diff changeset
   922
        IF_FALSE: [$2FDLIBM_CFLAGS=""])
1126811a5124 8160926: FLAGS_COMPILER_CHECK_ARGUMENTS doesn't handle cross-compilation
erikj
parents: 53366
diff changeset
   923
  fi
1126811a5124 8160926: FLAGS_COMPILER_CHECK_ARGUMENTS doesn't handle cross-compilation
erikj
parents: 53366
diff changeset
   924
  AC_SUBST($2FDLIBM_CFLAGS)
49120
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   925
])
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   926
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   927
# FLAGS_SETUP_GCC6_COMPILER_FLAGS([PREFIX])
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   928
# Arguments:
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   929
# $1 - Prefix for each variable defined.
53643
1126811a5124 8160926: FLAGS_COMPILER_CHECK_ARGUMENTS doesn't handle cross-compilation
erikj
parents: 53366
diff changeset
   930
# $2 - Prefix for compiler variables (either BUILD_ or nothing).
49120
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   931
AC_DEFUN([FLAGS_SETUP_GCC6_COMPILER_FLAGS],
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   932
[
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   933
  # These flags are required for GCC 6 builds as undefined behaviour in OpenJDK code
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   934
  # runs afoul of the more aggressive versions of these optimisations.
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   935
  # Notably, value range propagation now assumes that the this pointer of C++
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   936
  # member functions is non-null.
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   937
  NO_DELETE_NULL_POINTER_CHECKS_CFLAG="-fno-delete-null-pointer-checks"
53643
1126811a5124 8160926: FLAGS_COMPILER_CHECK_ARGUMENTS doesn't handle cross-compilation
erikj
parents: 53366
diff changeset
   938
  FLAGS_COMPILER_CHECK_ARGUMENTS(ARGUMENT: [$NO_DELETE_NULL_POINTER_CHECKS_CFLAG -Werror],
1126811a5124 8160926: FLAGS_COMPILER_CHECK_ARGUMENTS doesn't handle cross-compilation
erikj
parents: 53366
diff changeset
   939
      PREFIX: $2, IF_FALSE: [NO_DELETE_NULL_POINTER_CHECKS_CFLAG=""])
49120
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   940
  NO_LIFETIME_DSE_CFLAG="-fno-lifetime-dse"
53643
1126811a5124 8160926: FLAGS_COMPILER_CHECK_ARGUMENTS doesn't handle cross-compilation
erikj
parents: 53366
diff changeset
   941
  FLAGS_COMPILER_CHECK_ARGUMENTS(ARGUMENT: [$NO_LIFETIME_DSE_CFLAG -Werror],
1126811a5124 8160926: FLAGS_COMPILER_CHECK_ARGUMENTS doesn't handle cross-compilation
erikj
parents: 53366
diff changeset
   942
      PREFIX: $2, IF_FALSE: [NO_LIFETIME_DSE_CFLAG=""])
49120
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   943
  $1_GCC6_CFLAGS="${NO_DELETE_NULL_POINTER_CHECKS_CFLAG} ${NO_LIFETIME_DSE_CFLAG}"
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   944
])
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   945
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   946
# Documentation on common flags used for solstudio in HIGHEST.
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   947
#
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   948
# WARNING: Use of OPTIMIZATION_LEVEL=HIGHEST in your Makefile needs to be
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   949
#          done with care, there are some assumptions below that need to
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   950
#          be understood about the use of pointers, and IEEE behavior.
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   951
#
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   952
# -fns: Use non-standard floating point mode (not IEEE 754)
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   953
# -fsimple: Do some simplification of floating point arithmetic (not IEEE 754)
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   954
# -fsingle: Use single precision floating point with 'float'
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   955
# -xalias_level=basic: Assume memory references via basic pointer types do not alias
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   956
#   (Source with excessing pointer casting and data access with mixed
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   957
#    pointer types are not recommended)
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   958
# -xbuiltin=%all: Use intrinsic or inline versions for math/std functions
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   959
#   (If you expect perfect errno behavior, do not use this)
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   960
# -xdepend: Loop data dependency optimizations (need -xO3 or higher)
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   961
# -xrestrict: Pointer parameters to functions do not overlap
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   962
#   (Similar to -xalias_level=basic usage, but less obvious sometimes.
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   963
#    If you pass in multiple pointers to the same data, do not use this)
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   964
# -xlibmil: Inline some library routines
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   965
#   (If you expect perfect errno behavior, do not use this)
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   966
# -xlibmopt: Use optimized math routines (CURRENTLY DISABLED)
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   967
#   (If you expect perfect errno behavior, do not use this)
c04d813140dc 8198724: Refactor FLAGS handling in configure
ihse
parents:
diff changeset
   968
#  Can cause undefined external on Solaris 8 X86 on __sincos, removing for now