make/autoconf/flags-cflags.m4
author ihse
Thu, 01 Mar 2018 14:31:04 +0100
branchihse-cflags-rewrite-branch
changeset 56217 e550367df595
parent 56193 9aa8244e6b5d
child 56219 852414e4ae77
permissions -rw-r--r--
Add LDFLAGS_WARNINGS_ARE_ERRORS.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
13133
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
     1
#
48767
0c6ce8fdb50a 8080990: libdt_socket/socket_md.c(202) : warning C4996: 'gethostbyname': Use getaddrinfo() or GetAddrInfoW()
gadams
parents: 48751
diff changeset
     2
# Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved.
13133
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
     3
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
     4
#
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
     5
# This code is free software; you can redistribute it and/or modify it
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
     6
# under the terms of the GNU General Public License version 2 only, as
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
     7
# published by the Free Software Foundation.  Oracle designates this
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
     8
# particular file as subject to the "Classpath" exception as provided
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
     9
# by Oracle in the LICENSE file that accompanied this code.
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
    10
#
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
    11
# This code is distributed in the hope that it will be useful, but WITHOUT
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
    12
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
    13
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
    14
# version 2 for more details (a copy is included in the LICENSE file that
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
    15
# accompanied this code).
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
    16
#
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
    17
# You should have received a copy of the GNU General Public License version
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
    18
# 2 along with this work; if not, write to the Free Software Foundation,
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
    19
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
    20
#
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
    21
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
    22
# or visit www.oracle.com if you need additional information or have any
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
    23
# questions.
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
    24
#
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
    25
42538
973e43884dba 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents: 42530
diff changeset
    26
################################################################################
973e43884dba 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents: 42530
diff changeset
    27
#
56124
b2b9dfdc39c8 Start breaking out stuff from flags.m4.
ihse
parents: 48854
diff changeset
    28
# Setup flags for C/C++ compiler
42538
973e43884dba 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents: 42530
diff changeset
    29
#
973e43884dba 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents: 42530
diff changeset
    30
56124
b2b9dfdc39c8 Start breaking out stuff from flags.m4.
ihse
parents: 48854
diff changeset
    31
###############################################################################
b2b9dfdc39c8 Start breaking out stuff from flags.m4.
ihse
parents: 48854
diff changeset
    32
#
b2b9dfdc39c8 Start breaking out stuff from flags.m4.
ihse
parents: 48854
diff changeset
    33
# How to compile shared libraries.
b2b9dfdc39c8 Start breaking out stuff from flags.m4.
ihse
parents: 48854
diff changeset
    34
#
b2b9dfdc39c8 Start breaking out stuff from flags.m4.
ihse
parents: 48854
diff changeset
    35
AC_DEFUN([FLAGS_SETUP_SHARED_LIBS],
32810
8203e52cd373 8138694: Devkit build on Macosx still requires Xcode to be installed
erikj
parents: 30856
diff changeset
    36
[
22721
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
    37
  if test "x$TOOLCHAIN_TYPE" = xgcc; then
13133
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
    38
    C_FLAG_REORDER=''
56168
cb0b10e44247 Cleaning up.
ihse
parents: 56162
diff changeset
    39
cb0b10e44247 Cleaning up.
ihse
parents: 56162
diff changeset
    40
    # Default works for linux, might work on other platforms as well.
cb0b10e44247 Cleaning up.
ihse
parents: 56162
diff changeset
    41
    SHARED_LIBRARY_FLAGS='-shared'
cb0b10e44247 Cleaning up.
ihse
parents: 56162
diff changeset
    42
    SET_EXECUTABLE_ORIGIN='-Wl,-rpath,\$$ORIGIN[$]1'
cb0b10e44247 Cleaning up.
ihse
parents: 56162
diff changeset
    43
    SET_SHARED_LIBRARY_ORIGIN="-Wl,-z,origin $SET_EXECUTABLE_ORIGIN"
cb0b10e44247 Cleaning up.
ihse
parents: 56162
diff changeset
    44
    SET_SHARED_LIBRARY_NAME='-Wl,-soname=[$]1'
cb0b10e44247 Cleaning up.
ihse
parents: 56162
diff changeset
    45
    SET_SHARED_LIBRARY_MAPFILE='-Wl,-version-script=[$]1'
cb0b10e44247 Cleaning up.
ihse
parents: 56162
diff changeset
    46
cb0b10e44247 Cleaning up.
ihse
parents: 56162
diff changeset
    47
  elif test "x$TOOLCHAIN_TYPE" = xclang; then
cb0b10e44247 Cleaning up.
ihse
parents: 56162
diff changeset
    48
    C_FLAG_REORDER=''
13133
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
    49
14111
2a82ecb35fc7 8000992: Update new build-infra makefiles
ohair
parents: 13697
diff changeset
    50
    if test "x$OPENJDK_TARGET_OS" = xmacosx; then
22721
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
    51
      # Linking is different on MacOSX
56158
97b2b2de66f2 Fixing PIC-flag issues, and all remaining differences on linux_x64.
ihse
parents: 56146
diff changeset
    52
      SHARED_LIBRARY_FLAGS="-dynamiclib -compatibility_version 1.0.0 -current_version 1.0.0"
44398
406532d25529 8177634: Fix for 8175307 may cause linker errors on OS X 10.9
ihse
parents: 44074
diff changeset
    53
      SET_EXECUTABLE_ORIGIN='-Wl,-rpath,@loader_path$(or [$]1,/.)'
23161
85635b5bf0a6 8019470: Changes needed to compile JDK 8 on MacOS with clang compiler
henryjen
parents: 22730
diff changeset
    54
      SET_SHARED_LIBRARY_ORIGIN="$SET_EXECUTABLE_ORIGIN"
34596
e8328ce5b64e 8142907: Integration of minor fixes from the build-infra project
ihse
parents: 34120
diff changeset
    55
      SET_SHARED_LIBRARY_NAME='-Wl,-install_name,@rpath/[$]1'
35747
aeaa6d0101a8 8149647: Incremental enhancements from build-infra
ihse
parents: 35451
diff changeset
    56
      SET_SHARED_LIBRARY_MAPFILE='-Wl,-exported_symbols_list,[$]1'
37402
62b5f067032e 8152666: The new Hotspot Build System
erikj
parents: 36541
diff changeset
    57
23161
85635b5bf0a6 8019470: Changes needed to compile JDK 8 on MacOS with clang compiler
henryjen
parents: 22730
diff changeset
    58
    else
85635b5bf0a6 8019470: Changes needed to compile JDK 8 on MacOS with clang compiler
henryjen
parents: 22730
diff changeset
    59
      # Default works for linux, might work on other platforms as well.
85635b5bf0a6 8019470: Changes needed to compile JDK 8 on MacOS with clang compiler
henryjen
parents: 22730
diff changeset
    60
      SHARED_LIBRARY_FLAGS='-shared'
41875
854ef5325653 8160491: tar.gz bundles missing files containing $
erikj
parents: 41662
diff changeset
    61
      SET_EXECUTABLE_ORIGIN='-Wl,-rpath,\$$ORIGIN[$]1'
34596
e8328ce5b64e 8142907: Integration of minor fixes from the build-infra project
ihse
parents: 34120
diff changeset
    62
      SET_SHARED_LIBRARY_NAME='-Wl,-soname=[$]1'
e8328ce5b64e 8142907: Integration of minor fixes from the build-infra project
ihse
parents: 34120
diff changeset
    63
      SET_SHARED_LIBRARY_MAPFILE='-Wl,-version-script=[$]1'
42538
973e43884dba 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents: 42530
diff changeset
    64
973e43884dba 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents: 42530
diff changeset
    65
      # arm specific settings
973e43884dba 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents: 42530
diff changeset
    66
      if test "x$OPENJDK_TARGET_CPU" = "xarm"; then
973e43884dba 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents: 42530
diff changeset
    67
        # '-Wl,-z,origin' isn't used on arm.
973e43884dba 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents: 42530
diff changeset
    68
        SET_SHARED_LIBRARY_ORIGIN='-Wl,-rpath,\$$$$ORIGIN[$]1'
973e43884dba 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents: 42530
diff changeset
    69
      else
973e43884dba 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents: 42530
diff changeset
    70
        SET_SHARED_LIBRARY_ORIGIN="-Wl,-z,origin $SET_EXECUTABLE_ORIGIN"
973e43884dba 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents: 42530
diff changeset
    71
      fi
56168
cb0b10e44247 Cleaning up.
ihse
parents: 56162
diff changeset
    72
    fi
42538
973e43884dba 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents: 42530
diff changeset
    73
22721
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
    74
  elif test "x$TOOLCHAIN_TYPE" = xsolstudio; then
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
    75
    C_FLAG_REORDER='-xF'
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
    76
    SHARED_LIBRARY_FLAGS="-G"
41875
854ef5325653 8160491: tar.gz bundles missing files containing $
erikj
parents: 41662
diff changeset
    77
    SET_EXECUTABLE_ORIGIN='-R\$$ORIGIN[$]1'
22721
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
    78
    SET_SHARED_LIBRARY_ORIGIN="$SET_EXECUTABLE_ORIGIN"
34596
e8328ce5b64e 8142907: Integration of minor fixes from the build-infra project
ihse
parents: 34120
diff changeset
    79
    SET_SHARED_LIBRARY_NAME='-h [$]1'
22721
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
    80
    SET_SHARED_LIBRARY_MAPFILE='-M[$]1'
56168
cb0b10e44247 Cleaning up.
ihse
parents: 56162
diff changeset
    81
22721
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
    82
  elif test "x$TOOLCHAIN_TYPE" = xxlc; then
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
    83
    C_FLAG_REORDER=''
36051
25fa80338f92 8150197: Integrate AIX fixes from build-infra
simonis
parents: 36050
diff changeset
    84
    SHARED_LIBRARY_FLAGS="-qmkshrobj -bM:SRE -bnoentry"
22721
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
    85
    SET_EXECUTABLE_ORIGIN=""
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
    86
    SET_SHARED_LIBRARY_ORIGIN=''
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
    87
    SET_SHARED_LIBRARY_NAME=''
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
    88
    SET_SHARED_LIBRARY_MAPFILE=''
56168
cb0b10e44247 Cleaning up.
ihse
parents: 56162
diff changeset
    89
22721
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
    90
  elif test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
    91
    C_FLAG_REORDER=''
34596
e8328ce5b64e 8142907: Integration of minor fixes from the build-infra project
ihse
parents: 34120
diff changeset
    92
    SHARED_LIBRARY_FLAGS="-dll"
22721
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
    93
    SET_EXECUTABLE_ORIGIN=''
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
    94
    SET_SHARED_LIBRARY_ORIGIN=''
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
    95
    SET_SHARED_LIBRARY_NAME=''
35747
aeaa6d0101a8 8149647: Incremental enhancements from build-infra
ihse
parents: 35451
diff changeset
    96
    SET_SHARED_LIBRARY_MAPFILE='-def:[$]1'
20363
fa7663fc5d50 8001931: The new build system whitespace cleanup
ihse
parents: 20362
diff changeset
    97
  fi
13133
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
    98
22721
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
    99
  AC_SUBST(C_FLAG_REORDER)
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   100
  AC_SUBST(SET_EXECUTABLE_ORIGIN)
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   101
  AC_SUBST(SET_SHARED_LIBRARY_ORIGIN)
20363
fa7663fc5d50 8001931: The new build system whitespace cleanup
ihse
parents: 20362
diff changeset
   102
  AC_SUBST(SET_SHARED_LIBRARY_NAME)
fa7663fc5d50 8001931: The new build system whitespace cleanup
ihse
parents: 20362
diff changeset
   103
  AC_SUBST(SET_SHARED_LIBRARY_MAPFILE)
34596
e8328ce5b64e 8142907: Integration of minor fixes from the build-infra project
ihse
parents: 34120
diff changeset
   104
  AC_SUBST(SHARED_LIBRARY_FLAGS)
13133
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
   105
])
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
   106
56124
b2b9dfdc39c8 Start breaking out stuff from flags.m4.
ihse
parents: 48854
diff changeset
   107
