--- old/hotspot/make/bsd/makefiles/gcc.make 2014-03-10 16:41:12.554156633 -0700 +++ new/hotspot/make/bsd/makefiles/gcc.make 2014-03-10 16:41:12.446156628 -0700 @@ -80,7 +80,7 @@ HOSTCC = $(CC) endif - AS = $(CC) -c + AS = $(CC) -c endif ifeq ($(OS_VENDOR), Darwin) @@ -100,7 +100,7 @@ endif ifeq ($(USE_CLANG), true) - # clang has precompiled headers support by default, but the user can switch + # Clang has precompiled headers support by default, but the user can switch # it off by using 'USE_PRECOMPILED_HEADER=0'. ifdef LP64 ifeq ($(USE_PRECOMPILED_HEADER),) @@ -266,7 +266,7 @@ # Since GCC 4.3, -Wconversion has changed its meanings to warn these implicit # conversions which might affect the values. Only enable it in earlier versions. ifeq "$(shell expr \( $(CC_VER_MAJOR) \> 4 \) \| \( \( $(CC_VER_MAJOR) = 4 \) \& \( $(CC_VER_MINOR) \>= 3 \) \))" "0" - WARNINGS_FLAGS += -Wconversion + WARNING_FLAGS += -Wconversion endif endif @@ -278,23 +278,31 @@ CFLAGS_WARN/os_bsd.o = $(CFLAGS_WARN/DEFAULT) -Wno-deprecated-declarations endif +# optimization control flags (Used by fastdebug and release variants) +OPT_CFLAGS/NOOPT=-O0 +ifeq "$(shell expr \( $(CC_VER_MAJOR) \> 4 \) \| \( \( $(CC_VER_MAJOR) = 4 \) \& \( $(CC_VER_MINOR) \>= 8 \) \))" "1" + # Allow basic optimizations which don't distrupt debugging. (Principally dead code elimination) + OPT_CFLAGS/DEBUG=-Og +else + # Allow no optimizations. + OPT_CFLAGS/DEBUG=-O0 +endif OPT_CFLAGS/SIZE=-Os OPT_CFLAGS/SPEED=-O3 ++ifeq ($(OS_VENDOR), Darwin) ++ # use -Os by default, unless -O3 can be proved to be worth the cost, as per policy ++ # ++ OPT_CFLAGS_DEFAULT ?= SIZE ++else ++ OPT_CFLAGS_DEFAULT ?= SPEED ++endif ++ # Hotspot uses very unstrict aliasing turn this optimization off # This option is added to CFLAGS rather than OPT_CFLAGS # so that OPT_CFLAGS overrides get this option too. CFLAGS += -fno-strict-aliasing -# The flags to use for an Optimized g++ build -ifeq ($(OS_VENDOR), Darwin) - # use -Os by default, unless -O3 can be proved to be worth the cost, as per policy - # - OPT_CFLAGS_DEFAULT ?= SIZE -else - OPT_CFLAGS_DEFAULT ?= SPEED -endif - ifdef OPT_CFLAGS ifneq ("$(origin OPT_CFLAGS)", "command line") $(error " Use OPT_EXTRAS instead of OPT_CFLAGS to add extra flags to OPT_CFLAGS.") @@ -309,8 +317,6 @@ OPT_CFLAGS += -fno-expensive-optimizations endif -OPT_CFLAGS/NOOPT=-O0 - # Work around some compiler bugs. ifeq ($(USE_CLANG), true) ifeq ($(shell expr $(CC_VER_MAJOR) = 4 \& $(CC_VER_MINOR) = 2), 1) @@ -371,10 +377,23 @@ ifeq ($(USE_CLANG),) # statically link libgcc and/or libgcc_s, libgcc does not exist before gcc-3.x. - ifneq ("${CC_VER_MAJOR}", "2") + ifneq ($(CC_VER_MAJOR), 2) STATIC_LIBGCC += -static-libgcc endif + # Enable linker optimization + LFLAGS += -Xlinker -O1 + + ifeq ($(VARIANT), DBG) + # for relocations read-only + LFLAGS += -Xlinker -z -Xlinker relro + + ifeq ($(FASTDEBUG), false) + # disable incremental relocations linking + LFLAGS += -Xlinker -z -Xlinker now + endif + endif + ifeq ($(BUILDARCH), ia64) LFLAGS += -Wl,-relax endif @@ -425,6 +444,14 @@ CFLAGS += -flimit-debug-info endif +ifeq "$(shell expr \( $(CC_VER_MAJOR) \> 4 \) \| \( \( $(CC_VER_MAJOR) = 4 \) \& \( $(CC_VER_MINOR) \>= 8 \) \))" "1" + # Allow basic optimizations which don't distrupt debugging. (Principally dead code elimination) + DEBUG_CFLAGS=-Og +else + # Allow no optimizations. + DEBUG_CFLAGS=-O0 +endif + # DEBUG_BINARIES uses full -g debug information for all configs ifeq ($(DEBUG_BINARIES), true) CFLAGS += -g @@ -441,7 +468,12 @@ DEBUG_CFLAGS/ppc = -g DEBUG_CFLAGS += $(DEBUG_CFLAGS/$(BUILDARCH)) ifeq ($(DEBUG_CFLAGS/$(BUILDARCH)),) - DEBUG_CFLAGS += -gstabs + ifeq ($(USE_CLANG), true) + # Clang doesn't understand -gstabs + DEBUG_CFLAGS += -g + else + DEBUG_CFLAGS += -gstabs + endif endif ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1) @@ -474,6 +506,20 @@ endif endif endif + +# Enable bounds checking. +ifeq ($(VARIANT), DBG) + # _FORTIFY_SOURCE appears in GCC 4.0+ + ifeq "$(shell expr \( $(CC_VER_MAJOR) \> 3 \) )" "0" + ifeq ($(FASTDEBUG), true) + # compile time size bounds checks + CFLAGS += -D_FORTIFY_SOURCE=1 + else + # and runtime size bounds checks and paranoid stack smashing checks. + CFLAGS += -D_FORTIFY_SOURCE=2 -fstack-protector-all --param ssp-buffer-size=1 + endif + endif +endif # If we are building HEADLESS, pass on to VM # so it can set the java.awt.headless property