make/linux/makefiles/gcc.make

Sat, 03 Mar 2012 12:36:35 -0800

author
jcoomes
date
Sat, 03 Mar 2012 12:36:35 -0800
changeset 3621
e4624321d36a
parent 3518
719f7007c8e8
child 3600
7292cff45988
child 3724
d652a62d6e03
permissions
-rw-r--r--

7150454: add release jdk7u4 to jprt.properties
Reviewed-by: ohair, never

duke@435 1 #
trims@2708 2 # Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
duke@435 3 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
duke@435 4 #
duke@435 5 # This code is free software; you can redistribute it and/or modify it
duke@435 6 # under the terms of the GNU General Public License version 2 only, as
duke@435 7 # published by the Free Software Foundation.
duke@435 8 #
duke@435 9 # This code is distributed in the hope that it will be useful, but WITHOUT
duke@435 10 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
duke@435 11 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
duke@435 12 # version 2 for more details (a copy is included in the LICENSE file that
duke@435 13 # accompanied this code).
duke@435 14 #
duke@435 15 # You should have received a copy of the GNU General Public License version
duke@435 16 # 2 along with this work; if not, write to the Free Software Foundation,
duke@435 17 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
duke@435 18 #
trims@1907 19 # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
trims@1907 20 # or visit www.oracle.com if you need additional information or have any
trims@1907 21 # questions.
duke@435 22 #
duke@435 23 #
duke@435 24
duke@435 25 #------------------------------------------------------------------------
erikj@3518 26 # CC, CXX & AS
duke@435 27
dholmes@2362 28 # When cross-compiling the ALT_COMPILER_PATH points
dholmes@2362 29 # to the cross-compilation toolset
dholmes@2362 30 ifdef CROSS_COMPILE_ARCH
erikj@3518 31 CXX = $(ALT_COMPILER_PATH)/g++
bobv@2036 32 CC = $(ALT_COMPILER_PATH)/gcc
erikj@3518 33 HOSTCXX = g++
roland@2683 34 HOSTCC = gcc
bobv@2036 35 else
erikj@3518 36 CXX = g++
duke@435 37 CC = gcc
erikj@3518 38 HOSTCXX = $(CXX)
roland@2683 39 HOSTCC = $(CC)
bobv@2036 40 endif
bobv@2036 41
duke@435 42 AS = $(CC) -c
duke@435 43
duke@435 44 # -dumpversion in gcc-2.91 shows "egcs-2.91.66". In later version, it only
duke@435 45 # prints the numbers (e.g. "2.95", "3.2.1")
duke@435 46 CC_VER_MAJOR := $(shell $(CC) -dumpversion | sed 's/egcs-//' | cut -d'.' -f1)
duke@435 47 CC_VER_MINOR := $(shell $(CC) -dumpversion | sed 's/egcs-//' | cut -d'.' -f2)
duke@435 48
duke@435 49 # check for precompiled headers support
duke@435 50 ifneq "$(shell expr \( $(CC_VER_MAJOR) \> 3 \) \| \( \( $(CC_VER_MAJOR) = 3 \) \& \( $(CC_VER_MINOR) \>= 4 \) \))" "0"
stefank@2325 51 # Allow the user to turn off precompiled headers from the command line.
stefank@2325 52 ifneq ($(USE_PRECOMPILED_HEADER),0)
duke@435 53 PRECOMPILED_HEADER_DIR=.
brutisso@3229 54 PRECOMPILED_HEADER_SRC=$(GAMMADIR)/src/share/vm/precompiled/precompiled.hpp
stefank@2314 55 PRECOMPILED_HEADER=$(PRECOMPILED_HEADER_DIR)/precompiled.hpp.gch
duke@435 56 endif
stefank@2325 57 endif
duke@435 58
duke@435 59
duke@435 60 #------------------------------------------------------------------------
duke@435 61 # Compiler flags
duke@435 62
duke@435 63 # position-independent code
duke@435 64 PICFLAG = -fPIC
duke@435 65
duke@435 66 VM_PICFLAG/LIBJVM = $(PICFLAG)
duke@435 67 VM_PICFLAG/AOUT =
duke@435 68 VM_PICFLAG = $(VM_PICFLAG/$(LINK_INTO))
duke@435 69
never@1445 70 ifeq ($(ZERO_BUILD), true)
never@1445 71 CFLAGS += $(LIBFFI_CFLAGS)
never@1445 72 endif
twisti@2047 73 ifeq ($(SHARK_BUILD), true)
twisti@2047 74 CFLAGS += $(LLVM_CFLAGS)
twisti@2047 75 endif
duke@435 76 CFLAGS += $(VM_PICFLAG)
duke@435 77 CFLAGS += -fno-rtti
duke@435 78 CFLAGS += -fno-exceptions
duke@435 79 CFLAGS += -D_REENTRANT
duke@435 80 CFLAGS += -fcheck-new
coleenp@2507 81 # version 4 and above support fvisibility=hidden (matches jni_x86.h file)
coleenp@2507 82 # except 4.1.2 gives pointless warnings that can't be disabled (afaik)
coleenp@2507 83 ifneq "$(shell expr \( $(CC_VER_MAJOR) \> 4 \) \| \( \( $(CC_VER_MAJOR) = 4 \) \& \( $(CC_VER_MINOR) \>= 3 \) \))" "0"
coleenp@2507 84 CFLAGS += -fvisibility=hidden
coleenp@2507 85 endif
duke@435 86
duke@435 87 ARCHFLAG = $(ARCHFLAG/$(BUILDARCH))
duke@435 88 ARCHFLAG/i486 = -m32 -march=i586
duke@435 89 ARCHFLAG/amd64 = -m64
duke@435 90 ARCHFLAG/ia64 =
duke@435 91 ARCHFLAG/sparc = -m32 -mcpu=v9
duke@435 92 ARCHFLAG/sparcv9 = -m64 -mcpu=v9
bobv@2036 93 ARCHFLAG/arm = -fsigned-char
never@1445 94 ARCHFLAG/zero = $(ZERO_ARCHFLAG)
bobv@2036 95 ifndef E500V2
bobv@2036 96 ARCHFLAG/ppc = -mcpu=powerpc
bobv@2036 97 endif
duke@435 98
duke@435 99 CFLAGS += $(ARCHFLAG)
duke@435 100 AOUT_FLAGS += $(ARCHFLAG)
duke@435 101 LFLAGS += $(ARCHFLAG)
duke@435 102 ASFLAGS += $(ARCHFLAG)
duke@435 103
bobv@2036 104 ifdef E500V2
bobv@2036 105 CFLAGS += -DE500V2
bobv@2036 106 endif
bobv@2036 107
duke@435 108 # Use C++ Interpreter
duke@435 109 ifdef CC_INTERP
duke@435 110 CFLAGS += -DCC_INTERP
duke@435 111 endif
duke@435 112
bobv@2036 113 # Build for embedded targets
bobv@2036 114 ifdef JAVASE_EMBEDDED
bobv@2036 115 CFLAGS += -DJAVASE_EMBEDDED
bobv@2036 116 endif
bobv@2036 117
duke@435 118 # Keep temporary files (.ii, .s)
duke@435 119 ifdef NEED_ASM
duke@435 120 CFLAGS += -save-temps
duke@435 121 else
duke@435 122 CFLAGS += -pipe
duke@435 123 endif
duke@435 124
duke@435 125 # Compiler warnings are treated as errors
duke@435 126 WARNINGS_ARE_ERRORS = -Werror
xlu@664 127
duke@435 128 # Except for a few acceptable ones
xlu@664 129 # Since GCC 4.3, -Wconversion has changed its meanings to warn these implicit
xlu@664 130 # conversions which might affect the values. To avoid that, we need to turn
xlu@664 131 # it off explicitly.
xlu@664 132 ifneq "$(shell expr \( $(CC_VER_MAJOR) \> 4 \) \| \( \( $(CC_VER_MAJOR) = 4 \) \& \( $(CC_VER_MINOR) \>= 3 \) \))" "0"
xlu@664 133 ACCEPTABLE_WARNINGS = -Wpointer-arith -Wsign-compare
xlu@664 134 else
duke@435 135 ACCEPTABLE_WARNINGS = -Wpointer-arith -Wconversion -Wsign-compare
xlu@664 136 endif
xlu@664 137
duke@435 138 CFLAGS_WARN/DEFAULT = $(WARNINGS_ARE_ERRORS) $(ACCEPTABLE_WARNINGS)
duke@435 139 # Special cases
duke@435 140 CFLAGS_WARN/BYFILE = $(CFLAGS_WARN/$@)$(CFLAGS_WARN/DEFAULT$(CFLAGS_WARN/$@))
duke@435 141
duke@435 142 # The flags to use for an Optimized g++ build
duke@435 143 OPT_CFLAGS += -O3
duke@435 144
duke@435 145 # Hotspot uses very unstrict aliasing turn this optimization off
duke@435 146 OPT_CFLAGS += -fno-strict-aliasing
duke@435 147
duke@435 148 # The gcc compiler segv's on ia64 when compiling bytecodeInterpreter.cpp
duke@435 149 # if we use expensive-optimizations
duke@435 150 ifeq ($(BUILDARCH), ia64)
duke@435 151 OPT_CFLAGS += -fno-expensive-optimizations
duke@435 152 endif
duke@435 153
duke@435 154 OPT_CFLAGS/NOOPT=-O0
duke@435 155
kvn@1179 156 # 6835796. Problem in GCC 4.3.0 with mulnode.o optimized compilation.
kvn@1179 157 ifneq "$(shell expr \( \( $(CC_VER_MAJOR) = 4 \) \& \( $(CC_VER_MINOR) = 3 \) \))" "0"
kvn@1179 158 OPT_CFLAGS/mulnode.o += -O0
kvn@1179 159 endif
kvn@1179 160
stefank@2314 161 # Flags for generating make dependency flags.
stefank@2314 162 ifneq ("${CC_VER_MAJOR}", "2")
stefank@2314 163 DEPFLAGS = -MMD -MP -MF $(DEP_DIR)/$(@:%=%.d)
stefank@2314 164 endif
stefank@2314 165
stefank@2325 166 # -DDONT_USE_PRECOMPILED_HEADER will exclude all includes in precompiled.hpp.
stefank@3325 167 ifeq ($(USE_PRECOMPILED_HEADER),0)
stefank@2325 168 CFLAGS += -DDONT_USE_PRECOMPILED_HEADER
stefank@2325 169 endif
stefank@2325 170
duke@435 171 #------------------------------------------------------------------------
duke@435 172 # Linker flags
duke@435 173
duke@435 174 # statically link libstdc++.so, work with gcc but ignored by g++
duke@435 175 STATIC_STDCXX = -Wl,-Bstatic -lstdc++ -Wl,-Bdynamic
duke@435 176
duke@435 177 # statically link libgcc and/or libgcc_s, libgcc does not exist before gcc-3.x.
duke@435 178 ifneq ("${CC_VER_MAJOR}", "2")
duke@435 179 STATIC_LIBGCC += -static-libgcc
duke@435 180 endif
duke@435 181
duke@435 182 ifeq ($(BUILDARCH), ia64)
duke@435 183 LFLAGS += -Wl,-relax
duke@435 184 endif
duke@435 185
duke@435 186 # Enable linker optimization
duke@435 187 LFLAGS += -Xlinker -O1
duke@435 188
ohair@1011 189 # If this is a --hash-style=gnu system, use --hash-style=both
ohair@1011 190 # The gnu .hash section won't work on some Linux systems like SuSE 10.
ohair@1011 191 _HAS_HASH_STYLE_GNU:=$(shell $(CC) -dumpspecs | grep -- '--hash-style=gnu')
ohair@1011 192 ifneq ($(_HAS_HASH_STYLE_GNU),)
ohair@1011 193 LDFLAGS_HASH_STYLE = -Wl,--hash-style=both
ohair@1011 194 endif
ohair@1011 195 LFLAGS += $(LDFLAGS_HASH_STYLE)
ohair@1011 196
duke@435 197 # Use $(MAPFLAG:FILENAME=real_file_name) to specify a map file.
duke@435 198 MAPFLAG = -Xlinker --version-script=FILENAME
duke@435 199
duke@435 200 # Use $(SONAMEFLAG:SONAME=soname) to specify the intrinsic name of a shared obj
duke@435 201 SONAMEFLAG = -Xlinker -soname=SONAME
duke@435 202
duke@435 203 # Build shared library
duke@435 204 SHARED_FLAG = -shared
duke@435 205
duke@435 206 # Keep symbols even they are not used
dsamersoff@2839 207 AOUT_FLAGS += -Xlinker -export-dynamic
duke@435 208
duke@435 209 #------------------------------------------------------------------------
duke@435 210 # Debug flags
duke@435 211
duke@435 212 # Use the stabs format for debugging information (this is the default
duke@435 213 # on gcc-2.91). It's good enough, has all the information about line
duke@435 214 # numbers and local variables, and libjvm_g.so is only about 16M.
duke@435 215 # Change this back to "-g" if you want the most expressive format.
duke@435 216 # (warning: that could easily inflate libjvm_g.so to 150M!)
duke@435 217 # Note: The Itanium gcc compiler crashes when using -gstabs.
duke@435 218 DEBUG_CFLAGS/ia64 = -g
duke@435 219 DEBUG_CFLAGS/amd64 = -g
bobv@2036 220 DEBUG_CFLAGS/arm = -g
bobv@2036 221 DEBUG_CFLAGS/ppc = -g
duke@435 222 DEBUG_CFLAGS += $(DEBUG_CFLAGS/$(BUILDARCH))
duke@435 223 ifeq ($(DEBUG_CFLAGS/$(BUILDARCH)),)
duke@435 224 DEBUG_CFLAGS += -gstabs
duke@435 225 endif
aph@1202 226
dcubed@3150 227 ifneq ($(OBJCOPY),)
dcubed@3150 228 FASTDEBUG_CFLAGS/ia64 = -g
dcubed@3150 229 FASTDEBUG_CFLAGS/amd64 = -g
dcubed@3150 230 FASTDEBUG_CFLAGS/arm = -g
dcubed@3150 231 FASTDEBUG_CFLAGS/ppc = -g
dcubed@3150 232 FASTDEBUG_CFLAGS += $(DEBUG_CFLAGS/$(BUILDARCH))
dcubed@3150 233 ifeq ($(FASTDEBUG_CFLAGS/$(BUILDARCH)),)
dcubed@3150 234 FASTDEBUG_CFLAGS += -gstabs
dcubed@3150 235 endif
dcubed@3150 236
dcubed@3150 237 OPT_CFLAGS/ia64 = -g
dcubed@3150 238 OPT_CFLAGS/amd64 = -g
dcubed@3150 239 OPT_CFLAGS/arm = -g
dcubed@3150 240 OPT_CFLAGS/ppc = -g
dcubed@3150 241 OPT_CFLAGS += $(OPT_CFLAGS/$(BUILDARCH))
dcubed@3150 242 ifeq ($(OPT_CFLAGS/$(BUILDARCH)),)
dcubed@3150 243 OPT_CFLAGS += -gstabs
dcubed@3150 244 endif
dcubed@3150 245 endif
dcubed@3150 246
aph@1202 247 # DEBUG_BINARIES overrides everything, use full -g debug information
aph@1202 248 ifeq ($(DEBUG_BINARIES), true)
aph@1202 249 DEBUG_CFLAGS = -g
aph@1202 250 CFLAGS += $(DEBUG_CFLAGS)
aph@1202 251 endif
bobv@2036 252
bobv@2036 253 # If we are building HEADLESS, pass on to VM
bobv@2036 254 # so it can set the java.awt.headless property
bobv@2036 255 ifdef HEADLESS
bobv@2036 256 CFLAGS += -DHEADLESS
bobv@2036 257 endif
bobv@2036 258
bobv@2036 259 # We are building Embedded for a small device
bobv@2036 260 # favor code space over speed
bobv@2036 261 ifdef MINIMIZE_RAM_USAGE
bobv@2036 262 CFLAGS += -DMINIMIZE_RAM_USAGE
bobv@2036 263 endif
dcubed@3150 264
dcubed@3150 265 ifdef CROSS_COMPILE_ARCH
dcubed@3150 266 STRIP = $(ALT_COMPILER_PATH)/strip
dcubed@3150 267 else
dcubed@3150 268 STRIP = strip
dcubed@3150 269 endif

mercurial