AC_DEFUN([FLAGS_SETUP_DEBUG_SYMBOLS],
13133
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
   108
[
22721
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   109
  # Debug symbols
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   110
  if test "x$TOOLCHAIN_TYPE" = xgcc; then
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   111
    if test "x$OPENJDK_TARGET_CPU_BITS" = "x64" && test "x$DEBUG_LEVEL" = "xfastdebug"; then
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   112
      CFLAGS_DEBUG_SYMBOLS="-g1"
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   113
    else
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   114
      CFLAGS_DEBUG_SYMBOLS="-g"
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   115
    fi
23161
85635b5bf0a6 8019470: Changes needed to compile JDK 8 on MacOS with clang compiler
henryjen
parents: 22730
diff changeset
   116
  elif test "x$TOOLCHAIN_TYPE" = xclang; then
85635b5bf0a6 8019470: Changes needed to compile JDK 8 on MacOS with clang compiler
henryjen
parents: 22730
diff changeset
   117
    CFLAGS_DEBUG_SYMBOLS="-g"
22721
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   118
  elif test "x$TOOLCHAIN_TYPE" = xsolstudio; then
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   119
    CFLAGS_DEBUG_SYMBOLS="-g -xs"
35032
c2f315819691 8145596: Enable debug symbols for all libraries
ihse
parents: 35029
diff changeset
   120
    # -g0 enables debug symbols without disabling inlining.
22721
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   121
    CXXFLAGS_DEBUG_SYMBOLS="-g0 -xs"
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   122
  elif test "x$TOOLCHAIN_TYPE" = xxlc; then
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   123
    CFLAGS_DEBUG_SYMBOLS="-g"
36531
ef4e1ca50af8 8151619: genSocketOptionRegistry.exe always relinked on Windows
erikj
parents: 36051
diff changeset
   124
  elif test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
ef4e1ca50af8 8151619: genSocketOptionRegistry.exe always relinked on Windows
erikj
parents: 36051
diff changeset
   125
    CFLAGS_DEBUG_SYMBOLS="-Zi"
56162
d421dac1932f Remove duplication in debug flags.
ihse
parents: 56161
diff changeset
   126
  fi
d421dac1932f Remove duplication in debug flags.
ihse
parents: 56161
diff changeset
   127
d421dac1932f Remove duplication in debug flags.
ihse
parents: 56161
diff changeset
   128
  if test "x$CXXFLAGS_DEBUG_SYMBOLS" = x; then
d421dac1932f Remove duplication in debug flags.
ihse
parents: 56161
diff changeset
   129
    # If we did not specify special flags for C++, use C version
d421dac1932f Remove duplication in debug flags.
ihse
parents: 56161
diff changeset
   130
    CXXFLAGS_DEBUG_SYMBOLS="$CFLAGS_DEBUG_SYMBOLS"
22721
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   131
  fi
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   132
  AC_SUBST(CFLAGS_DEBUG_SYMBOLS)
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   133
  AC_SUBST(CXXFLAGS_DEBUG_SYMBOLS)
56161
a7585ecb9fc2 Trying to sort out EXTRA_CFLAGS. Moving all flag handling to flags.m4.
ihse
parents: 56158
diff changeset
   134
a7585ecb9fc2 Trying to sort out EXTRA_CFLAGS. Moving all flag handling to flags.m4.
ihse
parents: 56158
diff changeset
   135
  # FIXME: This was never used in the old build. What to do with it?
a7585ecb9fc2 Trying to sort out EXTRA_CFLAGS. Moving all flag handling to flags.m4.
ihse
parents: 56158
diff changeset
   136
  if test "x$TOOLCHAIN_TYPE" = xgcc; then
a7585ecb9fc2 Trying to sort out EXTRA_CFLAGS. Moving all flag handling to flags.m4.
ihse
parents: 56158
diff changeset
   137
    # "-Og" suppported for GCC 4.8 and later
a7585ecb9fc2 Trying to sort out EXTRA_CFLAGS. Moving all flag handling to flags.m4.
ihse
parents: 56158
diff changeset
   138
    CFLAG_OPTIMIZE_DEBUG_FLAG="-Og"
a7585ecb9fc2 Trying to sort out EXTRA_CFLAGS. Moving all flag handling to flags.m4.
ihse
parents: 56158
diff changeset
   139
    FLAGS_COMPILER_CHECK_ARGUMENTS(ARGUMENT: [$CFLAG_OPTIMIZE_DEBUG_FLAG],
a7585ecb9fc2 Trying to sort out EXTRA_CFLAGS. Moving all flag handling to flags.m4.
ihse
parents: 56158
diff changeset
   140
      IF_TRUE: [HAS_CFLAG_OPTIMIZE_DEBUG=true],
a7585ecb9fc2 Trying to sort out EXTRA_CFLAGS. Moving all flag handling to flags.m4.
ihse
parents: 56158
diff changeset
   141
      IF_FALSE: [HAS_CFLAG_OPTIMIZE_DEBUG=false])
a7585ecb9fc2 Trying to sort out EXTRA_CFLAGS. Moving all flag handling to flags.m4.
ihse
parents: 56158
diff changeset
   142
  fi
56177
2fbe3b84ee3d Even more restructuring.
ihse
parents: 56176
diff changeset
   143
2fbe3b84ee3d Even more restructuring.
ihse
parents: 56176
diff changeset
   144
  # Debug symbols for JVM_CFLAGS
2fbe3b84ee3d Even more restructuring.
ihse
parents: 56176
diff changeset
   145
  if test "x$TOOLCHAIN_TYPE" = xsolstudio; then
2fbe3b84ee3d Even more restructuring.
ihse
parents: 56176
diff changeset
   146
    JVM_CFLAGS_SYMBOLS="$JVM_CFLAGS_SYMBOLS -xs"
2fbe3b84ee3d Even more restructuring.
ihse
parents: 56176
diff changeset
   147
    if test "x$DEBUG_LEVEL" = xslowdebug; then
2fbe3b84ee3d Even more restructuring.
ihse
parents: 56176
diff changeset
   148
      JVM_CFLAGS_SYMBOLS="$JVM_CFLAGS_SYMBOLS -g"
2fbe3b84ee3d Even more restructuring.
ihse
parents: 56176
diff changeset
   149
    else
2fbe3b84ee3d Even more restructuring.
ihse
parents: 56176
diff changeset
   150
      # -g0 does not disable inlining, which -g does.
2fbe3b84ee3d Even more restructuring.
ihse
parents: 56176
diff changeset
   151
      JVM_CFLAGS_SYMBOLS="$JVM_CFLAGS_SYMBOLS -g0"
2fbe3b84ee3d Even more restructuring.
ihse
parents: 56176
diff changeset
   152
    fi
2fbe3b84ee3d Even more restructuring.
ihse
parents: 56176
diff changeset
   153
  elif test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
2fbe3b84ee3d Even more restructuring.
ihse
parents: 56176
diff changeset
   154
    JVM_CFLAGS_SYMBOLS="$JVM_CFLAGS_SYMBOLS -Z7 -d2Zi+"
2fbe3b84ee3d Even more restructuring.
ihse
parents: 56176
diff changeset
   155
  else
2fbe3b84ee3d Even more restructuring.
ihse
parents: 56176
diff changeset
   156
    JVM_CFLAGS_SYMBOLS="$JVM_CFLAGS_SYMBOLS -g"
2fbe3b84ee3d Even more restructuring.
ihse
parents: 56176
diff changeset
   157
  fi
2fbe3b84ee3d Even more restructuring.
ihse
parents: 56176
diff changeset
   158
  AC_SUBST(JVM_CFLAGS_SYMBOLS)
56124
b2b9dfdc39c8 Start breaking out stuff from flags.m4.
ihse
parents: 48854
diff changeset
   159
])
22721
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   160
56179
dc0add3a3212 More cleaning up. Probably done now...
ihse
parents: 56178
diff changeset
   161
AC_DEFUN([FLAGS_SETUP_WARNINGS],
56124
b2b9dfdc39c8 Start breaking out stuff from flags.m4.
ihse
parents: 48854
diff changeset
   162
[
56176
b3e3a12dcb33 Lots of structural rearrangements. Also fix for adding EXTRA_FLAGS to BUILD
ihse
parents: 56168
diff changeset
   163
  AC_ARG_ENABLE([warnings-as-errors], [AS_HELP_STRING([--disable-warnings-as-errors],
b3e3a12dcb33 Lots of structural rearrangements. Also fix for adding EXTRA_FLAGS to BUILD
ihse
parents: 56168
diff changeset
   164
      [do not consider native warnings to be an error @<:@enabled@:>@])])
b3e3a12dcb33 Lots of structural rearrangements. Also fix for adding EXTRA_FLAGS to BUILD
ihse
parents: 56168
diff changeset
   165
b3e3a12dcb33 Lots of structural rearrangements. Also fix for adding EXTRA_FLAGS to BUILD
ihse
parents: 56168
diff changeset
   166
  AC_MSG_CHECKING([if native warnings are errors])
b3e3a12dcb33 Lots of structural rearrangements. Also fix for adding EXTRA_FLAGS to BUILD
ihse
parents: 56168
diff changeset
   167
  if test "x$enable_warnings_as_errors" = "xyes"; then
b3e3a12dcb33 Lots of structural rearrangements. Also fix for adding EXTRA_FLAGS to BUILD
ihse
parents: 56168
diff changeset
   168
    AC_MSG_RESULT([yes (explicitly set)])
b3e3a12dcb33 Lots of structural rearrangements. Also fix for adding EXTRA_FLAGS to BUILD
ihse
parents: 56168
diff changeset
   169
    WARNINGS_AS_ERRORS=true
b3e3a12dcb33 Lots of structural rearrangements. Also fix for adding EXTRA_FLAGS to BUILD
ihse
parents: 56168
diff changeset
   170
  elif test "x$enable_warnings_as_errors" = "xno"; then
b3e3a12dcb33 Lots of structural rearrangements. Also fix for adding EXTRA_FLAGS to BUILD
ihse
parents: 56168
diff changeset
   171
    AC_MSG_RESULT([no])
b3e3a12dcb33 Lots of structural rearrangements. Also fix for adding EXTRA_FLAGS to BUILD
ihse
parents: 56168
diff changeset
   172
    WARNINGS_AS_ERRORS=false
b3e3a12dcb33 Lots of structural rearrangements. Also fix for adding EXTRA_FLAGS to BUILD
ihse
parents: 56168
diff changeset
   173
  elif test "x$enable_warnings_as_errors" = "x"; then
b3e3a12dcb33 Lots of structural rearrangements. Also fix for adding EXTRA_FLAGS to BUILD
ihse
parents: 56168
diff changeset
   174
    AC_MSG_RESULT([yes (default)])
b3e3a12dcb33 Lots of structural rearrangements. Also fix for adding EXTRA_FLAGS to BUILD
ihse
parents: 56168
diff changeset
   175
    WARNINGS_AS_ERRORS=true
b3e3a12dcb33 Lots of structural rearrangements. Also fix for adding EXTRA_FLAGS to BUILD
ihse
parents: 56168
diff changeset
   176
  else
b3e3a12dcb33 Lots of structural rearrangements. Also fix for adding EXTRA_FLAGS to BUILD
ihse
parents: 56168
diff changeset
   177
    AC_MSG_ERROR([--enable-warnings-as-errors accepts no argument])
b3e3a12dcb33 Lots of structural rearrangements. Also fix for adding EXTRA_FLAGS to BUILD
ihse
parents: 56168
diff changeset
   178
  fi
b3e3a12dcb33 Lots of structural rearrangements. Also fix for adding EXTRA_FLAGS to BUILD
ihse
parents: 56168
diff changeset
   179
b3e3a12dcb33 Lots of structural rearrangements. Also fix for adding EXTRA_FLAGS to BUILD
ihse
parents: 56168
diff changeset
   180
  AC_SUBST(WARNINGS_AS_ERRORS)
b3e3a12dcb33 Lots of structural rearrangements. Also fix for adding EXTRA_FLAGS to BUILD
ihse
parents: 56168
diff changeset
   181
56217
e550367df595 Add LDFLAGS_WARNINGS_ARE_ERRORS.
ihse
parents: 56193
diff changeset
   182
  LDFLAGS_WARNINGS_ARE_ERRORS=""
56176
b3e3a12dcb33 Lots of structural rearrangements. Also fix for adding EXTRA_FLAGS to BUILD
ihse
parents: 56168
diff changeset
   183
  case "${TOOLCHAIN_TYPE}" in
b3e3a12dcb33 Lots of structural rearrangements. Also fix for adding EXTRA_FLAGS to BUILD
ihse
parents: 56168
diff changeset
   184
    microsoft)
b3e3a12dcb33 Lots of structural rearrangements. Also fix for adding EXTRA_FLAGS to BUILD
ihse
parents: 56168
diff changeset
   185
      DISABLE_WARNING_PREFIX="-wd"
b3e3a12dcb33 Lots of structural rearrangements. Also fix for adding EXTRA_FLAGS to BUILD
ihse
parents: 56168
diff changeset
   186
      CFLAGS_WARNINGS_ARE_ERRORS="-WX"
b3e3a12dcb33 Lots of structural rearrangements. Also fix for adding EXTRA_FLAGS to BUILD
ihse
parents: 56168
diff changeset
   187
      ;;
b3e3a12dcb33 Lots of structural rearrangements. Also fix for adding EXTRA_FLAGS to BUILD
ihse
parents: 56168
diff changeset
   188
    solstudio)
