annotate common/autoconf/flags.m4 @ 2345:5d868c42d888

8151619: genSocketOptionRegistry.exe always relinked on Windows Reviewed-by: tbell
author erikj
date Mon, 14 Mar 2016 12:00:24 +0100
parents 900e2e405414
children 9d77f922d694
rev   line source
erikj@457 1 #
ihse@2255 2 # Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
erikj@457 3 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
erikj@457 4 #
erikj@457 5 # This code is free software; you can redistribute it and/or modify it
erikj@457 6 # under the terms of the GNU General Public License version 2 only, as
erikj@457 7 # published by the Free Software Foundation. Oracle designates this
erikj@457 8 # particular file as subject to the "Classpath" exception as provided
erikj@457 9 # by Oracle in the LICENSE file that accompanied this code.
erikj@457 10 #
erikj@457 11 # This code is distributed in the hope that it will be useful, but WITHOUT
erikj@457 12 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
erikj@457 13 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
erikj@457 14 # version 2 for more details (a copy is included in the LICENSE file that
erikj@457 15 # accompanied this code).
erikj@457 16 #
erikj@457 17 # You should have received a copy of the GNU General Public License version
erikj@457 18 # 2 along with this work; if not, write to the Free Software Foundation,
erikj@457 19 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
erikj@457 20 #
erikj@457 21 # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
erikj@457 22 # or visit www.oracle.com if you need additional information or have any
erikj@457 23 # questions.
erikj@457 24 #
erikj@457 25
erikj@1838 26 # Reset the global CFLAGS/LDFLAGS variables and initialize them with the
erikj@1838 27 # corresponding configure arguments instead
erikj@1838 28 AC_DEFUN_ONCE([FLAGS_SETUP_USER_SUPPLIED_FLAGS],
erikj@1838 29 [
erikj@1838 30 if test "x$CFLAGS" != "x${ADDED_CFLAGS}"; then
erikj@1838 31 AC_MSG_WARN([Ignoring CFLAGS($CFLAGS) found in environment. Use --with-extra-cflags])
erikj@1838 32 fi
erikj@1838 33
erikj@1838 34 if test "x$CXXFLAGS" != "x${ADDED_CXXFLAGS}"; then
erikj@1838 35 AC_MSG_WARN([Ignoring CXXFLAGS($CXXFLAGS) found in environment. Use --with-extra-cxxflags])
erikj@1838 36 fi
erikj@1838 37
erikj@1838 38 if test "x$LDFLAGS" != "x${ADDED_LDFLAGS}"; then
erikj@1838 39 AC_MSG_WARN([Ignoring LDFLAGS($LDFLAGS) found in environment. Use --with-extra-ldflags])
erikj@1838 40 fi
erikj@1838 41
erikj@1838 42 AC_ARG_WITH(extra-cflags, [AS_HELP_STRING([--with-extra-cflags],
erikj@1838 43 [extra flags to be used when compiling jdk c-files])])
erikj@1838 44
erikj@1838 45 AC_ARG_WITH(extra-cxxflags, [AS_HELP_STRING([--with-extra-cxxflags],
erikj@1838 46 [extra flags to be used when compiling jdk c++-files])])
erikj@1838 47
erikj@1838 48 AC_ARG_WITH(extra-ldflags, [AS_HELP_STRING([--with-extra-ldflags],
erikj@1838 49 [extra flags to be used when linking jdk])])
erikj@1838 50
erikj@1838 51 EXTRA_CFLAGS="$with_extra_cflags"
erikj@1838 52 EXTRA_CXXFLAGS="$with_extra_cxxflags"
erikj@1838 53 EXTRA_LDFLAGS="$with_extra_ldflags"
erikj@1838 54
erikj@1838 55 # Hotspot needs these set in their legacy form
erikj@1838 56 LEGACY_EXTRA_CFLAGS="$LEGACY_EXTRA_CFLAGS $EXTRA_CFLAGS"
erikj@1838 57 LEGACY_EXTRA_CXXFLAGS="$LEGACY_EXTRA_CXXFLAGS $EXTRA_CXXFLAGS"
erikj@1838 58 LEGACY_EXTRA_LDFLAGS="$LEGACY_EXTRA_LDFLAGS $EXTRA_LDFLAGS"
erikj@1838 59
erikj@1838 60 AC_SUBST(LEGACY_EXTRA_CFLAGS)
erikj@1838 61 AC_SUBST(LEGACY_EXTRA_CXXFLAGS)
erikj@1838 62 AC_SUBST(LEGACY_EXTRA_LDFLAGS)
erikj@1838 63
erikj@1838 64 # The global CFLAGS and LDLAGS variables are used by configure tests and
erikj@1838 65 # should include the extra parameters
erikj@1838 66 CFLAGS="$EXTRA_CFLAGS"
erikj@1838 67 CXXFLAGS="$EXTRA_CXXFLAGS"
erikj@1838 68 LDFLAGS="$EXTRA_LDFLAGS"
erikj@1838 69 CPPFLAGS=""
erikj@1838 70 ])
erikj@1838 71
erikj@1838 72 # Setup the sysroot flags and add them to global CFLAGS and LDFLAGS so
erikj@1838 73 # that configure can use them while detecting compilers.
erikj@1838 74 # TOOLCHAIN_TYPE is available here.
erikj@1900 75 # Param 1 - Optional prefix to all variables. (e.g BUILD_)
erikj@1900 76 AC_DEFUN([FLAGS_SETUP_SYSROOT_FLAGS],
erikj@1838 77 [
erikj@1900 78 if test "x[$]$1SYSROOT" != "x"; then
erikj@1838 79 if test "x$TOOLCHAIN_TYPE" = xsolstudio; then
erikj@1838 80 if test "x$OPENJDK_TARGET_OS" = xsolaris; then
erikj@1838 81 # Solaris Studio does not have a concept of sysroot. Instead we must
erikj@1838 82 # make sure the default include and lib dirs are appended to each
erikj@2254 83 # compile and link command line. Must also add -I-xbuiltin to enable
erikj@2254 84 # inlining of system functions and intrinsics.
erikj@2254 85 $1SYSROOT_CFLAGS="-I-xbuiltin -I[$]$1SYSROOT/usr/include"
erikj@1900 86 $1SYSROOT_LDFLAGS="-L[$]$1SYSROOT/usr/lib$OPENJDK_TARGET_CPU_ISADIR \
erikj@1900 87 -L[$]$1SYSROOT/lib$OPENJDK_TARGET_CPU_ISADIR \
erikj@1900 88 -L[$]$1SYSROOT/usr/ccs/lib$OPENJDK_TARGET_CPU_ISADIR"
erikj@1838 89 fi
erikj@1838 90 elif test "x$TOOLCHAIN_TYPE" = xgcc; then
erikj@1900 91 $1SYSROOT_CFLAGS="--sysroot=[$]$1SYSROOT"
erikj@1900 92 $1SYSROOT_LDFLAGS="--sysroot=[$]$1SYSROOT"
erikj@1838 93 elif test "x$TOOLCHAIN_TYPE" = xclang; then
erikj@1900 94 $1SYSROOT_CFLAGS="-isysroot [$]$1SYSROOT"
erikj@1900 95 $1SYSROOT_LDFLAGS="-isysroot [$]$1SYSROOT"
erikj@1838 96 fi
erikj@1838 97 # Propagate the sysroot args to hotspot
erikj@1900 98 $1LEGACY_EXTRA_CFLAGS="[$]$1LEGACY_EXTRA_CFLAGS [$]$1SYSROOT_CFLAGS"
erikj@1900 99 $1LEGACY_EXTRA_CXXFLAGS="[$]$1LEGACY_EXTRA_CXXFLAGS [$]$1SYSROOT_CFLAGS"
erikj@1900 100 $1LEGACY_EXTRA_LDFLAGS="[$]$1LEGACY_EXTRA_LDFLAGS [$]$1SYSROOT_LDFLAGS"
erikj@1838 101 # The global CFLAGS and LDFLAGS variables need these for configure to function
erikj@1900 102 $1CFLAGS="[$]$1CFLAGS [$]$1SYSROOT_CFLAGS"
erikj@1900 103 $1CPPFLAGS="[$]$1CPPFLAGS [$]$1SYSROOT_CFLAGS"
erikj@1900 104 $1CXXFLAGS="[$]$1CXXFLAGS [$]$1SYSROOT_CFLAGS"
erikj@1900 105 $1LDFLAGS="[$]$1LDFLAGS [$]$1SYSROOT_LDFLAGS"
erikj@1838 106 fi
erikj@1838 107
erikj@1838 108 if test "x$OPENJDK_TARGET_OS" = xmacosx; then
erikj@1838 109 # We also need -iframework<path>/System/Library/Frameworks
erikj@1900 110 $1SYSROOT_CFLAGS="[$]$1SYSROOT_CFLAGS -iframework [$]$1SYSROOT/System/Library/Frameworks"
erikj@1900 111 $1SYSROOT_LDFLAGS="[$]$1SYSROOT_LDFLAGS -iframework [$]$1SYSROOT/System/Library/Frameworks"
erikj@1838 112 # These always need to be set, or we can't find the frameworks embedded in JavaVM.framework
erikj@1838 113 # set this here so it doesn't have to be peppered throughout the forest
erikj@1900 114 $1SYSROOT_CFLAGS="[$]$1SYSROOT_CFLAGS -F [$]$1SYSROOT/System/Library/Frameworks/JavaVM.framework/Frameworks"
erikj@1900 115 $1SYSROOT_LDFLAGS="[$]$1SYSROOT_LDFLAGS -F [$]$1SYSROOT/System/Library/Frameworks/JavaVM.framework/Frameworks"
erikj@1838 116 fi
erikj@1838 117
erikj@1900 118 AC_SUBST($1SYSROOT_CFLAGS)
erikj@1900 119 AC_SUBST($1SYSROOT_LDFLAGS)
erikj@1838 120 ])
erikj@1838 121
ihse@975 122 AC_DEFUN_ONCE([FLAGS_SETUP_INIT_FLAGS],
erikj@457 123 [
ihse@2050 124 # COMPILER_TARGET_BITS_FLAG : option for selecting 32- or 64-bit output
ihse@2050 125 # COMPILER_COMMAND_FILE_FLAG : option for passing a command file to the compiler
simonis@2304 126 # COMPILER_BINDCMD_FILE_FLAG : option for specifying a file which saves the binder
simonis@2304 127 # commands produced by the link step (currently AIX only)
ihse@975 128 if test "x$TOOLCHAIN_TYPE" = xxlc; then
ihse@975 129 COMPILER_TARGET_BITS_FLAG="-q"
ihse@2050 130 COMPILER_COMMAND_FILE_FLAG="-f"
simonis@2304 131 COMPILER_BINDCMD_FILE_FLAG="-bloadmap:"
ohair@492 132 else
ihse@975 133 COMPILER_TARGET_BITS_FLAG="-m"
ihse@2050 134 COMPILER_COMMAND_FILE_FLAG="@"
simonis@2304 135 COMPILER_BINDCMD_FILE_FLAG=""
simonis@2071 136
simonis@2071 137 # The solstudio linker does not support @-files.
simonis@2071 138 if test "x$TOOLCHAIN_TYPE" = xsolstudio; then
simonis@2071 139 COMPILER_COMMAND_FILE_FLAG=
simonis@2071 140 fi
simonis@2071 141
simonis@2071 142 # Check if @file is supported by gcc
simonis@2071 143 if test "x$TOOLCHAIN_TYPE" = xgcc; then
simonis@2071 144 AC_MSG_CHECKING([if @file is supported by gcc])
simonis@2071 145 # Extra emtpy "" to prevent ECHO from interpreting '--version' as argument
simonis@2071 146 $ECHO "" "--version" > command.file
simonis@2071 147 if $CXX @command.file 2>&AS_MESSAGE_LOG_FD >&AS_MESSAGE_LOG_FD; then
simonis@2071 148 AC_MSG_RESULT(yes)
simonis@2071 149 COMPILER_COMMAND_FILE_FLAG="@"
simonis@2071 150 else
simonis@2071 151 AC_MSG_RESULT(no)
simonis@2071 152 COMPILER_COMMAND_FILE_FLAG=
simonis@2071 153 fi
simonis@2071 154 rm -rf command.file
simonis@2071 155 fi
ohair@492 156 fi
kvn@946 157 AC_SUBST(COMPILER_TARGET_BITS_FLAG)
ihse@2050 158 AC_SUBST(COMPILER_COMMAND_FILE_FLAG)
simonis@2304 159 AC_SUBST(COMPILER_BINDCMD_FILE_FLAG)
simonis@945 160
ihse@975 161 # FIXME: figure out if we should select AR flags depending on OS or toolchain.
ihse@837 162 if test "x$OPENJDK_TARGET_OS" = xmacosx; then
erikj@457 163 ARFLAGS="-r"
kvn@946 164 elif test "x$OPENJDK_TARGET_OS" = xaix; then
simonis@945 165 ARFLAGS="-X64"
ihse@975 166 elif test "x$OPENJDK_TARGET_OS" = xwindows; then
ihse@975 167 # lib.exe is used as AR to create static libraries.
ihse@975 168 ARFLAGS="-nologo -NODEFAULTLIB:MSVCRT"
ihse@837 169 else
erikj@457 170 ARFLAGS=""
ihse@837 171 fi
ihse@837 172 AC_SUBST(ARFLAGS)
erikj@457 173
ihse@975 174 ## Setup strip.
ihse@975 175 # FIXME: should this really be per platform, or should it be per toolchain type?
ihse@975 176 # strip is not provided by clang or solstudio; so guessing platform makes most sense.
ihse@975 177 # FIXME: we should really only export STRIPFLAGS from here, not POST_STRIP_CMD.
ihse@975 178 if test "x$OPENJDK_TARGET_OS" = xlinux; then
ihse@975 179 STRIPFLAGS="-g"
ihse@975 180 elif test "x$OPENJDK_TARGET_OS" = xsolaris; then
ihse@975 181 STRIPFLAGS="-x"
ihse@975 182 elif test "x$OPENJDK_TARGET_OS" = xmacosx; then
ihse@975 183 STRIPFLAGS="-S"
ihse@975 184 elif test "x$OPENJDK_TARGET_OS" = xaix; then
ihse@975 185 STRIPFLAGS="-X32_64"
ihse@975 186 fi
ohair@492 187
erikj@1839 188 AC_SUBST(STRIPFLAGS)
ihse@975 189
ihse@975 190 if test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
erikj@457 191 CC_OUT_OPTION=-Fo
erikj@457 192 EXE_OUT_OPTION=-out:
erikj@457 193 LD_OUT_OPTION=-out:
erikj@457 194 AR_OUT_OPTION=-out:
ihse@975 195 else
ihse@975 196 # The option used to specify the target .o,.a or .so file.
ihse@975 197 # When compiling, how to specify the to be created object file.
ihse@975 198 CC_OUT_OPTION='-o$(SPACE)'
ihse@975 199 # When linking, how to specify the to be created executable.
ihse@975 200 EXE_OUT_OPTION='-o$(SPACE)'
ihse@975 201 # When linking, how to specify the to be created dynamically linkable library.
ihse@975 202 LD_OUT_OPTION='-o$(SPACE)'
ihse@975 203 # When archiving, how to specify the to be create static archive for object files.
ihse@975 204 AR_OUT_OPTION='rcs$(SPACE)'
ihse@975 205 fi
ihse@975 206 AC_SUBST(CC_OUT_OPTION)
ihse@975 207 AC_SUBST(EXE_OUT_OPTION)
ihse@975 208 AC_SUBST(LD_OUT_OPTION)
ihse@975 209 AC_SUBST(AR_OUT_OPTION)
ihse@975 210
ihse@975 211 # On Windows, we need to set RC flags.
ihse@975 212 if test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
ihse@1287 213 RC_FLAGS="-nologo -l0x409"
ihse@2275 214 if test "x$DEBUG_LEVEL" = xrelease; then
ihse@1287 215 RC_FLAGS="$RC_FLAGS -DNDEBUG"
ohair@476 216 fi
erikj@457 217
ihse@975 218 # The version variables used to create RC_FLAGS may be overridden
ihse@975 219 # in a custom configure script, or possibly the command line.
ihse@975 220 # Let those variables be expanded at make time in spec.gmk.
ihse@975 221 # The \$ are escaped to the shell, and the $(...) variables
ihse@975 222 # are evaluated by make.
ihse@975 223 RC_FLAGS="$RC_FLAGS \
ihse@1961 224 -D\"JDK_VERSION_STRING=\$(VERSION_STRING)\" \
ihse@1287 225 -D\"JDK_COMPANY=\$(COMPANY_NAME)\" \
ihse@1287 226 -D\"JDK_COMPONENT=\$(PRODUCT_NAME) \$(JDK_RC_PLATFORM_NAME) binary\" \
dtitov@1976 227 -D\"JDK_VER=\$(VERSION_NUMBER)\" \
ihse@1287 228 -D\"JDK_COPYRIGHT=Copyright \xA9 $COPYRIGHT_YEAR\" \
ihse@1961 229 -D\"JDK_NAME=\$(PRODUCT_NAME) \$(JDK_RC_PLATFORM_NAME) \$(VERSION_MAJOR)\" \
ihse@1961 230 -D\"JDK_FVER=\$(subst .,\$(COMMA),\$(VERSION_NUMBER_FOUR_POSITIONS))\""
ihse@975 231 fi
ihse@975 232 AC_SUBST(RC_FLAGS)
erikj@457 233
ihse@975 234 if test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
mduigou@1073 235 # silence copyright notice and other headers.
mduigou@1073 236 COMMON_CCXXFLAGS="$COMMON_CCXXFLAGS -nologo"
ihse@837 237 fi
erikj@457 238 ])
erikj@457 239
ihse@975 240 AC_DEFUN_ONCE([FLAGS_SETUP_COMPILER_FLAGS_FOR_LIBS],
erikj@457 241 [
ihse@837 242 ###############################################################################
ihse@837 243 #
ihse@837 244 # How to compile shared libraries.
ihse@837 245 #
erikj@457 246
ihse@975 247 if test "x$TOOLCHAIN_TYPE" = xgcc; then
erikj@457 248 PICFLAG="-fPIC"
erikj@457 249 C_FLAG_REORDER=''
erikj@457 250 CXX_FLAG_REORDER=''
erikj@457 251
ohair@492 252 if test "x$OPENJDK_TARGET_OS" = xmacosx; then
ihse@975 253 # Linking is different on MacOSX
bobv@1939 254 if test "x$STATIC_BUILD" = xtrue; then
bobv@1939 255 SHARED_LIBRARY_FLAGS ='-undefined dynamic_lookup'
bobv@1939 256 else
bobv@1939 257 SHARED_LIBRARY_FLAGS="-dynamiclib -compatibility_version 1.0.0 -current_version 1.0.0 $PICFLAG"
bobv@1939 258 fi
ihse@2050 259 SET_EXECUTABLE_ORIGIN='-Wl,-rpath,@loader_path/.'
ihse@975 260 SET_SHARED_LIBRARY_ORIGIN="$SET_EXECUTABLE_ORIGIN"
ihse@2050 261 SET_SHARED_LIBRARY_NAME='-Wl,-install_name,@rpath/[$]1'
ihse@2275 262 SET_SHARED_LIBRARY_MAPFILE='-Wl,-exported_symbols_list,[$]1'
ihse@975 263 else
ihse@975 264 # Default works for linux, might work on other platforms as well.
ihse@975 265 SHARED_LIBRARY_FLAGS='-shared'
ihse@2050 266 SET_EXECUTABLE_ORIGIN='-Wl,-rpath,\$$$$ORIGIN[$]1'
ihse@2050 267 SET_SHARED_LIBRARY_ORIGIN="-Wl,-z,origin $SET_EXECUTABLE_ORIGIN"
ihse@2050 268 SET_SHARED_LIBRARY_NAME='-Wl,-soname=[$]1'
ihse@2050 269 SET_SHARED_LIBRARY_MAPFILE='-Wl,-version-script=[$]1'
erikj@457 270 fi
henryjen@988 271 elif test "x$TOOLCHAIN_TYPE" = xclang; then
henryjen@988 272 C_FLAG_REORDER=''
henryjen@988 273 CXX_FLAG_REORDER=''
henryjen@988 274
henryjen@988 275 if test "x$OPENJDK_TARGET_OS" = xmacosx; then
henryjen@988 276 # Linking is different on MacOSX
ihse@2050 277 PICFLAG=''
henryjen@988 278 SHARED_LIBRARY_FLAGS="-dynamiclib -compatibility_version 1.0.0 -current_version 1.0.0 $PICFLAG"
ihse@2050 279 SET_EXECUTABLE_ORIGIN='-Wl,-rpath,@loader_path/.'
henryjen@988 280 SET_SHARED_LIBRARY_ORIGIN="$SET_EXECUTABLE_ORIGIN"
ihse@2050 281 SET_SHARED_LIBRARY_NAME='-Wl,-install_name,@rpath/[$]1'
ihse@2275 282 SET_SHARED_LIBRARY_MAPFILE='-Wl,-exported_symbols_list,[$]1'
henryjen@988 283 else
henryjen@988 284 # Default works for linux, might work on other platforms as well.
ihse@2050 285 PICFLAG='-fPIC'
henryjen@988 286 SHARED_LIBRARY_FLAGS='-shared'
ihse@2050 287 SET_EXECUTABLE_ORIGIN='-Wl,-rpath,\$$$$ORIGIN[$]1'
ihse@2050 288 SET_SHARED_LIBRARY_ORIGIN="-Wl,-z,origin $SET_EXECUTABLE_ORIGIN"
ihse@2050 289 SET_SHARED_LIBRARY_NAME='-Wl,-soname=[$]1'
ihse@2050 290 SET_SHARED_LIBRARY_MAPFILE='-Wl,-version-script=[$]1'
henryjen@988 291 fi
ihse@975 292 elif test "x$TOOLCHAIN_TYPE" = xsolstudio; then
ihse@975 293 PICFLAG="-KPIC"
ihse@975 294 C_FLAG_REORDER='-xF'
ihse@975 295 CXX_FLAG_REORDER='-xF'
ihse@975 296 SHARED_LIBRARY_FLAGS="-G"
ihse@975 297 SET_EXECUTABLE_ORIGIN='-R\$$$$ORIGIN[$]1'
ihse@975 298 SET_SHARED_LIBRARY_ORIGIN="$SET_EXECUTABLE_ORIGIN"
ihse@2050 299 SET_SHARED_LIBRARY_NAME='-h [$]1'
ihse@975 300 SET_SHARED_LIBRARY_MAPFILE='-M[$]1'
ihse@975 301 elif test "x$TOOLCHAIN_TYPE" = xxlc; then
simonis@2304 302 # '-qpic' defaults to 'qpic=small'. This means that the compiler generates only
simonis@2304 303 # one instruction for accessing the TOC. If the TOC grows larger than 64K, the linker
simonis@2304 304 # will have to patch this single instruction with a call to some out-of-order code which
simonis@2304 305 # does the load from the TOC. This is of course slow. But in that case we also would have
simonis@2304 306 # to use '-bbigtoc' for linking anyway so we could also change the PICFLAG to 'qpic=large'.
simonis@2304 307 # With 'qpic=large' the compiler will by default generate a two-instruction sequence which
simonis@2304 308 # can be patched directly by the linker and does not require a jump to out-of-order code.
simonis@2304 309 # Another alternative instead of using 'qpic=large -bbigtoc' may be to use '-qminimaltoc'
simonis@2304 310 # instead. This creates a distinct TOC for every compilation unit (and thus requires two
simonis@2304 311 # loads for accessing a global variable). But there are rumors that this may be seen as a
simonis@2304 312 # 'performance feature' because of improved code locality of the symbols used in a
simonis@2304 313 # compilation unit.
simonis@2304 314 PICFLAG="-qpic"
simonis@2304 315 JVM_CFLAGS="$JVM_CFLAGS $PICFLAG"
ihse@975 316 C_FLAG_REORDER=''
ihse@975 317 CXX_FLAG_REORDER=''
simonis@2304 318 SHARED_LIBRARY_FLAGS="-qmkshrobj -bM:SRE -bnoentry"
ihse@975 319 SET_EXECUTABLE_ORIGIN=""
ihse@975 320 SET_SHARED_LIBRARY_ORIGIN=''
ihse@975 321 SET_SHARED_LIBRARY_NAME=''
ihse@975 322 SET_SHARED_LIBRARY_MAPFILE=''
ihse@975 323 elif test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
ihse@975 324 PICFLAG=""
ihse@975 325 C_FLAG_REORDER=''
ihse@975 326 CXX_FLAG_REORDER=''
ihse@2050 327 SHARED_LIBRARY_FLAGS="-dll"
ihse@975 328 SET_EXECUTABLE_ORIGIN=''
ihse@975 329 SET_SHARED_LIBRARY_ORIGIN=''
ihse@975 330 SET_SHARED_LIBRARY_NAME=''
ihse@2275 331 SET_SHARED_LIBRARY_MAPFILE='-def:[$]1'
ihse@837 332 fi
erikj@457 333
ihse@975 334 AC_SUBST(C_FLAG_REORDER)
ihse@975 335 AC_SUBST(CXX_FLAG_REORDER)
ihse@975 336 AC_SUBST(SET_EXECUTABLE_ORIGIN)
ihse@975 337 AC_SUBST(SET_SHARED_LIBRARY_ORIGIN)
ihse@837 338 AC_SUBST(SET_SHARED_LIBRARY_NAME)
ihse@837 339 AC_SUBST(SET_SHARED_LIBRARY_MAPFILE)
ihse@2050 340 AC_SUBST(SHARED_LIBRARY_FLAGS)
erikj@457 341
ihse@975 342 if test "x$OPENJDK_TARGET_OS" = xsolaris; then
ihse@975 343 CFLAGS_JDK="${CFLAGS_JDK} -D__solaris__"
ihse@975 344 CXXFLAGS_JDK="${CXXFLAGS_JDK} -D__solaris__"
ihse@975 345 CFLAGS_JDKLIB_EXTRA='-xstrconst'
ihse@975 346 fi
ihse@837 347 # The (cross) compiler is now configured, we can now test capabilities
ihse@837 348 # of the target platform.
erikj@457 349 ])
erikj@457 350
ihse@975 351 # Documentation on common flags used for solstudio in HIGHEST.
ihse@975 352 #
ihse@975 353 # WARNING: Use of OPTIMIZATION_LEVEL=HIGHEST in your Makefile needs to be
ihse@975 354 # done with care, there are some assumptions below that need to
ihse@975 355 # be understood about the use of pointers, and IEEE behavior.
ihse@975 356 #
ihse@975 357 # -fns: Use non-standard floating point mode (not IEEE 754)
ihse@975 358 # -fsimple: Do some simplification of floating point arithmetic (not IEEE 754)
ihse@975 359 # -fsingle: Use single precision floating point with 'float'
ihse@975 360 # -xalias_level=basic: Assume memory references via basic pointer types do not alias
ihse@975 361 # (Source with excessing pointer casting and data access with mixed
ihse@975 362 # pointer types are not recommended)
ihse@975 363 # -xbuiltin=%all: Use intrinsic or inline versions for math/std functions
ihse@975 364 # (If you expect perfect errno behavior, do not use this)
ihse@975 365 # -xdepend: Loop data dependency optimizations (need -xO3 or higher)
ihse@975 366 # -xrestrict: Pointer parameters to functions do not overlap
ihse@975 367 # (Similar to -xalias_level=basic usage, but less obvious sometimes.
ihse@975 368 # If you pass in multiple pointers to the same data, do not use this)
ihse@975 369 # -xlibmil: Inline some library routines
ihse@975 370 # (If you expect perfect errno behavior, do not use this)
ihse@975 371 # -xlibmopt: Use optimized math routines (CURRENTLY DISABLED)
ihse@975 372 # (If you expect perfect errno behavior, do not use this)
ihse@975 373 # Can cause undefined external on Solaris 8 X86 on __sincos, removing for now
ihse@975 374
ihse@975 375 # FIXME: this will never happen since sparc != sparcv9, ie 32 bit, which we don't build anymore.
ihse@975 376 # Bug?
ihse@975 377 #if test "x$OPENJDK_TARGET_CPU" = xsparc; then
ihse@975 378 # CFLAGS_JDK="${CFLAGS_JDK} -xmemalign=4s"
ihse@975 379 # CXXFLAGS_JDK="${CXXFLAGS_JDK} -xmemalign=4s"
ihse@975 380 #fi
ihse@975 381
ihse@975 382 AC_DEFUN_ONCE([FLAGS_SETUP_COMPILER_FLAGS_FOR_OPTIMIZATION],
erikj@457 383 [
erikj@457 384
ihse@837 385 ###############################################################################
ihse@837 386 #
ihse@837 387 # Setup the opt flags for different compilers
ihse@837 388 # and different operating systems.
ihse@837 389 #
ohair@476 390
ihse@975 391 # FIXME: this was indirectly the old default, but just inherited.
ihse@975 392 # if test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
ihse@975 393 # C_FLAG_DEPS="-MMD -MF"
ihse@975 394 # fi
ihse@975 395
ihse@975 396 # Generate make dependency files
ihse@975 397 if test "x$TOOLCHAIN_TYPE" = xgcc; then
ihse@975 398 C_FLAG_DEPS="-MMD -MF"
henryjen@988 399 elif test "x$TOOLCHAIN_TYPE" = xclang; then
henryjen@988 400 C_FLAG_DEPS="-MMD -MF"
ihse@975 401 elif test "x$TOOLCHAIN_TYPE" = xsolstudio; then
ihse@975 402 C_FLAG_DEPS="-xMMD -xMF"
ihse@975 403 elif test "x$TOOLCHAIN_TYPE" = xxlc; then
ihse@975 404 C_FLAG_DEPS="-qmakedep=gcc -MF"
ihse@837 405 fi
ihse@975 406 CXX_FLAG_DEPS="$C_FLAG_DEPS"
ihse@975 407 AC_SUBST(C_FLAG_DEPS)
ihse@975 408 AC_SUBST(CXX_FLAG_DEPS)
ohair@476 409
ihse@975 410 # Debug symbols
ihse@975 411 if test "x$TOOLCHAIN_TYPE" = xgcc; then
ihse@975 412 if test "x$OPENJDK_TARGET_CPU_BITS" = "x64" && test "x$DEBUG_LEVEL" = "xfastdebug"; then
mduigou@1073 413 # reduce from default "-g2" option to save space
ihse@975 414 CFLAGS_DEBUG_SYMBOLS="-g1"
ihse@975 415 CXXFLAGS_DEBUG_SYMBOLS="-g1"
ihse@975 416 else
ihse@975 417 CFLAGS_DEBUG_SYMBOLS="-g"
ihse@975 418 CXXFLAGS_DEBUG_SYMBOLS="-g"
ihse@975 419 fi
henryjen@988 420 elif test "x$TOOLCHAIN_TYPE" = xclang; then
henryjen@988 421 CFLAGS_DEBUG_SYMBOLS="-g"
henryjen@988 422 CXXFLAGS_DEBUG_SYMBOLS="-g"
ihse@975 423 elif test "x$TOOLCHAIN_TYPE" = xsolstudio; then
ihse@975 424 CFLAGS_DEBUG_SYMBOLS="-g -xs"
ihse@2144 425 # -g0 enables debug symbols without disabling inlining.
ihse@975 426 CXXFLAGS_DEBUG_SYMBOLS="-g0 -xs"
ihse@975 427 elif test "x$TOOLCHAIN_TYPE" = xxlc; then
ihse@975 428 CFLAGS_DEBUG_SYMBOLS="-g"
ihse@975 429 CXXFLAGS_DEBUG_SYMBOLS="-g"
erikj@2345 430 elif test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
erikj@2345 431 CFLAGS_DEBUG_SYMBOLS="-Zi"
erikj@2345 432 CXXFLAGS_DEBUG_SYMBOLS="-Zi"
ihse@975 433 fi
ihse@975 434 AC_SUBST(CFLAGS_DEBUG_SYMBOLS)
ihse@975 435 AC_SUBST(CXXFLAGS_DEBUG_SYMBOLS)
erikj@457 436
mduigou@1073 437 # bounds, memory and behavior checking options
mduigou@1073 438 if test "x$TOOLCHAIN_TYPE" = xgcc; then
mduigou@1073 439 case $DEBUG_LEVEL in
mduigou@1073 440 release )
mduigou@1073 441 # no adjustment
mduigou@1073 442 ;;
mduigou@1073 443 fastdebug )
mduigou@1141 444 # no adjustment
mduigou@1073 445 ;;
mduigou@1073 446 slowdebug )
ihse@2275 447 # FIXME: By adding this to C(XX)FLAGS_DEBUG_OPTIONS it
ihse@2275 448 # get's added conditionally on whether we produce debug symbols or not.
ihse@2275 449 # This is most likely not really correct.
ihse@2275 450
ihse@1635 451 # Add runtime stack smashing and undefined behavior checks.
ihse@1635 452 # Not all versions of gcc support -fstack-protector
ihse@1635 453 STACK_PROTECTOR_CFLAG="-fstack-protector-all"
ihse@2255 454 FLAGS_COMPILER_CHECK_ARGUMENTS(ARGUMENT: [$STACK_PROTECTOR_CFLAG -Werror], IF_FALSE: [STACK_PROTECTOR_CFLAG=""])
ihse@1635 455
ihse@1635 456 CFLAGS_DEBUG_OPTIONS="$STACK_PROTECTOR_CFLAG --param ssp-buffer-size=1"
ihse@1635 457 CXXFLAGS_DEBUG_OPTIONS="$STACK_PROTECTOR_CFLAG --param ssp-buffer-size=1"
mduigou@1073 458 ;;
mduigou@1073 459 esac
mduigou@1073 460 fi
mduigou@1073 461
ihse@975 462 # Optimization levels
ihse@975 463 if test "x$TOOLCHAIN_TYPE" = xsolstudio; then
erikj@984 464 CC_HIGHEST="$CC_HIGHEST -fns -fsimple -fsingle -xbuiltin=%all -xdepend -xrestrict -xlibmil"
erikj@457 465
ihse@975 466 if test "x$OPENJDK_TARGET_CPU_ARCH" = "xx86"; then
ihse@975 467 # FIXME: seems we always set -xregs=no%frameptr; put it elsewhere more global?
erikj@984 468 C_O_FLAG_HIGHEST="-xO4 -Wu,-O4~yz $CC_HIGHEST -xalias_level=basic -xregs=no%frameptr"
ihse@975 469 C_O_FLAG_HI="-xO4 -Wu,-O4~yz -xregs=no%frameptr"
ihse@975 470 C_O_FLAG_NORM="-xO2 -Wu,-O2~yz -xregs=no%frameptr"
mduigou@1073 471 C_O_FLAG_DEBUG="-xregs=no%frameptr"
ihse@975 472 C_O_FLAG_NONE="-xregs=no%frameptr"
ihse@975 473 CXX_O_FLAG_HIGHEST="-xO4 -Qoption ube -O4~yz $CC_HIGHEST -xregs=no%frameptr"
ihse@975 474 CXX_O_FLAG_HI="-xO4 -Qoption ube -O4~yz -xregs=no%frameptr"
ihse@975 475 CXX_O_FLAG_NORM="-xO2 -Qoption ube -O2~yz -xregs=no%frameptr"
mduigou@1073 476 CXX_O_FLAG_DEBUG="-xregs=no%frameptr"
ihse@975 477 CXX_O_FLAG_NONE="-xregs=no%frameptr"
ihse@975 478 if test "x$OPENJDK_TARGET_CPU_BITS" = "x32"; then
ihse@975 479 C_O_FLAG_HIGHEST="$C_O_FLAG_HIGHEST -xchip=pentium"
ihse@975 480 CXX_O_FLAG_HIGHEST="$CXX_O_FLAG_HIGHEST -xchip=pentium"
ihse@975 481 fi
ihse@975 482 elif test "x$OPENJDK_TARGET_CPU_ARCH" = "xsparc"; then
erikj@984 483 C_O_FLAG_HIGHEST="-xO4 -Wc,-Qrm-s -Wc,-Qiselect-T0 $CC_HIGHEST -xalias_level=basic -xprefetch=auto,explicit -xchip=ultra"
ihse@975 484 C_O_FLAG_HI="-xO4 -Wc,-Qrm-s -Wc,-Qiselect-T0"
ihse@975 485 C_O_FLAG_NORM="-xO2 -Wc,-Qrm-s -Wc,-Qiselect-T0"
mduigou@1073 486 C_O_FLAG_DEBUG=""
ihse@975 487 C_O_FLAG_NONE=""
ihse@975 488 CXX_O_FLAG_HIGHEST="-xO4 -Qoption cg -Qrm-s -Qoption cg -Qiselect-T0 $CC_HIGHEST -xprefetch=auto,explicit -xchip=ultra"
ihse@975 489 CXX_O_FLAG_HI="-xO4 -Qoption cg -Qrm-s -Qoption cg -Qiselect-T0"
ihse@975 490 CXX_O_FLAG_NORM="-xO2 -Qoption cg -Qrm-s -Qoption cg -Qiselect-T0"
ihse@2275 491 CXX_O_FLAG_DEBUG=""
ihse@975 492 CXX_O_FLAG_NONE=""
ihse@975 493 fi
ihse@975 494 else
ihse@975 495 # The remaining toolchains share opt flags between CC and CXX;
ihse@975 496 # setup for C and duplicate afterwards.
ihse@975 497 if test "x$TOOLCHAIN_TYPE" = xgcc; then
ihse@975 498 if test "x$OPENJDK_TARGET_OS" = xmacosx; then
ihse@975 499 # On MacOSX we optimize for size, something
ihse@975 500 # we should do for all platforms?
ihse@975 501 C_O_FLAG_HIGHEST="-Os"
ihse@975 502 C_O_FLAG_HI="-Os"
ihse@975 503 C_O_FLAG_NORM="-Os"
ihse@975 504 else
ihse@975 505 C_O_FLAG_HIGHEST="-O3"
ihse@975 506 C_O_FLAG_HI="-O3"
ihse@975 507 C_O_FLAG_NORM="-O2"
ihse@975 508 fi
mduigou@1105 509 C_O_FLAG_DEBUG="-O0"
mduigou@1073 510 C_O_FLAG_NONE="-O0"
henryjen@988 511 elif test "x$TOOLCHAIN_TYPE" = xclang; then
henryjen@988 512 if test "x$OPENJDK_TARGET_OS" = xmacosx; then
henryjen@988 513 # On MacOSX we optimize for size, something
henryjen@988 514 # we should do for all platforms?
henryjen@988 515 C_O_FLAG_HIGHEST="-Os"
henryjen@988 516 C_O_FLAG_HI="-Os"
henryjen@988 517 C_O_FLAG_NORM="-Os"
henryjen@988 518 else
henryjen@988 519 C_O_FLAG_HIGHEST="-O3"
henryjen@988 520 C_O_FLAG_HI="-O3"
henryjen@988 521 C_O_FLAG_NORM="-O2"
henryjen@988 522 fi
mduigou@1073 523 C_O_FLAG_DEBUG="-O0"
mduigou@1073 524 C_O_FLAG_NONE="-O0"
ihse@975 525 elif test "x$TOOLCHAIN_TYPE" = xxlc; then
ihse@975 526 C_O_FLAG_HIGHEST="-O3"
ihse@975 527 C_O_FLAG_HI="-O3 -qstrict"
ihse@975 528 C_O_FLAG_NORM="-O2"
mduigou@1073 529 C_O_FLAG_DEBUG="-qnoopt"
stuefe@2132 530 C_O_FLAG_NONE="-qnoopt"
ihse@975 531 elif test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
ihse@837 532 C_O_FLAG_HIGHEST="-O2"
ihse@837 533 C_O_FLAG_HI="-O1"
ihse@837 534 C_O_FLAG_NORM="-O1"
mduigou@1073 535 C_O_FLAG_DEBUG="-Od"
ihse@837 536 C_O_FLAG_NONE="-Od"
ihse@975 537 fi
ihse@975 538 CXX_O_FLAG_HIGHEST="$C_O_FLAG_HIGHEST"
ihse@975 539 CXX_O_FLAG_HI="$C_O_FLAG_HI"
ihse@975 540 CXX_O_FLAG_NORM="$C_O_FLAG_NORM"
mduigou@1073 541 CXX_O_FLAG_DEBUG="$C_O_FLAG_DEBUG"
ihse@975 542 CXX_O_FLAG_NONE="$C_O_FLAG_NONE"
ihse@837 543 fi
erikj@457 544
mduigou@1073 545 # Adjust optimization flags according to debug level.
mduigou@1073 546 case $DEBUG_LEVEL in
mduigou@1073 547 release )
mduigou@1073 548 # no adjustment
mduigou@1073 549 ;;
mduigou@1073 550 fastdebug )
mduigou@1073 551 # Not quite so much optimization
mduigou@1073 552 C_O_FLAG_HI="$C_O_FLAG_NORM"
mduigou@1073 553 CXX_O_FLAG_HI="$CXX_O_FLAG_NORM"
mduigou@1073 554 ;;
mduigou@1073 555 slowdebug )
mduigou@1073 556 # Disable optimization
mduigou@1073 557 C_O_FLAG_HIGHEST="$C_O_FLAG_DEBUG"
mduigou@1073 558 C_O_FLAG_HI="$C_O_FLAG_DEBUG"
mduigou@1073 559 C_O_FLAG_NORM="$C_O_FLAG_DEBUG"
mduigou@1073 560 CXX_O_FLAG_HIGHEST="$CXX_O_FLAG_DEBUG"
mduigou@1073 561 CXX_O_FLAG_HI="$CXX_O_FLAG_DEBUG"
mduigou@1073 562 CXX_O_FLAG_NORM="$CXX_O_FLAG_DEBUG"
mduigou@1073 563 ;;
mduigou@1073 564 esac
mduigou@1073 565
ihse@837 566 AC_SUBST(C_O_FLAG_HIGHEST)
ihse@837 567 AC_SUBST(C_O_FLAG_HI)
ihse@837 568 AC_SUBST(C_O_FLAG_NORM)
mduigou@1073 569 AC_SUBST(C_O_FLAG_DEBUG)
ihse@837 570 AC_SUBST(C_O_FLAG_NONE)
ihse@837 571 AC_SUBST(CXX_O_FLAG_HIGHEST)
ihse@837 572 AC_SUBST(CXX_O_FLAG_HI)
ihse@837 573 AC_SUBST(CXX_O_FLAG_NORM)
mduigou@1073 574 AC_SUBST(CXX_O_FLAG_DEBUG)
ihse@837 575 AC_SUBST(CXX_O_FLAG_NONE)
erikj@457 576 ])
erikj@457 577
ihse@975 578 AC_DEFUN_ONCE([FLAGS_SETUP_COMPILER_FLAGS_FOR_JDK],
erikj@457 579 [
ihse@975 580 # Special extras...
ihse@975 581 if test "x$TOOLCHAIN_TYPE" = xsolstudio; then
ihse@975 582 if test "x$OPENJDK_TARGET_CPU_ARCH" = "xsparc"; then
ihse@975 583 CFLAGS_JDKLIB_EXTRA="${CFLAGS_JDKLIB_EXTRA} -xregs=no%appl"
ihse@975 584 CXXFLAGS_JDKLIB_EXTRA="${CXXFLAGS_JDKLIB_EXTRA} -xregs=no%appl"
ihse@975 585 fi
ihse@1466 586 CFLAGS_JDKLIB_EXTRA="${CFLAGS_JDKLIB_EXTRA} -errtags=yes -errfmt"
ihse@1466 587 CXXFLAGS_JDKLIB_EXTRA="${CXXFLAGS_JDKLIB_EXTRA} -errtags=yes -errfmt"
ihse@975 588 elif test "x$TOOLCHAIN_TYPE" = xxlc; then
simonis@1495 589 CFLAGS_JDK="${CFLAGS_JDK} -qchars=signed -qfullpath -qsaveopt"
simonis@1495 590 CXXFLAGS_JDK="${CXXFLAGS_JDK} -qchars=signed -qfullpath -qsaveopt"
ihse@975 591 fi
erikj@457 592
erikj@1838 593 CFLAGS_JDK="${CFLAGS_JDK} $EXTRA_CFLAGS"
erikj@1838 594 CXXFLAGS_JDK="${CXXFLAGS_JDK} $EXTRA_CXXFLAGS"
erikj@1838 595 LDFLAGS_JDK="${LDFLAGS_JDK} $EXTRA_LDFLAGS"
ohair@476 596
ihse@837 597 ###############################################################################
ihse@837 598 #
ihse@837 599 # Now setup the CFLAGS and LDFLAGS for the JDK build.
ihse@837 600 # Later we will also have CFLAGS and LDFLAGS for the hotspot subrepo build.
ihse@837 601 #
ohair@476 602
mduigou@1073 603 # Setup compiler/platform specific flags into
mduigou@1073 604 # CFLAGS_JDK - C Compiler flags
mduigou@1073 605 # CXXFLAGS_JDK - C++ Compiler flags
mduigou@1073 606 # COMMON_CCXXFLAGS_JDK - common to C and C++
ihse@975 607 if test "x$TOOLCHAIN_TYPE" = xgcc; then
erikj@1588 608 if test "x$OPENJDK_TARGET_CPU" = xx86; then
erikj@1588 609 # Force compatibility with i586 on 32 bit intel platforms.
erikj@1588 610 COMMON_CCXXFLAGS="${COMMON_CCXXFLAGS} -march=i586"
erikj@1588 611 fi
ihse@1466 612 COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS $COMMON_CCXXFLAGS_JDK -Wall -Wextra -Wno-unused -Wno-unused-parameter -Wformat=2 \
ihse@975 613 -pipe -D_GNU_SOURCE -D_REENTRANT -D_LARGEFILE64_SOURCE"
ihse@975 614 case $OPENJDK_TARGET_CPU_ARCH in
ihse@975 615 arm )
ihse@975 616 # on arm we don't prevent gcc to omit frame pointer but do prevent strict aliasing
ihse@975 617 CFLAGS_JDK="${CFLAGS_JDK} -fno-strict-aliasing"
ihse@975 618 ;;
ihse@975 619 ppc )
dholmes@1030 620 # on ppc we don't prevent gcc to omit frame pointer but do prevent strict aliasing
dholmes@1030 621 CFLAGS_JDK="${CFLAGS_JDK} -fno-strict-aliasing"
ihse@975 622 ;;
ihse@975 623 * )
mduigou@1073 624 COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -fno-omit-frame-pointer"
ihse@975 625 CFLAGS_JDK="${CFLAGS_JDK} -fno-strict-aliasing"
ihse@975 626 ;;
ihse@975 627 esac
ihse@2050 628 elif test "x$TOOLCHAIN_TYPE" = xclang; then
ihse@2050 629 if test "x$OPENJDK_TARGET_OS" = xlinux; then
ihse@2248 630 if test "x$OPENJDK_TARGET_CPU" = xx86; then
ihse@2248 631 # Force compatibility with i586 on 32 bit intel platforms.
ihse@2248 632 COMMON_CCXXFLAGS="${COMMON_CCXXFLAGS} -march=i586"
ihse@2248 633 fi
ihse@2248 634 COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS $COMMON_CCXXFLAGS_JDK -Wall -Wextra -Wno-unused -Wno-unused-parameter -Wformat=2 \
ihse@2248 635 -pipe -D_GNU_SOURCE -D_REENTRANT -D_LARGEFILE64_SOURCE"
ihse@2248 636 case $OPENJDK_TARGET_CPU_ARCH in
ihse@2248 637 ppc )
ihse@2248 638 # on ppc we don't prevent gcc to omit frame pointer but do prevent strict aliasing
ihse@2248 639 CFLAGS_JDK="${CFLAGS_JDK} -fno-strict-aliasing"
ihse@2248 640 ;;
ihse@2248 641 * )
ihse@2248 642 COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -fno-omit-frame-pointer"
ihse@2248 643 CFLAGS_JDK="${CFLAGS_JDK} -fno-strict-aliasing"
ihse@2248 644 ;;
ihse@2248 645 esac
ihse@2050 646 fi
ihse@975 647 elif test "x$TOOLCHAIN_TYPE" = xsolstudio; then
mduigou@1073 648 COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS $COMMON_CCXXFLAGS_JDK -DTRACING -DMACRO_MEMSYS_OPS -DBREAKPTS"
ihse@975 649 if test "x$OPENJDK_TARGET_CPU_ARCH" = xx86; then
mduigou@1073 650 COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -DcpuIntel -Di586 -D$OPENJDK_TARGET_CPU_LEGACY_LIB"
ihse@975 651 fi
mduigou@1073 652
ihse@975 653 CFLAGS_JDK="$CFLAGS_JDK -xc99=%none -xCC -errshort=tags -Xa -v -mt -W0,-noglobal"
ihse@975 654 CXXFLAGS_JDK="$CXXFLAGS_JDK -errtags=yes +w -mt -features=no%except -DCC_NOEX -norunpath -xnolib"
ihse@975 655 elif test "x$TOOLCHAIN_TYPE" = xxlc; then
ihse@975 656 CFLAGS_JDK="$CFLAGS_JDK -D_GNU_SOURCE -D_REENTRANT -D_LARGEFILE64_SOURCE -DSTDC"
ihse@975 657 CXXFLAGS_JDK="$CXXFLAGS_JDK -D_GNU_SOURCE -D_REENTRANT -D_LARGEFILE64_SOURCE -DSTDC"
ihse@975 658 elif test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
erikj@1355 659 COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS $COMMON_CCXXFLAGS_JDK \
erikj@2345 660 -MD -Zc:wchar_t- -W3 -wd4800 \
erikj@1355 661 -DWIN32_LEAN_AND_MEAN \
erikj@1355 662 -D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE \
erikj@1627 663 -D_WINSOCK_DEPRECATED_NO_WARNINGS \
erikj@1355 664 -DWIN32 -DIAL"
ihse@975 665 if test "x$OPENJDK_TARGET_CPU" = xx86_64; then
mduigou@1073 666 COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -D_AMD64_ -Damd64"
ihse@975 667 else
mduigou@1073 668 COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -D_X86_ -Dx86"
ihse@975 669 fi
erikj@1355 670 # If building with Visual Studio 2010, we can still use _STATIC_CPPLIB to
erikj@1355 671 # avoid bundling msvcpNNN.dll. Doesn't work with newer versions of visual
erikj@1355 672 # studio.
erikj@1355 673 if test "x$TOOLCHAIN_VERSION" = "x2010"; then
ihse@2275 674 STATIC_CPPLIB_FLAGS="-D_STATIC_CPPLIB -D_DISABLE_DEPRECATE_STATIC_CPPLIB"
ihse@2275 675 COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK $STATIC_CPPLIB_FLAGS"
erikj@1355 676 fi
ihse@975 677 fi
erikj@457 678
ihse@837 679 ###############################################################################
erikj@457 680
ihse@837 681 # Adjust flags according to debug level.
ihse@837 682 case $DEBUG_LEVEL in
mduigou@1073 683 fastdebug | slowdebug )
mduigou@1073 684 CFLAGS_JDK="$CFLAGS_JDK $CFLAGS_DEBUG_SYMBOLS $CFLAGS_DEBUG_OPTIONS"
mduigou@1073 685 CXXFLAGS_JDK="$CXXFLAGS_JDK $CXXFLAGS_DEBUG_SYMBOLS $CXXFLAGS_DEBUG_OPTIONS"
ihse@837 686 JAVAC_FLAGS="$JAVAC_FLAGS -g"
ihse@837 687 ;;
mduigou@1073 688 release )
mduigou@1073 689 ;;
mduigou@1073 690 * )
mduigou@1073 691 AC_MSG_ERROR([Unrecognized \$DEBUG_LEVEL: $DEBUG_LEVEL])
ihse@837 692 ;;
ihse@837 693 esac
erikj@737 694
ihse@975 695 # Setup LP64
mduigou@1073 696 COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK $ADD_LP64"
erikj@457 697
ihse@975 698 # Set some common defines. These works for all compilers, but assume
ihse@975 699 # -D is universally accepted.
erikj@457 700
ihse@975 701 # Setup endianness
ihse@837 702 if test "x$OPENJDK_TARGET_CPU_ENDIAN" = xlittle; then
ohair@476 703 # The macro _LITTLE_ENDIAN needs to be defined the same to avoid the
ohair@476 704 # Sun C compiler warning message: warning: macro redefined: _LITTLE_ENDIAN
ohair@476 705 # (The Solaris X86 system defines this in file /usr/include/sys/isa_defs.h).
ohair@476 706 # Note: -Dmacro is the same as #define macro 1
ihse@837 707 # -Dmacro= is the same as #define macro
ohair@476 708 if test "x$OPENJDK_TARGET_OS" = xsolaris; then
mduigou@1073 709 COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -D_LITTLE_ENDIAN="
ohair@476 710 else
mduigou@1073 711 COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -D_LITTLE_ENDIAN"
ohair@476 712 fi
ihse@837 713 else
erikj@1012 714 # Same goes for _BIG_ENDIAN. Do we really need to set *ENDIAN on Solaris if they
erikj@1012 715 # are defined in the system?
erikj@1012 716 if test "x$OPENJDK_TARGET_OS" = xsolaris; then
mduigou@1073 717 COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -D_BIG_ENDIAN="
erikj@1012 718 else
mduigou@1073 719 COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -D_BIG_ENDIAN"
erikj@1012 720 fi
ihse@837 721 fi
mduigou@1073 722
ihse@975 723 # Setup target OS define. Use OS target name but in upper case.
ihse@975 724 OPENJDK_TARGET_OS_UPPERCASE=`$ECHO $OPENJDK_TARGET_OS | $TR 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
mduigou@1073 725 COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -D$OPENJDK_TARGET_OS_UPPERCASE"
ihse@975 726
ihse@975 727 # Setup target CPU
mduigou@1073 728 COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -DARCH='\"$OPENJDK_TARGET_CPU_LEGACY\"' -D$OPENJDK_TARGET_CPU_LEGACY"
mduigou@1073 729
ihse@975 730 # Setup debug/release defines
ihse@837 731 if test "x$DEBUG_LEVEL" = xrelease; then
mduigou@1073 732 COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -DNDEBUG"
ihse@975 733 if test "x$OPENJDK_TARGET_OS" = xsolaris; then
mduigou@1073 734 COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -DTRIMMED"
ihse@975 735 fi
ihse@837 736 else
mduigou@1073 737 COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -DDEBUG"
ihse@837 738 fi
erikj@457 739
ihse@975 740 # Set some additional per-OS defines.
ihse@975 741 if test "x$OPENJDK_TARGET_OS" = xmacosx; then
mduigou@1073 742 COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -D_ALLBSD_SOURCE -D_DARWIN_UNLIMITED_SELECT"
ihse@975 743 elif test "x$OPENJDK_TARGET_OS" = xbsd; then
mduigou@1073 744 COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -D_ALLBSD_SOURCE"
ihse@975 745 fi
ihse@975 746
ihse@975 747 # Additional macosx handling
ihse@975 748 if test "x$OPENJDK_TARGET_OS" = xmacosx; then
ddehaven@1077 749 # Setting these parameters makes it an error to link to macosx APIs that are
ddehaven@1077 750 # newer than the given OS version and makes the linked binaries compatible
ddehaven@1077 751 # even if built on a newer version of the OS.
ddehaven@1077 752 # The expected format is X.Y.Z
ddehaven@1077 753 MACOSX_VERSION_MIN=10.7.0
ddehaven@1077 754 AC_SUBST(MACOSX_VERSION_MIN)
ihse@975 755
ddehaven@1077 756 # The macro takes the version with no dots, ex: 1070
ddehaven@1077 757 # Let the flags variables get resolved in make for easier override on make
ddehaven@1077 758 # command line.
ddehaven@1077 759 COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -DMAC_OS_X_VERSION_MAX_ALLOWED=\$(subst .,,\$(MACOSX_VERSION_MIN)) -mmacosx-version-min=\$(MACOSX_VERSION_MIN)"
ddehaven@1077 760 LDFLAGS_JDK="$LDFLAGS_JDK -mmacosx-version-min=\$(MACOSX_VERSION_MIN)"
ihse@975 761 fi
ihse@975 762
ihse@975 763 # Setup some hard coded includes
mduigou@1073 764 COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK \
chegar@1128 765 -I${JDK_TOPDIR}/src/java.base/share/native/include \
chegar@1128 766 -I${JDK_TOPDIR}/src/java.base/$OPENJDK_TARGET_OS/native/include \
bobv@1939 767 -I${JDK_TOPDIR}/src/java.base/$OPENJDK_TARGET_OS_TYPE/native/include \
ihse@2103 768 -I${JDK_TOPDIR}/src/java.base/share/native/libjava \
bobv@1939 769 -I${JDK_TOPDIR}/src/java.base/$OPENJDK_TARGET_OS_TYPE/native/libjava"
erikj@457 770
ihse@837 771 # The shared libraries are compiled using the picflag.
mduigou@1073 772 CFLAGS_JDKLIB="$COMMON_CCXXFLAGS_JDK $CFLAGS_JDK $PICFLAG $CFLAGS_JDKLIB_EXTRA"
erikj@1467 773 CXXFLAGS_JDKLIB="$COMMON_CCXXFLAGS_JDK $CXXFLAGS_JDK $PICFLAG $CXXFLAGS_JDKLIB_EXTRA"
erikj@457 774
ihse@837 775 # Executable flags
mduigou@1073 776 CFLAGS_JDKEXE="$COMMON_CCXXFLAGS_JDK $CFLAGS_JDK"
mduigou@1073 777 CXXFLAGS_JDKEXE="$COMMON_CCXXFLAGS_JDK $CXXFLAGS_JDK"
erikj@457 778
ihse@975 779 AC_SUBST(CFLAGS_JDKLIB)
ihse@975 780 AC_SUBST(CFLAGS_JDKEXE)
ihse@975 781 AC_SUBST(CXXFLAGS_JDKLIB)
ihse@975 782 AC_SUBST(CXXFLAGS_JDKEXE)
ihse@975 783
erikj@1467 784 # Flags for compiling test libraries
erikj@1467 785 CFLAGS_TESTLIB="$COMMON_CCXXFLAGS_JDK $CFLAGS_JDK $PICFLAG $CFLAGS_JDKLIB_EXTRA"
erikj@1467 786 CXXFLAGS_TESTLIB="$COMMON_CCXXFLAGS_JDK $CXXFLAGS_JDK $PICFLAG $CXXFLAGS_JDKLIB_EXTRA"
erikj@1467 787
erikj@1467 788 # Flags for compiling test executables
erikj@1467 789 CFLAGS_TESTEXE="$COMMON_CCXXFLAGS_JDK $CFLAGS_JDK"
erikj@1467 790 CXXFLAGS_TESTEXE="$COMMON_CCXXFLAGS_JDK $CXXFLAGS_JDK"
erikj@1467 791
erikj@1467 792 AC_SUBST(CFLAGS_TESTLIB)
erikj@1467 793 AC_SUBST(CFLAGS_TESTEXE)
erikj@1467 794 AC_SUBST(CXXFLAGS_TESTLIB)
erikj@1467 795 AC_SUBST(CXXFLAGS_TESTEXE)
erikj@1467 796
ihse@975 797 # Setup LDFLAGS et al.
ihse@975 798 #
mduigou@1073 799
ihse@975 800 if test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
ihse@2275 801 LDFLAGS_MICROSOFT="-nologo -opt:ref"
ihse@2275 802 LDFLAGS_JDK="$LDFLAGS_JDK $LDFLAGS_MICROSOFT -incremental:no"
ihse@975 803 if test "x$OPENJDK_TARGET_CPU_BITS" = "x32"; then
ihse@2275 804 LDFLAGS_SAFESH="-safeseh"
ihse@2275 805 LDFLAGS_JDK="$LDFLAGS_JDK $LDFLAGS_SAFESH"
erikj@457 806 fi
mduigou@1073 807 elif test "x$TOOLCHAIN_TYPE" = xgcc; then
mduigou@1073 808 # If this is a --hash-style=gnu system, use --hash-style=both, why?
mduigou@1073 809 # We have previously set HAS_GNU_HASH if this is the case
mduigou@1073 810 if test -n "$HAS_GNU_HASH"; then
ihse@2275 811 LDFLAGS_HASH_STYLE="-Wl,--hash-style=both"
ihse@2275 812 LDFLAGS_JDK="${LDFLAGS_JDK} $LDFLAGS_HASH_STYLE"
mduigou@1073 813 fi
mduigou@1073 814 if test "x$OPENJDK_TARGET_OS" = xlinux; then
mduigou@1073 815 # And since we now know that the linker is gnu, then add -z defs, to forbid
mduigou@1073 816 # undefined symbols in object files.
ihse@2275 817 LDFLAGS_NO_UNDEF_SYM="-Wl,-z,defs"
ihse@2275 818 LDFLAGS_JDK="${LDFLAGS_JDK} $LDFLAGS_NO_UNDEF_SYM"
mduigou@1073 819 case $DEBUG_LEVEL in
mduigou@1073 820 release )
mduigou@1073 821 # tell linker to optimize libraries.
mduigou@1073 822 # Should this be supplied to the OSS linker as well?
ihse@2275 823 LDFLAGS_DEBUGLEVEL_release="-Wl,-O1"
ihse@2275 824 LDFLAGS_JDK="${LDFLAGS_JDK} $LDFLAGS_DEBUGLEVEL_release"
mduigou@1073 825 ;;
mduigou@1073 826 slowdebug )
mduigou@1073 827 if test "x$HAS_LINKER_NOW" = "xtrue"; then
mduigou@1073 828 # do relocations at load
mduigou@1073 829 LDFLAGS_JDK="$LDFLAGS_JDK $LINKER_NOW_FLAG"
mduigou@1073 830 LDFLAGS_CXX_JDK="$LDFLAGS_CXX_JDK $LINKER_NOW_FLAG"
mduigou@1073 831 fi
mduigou@1073 832 if test "x$HAS_LINKER_RELRO" = "xtrue"; then
mduigou@1073 833 # mark relocations read only
mduigou@1073 834 LDFLAGS_JDK="$LDFLAGS_JDK $LINKER_RELRO_FLAG"
mduigou@1073 835 LDFLAGS_CXX_JDK="$LDFLAGS_CXX_JDK $LINKER_RELRO_FLAG"
mduigou@1073 836 fi
mduigou@1073 837 ;;
mduigou@1073 838 fastdebug )
mduigou@1073 839 if test "x$HAS_LINKER_RELRO" = "xtrue"; then
mduigou@1073 840 # mark relocations read only
mduigou@1073 841 LDFLAGS_JDK="$LDFLAGS_JDK $LINKER_RELRO_FLAG"
mduigou@1073 842 LDFLAGS_CXX_JDK="$LDFLAGS_CXX_JDK $LINKER_RELRO_FLAG"
mduigou@1073 843 fi
mduigou@1073 844 ;;
mduigou@1073 845 * )
mduigou@1073 846 AC_MSG_ERROR([Unrecognized \$DEBUG_LEVEL: $DEBUG_LEVEL])
mduigou@1073 847 ;;
mduigou@1073 848 esac
mduigou@1073 849 fi
mduigou@1073 850 elif test "x$TOOLCHAIN_TYPE" = xsolstudio; then
ihse@2275 851 LDFLAGS_SOLSTUDIO="-Wl,-z,defs"
ihse@2275 852 LDFLAGS_JDK="$LDFLAGS_JDK $LDFLAGS_SOLSTUDIO -xildoff -ztext"
ihse@2275 853 LDFLAGS_CXX_SOLSTUDIO="-norunpath"
ihse@2275 854 LDFLAGS_CXX_JDK="$LDFLAGS_CXX_JDK $LDFLAGS_CXX_SOLSTUDIO -xnolib"
simonis@1495 855 elif test "x$TOOLCHAIN_TYPE" = xxlc; then
simonis@2304 856 LDFLAGS_XLC="-b64 -brtl -bnolibpath -bexpall -bernotok"
ihse@2275 857 LDFLAGS_JDK="${LDFLAGS_JDK} $LDFLAGS_XLC"
mduigou@1073 858 fi
mduigou@1073 859
mduigou@1073 860 # Customize LDFLAGS for executables
mduigou@1073 861
mduigou@1073 862 LDFLAGS_JDKEXE="${LDFLAGS_JDK}"
mduigou@1073 863
mduigou@1073 864 if test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
erikj@457 865 if test "x$OPENJDK_TARGET_CPU_BITS" = "x64"; then
ihse@837 866 LDFLAGS_STACK_SIZE=1048576
erikj@457 867 else
ihse@837 868 LDFLAGS_STACK_SIZE=327680
erikj@457 869 fi
mduigou@1073 870 LDFLAGS_JDKEXE="${LDFLAGS_JDKEXE} /STACK:$LDFLAGS_STACK_SIZE"
mduigou@1073 871 elif test "x$OPENJDK_TARGET_OS" = xlinux; then
ihse@2050 872 LDFLAGS_JDKEXE="$LDFLAGS_JDKEXE -Wl,--allow-shlib-undefined"
mduigou@1073 873 fi
mduigou@1073 874
mduigou@1073 875 # Customize LDFLAGS for libs
mduigou@1073 876 LDFLAGS_JDKLIB="${LDFLAGS_JDK}"
mduigou@1073 877
ihse@2050 878 LDFLAGS_JDKLIB="${LDFLAGS_JDKLIB} ${SHARED_LIBRARY_FLAGS}"
mduigou@1073 879 if test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
ihse@2050 880 LDFLAGS_JDKLIB="${LDFLAGS_JDKLIB} \
ihse@2050 881 -libpath:${OUTPUT_ROOT}/support/modules_libs/java.base"
ihse@1899 882 JDKLIB_LIBS=""
ihse@837 883 else
ihse@2050 884 LDFLAGS_JDKLIB="${LDFLAGS_JDKLIB} \
chegar@1303 885 -L${OUTPUT_ROOT}/support/modules_libs/java.base${OPENJDK_TARGET_CPU_LIBDIR}"
ohair@476 886
erikj@515 887 # On some platforms (mac) the linker warns about non existing -L dirs.
erikj@517 888 # Add server first if available. Linking aginst client does not always produce the same results.
dholmes@540 889 # Only add client dir if client is being built. Add minimal (note not minimal1) if only building minimal1.
dholmes@540 890 # Default to server for other variants.
erikj@517 891 if test "x$JVM_VARIANT_SERVER" = xtrue; then
chegar@1303 892 LDFLAGS_JDKLIB="${LDFLAGS_JDKLIB} -L${OUTPUT_ROOT}/support/modules_libs/java.base${OPENJDK_TARGET_CPU_LIBDIR}/server"
erikj@517 893 elif test "x$JVM_VARIANT_CLIENT" = xtrue; then
chegar@1303 894 LDFLAGS_JDKLIB="${LDFLAGS_JDKLIB} -L${OUTPUT_ROOT}/support/modules_libs/java.base${OPENJDK_TARGET_CPU_LIBDIR}/client"
dholmes@540 895 elif test "x$JVM_VARIANT_MINIMAL1" = xtrue; then
chegar@1303 896 LDFLAGS_JDKLIB="${LDFLAGS_JDKLIB} -L${OUTPUT_ROOT}/support/modules_libs/java.base${OPENJDK_TARGET_CPU_LIBDIR}/minimal"
erikj@515 897 else
chegar@1303 898 LDFLAGS_JDKLIB="${LDFLAGS_JDKLIB} -L${OUTPUT_ROOT}/support/modules_libs/java.base${OPENJDK_TARGET_CPU_LIBDIR}/server"
erikj@515 899 fi
erikj@515 900
ihse@1899 901 JDKLIB_LIBS="-ljava -ljvm"
ihse@975 902 if test "x$TOOLCHAIN_TYPE" = xsolstudio; then
ihse@1899 903 JDKLIB_LIBS="$JDKLIB_LIBS -lc"
erikj@457 904 fi
mduigou@1073 905 fi
erikj@457 906
ihse@837 907 AC_SUBST(LDFLAGS_JDKLIB)
ihse@837 908 AC_SUBST(LDFLAGS_JDKEXE)
ihse@1899 909 AC_SUBST(JDKLIB_LIBS)
ihse@1899 910 AC_SUBST(JDKEXE_LIBS)
ihse@837 911 AC_SUBST(LDFLAGS_CXX_JDK)
ihse@2303 912 AC_SUBST(LDFLAGS_HASH_STYLE)
erikj@1467 913
erikj@1467 914 LDFLAGS_TESTLIB="$LDFLAGS_JDKLIB"
erikj@1467 915 LDFLAGS_TESTEXE="$LDFLAGS_JDKEXE"
erikj@1467 916
erikj@1467 917 AC_SUBST(LDFLAGS_TESTLIB)
erikj@1467 918 AC_SUBST(LDFLAGS_TESTEXE)
erikj@457 919 ])
erikj@696 920
ihse@2103 921 # FLAGS_COMPILER_CHECK_ARGUMENTS(ARGUMENT: [ARGUMENT], IF_TRUE: [RUN-IF-TRUE],
ihse@2103 922 # IF_FALSE: [RUN-IF-FALSE])
erikj@696 923 # ------------------------------------------------------------
erikj@696 924 # Check that the c and c++ compilers support an argument
ihse@2103 925 BASIC_DEFUN_NAMED([FLAGS_COMPILER_CHECK_ARGUMENTS],
ihse@2103 926 [*ARGUMENT IF_TRUE IF_FALSE], [$@],
erikj@696 927 [
ihse@2103 928 AC_MSG_CHECKING([if compiler supports "ARG_ARGUMENT"])
erikj@696 929 supports=yes
erikj@696 930
erikj@696 931 saved_cflags="$CFLAGS"
ihse@2103 932 CFLAGS="$CFLAGS ARG_ARGUMENT"
erikj@696 933 AC_LANG_PUSH([C])
mduigou@1073 934 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[int i;]])], [],
ihse@837 935 [supports=no])
erikj@696 936 AC_LANG_POP([C])
erikj@696 937 CFLAGS="$saved_cflags"
erikj@696 938
erikj@696 939 saved_cxxflags="$CXXFLAGS"
ihse@2103 940 CXXFLAGS="$CXXFLAG ARG_ARGUMENT"
erikj@696 941 AC_LANG_PUSH([C++])
mduigou@1073 942 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[int i;]])], [],
ihse@837 943 [supports=no])
erikj@696 944 AC_LANG_POP([C++])
erikj@696 945 CXXFLAGS="$saved_cxxflags"
erikj@696 946
erikj@696 947 AC_MSG_RESULT([$supports])
erikj@696 948 if test "x$supports" = "xyes" ; then
ihse@2103 949 :
ihse@2103 950 ARG_IF_TRUE
erikj@696 951 else
ihse@2103 952 :
ihse@2103 953 ARG_IF_FALSE
erikj@696 954 fi
erikj@696 955 ])
erikj@696 956
ihse@2103 957 # FLAGS_LINKER_CHECK_ARGUMENTS(ARGUMENT: [ARGUMENT], IF_TRUE: [RUN-IF-TRUE],
ihse@2103 958 # IF_FALSE: [RUN-IF-FALSE])
mduigou@1073 959 # ------------------------------------------------------------
mduigou@1073 960 # Check that the linker support an argument
ihse@2103 961 BASIC_DEFUN_NAMED([FLAGS_LINKER_CHECK_ARGUMENTS],
ihse@2103 962 [*ARGUMENT IF_TRUE IF_FALSE], [$@],
mduigou@1073 963 [
ihse@2103 964 AC_MSG_CHECKING([if linker supports "ARG_ARGUMENT"])
mduigou@1073 965 supports=yes
mduigou@1073 966
mduigou@1073 967 saved_ldflags="$LDFLAGS"
ihse@2103 968 LDFLAGS="$LDFLAGS ARG_ARGUMENT"
mduigou@1073 969 AC_LANG_PUSH([C])
mduigou@1073 970 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]],[[]])],
mduigou@1073 971 [], [supports=no])
mduigou@1073 972 AC_LANG_POP([C])
mduigou@1073 973 LDFLAGS="$saved_ldflags"
mduigou@1073 974
mduigou@1073 975 AC_MSG_RESULT([$supports])
mduigou@1073 976 if test "x$supports" = "xyes" ; then
ihse@2103 977 :
ihse@2103 978 ARG_IF_TRUE
mduigou@1073 979 else
ihse@2103 980 :
ihse@2103 981 ARG_IF_FALSE
mduigou@1073 982 fi
mduigou@1073 983 ])
mduigou@1073 984
ihse@975 985 AC_DEFUN_ONCE([FLAGS_SETUP_COMPILER_FLAGS_MISC],
erikj@696 986 [
erikj@696 987 # Some Zero and Shark settings.
erikj@696 988 # ZERO_ARCHFLAG tells the compiler which mode to build for
erikj@696 989 case "${OPENJDK_TARGET_CPU}" in
erikj@696 990 s390)
simonis@945 991 ZERO_ARCHFLAG="${COMPILER_TARGET_BITS_FLAG}31"
erikj@696 992 ;;
erikj@696 993 *)
simonis@945 994 ZERO_ARCHFLAG="${COMPILER_TARGET_BITS_FLAG}${OPENJDK_TARGET_CPU_BITS}"
erikj@696 995 esac
ihse@2103 996 FLAGS_COMPILER_CHECK_ARGUMENTS(ARGUMENT: [$ZERO_ARCHFLAG], IF_FALSE: [ZERO_ARCHFLAG=""])
erikj@696 997 AC_SUBST(ZERO_ARCHFLAG)
erikj@696 998
simonis@945 999 # Check that the compiler supports -mX (or -qX on AIX) flags
erikj@696 1000 # Set COMPILER_SUPPORTS_TARGET_BITS_FLAG to 'true' if it does
ihse@2103 1001 FLAGS_COMPILER_CHECK_ARGUMENTS(ARGUMENT: [${COMPILER_TARGET_BITS_FLAG}${OPENJDK_TARGET_CPU_BITS}],
ihse@2103 1002 IF_TRUE: [COMPILER_SUPPORTS_TARGET_BITS_FLAG=true],
ihse@2103 1003 IF_FALSE: [COMPILER_SUPPORTS_TARGET_BITS_FLAG=false])
erikj@696 1004 AC_SUBST(COMPILER_SUPPORTS_TARGET_BITS_FLAG)
sla@1007 1005
ihse@1585 1006 AC_ARG_ENABLE([warnings-as-errors], [AS_HELP_STRING([--disable-warnings-as-errors],
ihse@1585 1007 [do not consider native warnings to be an error @<:@enabled@:>@])])
ihse@1585 1008
ihse@1585 1009 AC_MSG_CHECKING([if native warnings are errors])
ihse@1585 1010 if test "x$enable_warnings_as_errors" = "xyes"; then
ihse@1585 1011 AC_MSG_RESULT([yes (explicitely set)])
ihse@1585 1012 WARNINGS_AS_ERRORS=true
ihse@1585 1013 elif test "x$enable_warnings_as_errors" = "xno"; then
ihse@1585 1014 AC_MSG_RESULT([no])
ihse@1585 1015 WARNINGS_AS_ERRORS=false
ihse@1585 1016 elif test "x$enable_warnings_as_errors" = "x"; then
ihse@1585 1017 AC_MSG_RESULT([yes (default)])
ihse@1585 1018 WARNINGS_AS_ERRORS=true
ihse@1585 1019 else
ihse@1585 1020 AC_MSG_ERROR([--enable-warnings-as-errors accepts no argument])
ihse@1585 1021 fi
ihse@1930 1022
ihse@1930 1023 if test "x$WARNINGS_AS_ERRORS" = "xfalse"; then
ihse@1930 1024 # Set legacy hotspot variable
erikj@1932 1025 HOTSPOT_SET_WARNINGS_AS_ERRORS="WARNINGS_ARE_ERRORS="
ihse@1930 1026 else
erikj@1932 1027 HOTSPOT_SET_WARNINGS_AS_ERRORS=""
ihse@1930 1028 fi
ihse@1930 1029
ihse@1585 1030 AC_SUBST(WARNINGS_AS_ERRORS)
ihse@1930 1031 AC_SUBST(HOTSPOT_SET_WARNINGS_AS_ERRORS)
ihse@1585 1032
sla@1007 1033 case "${TOOLCHAIN_TYPE}" in
sla@1007 1034 microsoft)
ihse@1466 1035 DISABLE_WARNING_PREFIX="-wd"
erikj@1130 1036 CFLAGS_WARNINGS_ARE_ERRORS="-WX"
sla@1007 1037 ;;
sla@1007 1038 solstudio)
ihse@1466 1039 DISABLE_WARNING_PREFIX="-erroff="
sla@1007 1040 CFLAGS_WARNINGS_ARE_ERRORS="-errtags -errwarn=%all"
sla@1007 1041 ;;
sla@1007 1042 gcc)
ihse@1466 1043 # Prior to gcc 4.4, a -Wno-X where X is unknown for that version of gcc will cause an error
ihse@2103 1044 FLAGS_COMPILER_CHECK_ARGUMENTS(ARGUMENT: [-Wno-this-is-a-warning-that-do-not-exist],
ihse@2103 1045 IF_TRUE: [GCC_CAN_DISABLE_WARNINGS=true],
ihse@2103 1046 IF_FALSE: [GCC_CAN_DISABLE_WARNINGS=false]
ihse@1466 1047 )
ihse@1466 1048 if test "x$GCC_CAN_DISABLE_WARNINGS" = "xtrue"; then
ihse@1466 1049 DISABLE_WARNING_PREFIX="-Wno-"
ihse@1466 1050 else
ihse@1466 1051 DISABLE_WARNING_PREFIX=
ihse@1466 1052 fi
sla@1007 1053 CFLAGS_WARNINGS_ARE_ERRORS="-Werror"
erikj@1997 1054 # Repeate the check for the BUILD_CC
erikj@1997 1055 CC_OLD="$CC"
erikj@1997 1056 CC="$BUILD_CC"
ihse@2103 1057 FLAGS_COMPILER_CHECK_ARGUMENTS(ARGUMENT: [-Wno-this-is-a-warning-that-do-not-exist],
ihse@2103 1058 IF_TRUE: [BUILD_CC_CAN_DISABLE_WARNINGS=true],
ihse@2103 1059 IF_FALSE: [BUILD_CC_CAN_DISABLE_WARNINGS=false]
erikj@1997 1060 )
erikj@1997 1061 if test "x$BUILD_CC_CAN_DISABLE_WARNINGS" = "xtrue"; then
erikj@1997 1062 BUILD_CC_DISABLE_WARNING_PREFIX="-Wno-"
erikj@1997 1063 else
erikj@1997 1064 BUILD_CC_DISABLE_WARNING_PREFIX=
erikj@1997 1065 fi
erikj@1997 1066 CC="$CC_OLD"
sla@1007 1067 ;;
sla@1007 1068 clang)
ihse@1466 1069 DISABLE_WARNING_PREFIX="-Wno-"
sla@1007 1070 CFLAGS_WARNINGS_ARE_ERRORS="-Werror"
sla@1007 1071 ;;
ihse@2275 1072 xlc)
ihse@2275 1073 DISABLE_WARNING_PREFIX="-qsuppress="
ihse@2275 1074 CFLAGS_WARNINGS_ARE_ERRORS="-qhalt=w"
ihse@2275 1075 ;;
sla@1007 1076 esac
ihse@1466 1077 AC_SUBST(DISABLE_WARNING_PREFIX)
sla@1007 1078 AC_SUBST(CFLAGS_WARNINGS_ARE_ERRORS)
erikj@696 1079 ])