1 #
   2 # Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved.
   3 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4 #
   5 # This code is free software; you can redistribute it and/or modify it
   6 # under the terms of the GNU General Public License version 2 only, as
   7 # published by the Free Software Foundation.
   8 #
   9 # This code is distributed in the hope that it will be useful, but WITHOUT
  10 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11 # FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12 # version 2 for more details (a copy is included in the LICENSE file that
  13 # accompanied this code).
  14 #
  15 # You should have received a copy of the GNU General Public License version
  16 # 2 along with this work; if not, write to the Free Software Foundation,
  17 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18 #
  19 # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20 # or visit www.oracle.com if you need additional information or have any
  21 # questions.
  22 #
  23 #
  24 
  25 OS_VENDOR = $(shell uname -s)
  26 
  27 #------------------------------------------------------------------------
  28 # CC, CXX & AS
  29 
  30 # If a SPEC is not set already, then use these defaults.
  31 ifeq ($(SPEC),)
  32   # When cross-compiling the ALT_COMPILER_PATH points
  33   # to the cross-compilation toolset
  34   ifdef CROSS_COMPILE_ARCH
  35     CXX = $(ALT_COMPILER_PATH)/g++
  36     CC  = $(ALT_COMPILER_PATH)/gcc
  37     HOSTCXX = g++
  38     HOSTCC  = gcc
  39   else ifneq ($(OS_VENDOR), Darwin)
  40     CXX = g++
  41     CC  = gcc
  42     HOSTCXX = $(CXX)
  43     HOSTCC  = $(CC)
  44   endif
  45 
  46   # i486 hotspot requires -mstackrealign on Darwin.
  47   # llvm-gcc supports this in Xcode 3.2.6 and 4.0.
  48   # gcc-4.0 supports this on earlier versions.
  49   # Prefer llvm-gcc where available.
  50   ifeq ($(OS_VENDOR), Darwin)
  51     ifeq ($(origin CXX), default)
  52       CXX = llvm-g++
  53     endif
  54     ifeq ($(origin CC), default)
  55       CC  = llvm-gcc
  56     endif
  57 
  58     ifeq ($(ARCH), i486)
  59       LLVM_SUPPORTS_STACKREALIGN := $(shell \
  60        [ "0"`llvm-gcc -v 2>&1 | grep LLVM | sed -E "s/.*LLVM build ([0-9]+).*/\1/"` -gt "2333" ] \
  61        && echo true || echo false)
  62 
  63       ifeq ($(LLVM_SUPPORTS_STACKREALIGN), true)
  64         CXX32 ?= llvm-g++
  65         CC32  ?= llvm-gcc
  66       else
  67         CXX32 ?= g++-4.0
  68         CC32  ?= gcc-4.0
  69       endif
  70       CXX = $(CXX32)
  71       CC  = $(CC32)
  72     endif
  73 
  74     ifeq ($(USE_CLANG), true)
  75       CXX = clang++
  76       CC  = clang
  77     endif
  78 
  79     HOSTCXX = $(CXX)
  80     HOSTCC  = $(CC)
  81   endif
  82 
  83   AS  = $(CC) -c
  84 endif
  85 
  86 ifeq ($(OS_VENDOR), Darwin)
  87   ifeq ($(DSYMUTIL),)
  88     DSYMUTIL=dsymutil
  89   endif
  90 endif
  91 
  92 ifeq ($(USE_CLANG), true)
  93   CC_VER_MAJOR := $(shell $(CC) -v 2>&1 | grep version | sed "s/.*version \([0-9]*\.[0-9]*\).*/\1/" | cut -d'.' -f1)
  94   CC_VER_MINOR := $(shell $(CC) -v 2>&1 | grep version | sed "s/.*version \([0-9]*\.[0-9]*\).*/\1/" | cut -d'.' -f2)
  95 else
  96   # -dumpversion in gcc-2.91 shows "egcs-2.91.66". In later version, it only
  97   # prints the numbers (e.g. "2.95", "3.2.1")
  98   CC_VER_MAJOR := $(shell $(CC) -dumpversion | sed 's/egcs-//' | cut -d'.' -f1)
  99   CC_VER_MINOR := $(shell $(CC) -dumpversion | sed 's/egcs-//' | cut -d'.' -f2)
 100   CC_VER_MICRO := $(shell $(CC) -dumpversion | sed 's/egcs-//' | cut -d'.' -f3)
 101 endif
 102 
 103 ifeq ($(USE_CLANG), true)
 104   # Clang has precompiled headers support by default, but the user can switch
 105   # it off by using 'USE_PRECOMPILED_HEADER=0'.
 106   ifdef LP64
 107     ifeq ($(USE_PRECOMPILED_HEADER),)
 108       USE_PRECOMPILED_HEADER=1
 109     endif
 110   else
 111     # We don't support precompiled headers on 32-bit builds because there some files are
 112     # compiled with -fPIC while others are compiled without (see 'NONPIC_OBJ_FILES' rules.make)
 113     # Clang produces an error if the PCH file was compiled with other options than the actual compilation unit.
 114     USE_PRECOMPILED_HEADER=0
 115   endif
 116 
 117   ifeq ($(USE_PRECOMPILED_HEADER),1)
 118 
 119     ifndef LP64
 120       $(error " Precompiled Headers only supported on 64-bit platforms!")
 121     endif
 122 
 123     PRECOMPILED_HEADER_DIR=.
 124     PRECOMPILED_HEADER_SRC=$(GAMMADIR)/src/share/vm/precompiled/precompiled.hpp
 125     PRECOMPILED_HEADER=$(PRECOMPILED_HEADER_DIR)/precompiled.hpp.pch
 126 
 127     PCH_FLAG = -include precompiled.hpp
 128     PCH_FLAG/DEFAULT = $(PCH_FLAG)
 129     PCH_FLAG/NO_PCH = -DNO_PCH
 130     PCH_FLAG/BY_FILE = $(PCH_FLAG/$@)$(PCH_FLAG/DEFAULT$(PCH_FLAG/$@))
 131 
 132     VM_PCH_FLAG/LIBJVM = $(PCH_FLAG/BY_FILE)
 133     VM_PCH_FLAG/AOUT =
 134     VM_PCH_FLAG = $(VM_PCH_FLAG/$(LINK_INTO))
 135 
 136     # We only use precompiled headers for the JVM build
 137     CFLAGS += $(VM_PCH_FLAG)
 138 
 139     # The following files are compiled at various optimization
 140     # levels due to optimization issues encountered at the
 141     # 'OPT_CFLAGS_DEFAULT' level. The Clang compiler issues a compile
 142     # time error if there is an optimization level specification
 143     # skew between the PCH file and the C++ file.  Especially if the
 144     # PCH file is compiled at a higher optimization level than
 145     # the C++ file.  One solution might be to prepare extra optimization
 146     # level specific PCH files for the opt build and use them here, but
 147     # it's probably not worth the effort as long as only a few files
 148     # need this special handling.
 149     PCH_FLAG/loopTransform.o = $(PCH_FLAG/NO_PCH)
 150     PCH_FLAG/sharedRuntimeTrig.o = $(PCH_FLAG/NO_PCH)
 151     PCH_FLAG/sharedRuntimeTrans.o = $(PCH_FLAG/NO_PCH)
 152     PCH_FLAG/unsafe.o = $(PCH_FLAG/NO_PCH)
 153     PCH_FLAG/jvmciCompilerToVM.o = $(PCH_FLAG/NO_PCH)
 154 
 155   endif
 156 else # ($(USE_CLANG), true)
 157   # check for precompiled headers support
 158   ifneq "$(shell expr \( $(CC_VER_MAJOR) \> 3 \) \| \( \( $(CC_VER_MAJOR) = 3 \) \& \( $(CC_VER_MINOR) \>= 4 \) \))" "0"
 159     # Allow the user to turn off precompiled headers from the command line.
 160     ifneq ($(USE_PRECOMPILED_HEADER),0)
 161       PRECOMPILED_HEADER_DIR=.
 162       PRECOMPILED_HEADER_SRC=$(GAMMADIR)/src/share/vm/precompiled/precompiled.hpp
 163       PRECOMPILED_HEADER=$(PRECOMPILED_HEADER_DIR)/precompiled.hpp.gch
 164     endif
 165   endif
 166 endif
 167 
 168 # -DDONT_USE_PRECOMPILED_HEADER will exclude all includes in precompiled.hpp.
 169 ifeq ($(USE_PRECOMPILED_HEADER),0)
 170   CFLAGS += -DDONT_USE_PRECOMPILED_HEADER
 171 endif
 172 
 173 #------------------------------------------------------------------------
 174 # Compiler flags
 175 
 176 # position-independent code
 177 PICFLAG = -fPIC
 178 
 179 VM_PICFLAG/LIBJVM = $(PICFLAG)
 180 VM_PICFLAG/AOUT   =
 181 VM_PICFLAG        = $(VM_PICFLAG/$(LINK_INTO))
 182 
 183 ifeq ($(JVM_VARIANT_ZERO), true)
 184   CFLAGS += $(LIBFFI_CFLAGS)
 185 endif
 186 ifeq ($(JVM_VARIANT_ZEROSHARK), true)
 187   CFLAGS += $(LIBFFI_CFLAGS)
 188   CFLAGS += $(LLVM_CFLAGS)
 189 endif
 190 
 191 ifeq ($(STATIC_BUILD),true)
 192 CXXFLAGS += -DSTATIC_BUILD
 193 CFLAGS += -DSTATIC_BUILD
 194 else
 195 CFLAGS += $(VM_PICFLAG)
 196 endif
 197 
 198 CFLAGS += -fno-rtti
 199 CFLAGS += -fno-exceptions
 200 ifeq ($(USE_CLANG),)
 201   CFLAGS += -pthread
 202   CFLAGS += -fcheck-new
 203   # version 4 and above support fvisibility=hidden (matches jni_x86.h file)
 204   # except 4.1.2 gives pointless warnings that can't be disabled (afaik)
 205   ifneq "$(shell expr \( $(CC_VER_MAJOR) \> 4 \) \| \( \( $(CC_VER_MAJOR) = 4 \) \& \( $(CC_VER_MINOR) \>= 3 \) \))" "0"
 206     CFLAGS += -fvisibility=hidden
 207   endif
 208 else
 209   CFLAGS += -fvisibility=hidden
 210 endif
 211 
 212 ifeq ($(USE_CLANG), true)
 213   # Before Clang 3.1, we had to pass the stack alignment specification directly to llvm with the help of '-mllvm'
 214   # Starting with version 3.1, Clang understands the '-mstack-alignment' (and rejects '-mllvm -stack-alignment')
 215   ifneq "$(shell expr \( $(CC_VER_MAJOR) \> 3 \) \| \( \( $(CC_VER_MAJOR) = 3 \) \& \( $(CC_VER_MINOR) \>= 1 \) \))" "0"
 216     STACK_ALIGNMENT_OPT = -mno-omit-leaf-frame-pointer -mstack-alignment=16
 217   else
 218     STACK_ALIGNMENT_OPT = -mno-omit-leaf-frame-pointer -mllvm -stack-alignment=16
 219   endif
 220 endif
 221 
 222 ARCHFLAG = $(ARCHFLAG/$(BUILDARCH))
 223 ARCHFLAG/i486    = -m32 -march=i586
 224 ARCHFLAG/amd64   = -m64 $(STACK_ALIGNMENT_OPT)
 225 ARCHFLAG/ia64    =
 226 ARCHFLAG/sparc   = -m32 -mcpu=v9
 227 ARCHFLAG/sparcv9 = -m64 -mcpu=v9
 228 ARCHFLAG/zero    = $(ZERO_ARCHFLAG)
 229 
 230 # Darwin-specific build flags
 231 ifeq ($(OS_VENDOR), Darwin)
 232   # Ineffecient 16-byte stack re-alignment on Darwin/IA32
 233   ARCHFLAG/i486 += -mstackrealign
 234 endif
 235 
 236 CFLAGS     += $(ARCHFLAG)
 237 AOUT_FLAGS += $(ARCHFLAG)
 238 LFLAGS     += $(ARCHFLAG)
 239 ASFLAGS    += $(ARCHFLAG)
 240 
 241 ifdef E500V2
 242 CFLAGS += -DE500V2
 243 endif
 244 
 245 # Use C++ Interpreter
 246 ifdef CC_INTERP
 247   CFLAGS += -DCC_INTERP
 248 endif
 249 
 250 # Keep temporary files (.ii, .s)
 251 ifdef NEED_ASM
 252   CFLAGS += -save-temps
 253 else
 254   CFLAGS += -pipe
 255 endif
 256 
 257 # Compiler warnings are treated as errors
 258 ifneq ($(COMPILER_WARNINGS_FATAL),false)
 259   WARNINGS_ARE_ERRORS ?= -Werror
 260 endif
 261 
 262 ifeq ($(USE_CLANG), true)
 263   # However we need to clean the code up before we can unrestrictedly enable this option with Clang
 264   WARNINGS_ARE_ERRORS += -Wno-logical-op-parentheses -Wno-parentheses-equality -Wno-parentheses
 265   WARNINGS_ARE_ERRORS += -Wno-switch -Wno-tautological-compare
 266 # Not yet supported by clang in Xcode 4.6.2
 267 #  WARNINGS_ARE_ERRORS += -Wno-tautological-constant-out-of-range-compare
 268   WARNINGS_ARE_ERRORS += -Wno-delete-non-virtual-dtor -Wno-deprecated -Wno-format -Wno-dynamic-class-memaccess
 269   WARNINGS_ARE_ERRORS += -Wno-empty-body
 270 endif
 271 
 272 WARNING_FLAGS = -Wpointer-arith -Wsign-compare -Wundef -Wunused-function -Wformat=2
 273 
 274 ifeq ($(USE_CLANG),)
 275   # Since GCC 4.3, -Wconversion has changed its meanings to warn these implicit
 276   # conversions which might affect the values. Only enable it in earlier versions.
 277   ifeq "$(shell expr \( $(CC_VER_MAJOR) \> 4 \) \| \( \( $(CC_VER_MAJOR) = 4 \) \& \( $(CC_VER_MINOR) \>= 3 \) \))" "0"
 278     WARNINGS_FLAGS += -Wconversion
 279   endif
 280 endif
 281 
 282 CFLAGS_WARN/DEFAULT = $(WARNINGS_ARE_ERRORS) $(WARNING_FLAGS)
 283 # Special cases
 284 CFLAGS_WARN/BYFILE = $(CFLAGS_WARN/$@)$(CFLAGS_WARN/DEFAULT$(CFLAGS_WARN/$@))
 285 # XXXDARWIN: for _dyld_bind_fully_image_containing_address
 286 ifeq ($(OS_VENDOR), Darwin)
 287   CFLAGS_WARN/os_bsd.o = $(CFLAGS_WARN/DEFAULT) -Wno-deprecated-declarations
 288 endif
 289 
 290 # optimization control flags (Used by fastdebug and release variants)
 291 OPT_CFLAGS/NOOPT=-O0
 292 OPT_CFLAGS/DEBUG=-O0
 293 OPT_CFLAGS/SIZE=-Os
 294 OPT_CFLAGS/SPEED=-O3
 295 
 296 ifeq ($(OS_VENDOR), Darwin)
 297   # use -Os by default, unless -O3 can be proved to be worth the cost, as per policy
 298   # <https://wiki.openjdk.java.net/display/MacOSXPort/Compiler+Errata>
 299   OPT_CFLAGS_DEFAULT ?= SIZE
 300 else
 301   OPT_CFLAGS_DEFAULT ?= SPEED
 302 endif
 303 
 304 # Hotspot uses very unstrict aliasing turn this optimization off
 305 # This option is added to CFLAGS rather than OPT_CFLAGS
 306 # so that OPT_CFLAGS overrides get this option too.
 307 CFLAGS += -fno-strict-aliasing
 308 
 309 ifdef OPT_CFLAGS
 310   ifneq ("$(origin OPT_CFLAGS)", "command line")
 311     $(error " Use OPT_EXTRAS instead of OPT_CFLAGS to add extra flags to OPT_CFLAGS.")
 312   endif
 313 endif
 314 
 315 OPT_CFLAGS = $(OPT_CFLAGS/$(OPT_CFLAGS_DEFAULT)) $(OPT_EXTRAS)
 316 
 317 # The gcc compiler segv's on ia64 when compiling bytecodeInterpreter.cpp
 318 # if we use expensive-optimizations
 319 ifeq ($(BUILDARCH), ia64)
 320 OPT_CFLAGS += -fno-expensive-optimizations
 321 endif
 322 
 323 # Work around some compiler bugs.
 324 ifeq ($(USE_CLANG), true)
 325   # Clang < 6 | <= 6.1 | <= 7.0
 326   ifeq ($(shell expr \
 327       $(CC_VER_MAJOR) \< 6 \| \
 328       \( $(CC_VER_MAJOR) = 6 \& $(CC_VER_MINOR) \<= 1 \) \| \
 329       \( $(CC_VER_MAJOR) = 7 \& $(CC_VER_MINOR) \<= 0 \) \
 330     ), 1)
 331     OPT_CFLAGS/loopTransform.o += $(OPT_CFLAGS/NOOPT)
 332     OPT_CFLAGS/unsafe.o += -O1
 333 
 334     # The debug flag is added to OPT_CFLAGS, but lost in case of per-file overrides
 335     # of OPT_CFLAGS. Restore it here.
 336     ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1)
 337       OPT_CFLAGS/loopTransform.o += -g
 338       OPT_CFLAGS/unsafe.o += -g
 339     endif
 340   else
 341     $(error "Update compiler workarounds for Clang $(CC_VER_MAJOR).$(CC_VER_MINOR)")
 342   endif
 343 else
 344   # Do not allow GCC 4.1.1
 345   ifeq ($(shell expr $(CC_VER_MAJOR) = 4 \& $(CC_VER_MINOR) = 1 \& $(CC_VER_MICRO) = 1), 1)
 346     $(error "GCC $(CC_VER_MAJOR).$(CC_VER_MINOR).$(CC_VER_MICRO) not supported because of https://gcc.gnu.org/bugzilla/show_bug.cgi?id=27724")
 347   endif
 348   # 6835796. Problem in GCC 4.3.0 with mulnode.o optimized compilation.
 349   ifeq ($(shell expr $(CC_VER_MAJOR) = 4 \& $(CC_VER_MINOR) = 3), 1)
 350     OPT_CFLAGS/mulnode.o += $(OPT_CFLAGS/NOOPT)
 351   endif 
 352 endif
 353 
 354 # Flags for generating make dependency flags.
 355 DEPFLAGS = -MMD -MP -MF $(DEP_DIR)/$(@:%=%.d)
 356 ifeq ($(USE_CLANG),)
 357   ifneq ($(CC_VER_MAJOR), 2)
 358     DEPFLAGS += -fpch-deps
 359   endif
 360 endif
 361 
 362 # -DDONT_USE_PRECOMPILED_HEADER will exclude all includes in precompiled.hpp.
 363 ifeq ($(USE_PRECOMPILED_HEADER),0)
 364 CFLAGS += -DDONT_USE_PRECOMPILED_HEADER
 365 endif
 366 
 367 ifeq ($(OS_VENDOR), Darwin)
 368   # Setting these parameters makes it an error to link to macosx APIs that are
 369   # newer than the given OS version and makes the linked binaries compatible even
 370   # if built on a newer version of the OS.
 371   # The expected format is X.Y.Z
 372   ifeq ($(MACOSX_VERSION_MIN),)
 373     MACOSX_VERSION_MIN=10.7.0
 374   endif
 375   # The macro takes the version with no dots, ex: 1070
 376   CFLAGS += -DMAC_OS_X_VERSION_MAX_ALLOWED=$(subst .,,$(MACOSX_VERSION_MIN)) \
 377             -mmacosx-version-min=$(MACOSX_VERSION_MIN)
 378   LDFLAGS += -mmacosx-version-min=$(MACOSX_VERSION_MIN)
 379 endif
 380 
 381 
 382 #------------------------------------------------------------------------
 383 # Assembler flags
 384 
 385 # Enforce prerpocessing of .s files
 386 ASFLAGS += -x assembler-with-cpp
 387 
 388 #------------------------------------------------------------------------
 389 # Linker flags
 390 
 391 # statically link libstdc++.so, work with gcc but ignored by g++
 392 STATIC_STDCXX = -Wl,-Bstatic -lstdc++ -Wl,-Bdynamic
 393 
 394 # Ensure use libstdc++ on clang, not libc++
 395 ifeq ($(USE_CLANG), true)
 396   LFLAGS += -stdlib=libstdc++
 397 endif
 398 
 399 ifeq ($(USE_CLANG),)
 400   # statically link libgcc and/or libgcc_s, libgcc does not exist before gcc-3.x.
 401   ifneq ($(CC_VER_MAJOR), 2)
 402     STATIC_LIBGCC += -static-libgcc
 403   endif
 404 
 405   ifneq ($(OS_VENDOR), Darwin)
 406     ifneq (, findstring(debug,$(BUILD_FLAVOR)))
 407       # for relocations read-only
 408       LFLAGS += -Xlinker -z -Xlinker relro
 409 
 410       ifeq ($(BUILD_FLAVOR), debug)
 411         # disable incremental relocations linking
 412         LFLAGS += -Xlinker -z -Xlinker now
 413       endif
 414     endif
 415   endif
 416 
 417   ifeq ($(BUILDARCH), ia64)
 418     LFLAGS += -Wl,-relax
 419   endif
 420 endif
 421 
 422 # Use $(MAPFLAG:FILENAME=real_file_name) to specify a map file.
 423 MAPFLAG = -Xlinker --version-script=FILENAME
 424 
 425 #
 426 # Shared Library
 427 #
 428 ifeq ($(OS_VENDOR), Darwin)
 429   # Standard linker flags
 430   LFLAGS +=
 431 
 432   # The apple linker has its own variant of mapfiles/version-scripts
 433   MAPFLAG = -Xlinker -exported_symbols_list -Xlinker FILENAME
 434 
 435   # Use $(SONAMEFLAG:SONAME=soname) to specify the intrinsic name of a shared obj
 436   SONAMEFLAG =
 437 
 438   # Build shared library
 439   SHARED_FLAG = -Wl,-install_name,@rpath/$(@F) -dynamiclib -compatibility_version 1.0.0 -current_version 1.0.0 $(VM_PICFLAG)
 440 
 441   # Keep symbols even they are not used
 442   #AOUT_FLAGS += -Xlinker -export-dynamic
 443 else
 444   # Enable linker optimization
 445   LFLAGS += -Xlinker -O1
 446 
 447   # Use $(SONAMEFLAG:SONAME=soname) to specify the intrinsic name of a shared obj
 448   SONAMEFLAG = -Xlinker -soname=SONAME
 449 
 450   # Build shared library
 451   SHARED_FLAG = -shared $(VM_PICFLAG)
 452 
 453   # Keep symbols even they are not used
 454   AOUT_FLAGS += -Xlinker -export-dynamic
 455 endif
 456 
 457 #------------------------------------------------------------------------
 458 # Debug flags
 459 
 460 ifeq ($(USE_CLANG), true)
 461   # Restrict the debug information created by Clang to avoid
 462   # too big object files and speed the build up a little bit
 463   # (see http://llvm.org/bugs/show_bug.cgi?id=7554)
 464   CFLAGS += -flimit-debug-info
 465 endif
 466 
 467 # Allow no optimizations.
 468 DEBUG_CFLAGS=-O0
 469 
 470 # DEBUG_BINARIES uses full -g debug information for all configs
 471 ifeq ($(DEBUG_BINARIES), true)
 472   CFLAGS += -g
 473 else
 474   # Use the stabs format for debugging information (this is the default
 475   # on gcc-2.91). It's good enough, has all the information about line
 476   # numbers and local variables, and libjvm.so is only about 16M.
 477   # Change this back to "-g" if you want the most expressive format.
 478   # (warning: that could easily inflate libjvm.so to 150M!)
 479   # Note: The Itanium gcc compiler crashes when using -gstabs.
 480   DEBUG_CFLAGS/ia64  = -g
 481   DEBUG_CFLAGS/amd64 = -g
 482   DEBUG_CFLAGS/arm   = -g
 483   DEBUG_CFLAGS/ppc   = -g
 484   DEBUG_CFLAGS += $(DEBUG_CFLAGS/$(BUILDARCH))
 485   ifeq ($(DEBUG_CFLAGS/$(BUILDARCH)),)
 486       ifeq ($(USE_CLANG), true)
 487         # Clang doesn't understand -gstabs
 488         DEBUG_CFLAGS += -g
 489       else
 490         DEBUG_CFLAGS += -gstabs
 491       endif
 492   endif
 493 
 494   ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1)
 495     FASTDEBUG_CFLAGS/ia64  = -g
 496     FASTDEBUG_CFLAGS/amd64 = -g
 497     FASTDEBUG_CFLAGS/arm   = -g
 498     FASTDEBUG_CFLAGS/ppc   = -g
 499     FASTDEBUG_CFLAGS += $(FASTDEBUG_CFLAGS/$(BUILDARCH))
 500     ifeq ($(FASTDEBUG_CFLAGS/$(BUILDARCH)),)
 501       ifeq ($(USE_CLANG), true)
 502         # Clang doesn't understand -gstabs
 503         FASTDEBUG_CFLAGS += -g
 504       else
 505         FASTDEBUG_CFLAGS += -gstabs
 506       endif
 507     endif
 508 
 509     OPT_CFLAGS/ia64  = -g
 510     OPT_CFLAGS/amd64 = -g
 511     OPT_CFLAGS/arm   = -g
 512     OPT_CFLAGS/ppc   = -g
 513     OPT_CFLAGS += $(OPT_CFLAGS/$(BUILDARCH))
 514     ifeq ($(OPT_CFLAGS/$(BUILDARCH)),)
 515       ifeq ($(USE_CLANG), true)
 516         # Clang doesn't understand -gstabs
 517         OPT_CFLAGS += -g
 518       else
 519         OPT_CFLAGS += -gstabs
 520       endif
 521     endif
 522   endif
 523 endif
 524 
 525 ifeq ($(USE_CLANG),)
 526   # Enable bounds checking.
 527   ifeq "$(shell expr \( $(CC_VER_MAJOR) \> 3 \) )" "1"
 528     # stack smashing checks.
 529     DEBUG_CFLAGS += -fstack-protector-all --param ssp-buffer-size=1
 530   endif
 531 endif
 532 
 533 # If we are building HEADLESS, pass on to VM
 534 # so it can set the java.awt.headless property
 535 ifdef HEADLESS
 536 CFLAGS += -DHEADLESS
 537 endif
 538 
 539 # We are building Embedded for a small device
 540 # favor code space over speed
 541 ifdef MINIMIZE_RAM_USAGE
 542 CFLAGS += -DMINIMIZE_RAM_USAGE
 543 endif