b3e3a12dcb33 Lots of structural rearrangements. Also fix for adding EXTRA_FLAGS to BUILD
ihse
parents: 56168
diff changeset
   189
      DISABLE_WARNING_PREFIX="-erroff="
b3e3a12dcb33 Lots of structural rearrangements. Also fix for adding EXTRA_FLAGS to BUILD
ihse
parents: 56168
diff changeset
   190
      CFLAGS_WARNINGS_ARE_ERRORS="-errtags -errwarn=%all"
56217
e550367df595 Add LDFLAGS_WARNINGS_ARE_ERRORS.
ihse
parents: 56193
diff changeset
   191
      LDFLAGS_WARNINGS_ARE_ERRORS="-Wl,-z,fatal-warnings"
56176
b3e3a12dcb33 Lots of structural rearrangements. Also fix for adding EXTRA_FLAGS to BUILD
ihse
parents: 56168
diff changeset
   192
      ;;
b3e3a12dcb33 Lots of structural rearrangements. Also fix for adding EXTRA_FLAGS to BUILD
ihse
parents: 56168
diff changeset
   193
    gcc)
b3e3a12dcb33 Lots of structural rearrangements. Also fix for adding EXTRA_FLAGS to BUILD
ihse
parents: 56168
diff changeset
   194
      # Prior to gcc 4.4, a -Wno-X where X is unknown for that version of gcc will cause an error
b3e3a12dcb33 Lots of structural rearrangements. Also fix for adding EXTRA_FLAGS to BUILD
ihse
parents: 56168
diff changeset
   195
      FLAGS_COMPILER_CHECK_ARGUMENTS(ARGUMENT: [-Wno-this-is-a-warning-that-do-not-exist],
b3e3a12dcb33 Lots of structural rearrangements. Also fix for adding EXTRA_FLAGS to BUILD
ihse
parents: 56168
diff changeset
   196
          IF_TRUE: [GCC_CAN_DISABLE_WARNINGS=true],
b3e3a12dcb33 Lots of structural rearrangements. Also fix for adding EXTRA_FLAGS to BUILD
ihse
parents: 56168
diff changeset
   197
          IF_FALSE: [GCC_CAN_DISABLE_WARNINGS=false]
b3e3a12dcb33 Lots of structural rearrangements. Also fix for adding EXTRA_FLAGS to BUILD
ihse
parents: 56168
diff changeset
   198
      )
b3e3a12dcb33 Lots of structural rearrangements. Also fix for adding EXTRA_FLAGS to BUILD
ihse
parents: 56168
diff changeset
   199
      if test "x$GCC_CAN_DISABLE_WARNINGS" = "xtrue"; then
b3e3a12dcb33 Lots of structural rearrangements. Also fix for adding EXTRA_FLAGS to BUILD
ihse
parents: 56168
diff changeset
   200
        DISABLE_WARNING_PREFIX="-Wno-"
b3e3a12dcb33 Lots of structural rearrangements. Also fix for adding EXTRA_FLAGS to BUILD
ihse
parents: 56168
diff changeset
   201
      else
b3e3a12dcb33 Lots of structural rearrangements. Also fix for adding EXTRA_FLAGS to BUILD
ihse
parents: 56168
diff changeset
   202
        DISABLE_WARNING_PREFIX=
b3e3a12dcb33 Lots of structural rearrangements. Also fix for adding EXTRA_FLAGS to BUILD
ihse
parents: 56168
diff changeset
   203
      fi
b3e3a12dcb33 Lots of structural rearrangements. Also fix for adding EXTRA_FLAGS to BUILD
ihse
parents: 56168
diff changeset
   204
      CFLAGS_WARNINGS_ARE_ERRORS="-Werror"
b3e3a12dcb33 Lots of structural rearrangements. Also fix for adding EXTRA_FLAGS to BUILD
ihse
parents: 56168
diff changeset
   205
      # Repeate the check for the BUILD_CC and BUILD_CXX. Need to also reset
b3e3a12dcb33 Lots of structural rearrangements. Also fix for adding EXTRA_FLAGS to BUILD
ihse
parents: 56168
diff changeset
   206
      # CFLAGS since any target specific flags will likely not work with the
b3e3a12dcb33 Lots of structural rearrangements. Also fix for adding EXTRA_FLAGS to BUILD
ihse
parents: 56168
diff changeset
   207
      # build compiler
b3e3a12dcb33 Lots of structural rearrangements. Also fix for adding EXTRA_FLAGS to BUILD
ihse
parents: 56168
diff changeset
   208
      CC_OLD="$CC"
b3e3a12dcb33 Lots of structural rearrangements. Also fix for adding EXTRA_FLAGS to BUILD
ihse
parents: 56168
diff changeset
   209
      CXX_OLD="$CXX"
b3e3a12dcb33 Lots of structural rearrangements. Also fix for adding EXTRA_FLAGS to BUILD
ihse
parents: 56168
diff changeset
   210
      CC="$BUILD_CC"
b3e3a12dcb33 Lots of structural rearrangements. Also fix for adding EXTRA_FLAGS to BUILD
ihse
parents: 56168
diff changeset
   211
      CXX="$BUILD_CXX"
b3e3a12dcb33 Lots of structural rearrangements. Also fix for adding EXTRA_FLAGS to BUILD
ihse
parents: 56168
diff changeset
   212
      CFLAGS_OLD="$CFLAGS"
b3e3a12dcb33 Lots of structural rearrangements. Also fix for adding EXTRA_FLAGS to BUILD
ihse
parents: 56168
diff changeset
   213
      CFLAGS=""
b3e3a12dcb33 Lots of structural rearrangements. Also fix for adding EXTRA_FLAGS to BUILD
ihse
parents: 56168
diff changeset
   214
      FLAGS_COMPILER_CHECK_ARGUMENTS(ARGUMENT: [-Wno-this-is-a-warning-that-do-not-exist],
b3e3a12dcb33 Lots of structural rearrangements. Also fix for adding EXTRA_FLAGS to BUILD
ihse
parents: 56168
diff changeset
   215
          IF_TRUE: [BUILD_CC_CAN_DISABLE_WARNINGS=true],
b3e3a12dcb33 Lots of structural rearrangements. Also fix for adding EXTRA_FLAGS to BUILD
ihse
parents: 56168
diff changeset
   216
          IF_FALSE: [BUILD_CC_CAN_DISABLE_WARNINGS=false]
b3e3a12dcb33 Lots of structural rearrangements. Also fix for adding EXTRA_FLAGS to BUILD
ihse
parents: 56168
diff changeset
   217
      )
b3e3a12dcb33 Lots of structural rearrangements. Also fix for adding EXTRA_FLAGS to BUILD
ihse
parents: 56168
diff changeset
   218
      if test "x$BUILD_CC_CAN_DISABLE_WARNINGS" = "xtrue"; then
b3e3a12dcb33 Lots of structural rearrangements. Also fix for adding EXTRA_FLAGS to BUILD
ihse
parents: 56168
diff changeset
   219
        BUILD_CC_DISABLE_WARNING_PREFIX="-Wno-"
b3e3a12dcb33 Lots of structural rearrangements. Also fix for adding EXTRA_FLAGS to BUILD
ihse
parents: 56168
diff changeset
   220
      else
b3e3a12dcb33 Lots of structural rearrangements. Also fix for adding EXTRA_FLAGS to BUILD
ihse
parents: 56168
diff changeset
   221
        BUILD_CC_DISABLE_WARNING_PREFIX=
b3e3a12dcb33 Lots of structural rearrangements. Also fix for adding EXTRA_FLAGS to BUILD
ihse
parents: 56168
diff changeset
   222
      fi
b3e3a12dcb33 Lots of structural rearrangements. Also fix for adding EXTRA_FLAGS to BUILD
ihse
parents: 56168
diff changeset
   223
      CC="$CC_OLD"
b3e3a12dcb33 Lots of structural rearrangements. Also fix for adding EXTRA_FLAGS to BUILD
ihse
parents: 56168
diff changeset
   224
      CXX="$CXX_OLD"
b3e3a12dcb33 Lots of structural rearrangements. Also fix for adding EXTRA_FLAGS to BUILD
ihse
parents: 56168
diff changeset
   225
      CFLAGS="$CFLAGS_OLD"
b3e3a12dcb33 Lots of structural rearrangements. Also fix for adding EXTRA_FLAGS to BUILD
ihse
parents: 56168
diff changeset
   226
      ;;
b3e3a12dcb33 Lots of structural rearrangements. Also fix for adding EXTRA_FLAGS to BUILD
ihse
parents: 56168
diff changeset
   227
    clang)
b3e3a12dcb33 Lots of structural rearrangements. Also fix for adding EXTRA_FLAGS to BUILD
ihse
parents: 56168
diff changeset
   228
      DISABLE_WARNING_PREFIX="-Wno-"
b3e3a12dcb33 Lots of structural rearrangements. Also fix for adding EXTRA_FLAGS to BUILD
ihse
parents: 56168
diff changeset
   229
      CFLAGS_WARNINGS_ARE_ERRORS="-Werror"
b3e3a12dcb33 Lots of structural rearrangements. Also fix for adding EXTRA_FLAGS to BUILD
ihse
parents: 56168
diff changeset
   230
      ;;
b3e3a12dcb33 Lots of structural rearrangements. Also fix for adding EXTRA_FLAGS to BUILD
ihse
parents: 56168
diff changeset
   231
    xlc)
b3e3a12dcb33 Lots of structural rearrangements. Also fix for adding EXTRA_FLAGS to BUILD
ihse
parents: 56168
diff changeset
   232
      DISABLE_WARNING_PREFIX="-qsuppress="
b3e3a12dcb33 Lots of structural rearrangements. Also fix for adding EXTRA_FLAGS to BUILD
ihse
parents: 56168
diff changeset
   233
      CFLAGS_WARNINGS_ARE_ERRORS="-qhalt=w"
b3e3a12dcb33 Lots of structural rearrangements. Also fix for adding EXTRA_FLAGS to BUILD
ihse
parents: 56168
diff changeset
   234
      ;;
b3e3a12dcb33 Lots of structural rearrangements. Also fix for adding EXTRA_FLAGS to BUILD
ihse
parents: 56168
diff changeset
   235
  esac
b3e3a12dcb33 Lots of structural rearrangements. Also fix for adding EXTRA_FLAGS to BUILD
ihse
parents: 56168
diff changeset
   236
  AC_SUBST(DISABLE_WARNING_PREFIX)
b3e3a12dcb33 Lots of structural rearrangements. Also fix for adding EXTRA_FLAGS to BUILD
ihse
parents: 56168
diff changeset
   237
  AC_SUBST(BUILD_CC_DISABLE_WARNING_PREFIX)
b3e3a12dcb33 Lots of structural rearrangements. Also fix for adding EXTRA_FLAGS to BUILD
ihse
parents: 56168
diff changeset
   238
  AC_SUBST(CFLAGS_WARNINGS_ARE_ERRORS)
56217
e550367df595 Add LDFLAGS_WARNINGS_ARE_ERRORS.
ihse
parents: 56193
diff changeset
   239
  AC_SUBST(LDFLAGS_WARNINGS_ARE_ERRORS)
56179
dc0add3a3212 More cleaning up. Probably done now...
ihse
parents: 56178
diff changeset
   240
])
56176
b3e3a12dcb33 Lots of structural rearrangements. Also fix for adding EXTRA_FLAGS to BUILD
ihse
parents: 56168
diff changeset
   241
56179
dc0add3a3212 More cleaning up. Probably done now...
ihse
parents: 56178
diff changeset
   242
AC_DEFUN([FLAGS_SETUP_QUALITY_CHECKS],
dc0add3a3212 More cleaning up. Probably done now...
ihse
parents: 56178
diff changeset
   243
[
24911
a039e17f8896 8032045: Enable compiler and linker safety switches for debug builds
mduigou
parents: 23981
diff changeset
   244
  # bounds, memory and behavior checking options
a039e17f8896 8032045: Enable compiler and linker safety switches for debug builds
mduigou
parents: 23981
diff changeset
   245
  if test "x$TOOLCHAIN_TYPE" = xgcc; then
a039e17f8896 8032045: Enable compiler and linker safety switches for debug builds
mduigou
parents: 23981
diff changeset
   246
    case $DEBUG_LEVEL in
a039e17f8896 8032045: Enable compiler and linker safety switches for debug builds
mduigou
parents: 23981
diff changeset
   247
    release )
a039e17f8896 8032045: Enable compiler and linker safety switches for debug builds
mduigou
parents: 23981
diff changeset
   248
      # no adjustment
a039e17f8896 8032045: Enable compiler and linker safety switches for debug builds
mduigou
parents: 23981
diff changeset
   249
      ;;
a039e17f8896 8032045: Enable compiler and linker safety switches for debug builds
mduigou
parents: 23981
diff changeset
   250
    fastdebug )
