hotspot/make/linux/makefiles/gcc.make

Print this page
rev 5915 : 8032045: Enable compiler and linker safety switches for debug builds
Reviewed-by: duke


  87     PRECOMPILED_HEADER_SRC=$(GAMMADIR)/src/share/vm/precompiled/precompiled.hpp
  88     PRECOMPILED_HEADER=$(PRECOMPILED_HEADER_DIR)/precompiled.hpp.pch
  89 
  90     PCH_FLAG = -include precompiled.hpp
  91     PCH_FLAG/DEFAULT = $(PCH_FLAG)
  92     PCH_FLAG/NO_PCH = -DNO_PCH
  93     PCH_FLAG/BY_FILE = $(PCH_FLAG/$@)$(PCH_FLAG/DEFAULT$(PCH_FLAG/$@))
  94 
  95     VM_PCH_FLAG/LIBJVM = $(PCH_FLAG/BY_FILE)
  96     VM_PCH_FLAG/AOUT =
  97     VM_PCH_FLAG = $(VM_PCH_FLAG/$(LINK_INTO))
  98 
  99     # We only use precompiled headers for the JVM build
 100     CFLAGS += $(VM_PCH_FLAG)
 101 
 102     # There are some files which don't like precompiled headers
 103     # The following files are build with 'OPT_CFLAGS/NOOPT' (-O0) in the opt build.
 104     # But Clang doesn't support a precompiled header which was compiled with -O3
 105     # to be used in a compilation unit which uses '-O0'. We could also prepare an
 106     # extra '-O0' PCH file for the opt build and use it here, but it's probably
 107     # not worth the effoert as long as only two files need this special handling.
 108     PCH_FLAG/loopTransform.o = $(PCH_FLAG/NO_PCH)
 109     PCH_FLAG/sharedRuntimeTrig.o = $(PCH_FLAG/NO_PCH)
 110     PCH_FLAG/sharedRuntimeTrans.o = $(PCH_FLAG/NO_PCH)
 111 
 112   endif
 113 else # ($(USE_CLANG), true)
 114   # check for precompiled headers support
 115   ifneq "$(shell expr \( $(CC_VER_MAJOR) \> 3 \) \| \( \( $(CC_VER_MAJOR) = 3 \) \& \( $(CC_VER_MINOR) \>= 4 \) \))" "0"
 116     # Allow the user to turn off precompiled headers from the command line.
 117     ifneq ($(USE_PRECOMPILED_HEADER),0)
 118       PRECOMPILED_HEADER_DIR=.
 119       PRECOMPILED_HEADER_SRC=$(GAMMADIR)/src/share/vm/precompiled/precompiled.hpp
 120       PRECOMPILED_HEADER=$(PRECOMPILED_HEADER_DIR)/precompiled.hpp.gch
 121     endif
 122   endif
 123 endif
 124 
 125 # -DDONT_USE_PRECOMPILED_HEADER will exclude all includes in precompiled.hpp.
 126 ifeq ($(USE_PRECOMPILED_HEADER),0)
 127   CFLAGS += -DDONT_USE_PRECOMPILED_HEADER


 208 
 209 ifeq ($(USE_CLANG), true)
 210   # However we need to clean the code up before we can unrestrictedly enable this option with Clang
 211   WARNINGS_ARE_ERRORS += -Wno-logical-op-parentheses -Wno-parentheses-equality -Wno-parentheses
 212   WARNINGS_ARE_ERRORS += -Wno-switch -Wno-tautological-constant-out-of-range-compare -Wno-tautological-compare
 213   WARNINGS_ARE_ERRORS += -Wno-delete-non-virtual-dtor -Wno-deprecated -Wno-format -Wno-dynamic-class-memaccess
 214   WARNINGS_ARE_ERRORS += -Wno-return-type -Wno-empty-body
 215 endif
 216 
 217 WARNING_FLAGS = -Wpointer-arith -Wsign-compare -Wundef -Wunused-function -Wunused-value
 218 
 219 ifeq ($(USE_CLANG),)
 220   # Since GCC 4.3, -Wconversion has changed its meanings to warn these implicit
 221   # conversions which might affect the values. Only enable it in earlier versions.
 222   ifeq "$(shell expr \( $(CC_VER_MAJOR) \> 4 \) \| \( \( $(CC_VER_MAJOR) = 4 \) \& \( $(CC_VER_MINOR) \>= 3 \) \))" "0"
 223     WARNING_FLAGS += -Wconversion
 224   endif
 225 endif
 226 
 227 CFLAGS_WARN/DEFAULT = $(WARNINGS_ARE_ERRORS) $(WARNING_FLAGS)

 228 # Special cases
 229 CFLAGS_WARN/BYFILE = $(CFLAGS_WARN/$@)$(CFLAGS_WARN/DEFAULT$(CFLAGS_WARN/$@)) 
 230 
 231 # The flags to use for an Optimized g++ build








 232 OPT_CFLAGS/SIZE=-Os
 233 OPT_CFLAGS/SPEED=-O3
 234 


 235 # Hotspot uses very unstrict aliasing turn this optimization off
 236 # This option is added to CFLAGS rather than OPT_CFLAGS
 237 # so that OPT_CFLAGS overrides get this option too.
 238 CFLAGS += -fno-strict-aliasing 
 239 
 240 OPT_CFLAGS_DEFAULT ?= SPEED
 241 
 242 ifdef OPT_CFLAGS
 243   ifneq ("$(origin OPT_CFLAGS)", "command line")
 244     $(error " Use OPT_EXTRAS instead of OPT_CFLAGS to add extra flags to OPT_CFLAGS.")
 245   endif
 246 endif
 247 
 248 OPT_CFLAGS = $(OPT_CFLAGS/$(OPT_CFLAGS_DEFAULT)) $(OPT_EXTRAS)
 249 
 250 # The gcc compiler segv's on ia64 when compiling bytecodeInterpreter.cpp 
 251 # if we use expensive-optimizations
 252 ifeq ($(BUILDARCH), ia64)
 253 OPT_CFLAGS += -fno-expensive-optimizations
 254 endif
 255 
 256 OPT_CFLAGS/NOOPT=-O0
 257 
 258 # Work around some compiler bugs.
 259 ifeq ($(USE_CLANG), true)
 260   ifeq ($(shell expr $(CC_VER_MAJOR) = 4 \& $(CC_VER_MINOR) = 2), 1)
 261     OPT_CFLAGS/loopTransform.o += $(OPT_CFLAGS/NOOPT)
 262   endif
 263 else
 264   # 6835796. Problem in GCC 4.3.0 with mulnode.o optimized compilation.
 265   ifeq ($(shell expr $(CC_VER_MAJOR) = 4 \& $(CC_VER_MINOR) = 3), 1)
 266     OPT_CFLAGS/mulnode.o += $(OPT_CFLAGS/NOOPT)
 267   endif
 268 endif
 269 
 270 # Flags for generating make dependency flags.
 271 DEPFLAGS = -MMD -MP -MF $(DEP_DIR)/$(@:%=%.d)
 272 ifeq ($(USE_CLANG),)
 273   ifneq ("${CC_VER_MAJOR}", "2")
 274     DEPFLAGS += -fpch-deps
 275   endif
 276 endif
 277 
 278 #------------------------------------------------------------------------
 279 # Linker flags
 280 
 281 # statically link libstdc++.so, work with gcc but ignored by g++
 282 STATIC_STDCXX = -Wl,-Bstatic -lstdc++ -Wl,-Bdynamic
 283 
 284 ifeq ($(USE_CLANG),)
 285   # statically link libgcc and/or libgcc_s, libgcc does not exist before gcc-3.x.
 286   ifneq ("${CC_VER_MAJOR}", "2")
 287     STATIC_LIBGCC += -static-libgcc
 288   endif
 289 













 290   ifeq ($(BUILDARCH), ia64)
 291     LFLAGS += -Wl,-relax
 292   endif
 293 endif
 294 
 295 # Enable linker optimization
 296 LFLAGS += -Xlinker -O1
 297 
 298 ifeq ($(USE_CLANG),)
 299   # If this is a --hash-style=gnu system, use --hash-style=both
 300   #   The gnu .hash section won't work on some Linux systems like SuSE 10.
 301   _HAS_HASH_STYLE_GNU:=$(shell $(CC) -dumpspecs | grep -- '--hash-style=gnu')
 302   ifneq ($(_HAS_HASH_STYLE_GNU),)
 303     LDFLAGS_HASH_STYLE = -Wl,--hash-style=both
 304   endif
 305 else
 306   # Don't know how to find out the 'hash style' of a system as '-dumpspecs'
 307   # doesn't work for Clang. So for now we'll alwys use --hash-style=both
 308   LDFLAGS_HASH_STYLE = -Wl,--hash-style=both
 309 endif
 310 
 311 LFLAGS += $(LDFLAGS_HASH_STYLE)
 312 
 313 # Use $(MAPFLAG:FILENAME=real_file_name) to specify a map file.
 314 MAPFLAG = -Xlinker --version-script=FILENAME
 315 
 316 # Use $(SONAMEFLAG:SONAME=soname) to specify the intrinsic name of a shared obj
 317 SONAMEFLAG = -Xlinker -soname=SONAME
 318 
 319 # Build shared library
 320 SHARED_FLAG = -shared
 321 
 322 # Keep symbols even they are not used
 323 AOUT_FLAGS += -Xlinker -export-dynamic
 324 
 325 #------------------------------------------------------------------------
 326 # Debug flags
 327 
 328 ifeq ($(USE_CLANG), true)
 329   # Restrict the debug information created by Clang to avoid
 330   # too big object files and speed the build up a little bit
 331   # (see http://llvm.org/bugs/show_bug.cgi?id=7554)
 332   CFLAGS += -flimit-debug-info
 333 endif
 334 








 335 # DEBUG_BINARIES uses full -g debug information for all configs
 336 ifeq ($(DEBUG_BINARIES), true)
 337   CFLAGS += -g
 338 else
 339   # Use the stabs format for debugging information (this is the default
 340   # on gcc-2.91). It's good enough, has all the information about line
 341   # numbers and local variables, and libjvm.so is only about 16M.
 342   # Change this back to "-g" if you want the most expressive format.
 343   # (warning: that could easily inflate libjvm.so to 150M!)
 344   # Note: The Itanium gcc compiler crashes when using -gstabs.
 345   DEBUG_CFLAGS/ia64  = -g
 346   DEBUG_CFLAGS/amd64 = -g
 347   DEBUG_CFLAGS/arm   = -g
 348   DEBUG_CFLAGS/ppc   = -g
 349   DEBUG_CFLAGS += $(DEBUG_CFLAGS/$(BUILDARCH))
 350   ifeq ($(DEBUG_CFLAGS/$(BUILDARCH)),)
 351       ifeq ($(USE_CLANG), true)
 352         # Clang doesn't understand -gstabs
 353         DEBUG_CFLAGS += -g
 354       else
 355         DEBUG_CFLAGS += -gstabs
 356       endif
 357   endif
 358   
 359   ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1)
 360     FASTDEBUG_CFLAGS/ia64  = -g
 361     FASTDEBUG_CFLAGS/amd64 = -g
 362     FASTDEBUG_CFLAGS/arm   = -g
 363     FASTDEBUG_CFLAGS/ppc   = -g
 364     FASTDEBUG_CFLAGS += $(DEBUG_CFLAGS/$(BUILDARCH))
 365     ifeq ($(FASTDEBUG_CFLAGS/$(BUILDARCH)),)
 366       ifeq ($(USE_CLANG), true)
 367         # Clang doesn't understand -gstabs
 368         FASTDEBUG_CFLAGS += -g
 369       else
 370         FASTDEBUG_CFLAGS += -gstabs
 371       endif
 372     endif
 373   
 374     OPT_CFLAGS/ia64  = -g
 375     OPT_CFLAGS/amd64 = -g
 376     OPT_CFLAGS/arm   = -g
 377     OPT_CFLAGS/ppc   = -g
 378     OPT_CFLAGS += $(OPT_CFLAGS/$(BUILDARCH))
 379     ifeq ($(OPT_CFLAGS/$(BUILDARCH)),)
 380       ifeq ($(USE_CLANG), true)
 381         # Clang doesn't understand -gstabs
 382         OPT_CFLAGS += -g
 383       else
 384         OPT_CFLAGS += -gstabs
 385       endif














 386     endif
 387   endif
 388 endif
 389 
 390 # If we are building HEADLESS, pass on to VM
 391 # so it can set the java.awt.headless property
 392 ifdef HEADLESS
 393 CFLAGS += -DHEADLESS
 394 endif
 395 
 396 # We are building Embedded for a small device
 397 # favor code space over speed
 398 ifdef MINIMIZE_RAM_USAGE
 399 CFLAGS += -DMINIMIZE_RAM_USAGE
 400 endif
 401 
 402 # Stack walking in the JVM relies on frame pointer (%rbp) to walk thread stack.
 403 # Explicitly specify -fno-omit-frame-pointer because it is off by default
 404 # starting with gcc 4.6.
 405 ifndef USE_SUNCC


  87     PRECOMPILED_HEADER_SRC=$(GAMMADIR)/src/share/vm/precompiled/precompiled.hpp
  88     PRECOMPILED_HEADER=$(PRECOMPILED_HEADER_DIR)/precompiled.hpp.pch
  89 
  90     PCH_FLAG = -include precompiled.hpp
  91     PCH_FLAG/DEFAULT = $(PCH_FLAG)
  92     PCH_FLAG/NO_PCH = -DNO_PCH
  93     PCH_FLAG/BY_FILE = $(PCH_FLAG/$@)$(PCH_FLAG/DEFAULT$(PCH_FLAG/$@))
  94 
  95     VM_PCH_FLAG/LIBJVM = $(PCH_FLAG/BY_FILE)
  96     VM_PCH_FLAG/AOUT =
  97     VM_PCH_FLAG = $(VM_PCH_FLAG/$(LINK_INTO))
  98 
  99     # We only use precompiled headers for the JVM build
 100     CFLAGS += $(VM_PCH_FLAG)
 101 
 102     # There are some files which don't like precompiled headers
 103     # The following files are build with 'OPT_CFLAGS/NOOPT' (-O0) in the opt build.
 104     # But Clang doesn't support a precompiled header which was compiled with -O3
 105     # to be used in a compilation unit which uses '-O0'. We could also prepare an
 106     # extra '-O0' PCH file for the opt build and use it here, but it's probably
 107     # not worth the effort as long as only two files need this special handling.
 108     PCH_FLAG/loopTransform.o = $(PCH_FLAG/NO_PCH)
 109     PCH_FLAG/sharedRuntimeTrig.o = $(PCH_FLAG/NO_PCH)
 110     PCH_FLAG/sharedRuntimeTrans.o = $(PCH_FLAG/NO_PCH)
 111 
 112   endif
 113 else # ($(USE_CLANG), true)
 114   # check for precompiled headers support
 115   ifneq "$(shell expr \( $(CC_VER_MAJOR) \> 3 \) \| \( \( $(CC_VER_MAJOR) = 3 \) \& \( $(CC_VER_MINOR) \>= 4 \) \))" "0"
 116     # Allow the user to turn off precompiled headers from the command line.
 117     ifneq ($(USE_PRECOMPILED_HEADER),0)
 118       PRECOMPILED_HEADER_DIR=.
 119       PRECOMPILED_HEADER_SRC=$(GAMMADIR)/src/share/vm/precompiled/precompiled.hpp
 120       PRECOMPILED_HEADER=$(PRECOMPILED_HEADER_DIR)/precompiled.hpp.gch
 121     endif
 122   endif
 123 endif
 124 
 125 # -DDONT_USE_PRECOMPILED_HEADER will exclude all includes in precompiled.hpp.
 126 ifeq ($(USE_PRECOMPILED_HEADER),0)
 127   CFLAGS += -DDONT_USE_PRECOMPILED_HEADER


 208 
 209 ifeq ($(USE_CLANG), true)
 210   # However we need to clean the code up before we can unrestrictedly enable this option with Clang
 211   WARNINGS_ARE_ERRORS += -Wno-logical-op-parentheses -Wno-parentheses-equality -Wno-parentheses
 212   WARNINGS_ARE_ERRORS += -Wno-switch -Wno-tautological-constant-out-of-range-compare -Wno-tautological-compare
 213   WARNINGS_ARE_ERRORS += -Wno-delete-non-virtual-dtor -Wno-deprecated -Wno-format -Wno-dynamic-class-memaccess
 214   WARNINGS_ARE_ERRORS += -Wno-return-type -Wno-empty-body
 215 endif
 216 
 217 WARNING_FLAGS = -Wpointer-arith -Wsign-compare -Wundef -Wunused-function -Wunused-value
 218 
 219 ifeq ($(USE_CLANG),)
 220   # Since GCC 4.3, -Wconversion has changed its meanings to warn these implicit
 221   # conversions which might affect the values. Only enable it in earlier versions.
 222   ifeq "$(shell expr \( $(CC_VER_MAJOR) \> 4 \) \| \( \( $(CC_VER_MAJOR) = 4 \) \& \( $(CC_VER_MINOR) \>= 3 \) \))" "0"
 223     WARNING_FLAGS += -Wconversion
 224   endif
 225 endif
 226 
 227 CFLAGS_WARN/DEFAULT = $(WARNINGS_ARE_ERRORS) $(WARNING_FLAGS)
 228 
 229 # Special cases
 230 CFLAGS_WARN/BYFILE = $(CFLAGS_WARN/$@)$(CFLAGS_WARN/DEFAULT$(CFLAGS_WARN/$@))
 231 
 232 # optimization control flags (Used by fastdebug and release variants)
 233 OPT_CFLAGS/NOOPT=-O0
 234 ifeq "$(shell expr \( $(CC_VER_MAJOR) \> 4 \) \| \( \( $(CC_VER_MAJOR) = 4 \) \& \( $(CC_VER_MINOR) \>= 8 \) \))" "1"
 235   # Allow basic optimizations which don't distrupt debugging. (Principally dead code elimination)
 236   OPT_CFLAGS/DEBUG=-Og
 237 else
 238   # Allow no optimizations.
 239   OPT_CFLAGS/DEBUG=-O0
 240 endif
 241 OPT_CFLAGS/SIZE=-Os
 242 OPT_CFLAGS/SPEED=-O3
 243 
 244 OPT_CFLAGS_DEFAULT ?= SPEED
 245 
 246 # Hotspot uses very unstrict aliasing turn this optimization off
 247 # This option is added to CFLAGS rather than OPT_CFLAGS
 248 # so that OPT_CFLAGS overrides get this option too.
 249 CFLAGS += -fno-strict-aliasing
 250 


 251 ifdef OPT_CFLAGS
 252   ifneq ("$(origin OPT_CFLAGS)", "command line")
 253     $(error " Use OPT_EXTRAS instead of OPT_CFLAGS to add extra flags to OPT_CFLAGS.")
 254   endif
 255 endif
 256 
 257 OPT_CFLAGS = $(OPT_CFLAGS/$(OPT_CFLAGS_DEFAULT)) $(OPT_EXTRAS)
 258 
 259 # The gcc compiler segv's on ia64 when compiling bytecodeInterpreter.cpp
 260 # if we use expensive-optimizations
 261 ifeq ($(BUILDARCH), ia64)
 262 OPT_CFLAGS += -fno-expensive-optimizations
 263 endif
 264 


 265 # Work around some compiler bugs.
 266 ifeq ($(USE_CLANG), true)
 267   ifeq ($(shell expr $(CC_VER_MAJOR) = 4 \& $(CC_VER_MINOR) = 2), 1)
 268     OPT_CFLAGS/loopTransform.o += $(OPT_CFLAGS/NOOPT)
 269   endif
 270 else
 271   # 6835796. Problem in GCC 4.3.0 with mulnode.o optimized compilation.
 272   ifeq ($(shell expr $(CC_VER_MAJOR) = 4 \& $(CC_VER_MINOR) = 3), 1)
 273     OPT_CFLAGS/mulnode.o += $(OPT_CFLAGS/NOOPT)
 274   endif
 275 endif
 276 
 277 # Flags for generating make dependency flags.
 278 DEPFLAGS = -MMD -MP -MF $(DEP_DIR)/$(@:%=%.d)
 279 ifeq ($(USE_CLANG),)
 280   ifneq ($(CC_VER_MAJOR), 2)
 281     DEPFLAGS += -fpch-deps
 282   endif
 283 endif
 284 
 285 #------------------------------------------------------------------------
 286 # Linker flags
 287 
 288 # statically link libstdc++.so, work with gcc but ignored by g++
 289 STATIC_STDCXX = -Wl,-Bstatic -lstdc++ -Wl,-Bdynamic
 290 
 291 ifeq ($(USE_CLANG),)
 292   # statically link libgcc and/or libgcc_s, libgcc does not exist before gcc-3.x.
 293   ifneq ($(CC_VER_MAJOR), 2)
 294     STATIC_LIBGCC += -static-libgcc
 295   endif
 296 
 297   # Enable linker optimization
 298   LFLAGS += -Xlinker -O1
 299 
 300   ifeq ($(VARIANT), DBG)
 301     # for relocations read-only
 302     LFLAGS += -Wl,-z,relro
 303 
 304     ifeq ($(FASTDEBUG), false)
 305       # disable incremental relocations linking
 306       LFLAGS += -Wl,-z,now
 307     endif
 308   endif
 309 
 310   ifeq ($(BUILDARCH), ia64)
 311     LFLAGS += -Wl,-relax
 312   endif




 313 

 314   # If this is a --hash-style=gnu system, use --hash-style=both
 315   #   The gnu .hash section won't work on some Linux systems like SuSE 10.
 316   _HAS_HASH_STYLE_GNU:=$(shell $(CC) -dumpspecs | grep -- '--hash-style=gnu')
 317   ifneq ($(_HAS_HASH_STYLE_GNU),)
 318     LDFLAGS_HASH_STYLE = -Wl,--hash-style=both
 319   endif
 320 else
 321   # Don't know how to find out the 'hash style' of a system as '-dumpspecs'
 322   # doesn't work for Clang. So for now we'll alwys use --hash-style=both
 323   LDFLAGS_HASH_STYLE = -Wl,--hash-style=both
 324 endif
 325 
 326 LFLAGS += $(LDFLAGS_HASH_STYLE)
 327 
 328 # Use $(MAPFLAG:FILENAME=real_file_name) to specify a map file.
 329 MAPFLAG = -Xlinker --version-script=FILENAME
 330 
 331 # Use $(SONAMEFLAG:SONAME=soname) to specify the intrinsic name of a shared obj
 332 SONAMEFLAG = -Xlinker -soname=SONAME
 333 
 334 # Build shared library
 335 SHARED_FLAG = -shared
 336 
 337 # Keep symbols even they are not used
 338 AOUT_FLAGS += -Xlinker -export-dynamic
 339 
 340 #------------------------------------------------------------------------
 341 # Debug flags
 342 
 343 ifeq ($(USE_CLANG), true)
 344   # Restrict the debug information created by Clang to avoid
 345   # too big object files and speed the build up a little bit
 346   # (see http://llvm.org/bugs/show_bug.cgi?id=7554)
 347   CFLAGS += -flimit-debug-info
 348 endif
 349 
 350 ifeq "$(shell expr \( $(CC_VER_MAJOR) \> 4 \) \| \( \( $(CC_VER_MAJOR) = 4 \) \& \( $(CC_VER_MINOR) \>= 8 \) \))" "1"
 351   # Allow basic optimizations which don't distrupt debugging. (Principally dead code elimination)
 352   DEBUG_CFLAGS=-Og
 353 else
 354   # Allow no optimizations.
 355   DEBUG_CFLAGS=-O0
 356 endif
 357 
 358 # DEBUG_BINARIES uses full -g debug information for all configs
 359 ifeq ($(DEBUG_BINARIES), true)
 360   CFLAGS += -g
 361 else
 362   # Use the stabs format for debugging information (this is the default
 363   # on gcc-2.91). It's good enough, has all the information about line
 364   # numbers and local variables, and libjvm.so is only about 16M.
 365   # Change this back to "-g" if you want the most expressive format.
 366   # (warning: that could easily inflate libjvm.so to 150M!)
 367   # Note: The Itanium gcc compiler crashes when using -gstabs.
 368   DEBUG_CFLAGS/ia64  = -g
 369   DEBUG_CFLAGS/amd64 = -g
 370   DEBUG_CFLAGS/arm   = -g
 371   DEBUG_CFLAGS/ppc   = -g
 372   DEBUG_CFLAGS += $(DEBUG_CFLAGS/$(BUILDARCH))
 373   ifeq ($(DEBUG_CFLAGS/$(BUILDARCH)),)
 374       ifeq ($(USE_CLANG), true)
 375         # Clang doesn't understand -gstabs
 376         DEBUG_CFLAGS += -g
 377       else
 378         DEBUG_CFLAGS += -gstabs
 379       endif
 380   endif
 381   
 382   ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1)
 383     FASTDEBUG_CFLAGS/ia64  = -g
 384     FASTDEBUG_CFLAGS/amd64 = -g
 385     FASTDEBUG_CFLAGS/arm   = -g
 386     FASTDEBUG_CFLAGS/ppc   = -g
 387     FASTDEBUG_CFLAGS += $(FASTDEBUG_CFLAGS/$(BUILDARCH))
 388     ifeq ($(FASTDEBUG_CFLAGS/$(BUILDARCH)),)
 389       ifeq ($(USE_CLANG), true)
 390         # Clang doesn't understand -gstabs
 391         FASTDEBUG_CFLAGS += -g
 392       else
 393         FASTDEBUG_CFLAGS += -gstabs
 394       endif
 395     endif
 396   
 397     OPT_CFLAGS/ia64  = -g
 398     OPT_CFLAGS/amd64 = -g
 399     OPT_CFLAGS/arm   = -g
 400     OPT_CFLAGS/ppc   = -g
 401     OPT_CFLAGS += $(OPT_CFLAGS/$(BUILDARCH))
 402     ifeq ($(OPT_CFLAGS/$(BUILDARCH)),)
 403       ifeq ($(USE_CLANG), true)
 404         # Clang doesn't understand -gstabs
 405         OPT_CFLAGS += -g
 406       else
 407         OPT_CFLAGS += -gstabs
 408       endif
 409     endif
 410   endif
 411 endif
 412 
 413 # Enable bounds checking.
 414 ifeq ($(VARIANT), DBG)
 415   # _FORTIFY_SOURCE appears in GCC 4.0+
 416   ifeq "$(shell expr \( $(CC_VER_MAJOR) \> 3 \) )" "0"
 417     ifeq ($(FASTDEBUG), true)
 418       # compile time size bounds checks
 419       CFLAGS += -D_FORTIFY_SOURCE=1
 420     else
 421       # and runtime size bounds checks and paranoid stack smashing checks.
 422       CFLAGS += -D_FORTIFY_SOURCE=2 -fstack-protector-all --param ssp-buffer-size=1
 423     endif
 424   endif
 425 endif
 426 
 427 # If we are building HEADLESS, pass on to VM
 428 # so it can set the java.awt.headless property
 429 ifdef HEADLESS
 430 CFLAGS += -DHEADLESS
 431 endif
 432 
 433 # We are building Embedded for a small device
 434 # favor code space over speed
 435 ifdef MINIMIZE_RAM_USAGE
 436 CFLAGS += -DMINIMIZE_RAM_USAGE
 437 endif
 438 
 439 # Stack walking in the JVM relies on frame pointer (%rbp) to walk thread stack.
 440 # Explicitly specify -fno-omit-frame-pointer because it is off by default
 441 # starting with gcc 4.6.
 442 ifndef USE_SUNCC