26123
44827e1a7a7b 8047952: Remove FORTIFY_SOURCE from fastdebug and slowdebug builds
mduigou
parents: 25459
diff changeset
   251
      # no adjustment
24911
a039e17f8896 8032045: Enable compiler and linker safety switches for debug builds
mduigou
parents: 23981
diff changeset
   252
      ;;
a039e17f8896 8032045: Enable compiler and linker safety switches for debug builds
mduigou
parents: 23981
diff changeset
   253
    slowdebug )
37402
62b5f067032e 8152666: The new Hotspot Build System
erikj
parents: 36541
diff changeset
   254
      # FIXME: By adding this to C(XX)FLAGS_DEBUG_OPTIONS/JVM_CFLAGS_SYMBOLS it
35747
aeaa6d0101a8 8149647: Incremental enhancements from build-infra
ihse
parents: 35451
diff changeset
   255
      # get's added conditionally on whether we produce debug symbols or not.
aeaa6d0101a8 8149647: Incremental enhancements from build-infra
ihse
parents: 35451
diff changeset
   256
      # This is most likely not really correct.
aeaa6d0101a8 8149647: Incremental enhancements from build-infra
ihse
parents: 35451
diff changeset
   257
30856
09b01c98ca8d 8081692: Configure should verify that -fstack-protector is valid
ihse
parents: 30740
diff changeset
   258
      # Add runtime stack smashing and undefined behavior checks.
09b01c98ca8d 8081692: Configure should verify that -fstack-protector is valid
ihse
parents: 30740
diff changeset
   259
      # Not all versions of gcc support -fstack-protector
09b01c98ca8d 8081692: Configure should verify that -fstack-protector is valid
ihse
parents: 30740
diff changeset
   260
      STACK_PROTECTOR_CFLAG="-fstack-protector-all"
56168
cb0b10e44247 Cleaning up.
ihse
parents: 56162
diff changeset
   261
      FLAGS_COMPILER_CHECK_ARGUMENTS(ARGUMENT: [$STACK_PROTECTOR_CFLAG -Werror],
cb0b10e44247 Cleaning up.
ihse
parents: 56162
diff changeset
   262
          IF_FALSE: [STACK_PROTECTOR_CFLAG=""])
30856
09b01c98ca8d 8081692: Configure should verify that -fstack-protector is valid
ihse
parents: 30740
diff changeset
   263
09b01c98ca8d 8081692: Configure should verify that -fstack-protector is valid
ihse
parents: 30740
diff changeset
   264
      CFLAGS_DEBUG_OPTIONS="$STACK_PROTECTOR_CFLAG --param ssp-buffer-size=1"
09b01c98ca8d 8081692: Configure should verify that -fstack-protector is valid
ihse
parents: 30740
diff changeset
   265
      CXXFLAGS_DEBUG_OPTIONS="$STACK_PROTECTOR_CFLAG --param ssp-buffer-size=1"
56179
dc0add3a3212 More cleaning up. Probably done now...
ihse
parents: 56178
diff changeset
   266
dc0add3a3212 More cleaning up. Probably done now...
ihse
parents: 56178
diff changeset
   267
      if test "x$STACK_PROTECTOR_CFLAG" != x; then
dc0add3a3212 More cleaning up. Probably done now...
ihse
parents: 56178
diff changeset
   268
        JVM_CFLAGS_SYMBOLS="$JVM_CFLAGS_SYMBOLS $STACK_PROTECTOR_CFLAG --param ssp-buffer-size=1"
dc0add3a3212 More cleaning up. Probably done now...
ihse
parents: 56178
diff changeset
   269
      fi
24911
a039e17f8896 8032045: Enable compiler and linker safety switches for debug builds
mduigou
parents: 23981
diff changeset
   270
      ;;
a039e17f8896 8032045: Enable compiler and linker safety switches for debug builds
mduigou
parents: 23981
diff changeset
   271
    esac
a039e17f8896 8032045: Enable compiler and linker safety switches for debug builds
mduigou
parents: 23981
diff changeset
   272
  fi
56124
b2b9dfdc39c8 Start breaking out stuff from flags.m4.
ihse
parents: 48854
diff changeset
   273
])
24911
a039e17f8896 8032045: Enable compiler and linker safety switches for debug builds
mduigou
parents: 23981
diff changeset
   274
56124
b2b9dfdc39c8 Start breaking out stuff from flags.m4.
ihse
parents: 48854
diff changeset
   275
AC_DEFUN([FLAGS_SETUP_OPTIMIZATION],
b2b9dfdc39c8 Start breaking out stuff from flags.m4.
ihse
parents: 48854
diff changeset
   276
[
22721
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   277
  if test "x$TOOLCHAIN_TYPE" = xsolstudio; then
56162
d421dac1932f Remove duplication in debug flags.
ihse
parents: 56161
diff changeset
   278
    CC_HIGHEST="-fns -fsimple -fsingle -xbuiltin=%all -xdepend -xrestrict -xlibmil"
13133
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
   279
56162
d421dac1932f Remove duplication in debug flags.
ihse
parents: 56161
diff changeset
   280
    C_O_FLAG_HIGHEST_JVM="-xO4"
d421dac1932f Remove duplication in debug flags.
ihse
parents: 56161
diff changeset
   281
    C_O_FLAG_DEBUG_JVM=""
d421dac1932f Remove duplication in debug flags.
ihse
parents: 56161
diff changeset
   282
    C_O_FLAG_SIZE=""
d421dac1932f Remove duplication in debug flags.
ihse
parents: 56161
diff changeset
   283
    C_O_FLAG_DEBUG=""
d421dac1932f Remove duplication in debug flags.
ihse
parents: 56161
diff changeset
   284
    C_O_FLAG_NONE=""
22721
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   285
    if test "x$OPENJDK_TARGET_CPU_ARCH" = "xx86"; then
56162
d421dac1932f Remove duplication in debug flags.
ihse
parents: 56161
diff changeset
   286
      C_O_FLAG_HIGHEST="-xO4 -Wu,-O4~yz $CC_HIGHEST"
d421dac1932f Remove duplication in debug flags.
ihse
parents: 56161
diff changeset
   287
      C_O_FLAG_HI="-xO4 -Wu,-O4~yz"
d421dac1932f Remove duplication in debug flags.
ihse
parents: 56161
diff changeset
   288
      C_O_FLAG_NORM="-xO2 -Wu,-O2~yz"
22721
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   289
    elif test "x$OPENJDK_TARGET_CPU_ARCH" = "xsparc"; then
56168
cb0b10e44247 Cleaning up.
ihse
parents: 56162
diff changeset
   290
      C_O_FLAG_HIGHEST="-xO4 -Wc,-Qrm-s -Wc,-Qiselect-T0 \
cb0b10e44247 Cleaning up.
ihse
parents: 56162
diff changeset
   291
          -xprefetch=auto,explicit -xchip=ultra $CC_HIGHEST"
22721
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   292
      C_O_FLAG_HI="-xO4 -Wc,-Qrm-s -Wc,-Qiselect-T0"
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   293
      C_O_FLAG_NORM="-xO2 -Wc,-Qrm-s -Wc,-Qiselect-T0"
56162
d421dac1932f Remove duplication in debug flags.
ihse
parents: 56161
diff changeset
   294
    fi
d421dac1932f Remove duplication in debug flags.
ihse
parents: 56161
diff changeset
   295
  elif test "x$TOOLCHAIN_TYPE" = xgcc; then
d421dac1932f Remove duplication in debug flags.
ihse
parents: 56161
diff changeset
   296
    C_O_FLAG_HIGHEST_JVM="-O3"
d421dac1932f Remove duplication in debug flags.
ihse
parents: 56161
diff changeset
   297
    C_O_FLAG_HIGHEST="-O3"
d421dac1932f Remove duplication in debug flags.
ihse
parents: 56161
diff changeset
   298
    C_O_FLAG_HI="-O3"
d421dac1932f Remove duplication in debug flags.
ihse
parents: 56161
diff changeset
   299
    C_O_FLAG_NORM="-O2"
d421dac1932f Remove duplication in debug flags.
ihse
parents: 56161
diff changeset
   300
    C_O_FLAG_SIZE="-Os"
d421dac1932f Remove duplication in debug flags.
ihse
parents: 56161
diff changeset
   301
    C_O_FLAG_DEBUG="-O0"
d421dac1932f Remove duplication in debug flags.
ihse
parents: 56161
diff changeset
   302
    C_O_FLAG_DEBUG_JVM="-O0"
d421dac1932f Remove duplication in debug flags.
ihse
parents: 56161
diff changeset
   303
    C_O_FLAG_NONE="-O0"
d421dac1932f Remove duplication in debug flags.
ihse
parents: 56161
diff changeset
   304
  elif test "x$TOOLCHAIN_TYPE" = xclang; then
d421dac1932f Remove duplication in debug flags.
ihse
parents: 56161
diff changeset
   305
    if test "x$OPENJDK_TARGET_OS" = xmacosx; then
d421dac1932f Remove duplication in debug flags.
ihse
parents: 56161
diff changeset
   306
      # On MacOSX we optimize for size, something
d421dac1932f Remove duplication in debug flags.
ihse
parents: 56161
diff changeset
   307
      # we should do for all platforms?
d421dac1932f Remove duplication in debug flags.
ihse
parents: 56161
diff changeset
   308
      C_O_FLAG_HIGHEST_JVM="-Os"
d421dac1932f Remove duplication in debug flags.
ihse
parents: 56161
diff changeset
   309
      C_O_FLAG_HIGHEST="-Os"
d421dac1932f Remove duplication in debug flags.
ihse
parents: 56161
diff changeset
   310
      C_O_FLAG_HI="-Os"
d421dac1932f Remove duplication in debug flags.
ihse
parents: 56161
diff changeset
   311
      C_O_FLAG_NORM="-Os"
37402
62b5f067032e 8152666: The new Hotspot Build System
erikj
parents: 36541
diff changeset
   312
      C_O_FLAG_DEBUG_JVM=""
56162
d421dac1932f Remove duplication in debug flags.
ihse
parents: 56161
diff changeset
   313
    else
d421dac1932f Remove duplication in debug flags.
ihse
parents: 56161
diff changeset
   314
      C_O_FLAG_HIGHEST_JVM="-O3"
d421dac1932f Remove duplication in debug flags.
ihse
parents: 56161
diff changeset
   315
      C_O_FLAG_HIGHEST="-O3"
d421dac1932f Remove duplication in debug flags.
ihse
parents: 56161
diff changeset
   316
      C_O_FLAG_HI="-O3"
d421dac1932f Remove duplication in debug flags.
ihse
parents: 56161
diff changeset
   317
      C_O_FLAG_NORM="-O2"
d421dac1932f Remove duplication in debug flags.
ihse
parents: 56161
diff changeset
   318
      C_O_FLAG_DEBUG_JVM="-O0"
22721
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   319
    fi
56162
d421dac1932f Remove duplication in debug flags.
ihse
parents: 56161
diff changeset
   320
    C_O_FLAG_SIZE="-Os"
d421dac1932f Remove duplication in debug flags.
ihse
parents: 56161
diff changeset
   321
    C_O_FLAG_DEBUG="-O0"
d421dac1932f Remove duplication in debug flags.
ihse
parents: 56161
diff changeset
   322
    C_O_FLAG_NONE="-O0"
d421dac1932f Remove duplication in debug flags.
ihse
parents: 56161
diff changeset
   323
  elif test "x$TOOLCHAIN_TYPE" = xxlc; then
d421dac1932f Remove duplication in debug flags.
ihse
parents: 56161
diff changeset
   324
    C_O_FLAG_HIGHEST_JVM="-O3 -qhot=level=1 -qinline -qinlglue"
d421dac1932f Remove duplication in debug flags.
ihse
parents: 56161
diff changeset
   325
    C_O_FLAG_HIGHEST="-O3 -qhot=level=1 -qinline -qinlglue"
d421dac1932f Remove duplication in debug flags.
ihse
parents: 56161
diff changeset
   326
    C_O_FLAG_HI="-O3 -qinline -qinlglue"
d421dac1932f Remove duplication in debug flags.
ihse
parents: 56161
diff changeset
   327
    C_O_FLAG_NORM="-O2"
d421dac1932f Remove duplication in debug flags.
ihse
parents: 56161
diff changeset
   328
    C_O_FLAG_DEBUG="-qnoopt"
d421dac1932f Remove duplication in debug flags.
ihse
parents: 56161
diff changeset
   329
    # FIXME: Value below not verified.
d421dac1932f Remove duplication in debug flags.
ihse
parents: 56161
diff changeset
   330
    C_O_FLAG_DEBUG_JVM=""
d421dac1932f Remove duplication in debug flags.
ihse
parents: 56161
diff changeset
   331
    C_O_FLAG_NONE="-qnoopt"
d421dac1932f Remove duplication in debug flags.
ihse
parents: 56161
diff changeset
   332
  elif test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
d421dac1932f Remove duplication in debug flags.
ihse
parents: 56161
diff changeset
   333
    C_O_FLAG_HIGHEST_JVM="-O2 -Oy-"
d421dac1932f Remove duplication in debug flags.
ihse
parents: 56161
diff changeset
   334
    C_O_FLAG_HIGHEST="-O2"
d421dac1932f Remove duplication in debug flags.
ihse
parents: 56161
diff changeset
   335
    C_O_FLAG_HI="-O1"
d421dac1932f Remove duplication in debug flags.
ihse
parents: 56161
diff changeset
   336
    C_O_FLAG_NORM="-O1"
d421dac1932f Remove duplication in debug flags.
ihse
parents: 56161
diff changeset
   337
    C_O_FLAG_DEBUG="-Od"
d421dac1932f Remove duplication in debug flags.
ihse
parents: 56161
diff changeset
   338
    C_O_FLAG_DEBUG_JVM=""
d421dac1932f Remove duplication in debug flags.
ihse
parents: 56161
diff changeset
   339
    C_O_FLAG_NONE="-Od"
d421dac1932f Remove duplication in debug flags.
ihse
parents: 56161
diff changeset
   340
    C_O_FLAG_SIZE="-Os"
d421dac1932f Remove duplication in debug flags.
ihse
parents: 56161
diff changeset
   341
  fi
d421dac1932f Remove duplication in debug flags.
ihse
parents: 56161
diff changeset
   342
d421dac1932f Remove duplication in debug flags.
ihse
parents: 56161
diff changeset
   343
  # Now copy to C++ flags
d421dac1932f Remove duplication in debug flags.
ihse
parents: 56161
diff changeset
   344
  CXX_O_FLAG_HIGHEST_JVM="$C_O_FLAG_HIGHEST_JVM"
d421dac1932f Remove duplication in debug flags.
ihse
parents: 56161
diff changeset
   345
  CXX_O_FLAG_HIGHEST="$C_O_FLAG_HIGHEST"
d421dac1932f Remove duplication in debug flags.
ihse
parents: 56161
diff changeset
   346
  CXX_O_FLAG_HI="$C_O_FLAG_HI"
d421dac1932f Remove duplication in debug flags.
ihse
parents: 56161
diff changeset
   347
  CXX_O_FLAG_NORM="$C_O_FLAG_NORM"
d421dac1932f Remove duplication in debug flags.
ihse
parents: 56161
diff changeset
   348
  CXX_O_FLAG_DEBUG="$C_O_FLAG_DEBUG"
d421dac1932f Remove duplication in debug flags.
ihse
parents: 56161
diff changeset
   349
  CXX_O_FLAG_DEBUG_JVM="$C_O_FLAG_DEBUG_JVM"
d421dac1932f Remove duplication in debug flags.
ihse
parents: 56161
diff changeset
   350
  CXX_O_FLAG_NONE="$C_O_FLAG_NONE"
d421dac1932f Remove duplication in debug flags.
ihse
parents: 56161
diff changeset
   351
  CXX_O_FLAG_SIZE="$C_O_FLAG_SIZE"
d421dac1932f Remove duplication in debug flags.
ihse
parents: 56161
diff changeset
   352
d421dac1932f Remove duplication in debug flags.
ihse
parents: 56161
diff changeset
   353
  if test "x$TOOLCHAIN_TYPE" = xsolstudio; then
d421dac1932f Remove duplication in debug flags.
ihse
parents: 56161
diff changeset
   354
    # In solstudio, also add this to C (but not C++) flags...
d421dac1932f Remove duplication in debug flags.
ihse
parents: 56161
diff changeset
   355
    C_O_FLAG_HIGHEST="$C_O_FLAG_HIGHEST -xalias_level=basic"
20363
fa7663fc5d50 8001931: The new build system whitespace cleanup
ihse
parents: 20362
diff changeset
   356
  fi
13133
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
   357
24911
a039e17f8896 8032045: Enable compiler and linker safety switches for debug builds
mduigou
parents: 23981
diff changeset
   358
  # Adjust optimization flags according to debug level.
a039e17f8896 8032045: Enable compiler and linker safety switches for debug builds
mduigou
parents: 23981
diff changeset
   359
  case $DEBUG_LEVEL in
a039e17f8896 8032045: Enable compiler and linker safety switches for debug builds
mduigou
parents: 23981
diff changeset
   360
    release )
a039e17f8896 8032045: Enable compiler and linker safety switches for debug builds
mduigou
parents: 23981
diff changeset
   361
      # no adjustment
a039e17f8896 8032045: Enable compiler and linker safety switches for debug builds
mduigou
parents: 23981
diff changeset
   362
      ;;
a039e17f8896 8032045: Enable compiler and linker safety switches for debug builds
mduigou
parents: 23981
diff changeset
   363
    fastdebug )
a039e17f8896 8032045: Enable compiler and linker safety switches for debug builds
mduigou
parents: 23981
diff changeset
   364
      # Not quite so much optimization
a039e17f8896 8032045: Enable compiler and linker safety switches for debug builds
mduigou
parents: 23981
diff changeset
   365
      C_O_FLAG_HI="$C_O_FLAG_NORM"
a039e17f8896 8032045: Enable compiler and linker safety switches for debug builds
mduigou
parents: 23981
diff changeset
   366
      CXX_O_FLAG_HI="$CXX_O_FLAG_NORM"
a039e17f8896 8032045: Enable compiler and linker safety switches for debug builds
mduigou
parents: 23981
diff changeset
   367
      ;;
a039e17f8896 8032045: Enable compiler and linker safety switches for debug builds
mduigou
parents: 23981
diff changeset
   368
    slowdebug )
a039e17f8896 8032045: Enable compiler and linker safety switches for debug builds
mduigou
parents: 23981
diff changeset
   369
      # Disable optimization
37402
62b5f067032e 8152666: The new Hotspot Build System
erikj
parents: 36541
diff changeset
   370
      C_O_FLAG_HIGHEST_JVM="$C_O_FLAG_DEBUG_JVM"
24911
a039e17f8896 8032045: Enable compiler and linker safety switches for debug builds
mduigou
parents: 23981
diff changeset
   371
      C_O_FLAG_HIGHEST="$C_O_FLAG_DEBUG"
a039e17f8896 8032045: Enable compiler and linker safety switches for debug builds
mduigou
parents: 23981
diff changeset
   372
      C_O_FLAG_HI="$C_O_FLAG_DEBUG"
a039e17f8896 8032045: Enable compiler and linker safety switches for debug builds
mduigou
parents: 23981
diff changeset
   373
      C_O_FLAG_NORM="$C_O_FLAG_DEBUG"
37402
62b5f067032e 8152666: The new Hotspot Build System
erikj
parents: 36541
diff changeset
   374
      C_O_FLAG_SIZE="$C_O_FLAG_DEBUG"
62b5f067032e 8152666: The new Hotspot Build System
erikj
parents: 36541
diff changeset
   375
      CXX_O_FLAG_HIGHEST_JVM="$CXX_O_FLAG_DEBUG_JVM"
24911
a039e17f8896 8032045: Enable compiler and linker safety switches for debug builds
mduigou
parents: 23981
diff changeset
   376
      CXX_O_FLAG_HIGHEST="$CXX_O_FLAG_DEBUG"
a039e17f8896 8032045: Enable compiler and linker safety switches for debug builds
mduigou
parents: 23981
diff changeset
   377
      CXX_O_FLAG_HI="$CXX_O_FLAG_DEBUG"
a039e17f8896 8032045: Enable compiler and linker safety switches for debug builds
mduigou
parents: 23981
diff changeset
   378
      CXX_O_FLAG_NORM="$CXX_O_FLAG_DEBUG"
37402
62b5f067032e 8152666: The new Hotspot Build System
erikj
parents: 36541
diff changeset
   379
      CXX_O_FLAG_SIZE="$CXX_O_FLAG_DEBUG"
24911
a039e17f8896 8032045: Enable compiler and linker safety switches for debug builds
mduigou
parents: 23981
diff changeset
   380
      ;;
a039e17f8896 8032045: Enable compiler and linker safety switches for debug builds
mduigou
parents: 23981
diff changeset
   381
  esac
a039e17f8896 8032045: Enable compiler and linker safety switches for debug builds
mduigou
parents: 23981
diff changeset
   382
37402
62b5f067032e 8152666: The new Hotspot Build System
erikj
parents: 36541
diff changeset
   383
  AC_SUBST(C_O_FLAG_HIGHEST_JVM)
20363
fa7663fc5d50 8001931: The new build system whitespace cleanup
ihse
parents: 20362
diff changeset
   384
  AC_SUBST(C_O_FLAG_HIGHEST)
fa7663fc5d50 8001931: The new build system whitespace cleanup
ihse
parents: 20362
diff changeset
   385
  AC_SUBST(C_O_FLAG_HI)
fa7663fc5d50 8001931: The new build system whitespace cleanup
ihse
parents: 20362
diff changeset
   386
  AC_SUBST(C_O_FLAG_NORM)
fa7663fc5d50 8001931: The new build system whitespace cleanup
ihse
parents: 20362
diff changeset
   387
  AC_SUBST(C_O_FLAG_NONE)
37402
62b5f067032e 8152666: The new Hotspot Build System
erikj
parents: 36541
diff changeset
   388
  AC_SUBST(C_O_FLAG_SIZE)
62b5f067032e 8152666: The new Hotspot Build System
erikj
parents: 36541
diff changeset
   389
  AC_SUBST(CXX_O_FLAG_HIGHEST_JVM)
20363
fa7663fc5d50 8001931: The new build system whitespace cleanup
ihse
parents: 20362
diff changeset
   390
  AC_SUBST(CXX_O_FLAG_HIGHEST)
fa7663fc5d50 8001931: The new build system whitespace cleanup
ihse
parents: 20362
diff changeset
   391
  AC_SUBST(CXX_O_FLAG_HI)
fa7663fc5d50 8001931: The new build system whitespace cleanup
ihse
parents: 20362
diff changeset
   392
  AC_SUBST(CXX_O_FLAG_NORM)
fa7663fc5d50 8001931: The new build system whitespace cleanup
ihse
parents: 20362
diff changeset
   393
  AC_SUBST(CXX_O_FLAG_NONE)
37402
62b5f067032e 8152666: The new Hotspot Build System
erikj
parents: 36541
diff changeset
   394
  AC_SUBST(CXX_O_FLAG_SIZE)
13133
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
   395
])
56178
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   396
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   397
AC_DEFUN([FLAGS_SETUP_CFLAGS],
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   398
[
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   399
  ### CFLAGS
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   400
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   401
  FLAGS_SETUP_CFLAGS_HELPER
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   402
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   403
  FLAGS_OS=$OPENJDK_TARGET_OS
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   404
  FLAGS_OS_TYPE=$OPENJDK_TARGET_OS_TYPE
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   405
  FLAGS_CPU=$OPENJDK_TARGET_CPU
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   406
  FLAGS_CPU_ARCH=$OPENJDK_TARGET_CPU_ARCH
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   407
  FLAGS_CPU_BITS=$OPENJDK_TARGET_CPU_BITS
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   408
  FLAGS_CPU_ENDIAN=$OPENJDK_TARGET_CPU_ENDIAN
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   409
  FLAGS_CPU_LEGACY=$OPENJDK_TARGET_CPU_LEGACY
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   410
  FLAGS_CPU_LEGACY_LIB=$OPENJDK_TARGET_CPU_LEGACY_LIB
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   411
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   412
  FLAGS_SETUP_CFLAGS_CPU_DEP([TARGET])
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   413
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   414
  FLAGS_OS=$OPENJDK_BUILD_OS
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   415
  FLAGS_OS_TYPE=$OPENJDK_BUILD_OS_TYPE
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   416
  FLAGS_CPU=$OPENJDK_BUILD_CPU
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   417
  FLAGS_CPU_ARCH=$OPENJDK_BUILD_CPU_ARCH
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   418
  FLAGS_CPU_BITS=$OPENJDK_BUILD_CPU_BITS
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   419
  FLAGS_CPU_ENDIAN=$OPENJDK_BUILD_CPU_ENDIAN
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   420
  FLAGS_CPU_LEGACY=$OPENJDK_BUILD_CPU_LEGACY
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   421
  FLAGS_CPU_LEGACY_LIB=$OPENJDK_BUILD_CPU_LEGACY_LIB
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   422
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   423
  FLAGS_SETUP_CFLAGS_CPU_DEP([BUILD], [OPENJDK_BUILD_])
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   424
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   425
  # Tests are only ever compiled for TARGET
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   426
  CFLAGS_TESTLIB="$CFLAGS_JDKLIB"
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   427
  CXXFLAGS_TESTLIB="$CXXFLAGS_JDKLIB"
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   428
  CFLAGS_TESTEXE="$CFLAGS_JDKEXE"
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   429
  CXXFLAGS_TESTEXE="$CXXFLAGS_JDKEXE"
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   430
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   431
  AC_SUBST(CFLAGS_TESTLIB)
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   432
  AC_SUBST(CFLAGS_TESTEXE)
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   433
  AC_SUBST(CXXFLAGS_TESTLIB)
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   434
  AC_SUBST(CXXFLAGS_TESTEXE)
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   435
])
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   436
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   437
################################################################################
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   438
# platform independent
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   439
AC_DEFUN([FLAGS_SETUP_CFLAGS_HELPER],
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   440
[
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   441
  #### OS DEFINES, these should be independent on toolchain
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   442
  if test "x$OPENJDK_TARGET_OS" = xlinux; then
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   443
    CFLAGS_OS_DEF_JVM="-DLINUX"
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   444
    CFLAGS_OS_DEF_JDK="-D_GNU_SOURCE -D_REENTRANT -D_LARGEFILE64_SOURCE"
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   445
  elif test "x$OPENJDK_TARGET_OS" = xsolaris; then
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   446
    CFLAGS_OS_DEF_JVM="-DSOLARIS"
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   447
    CFLAGS_OS_DEF_JDK="-D__solaris__"
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   448
  elif test "x$OPENJDK_TARGET_OS" = xmacosx; then
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   449
    CFLAGS_OS_DEF_JVM="-D_ALLBSD_SOURCE -D_DARWIN_C_SOURCE -D_XOPEN_SOURCE"
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   450
    CFLAGS_OS_DEF_JDK="-D_ALLBSD_SOURCE -D_DARWIN_UNLIMITED_SELECT"
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   451
  elif test "x$OPENJDK_TARGET_OS" = xaix; then
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   452
    CFLAGS_OS_DEF_JVM="-DAIX"
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   453
  elif test "x$OPENJDK_TARGET_OS" = xbsd; then
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   454
    CFLAGS_OS_DEF_JDK="-D_ALLBSD_SOURCE"
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   455
  elif test "x$OPENJDK_TARGET_OS" = xwindows; then
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   456
    CFLAGS_OS_DEF_JVM="-D_WINDOWS -DWIN32 -D_JNI_IMPLEMENTATION_"
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   457
  fi
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   458
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   459
  # Setup target OS define. Use OS target name but in upper case.
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   460
  OPENJDK_TARGET_OS_UPPERCASE=`$ECHO $OPENJDK_TARGET_OS | $TR 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   461
  CFLAGS_OS_DEF_JDK="$CFLAGS_OS_DEF_JDK -D$OPENJDK_TARGET_OS_UPPERCASE"
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   462
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   463
  #### GLOBAL DEFINES
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   464
  # Set some common defines. These works for all compilers, but assume
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   465
  # -D is universally accepted.
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   466
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   467
  # Always enable optional macros for VM.
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   468
  ALWAYS_CFLAGS_JVM="-D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS"
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   469
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   470
  # Setup some hard coded includes
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   471
  ALWAYS_CFLAGS_JDK=" \
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   472
      -I\$(SUPPORT_OUTPUTDIR)/modules_include/java.base \
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   473
      -I\$(SUPPORT_OUTPUTDIR)/modules_include/java.base/\$(OPENJDK_TARGET_OS_INCLUDE_SUBDIR) \
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   474
      -I${TOPDIR}/src/java.base/share/native/libjava \
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   475
      -I${TOPDIR}/src/java.base/$OPENJDK_TARGET_OS_TYPE/native/libjava \
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   476
      -I${TOPDIR}/src/hotspot/share/include \
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   477
      -I${TOPDIR}/src/hotspot/os/${HOTSPOT_TARGET_OS_TYPE}/include"
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   478
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   479
  ###############################################################################
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   480
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   481
  # Adjust flags according to debug level.
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   482
  # Setup debug/release defines
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   483
  if test "x$DEBUG_LEVEL" = xrelease; then
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   484
    DEBUG_CFLAGS_JDK="-DNDEBUG"
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   485
    if test "x$OPENJDK_TARGET_OS" = xsolaris; then
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   486
      DEBUG_CFLAGS_JDK="$DEBUG_CFLAGS_JDK -DTRIMMED"
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   487
    fi
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   488
  else
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   489
    DEBUG_CFLAGS_JDK="-DDEBUG"
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   490
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   491
    if test "x$TOOLCHAIN_TYPE" = xxlc; then
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   492
      # We need '-qminimaltoc' or '-qpic=large -bbigtoc' if the TOC overflows.
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   493
      # Hotspot now overflows its 64K TOC (currently only for debug),
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   494
      # so for debug we build with '-qpic=large -bbigtoc'.
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   495
      DEBUG_CFLAGS_JVM="-qpic=large"
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   496
    fi
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   497
  fi
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   498
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   499
  if test "x$DEBUG_LEVEL" != xrelease; then
56193
9aa8244e6b5d Fix -g0 for C++ on solstudio.
ihse
parents: 56190
diff changeset
   500
    DEBUG_OPTIONS_FLAGS_JDK="$CFLAGS_DEBUG_OPTIONS"
9aa8244e6b5d Fix -g0 for C++ on solstudio.
ihse
parents: 56190
diff changeset
   501
    DEBUG_SYMBOLS_CFLAGS_JDK="$CFLAGS_DEBUG_SYMBOLS"
9aa8244e6b5d Fix -g0 for C++ on solstudio.
ihse
parents: 56190
diff changeset
   502
    DEBUG_SYMBOLS_CXXFLAGS_JDK="$CXXFLAGS_DEBUG_SYMBOLS"
56178
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   503
  fi
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   504
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   505
  #### TOOLCHAIN DEFINES
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   506
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   507
  if test "x$TOOLCHAIN_TYPE" = xgcc; then
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   508
    ALWAYS_DEFINES_JVM="-D_GNU_SOURCE -D_REENTRANT"
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   509
  elif test "x$TOOLCHAIN_TYPE" = xclang; then
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   510
    ALWAYS_DEFINES_JVM="-D_GNU_SOURCE"
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   511
  elif test "x$TOOLCHAIN_TYPE" = xsolstudio; then
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   512
    ALWAYS_DEFINES_JVM="-DSPARC_WORKS -D_Crun_inline_placement"
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   513
    ALWAYS_DEFINES_JDK="-DTRACING -DMACRO_MEMSYS_OPS -DBREAKPTS"
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   514
    ALWAYS_DEFINES_JDK_CXXONLY="-DCC_NOEX"
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   515
  elif test "x$TOOLCHAIN_TYPE" = xxlc; then
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   516
    ALWAYS_DEFINES_JVM="-D_REENTRANT"
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   517
    ALWAYS_DEFINES_JDK="-D_GNU_SOURCE -D_REENTRANT -D_LARGEFILE64_SOURCE -DSTDC"
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   518
  elif test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   519
    ALWAYS_DEFINES_JDK="-DWIN32_LEAN_AND_MEAN -D_CRT_SECURE_NO_DEPRECATE \
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   520
        -D_CRT_NONSTDC_NO_DEPRECATE -DWIN32 -DIAL"
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   521
  fi
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   522
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   523
  ###############################################################################
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   524
  #
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   525
  #
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   526
  # CFLAGS BASIC
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   527
  if test "x$TOOLCHAIN_TYPE" = xgcc || test "x$TOOLCHAIN_TYPE" = xclang; then
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   528
    # COMMON to gcc and clang
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   529
    TOOLCHAIN_CFLAGS_JVM="-pipe -fno-rtti -fno-exceptions \
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   530
        -fvisibility=hidden -fno-strict-aliasing -fno-omit-frame-pointer"
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   531
  fi
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   532
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   533
  if test "x$TOOLCHAIN_TYPE" = xgcc; then
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   534
    TOOLCHAIN_CFLAGS_JVM="$TOOLCHAIN_CFLAGS_JVM -fcheck-new"
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   535
    TOOLCHAIN_CFLAGS_JDK="-pipe"
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   536
    TOOLCHAIN_CFLAGS_JDK_CONLY="-fno-strict-aliasing" # technically NOT for CXX (but since this gives *worse* performance, use no-strict-aliasing everywhere!)
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   537
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   538
    CXXSTD_CXXFLAG="-std=gnu++98"
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   539
    FLAGS_CXX_COMPILER_CHECK_ARGUMENTS(ARGUMENT: [$CXXSTD_CXXFLAG -Werror],
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   540
    						 IF_FALSE: [CXXSTD_CXXFLAG=""])
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   541
    TOOLCHAIN_CFLAGS_JDK_CXXONLY="$CXXSTD_CXXFLAG"
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   542
    TOOLCHAIN_CFLAGS_JVM="$TOOLCHAIN_CFLAGS_JVM $CXXSTD_CXXFLAG"
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   543
    ADLC_CXXFLAG="$CXXSTD_CXXFLAG"
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   544
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   545
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   546
  elif test "x$TOOLCHAIN_TYPE" = xclang; then
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   547
    # Restrict the debug information created by Clang to avoid
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   548
    # too big object files and speed the build up a little bit
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   549
    # (see http://llvm.org/bugs/show_bug.cgi?id=7554)
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   550
    TOOLCHAIN_CFLAGS_JVM="$TOOLCHAIN_CFLAGS_JVM -flimit-debug-info"
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   551
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   552
    if test "x$OPENJDK_TARGET_OS" = xlinux; then
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   553
      TOOLCHAIN_CFLAGS_JDK="-pipe"
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   554
      TOOLCHAIN_CFLAGS_JDK_CONLY="-fno-strict-aliasing" # technically NOT for CXX
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   555
    fi
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   556
  elif test "x$TOOLCHAIN_TYPE" = xsolstudio; then
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   557
    TOOLCHAIN_CFLAGS_JDK="-mt"
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   558
    TOOLCHAIN_CFLAGS_JDK_CONLY="-xc99=%none -xCC -Xa -v -W0,-noglobal" # C only
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   559
    TOOLCHAIN_CFLAGS_JDK_CXXONLY="-features=no%except -norunpath -xnolib" # CXX only
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   560
    TOOLCHAIN_CFLAGS_JVM="-template=no%extdef -features=no%split_init \
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   561
        -library=stlport4 -mt -features=no%except"
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   562
  elif test "x$TOOLCHAIN_TYPE" = xxlc; then
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   563
    TOOLCHAIN_CFLAGS_JDK="-qchars=signed -qfullpath -qsaveopt"  # add on both CFLAGS
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   564
    TOOLCHAIN_CFLAGS_JVM="-qtune=balanced \
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   565
        -qalias=noansi -qstrict -qtls=default -qlanglvl=c99vla \
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   566
        -qlanglvl=noredefmac -qnortti -qnoeh -qignerrno"
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   567
  elif test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   568
    TOOLCHAIN_CFLAGS_JVM="-nologo -MD -MP"
56189
4fde3036c652 Windows fixes.
ihse
parents: 56188
diff changeset
   569
    TOOLCHAIN_CFLAGS_JDK="-nologo -MD -Zc:wchar_t-"
56178
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   570
  fi
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   571
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   572
  # CFLAGS WARNINGS STUFF
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   573
  # Set JVM_CFLAGS warning handling
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   574
  if test "x$TOOLCHAIN_TYPE" = xgcc || test "x$TOOLCHAIN_TYPE" = xclang; then
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   575
    # COMMON to gcc and clang
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   576
    WARNING_CFLAGS_JVM="-Wpointer-arith -Wsign-compare -Wunused-function"
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   577
    if ! HOTSPOT_CHECK_JVM_VARIANT(zero); then
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   578
      # Non-zero builds have stricter warnings
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   579
      WARNING_CFLAGS_JVM="$WARNING_CFLAGS_JVM -Wundef -Wformat=2"
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   580
    fi
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   581
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   582
  fi
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   583
  if test "x$TOOLCHAIN_TYPE" = xgcc; then
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   584
    WARNING_CFLAGS_JDK="-Wall -Wextra -Wno-unused -Wno-unused-parameter -Wformat=2"
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   585
    WARNING_CFLAGS_JVM="$WARNING_CFLAGS_JVM -Wunused-value -Woverloaded-virtual"
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   586
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   587
    if ! HOTSPOT_CHECK_JVM_VARIANT(zero); then
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   588
      # Non-zero builds have stricter warnings
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   589
      WARNING_CFLAGS_JVM="$WARNING_CFLAGS_JVM -Wreturn-type"
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   590
    fi
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   591
  elif test "x$TOOLCHAIN_TYPE" = xclang; then
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   592
    WARNING_CFLAGS_JVM="$WARNING_CFLAGS_JVM -Wno-deprecated"
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   593
    if test "x$OPENJDK_TARGET_OS" = xlinux; then
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   594
      WARNING_CFLAGS_JVM="$WARNING_CFLAGS_JVM -Wno-sometimes-uninitialized"
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   595
      WARNING_CFLAGS_JDK="-Wall -Wextra -Wno-unused -Wno-unused-parameter -Wformat=2"
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   596
    fi
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   597
  elif test "x$TOOLCHAIN_TYPE" = xsolstudio; then
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   598
    WARNING_CFLAGS_JDK_CONLY="-errshort=tags"
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   599
    WARNING_CFLAGS_JDK_CXXONLY="+w"
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   600
    WARNING_CFLAGS_JDK="-errtags=yes -errfmt"
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   601
  elif test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   602
    WARNING_CFLAGS="-W3"
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   603
    WARNING_CFLAGS_JDK="-wd4800"
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   604
  fi
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   605
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   606
  # Set some additional per-OS defines.
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   607
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   608
  # Additional macosx handling
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   609
  if test "x$OPENJDK_TARGET_OS" = xmacosx; then
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   610
    OS_CFLAGS="-DMAC_OS_X_VERSION_MIN_REQUIRED=$MACOSX_VERSION_MIN_NODOTS \
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   611
        -mmacosx-version-min=$MACOSX_VERSION_MIN"
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   612
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   613
    if test -n "$MACOSX_VERSION_MAX"; then
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   614
        OS_CFLAGS="$OS_CFLAGS \
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   615
            -DMAC_OS_X_VERSION_MAX_ALLOWED=$MACOSX_VERSION_MAX_NODOTS"
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   616
    fi
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   617
  fi
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   618
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   619
  # Where does this really belong??
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   620
  if test "x$TOOLCHAIN_TYPE" = xgcc || test "x$TOOLCHAIN_TYPE" = xclang; then
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   621
    PICFLAG="-fPIC"
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   622
  elif test "x$TOOLCHAIN_TYPE" = xsolstudio; then
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   623
    PICFLAG="-KPIC"
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   624
  elif test "x$TOOLCHAIN_TYPE" = xxlc; then
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   625
    # '-qpic' defaults to 'qpic=small'. This means that the compiler generates only
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   626
    # one instruction for accessing the TOC. If the TOC grows larger than 64K, the linker
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   627
    # will have to patch this single instruction with a call to some out-of-order code which
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   628
    # does the load from the TOC. This is of course slow. But in that case we also would have
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   629
    # to use '-bbigtoc' for linking anyway so we could also change the PICFLAG to 'qpic=large'.
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   630
    # With 'qpic=large' the compiler will by default generate a two-instruction sequence which
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   631
    # can be patched directly by the linker and does not require a jump to out-of-order code.
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   632
    # Another alternative instead of using 'qpic=large -bbigtoc' may be to use '-qminimaltoc'
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   633
    # instead. This creates a distinct TOC for every compilation unit (and thus requires two
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   634
    # loads for accessing a global variable). But there are rumors that this may be seen as a
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   635
    # 'performance feature' because of improved code locality of the symbols used in a
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   636
    # compilation unit.
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   637
    PICFLAG="-qpic"
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   638
  elif test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   639
    PICFLAG=""
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   640
  fi
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   641
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   642
  JVM_PICFLAG="$PICFLAG"
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   643
  JDK_PICFLAG="$PICFLAG"
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   644
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   645
  if test "x$OPENJDK_TARGET_OS" = xmacosx; then
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   646
    # Linking is different on MacOSX
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   647
    JDK_PICFLAG=''
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   648
    if test "x$STATIC_BUILD" = xtrue; then
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   649
      JVM_PICFLAG=""
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   650
    fi
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   651
  fi
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   652
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   653
  if test "x$OPENJDK_TARGET_OS" = xmacosx; then
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   654
    OS_CFLAGS_JVM="$OS_CFLAGS_JVM -mno-omit-leaf-frame-pointer -mstack-alignment=16"
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   655
  fi
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   656
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   657
  # Optional POSIX functionality needed by the JVM
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   658
  #
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   659
  # Check if clock_gettime is available and in which library. This indicates
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   660
  # availability of CLOCK_MONOTONIC for hotspot. But we don't need to link, so
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   661
  # don't let it update LIBS.
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   662
  save_LIBS="$LIBS"
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   663
  AC_SEARCH_LIBS(clock_gettime, rt, [HAS_CLOCK_GETTIME=true], [])
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   664
  if test "x$LIBS" = "x-lrt "; then
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   665
    CLOCK_GETTIME_IN_LIBRT=true
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   666
  fi
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   667
  LIBS="$save_LIBS"
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   668
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   669
  if test "x$HAS_CLOCK_GETTIME" = "xtrue"; then
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   670
    OS_CFLAGS_JVM="$OS_CFLAGS_JVM -DSUPPORTS_CLOCK_MONOTONIC"
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   671
    if test "x$CLOCK_GETTIME_IN_LIBRT" = "xtrue"; then
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   672
      OS_CFLAGS_JVM="$OS_CFLAGS_JVM -DNEEDS_LIBRT"
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   673
    fi
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   674
  fi
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   675
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   676
  # EXPORT
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   677
  AC_SUBST(ADLC_CXXFLAG)
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   678
])
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   679
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   680
################################################################################
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   681
# $1 - Either BUILD or TARGET to pick the correct OS/CPU variables to check
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   682
#      conditionals against.
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   683
# $2 - Optional prefix for each variable defined.
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   684
AC_DEFUN([FLAGS_SETUP_CFLAGS_CPU_DEP],
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   685
[
56188
321c18a6b256 Only use special ENDIAN define on solstudio.
ihse
parents: 56179
diff changeset
   686
  #### CPU DEFINES, these should (in theory) be independent on toolchain
56178
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   687
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   688
  # Setup target CPU
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   689
  # Setup endianness
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   690
  if test "x$FLAGS_CPU_ENDIAN" = xlittle; then
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   691
    $1_DEFINES_CPU_JVM="-DVM_LITTLE_ENDIAN"
56188
321c18a6b256 Only use special ENDIAN define on solstudio.
ihse
parents: 56179
diff changeset
   692
  fi
321c18a6b256 Only use special ENDIAN define on solstudio.
ihse
parents: 56179
diff changeset
   693
  if test "x$TOOLCHAIN_TYPE" = xsolstudio; then
321c18a6b256 Only use special ENDIAN define on solstudio.
ihse
parents: 56179
diff changeset
   694
    # The macro _LITTLE_ENDIAN needs to be defined the same to avoid the
321c18a6b256 Only use special ENDIAN define on solstudio.
ihse
parents: 56179
diff changeset
   695
    #   Sun C compiler warning message: warning: macro redefined: _LITTLE_ENDIAN
321c18a6b256 Only use special ENDIAN define on solstudio.
ihse
parents: 56179
diff changeset
   696
    if test "x$FLAGS_CPU_ENDIAN" = xlittle; then
321c18a6b256 Only use special ENDIAN define on solstudio.
ihse
parents: 56179
diff changeset
   697
      $1_DEFINES_CPU_JDK="-D_LITTLE_ENDIAN="
321c18a6b256 Only use special ENDIAN define on solstudio.
ihse
parents: 56179
diff changeset
   698
    else
321c18a6b256 Only use special ENDIAN define on solstudio.
ihse
parents: 56179
diff changeset
   699
      $1_DEFINES_CPU_JDK="-D_BIG_ENDIAN="
321c18a6b256 Only use special ENDIAN define on solstudio.
ihse
parents: 56179
diff changeset
   700
    fi
56178
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   701
  else
56188
321c18a6b256 Only use special ENDIAN define on solstudio.
ihse
parents: 56179
diff changeset
   702
    if test "x$FLAGS_CPU_ENDIAN" = xlittle; then
321c18a6b256 Only use special ENDIAN define on solstudio.
ihse
parents: 56179
diff changeset
   703
      $1_DEFINES_CPU_JDK="-D_LITTLE_ENDIAN"
321c18a6b256 Only use special ENDIAN define on solstudio.
ihse
parents: 56179
diff changeset
   704
    else
321c18a6b256 Only use special ENDIAN define on solstudio.
ihse
parents: 56179
diff changeset
   705
      $1_DEFINES_CPU_JDK="-D_BIG_ENDIAN"
321c18a6b256 Only use special ENDIAN define on solstudio.
ihse
parents: 56179
diff changeset
   706
    fi
56178
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   707
  fi
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   708
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   709
  # setup CPU bit size
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   710
  $1_DEFINES_CPU_JDK="${$1_DEFINES_CPU_JDK} -DARCH='\"$FLAGS_CPU_LEGACY\"' \
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   711
      -D$FLAGS_CPU_LEGACY"
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   712
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   713
  if test "x$FLAGS_CPU_BITS" = x64; then
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   714
    # -D_LP64=1 is only set on linux and mac. Setting on windows causes diff in
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   715
    # unpack200.exe.
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   716
    if test "x$FLAGS_OS" = xlinux || test "x$FLAGS_OS" = xmacosx; then
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   717
      $1_DEFINES_CPU_JDK="${$1_DEFINES_CPU_JDK} -D_LP64=1"
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   718
    fi
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   719
    if test "x$FLAGS_OS" != xsolaris && test "x$FLAGS_OS" != xaix; then
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   720
      # Solaris does not have _LP64=1 in the old build.
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   721
      # xlc on AIX defines _LP64=1 by default and issues a warning if we redefine it.
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   722
      $1_DEFINES_CPU_JVM="${$1_DEFINES_CPU_JVM} -D_LP64=1"
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   723
    fi
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   724
  fi
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   725
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   726
  # toolchain dependend, per-cpu
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   727
  if test "x$TOOLCHAIN_TYPE" = xsolstudio; then
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   728
    if test "x$FLAGS_CPU_ARCH" = xx86; then
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   729
      $1_DEFINES_CPU_JDK="${$1_DEFINES_CPU_JDK} -DcpuIntel -Di586 -D$FLAGS_CPU_LEGACY_LIB"
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   730
    fi
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   731
  elif test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   732
    if test "x$FLAGS_CPU" = xx86_64; then
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   733
      $1_DEFINES_CPU_JDK="${$1_DEFINES_CPU_JDK} -D_AMD64_ -Damd64"
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   734
    else
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   735
      $1_DEFINES_CPU_JDK="${$1_DEFINES_CPU_JDK} -D_X86_ -Dx86"
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   736
    fi
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   737
  fi
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   738
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   739
  # CFLAGS PER CPU
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   740
  if test "x$TOOLCHAIN_TYPE" = xgcc || test "x$TOOLCHAIN_TYPE" = xclang; then
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   741
    # COMMON to gcc and clang
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   742
    if test "x$FLAGS_CPU" = xx86; then
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   743
      # Force compatibility with i586 on 32 bit intel platforms.
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   744
      $1_CFLAGS_CPU="-march=i586"
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   745
    fi
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   746
  fi
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   747
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   748
  if test "x$TOOLCHAIN_TYPE" = xgcc; then
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   749
    if test "x$FLAGS_CPU" = xarm; then
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   750
      # -Wno-psabi to get rid of annoying "note: the mangling of 'va_list' has changed in GCC 4.4"
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   751
      $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)\"'"
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   752
      $1_CFLAGS_CPU_JVM="-DARM"
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   753
    elif test "x$FLAGS_CPU" = xaarch64; then
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   754
      if test "x$HOTSPOT_TARGET_CPU_PORT" = xarm64; then
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   755
        $1_CFLAGS_CPU_JVM="-fsigned-char -DARM"
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   756
      fi
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   757
    elif test "x$FLAGS_CPU_ARCH" = xppc; then
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   758
      $1_CFLAGS_CPU_JVM="-minsert-sched-nops=regroup_exact -mno-multiple -mno-string"
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   759
      if test "x$FLAGS_CPU" = xppc64; then
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   760
        # -mminimal-toc fixes `relocation truncated to fit' error for gcc 4.1.
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   761
        # Use ppc64 instructions, but schedule for power5
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   762
        $1_CFLAGS_CPU_JVM="${$1_CFLAGS_CPU_JVM} -mminimal-toc -mcpu=powerpc64 -mtune=power5"
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   763
      elif test "x$FLAGS_CPU" = xppc64le; then
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   764
        # Little endian machine uses ELFv2 ABI.
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   765
        # Use Power8, this is the first CPU to support PPC64 LE with ELFv2 ABI.
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   766
        $1_CFLAGS_CPU_JVM="${$1_CFLAGS_CPU_JVM} -DABI_ELFv2 -mcpu=power8 -mtune=power8"
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   767
      fi
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   768
    elif test "x$FLAGS_CPU" = xs390x; then
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   769
      $1_CFLAGS_CPU="-mbackchain -march=z10"
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   770
    fi
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   771
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   772
    if test "x$FLAGS_CPU_ARCH" != xarm &&  test "x$FLAGS_CPU_ARCH" != xppc; then
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   773
      # for all archs except arm and ppc, prevent gcc to omit frame pointer
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   774
      $1_CFLAGS_CPU_JDK="${$1_CFLAGS_CPU_JDK} -fno-omit-frame-pointer"
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   775
    fi
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   776
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   777
  elif test "x$TOOLCHAIN_TYPE" = xclang; then
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   778
    if test "x$FLAGS_OS" = xlinux; then
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   779
      # ppc test not really needed for clang
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   780
      if test "x$FLAGS_CPU_ARCH" != xarm &&  test "x$FLAGS_CPU_ARCH" != xppc; then
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   781
        # for all archs except arm and ppc, prevent gcc to omit frame pointer
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   782
        $1_CFLAGS_CPU_JDK="${$1_CFLAGS_CPU_JDK} -fno-omit-frame-pointer"
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   783
      fi
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   784
    fi
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   785
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   786
  elif test "x$TOOLCHAIN_TYPE" = xsolstudio; then
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   787
    if test "x$FLAGS_CPU" = xx86_64; then
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   788
      # NOTE: -xregs=no%frameptr is supposed to be default on x64
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   789
      $1_CFLAGS_CPU_JDK="-xregs=no%frameptr"
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   790
    elif test "x$FLAGS_CPU" = xsparcv9; then
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   791
      $1_CFLAGS_CPU_JVM="-xarch=sparc"
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   792
      $1_CFLAGS_CPU_JDK_LIBONLY="-xregs=no%appl"
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   793
    fi
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   794
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   795
  elif test "x$TOOLCHAIN_TYPE" = xxlc; then
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   796
    if test "x$FLAGS_CPU" = xppc64; then
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   797
      $1_CFLAGS_CPU_JVM="-qarch=ppc64"
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   798
    fi
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   799
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   800
  elif test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   801
    if test "x$FLAGS_CPU" = xx86; then
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   802
      $1_CFLAGS_CPU_JVM="-arch:IA32"
56189
4fde3036c652 Windows fixes.
ihse
parents: 56188
diff changeset
   803
    elif test "x$OPENJDK_TARGET_CPU" = xx86_64; then
4fde3036c652 Windows fixes.
ihse
parents: 56188
diff changeset
   804
      if test "x$DEBUG_LEVEL" != xrelease; then
4fde3036c652 Windows fixes.
ihse
parents: 56188
diff changeset
   805
        # NOTE: This is probably redundant; -homeparams is default on
4fde3036c652 Windows fixes.
ihse
parents: 56188
diff changeset
   806
        # non-release builds.
4fde3036c652 Windows fixes.
ihse
parents: 56188
diff changeset
   807
        $1_CFLAGS_CPU_JVM="-homeparams"
4fde3036c652 Windows fixes.
ihse
parents: 56188
diff changeset
   808
      fi
56178
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   809
    fi
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   810
  fi
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   811
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   812
  if test "x$TOOLCHAIN_TYPE" = xgcc; then
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   813
    TOOLCHAIN_CHECK_COMPILER_VERSION(VERSION: 6, PREFIX: $2, IF_AT_LEAST: FLAGS_SETUP_GCC6_COMPILER_FLAGS($1))
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   814
    $1_TOOLCHAIN_CFLAGS="${$1_GCC6_CFLAGS}"
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   815
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   816
    TOOLCHAIN_CHECK_COMPILER_VERSION(VERSION: [4.8], PREFIX: $2,
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   817
        IF_AT_LEAST: [
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   818
          # These flags either do not work or give spurious warnings prior to gcc 4.8.
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   819
          $1_WARNING_CFLAGS_JVM="-Wno-format-zero-length -Wtype-limits -Wuninitialized"
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   820
        ]
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   821
    )
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   822
  fi
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   823
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   824
  # EXPORT to API
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   825
  CFLAGS_JVM_COMMON="$ALWAYS_CFLAGS_JVM $ALWAYS_DEFINES_JVM $TOOLCHAIN_CFLAGS_JVM \
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   826
      $OS_CFLAGS $OS_CFLAGS_JVM $CFLAGS_OS_DEF_JVM $DEBUG_CFLAGS_JVM \
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   827
      $WARNING_CFLAGS $WARNING_CFLAGS_JVM $JVM_PICFLAG"
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   828
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   829
  CFLAGS_JDK_COMMON="$ALWAYS_CFLAGS_JDK $ALWAYS_DEFINES_JDK $TOOLCHAIN_CFLAGS_JDK \
56193
9aa8244e6b5d Fix -g0 for C++ on solstudio.
ihse
parents: 56190
diff changeset
   830
      $OS_CFLAGS $CFLAGS_OS_DEF_JDK $DEBUG_CFLAGS_JDK $DEBUG_OPTIONS_FLAGS_JDK \
56178
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   831
      $WARNING_CFLAGS $WARNING_CFLAGS_JDK"
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   832
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   833
  # Use ${$2EXTRA_CFLAGS} to block EXTRA_CFLAGS to be added to build flags.
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   834
  # (Currently we don't have any OPENJDK_BUILD_EXTRA_CFLAGS, but that might
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   835
  # change in the future.)
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   836
56193
9aa8244e6b5d Fix -g0 for C++ on solstudio.
ihse
parents: 56190
diff changeset
   837
  CFLAGS_JDK_COMMON_CONLY="$TOOLCHAIN_CFLAGS_JDK_CONLY $DEBUG_SYMBOLS_CFLAGS_JDK \
9aa8244e6b5d Fix -g0 for C++ on solstudio.
ihse
parents: 56190
diff changeset
   838
      $WARNING_CFLAGS_JDK_CONLY ${$2EXTRA_CFLAGS}"
56178
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   839
  CFLAGS_JDK_COMMON_CXXONLY="$ALWAYS_DEFINES_JDK_CXXONLY $TOOLCHAIN_CFLAGS_JDK_CXXONLY \
56193
9aa8244e6b5d Fix -g0 for C++ on solstudio.
ihse
parents: 56190
diff changeset
   840
      $DEBUG_SYMBOLS_CXXFLAGS_JDK $WARNING_CFLAGS_JDK_CXXONLY ${$2EXTRA_CXXFLAGS}"
56178
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   841
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   842
  $1_CFLAGS_JVM="${$1_DEFINES_CPU_JVM} ${$1_CFLAGS_CPU} ${$1_CFLAGS_CPU_JVM} ${$1_TOOLCHAIN_CFLAGS} ${$1_WARNING_CFLAGS_JVM}"
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   843
  $1_CFLAGS_JDK="${$1_DEFINES_CPU_JDK} ${$1_CFLAGS_CPU} ${$1_CFLAGS_CPU_JDK} ${$1_TOOLCHAIN_CFLAGS}"
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   844
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   845
  $2JVM_CFLAGS="$CFLAGS_JVM_COMMON ${$1_CFLAGS_JVM} ${$2EXTRA_CXXFLAGS}"
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   846
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   847
  $2CFLAGS_JDKEXE="$CFLAGS_JDK_COMMON $CFLAGS_JDK_COMMON_CONLY ${$1_CFLAGS_JDK}"
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   848
  $2CXXFLAGS_JDKEXE="$CFLAGS_JDK_COMMON $CFLAGS_JDK_COMMON_CXXONLY ${$1_CFLAGS_JDK}"
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   849
  $2CFLAGS_JDKLIB="${$2CFLAGS_JDKEXE} $JDK_PICFLAG ${$1_CFLAGS_CPU_JDK_LIBONLY}"
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   850
  $2CXXFLAGS_JDKLIB="${$2CXXFLAGS_JDKEXE} $JDK_PICFLAG ${$1_CFLAGS_CPU_JDK_LIBONLY}"
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   851
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   852
  AC_SUBST($2JVM_CFLAGS)
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   853
  AC_SUBST($2CFLAGS_JDKLIB)
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   854
  AC_SUBST($2CFLAGS_JDKEXE)
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   855
  AC_SUBST($2CXXFLAGS_JDKLIB)
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   856
  AC_SUBST($2CXXFLAGS_JDKEXE)
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   857
])
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   858
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   859
# FLAGS_SETUP_GCC6_COMPILER_FLAGS([PREFIX])
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   860
# Arguments:
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   861
# $1 - Prefix for each variable defined.
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   862
AC_DEFUN([FLAGS_SETUP_GCC6_COMPILER_FLAGS],
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   863
[
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   864
  # These flags are required for GCC 6 builds as undefined behaviour in OpenJDK code
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   865
  # runs afoul of the more aggressive versions of these optimisations.
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   866
  # Notably, value range propagation now assumes that the this pointer of C++
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   867
  # member functions is non-null.
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   868
  NO_DELETE_NULL_POINTER_CHECKS_CFLAG="-fno-delete-null-pointer-checks"
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   869
  dnl Argument check is disabled until FLAGS_COMPILER_CHECK_ARGUMENTS handles cross-compilation
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   870
  dnl FLAGS_COMPILER_CHECK_ARGUMENTS(ARGUMENT: [$NO_DELETE_NULL_POINTER_CHECKS_CFLAG -Werror],
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   871
  dnl					     IF_FALSE: [NO_DELETE_NULL_POINTER_CHECKS_CFLAG=""])
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   872
  NO_LIFETIME_DSE_CFLAG="-fno-lifetime-dse"
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   873
  dnl Argument check is disabled until FLAGS_COMPILER_CHECK_ARGUMENTS handles cross-compilation
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   874
  dnl FLAGS_COMPILER_CHECK_ARGUMENTS(ARGUMENT: [$NO_LIFETIME_DSE_CFLAG -Werror],
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   875
  dnl					     IF_FALSE: [NO_LIFETIME_DSE_CFLAG=""])
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   876
  AC_MSG_NOTICE([GCC >= 6 detected; adding ${NO_DELETE_NULL_POINTER_CHECKS_CFLAG} and ${NO_LIFETIME_DSE_CFLAG}])
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   877
  $1_GCC6_CFLAGS="${NO_DELETE_NULL_POINTER_CHECKS_CFLAG} ${NO_LIFETIME_DSE_CFLAG}"
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   878
])
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   879
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   880
# Documentation on common flags used for solstudio in HIGHEST.
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   881
#
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   882
# WARNING: Use of OPTIMIZATION_LEVEL=HIGHEST in your Makefile needs to be
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   883
#          done with care, there are some assumptions below that need to
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   884
#          be understood about the use of pointers, and IEEE behavior.
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   885
#
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   886
# -fns: Use non-standard floating point mode (not IEEE 754)
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   887
# -fsimple: Do some simplification of floating point arithmetic (not IEEE 754)
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   888
# -fsingle: Use single precision floating point with 'float'
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   889
# -xalias_level=basic: Assume memory references via basic pointer types do not alias
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   890
#   (Source with excessing pointer casting and data access with mixed
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   891
#    pointer types are not recommended)
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   892
# -xbuiltin=%all: Use intrinsic or inline versions for math/std functions
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   893
#   (If you expect perfect errno behavior, do not use this)
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   894
# -xdepend: Loop data dependency optimizations (need -xO3 or higher)
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   895
# -xrestrict: Pointer parameters to functions do not overlap
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   896
#   (Similar to -xalias_level=basic usage, but less obvious sometimes.
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   897
#    If you pass in multiple pointers to the same data, do not use this)
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   898
# -xlibmil: Inline some library routines
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   899
#   (If you expect perfect errno behavior, do not use this)
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   900
# -xlibmopt: Use optimized math routines (CURRENTLY DISABLED)
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   901
#   (If you expect perfect errno behavior, do not use this)
7e63ac6274dd Move all CFLAGS handling to cflags.m4.
ihse
parents: 56177
diff changeset
   902
#  Can cause undefined external on Solaris 8 X86 on __sincos, removing for now