make/linux/makefiles/gcc.make

Thu, 09 Dec 2010 20:12:06 -0500

author
dholmes
date
Thu, 09 Dec 2010 20:12:06 -0500
changeset 2362
a5610f0862fe
parent 2325
c760f78e0a53
child 2507
d70fe6ab4436
permissions
-rw-r--r--

7005007: Refine use of ALT_COMPILER_PATH to avoid conflict with JPRT usage
Summary: Check for CROSS_COMPILE_ARCH being set as an indicator to use ALT_COMPILER_PATH
Reviewed-by: acorn, ohair

duke@435 1 #
twisti@2047 2 # Copyright (c) 1999, 2010, 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 #------------------------------------------------------------------------
duke@435 26 # CC, CPP & 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
bobv@2036 31 CPP = $(ALT_COMPILER_PATH)/g++
bobv@2036 32 CC = $(ALT_COMPILER_PATH)/gcc
bobv@2036 33 else
duke@435 34 CPP = g++
duke@435 35 CC = gcc
bobv@2036 36 endif
bobv@2036 37
duke@435 38 AS = $(CC) -c
duke@435 39
duke@435 40 # -dumpversion in gcc-2.91 shows "egcs-2.91.66". In later version, it only
duke@435 41 # prints the numbers (e.g. "2.95", "3.2.1")
duke@435 42 CC_VER_MAJOR := $(shell $(CC) -dumpversion | sed 's/egcs-//' | cut -d'.' -f1)
duke@435 43 CC_VER_MINOR := $(shell $(CC) -dumpversion | sed 's/egcs-//' | cut -d'.' -f2)
duke@435 44
duke@435 45 # check for precompiled headers support
duke@435 46 ifneq "$(shell expr \( $(CC_VER_MAJOR) \> 3 \) \| \( \( $(CC_VER_MAJOR) = 3 \) \& \( $(CC_VER_MINOR) \>= 4 \) \))" "0"
stefank@2325 47 # Allow the user to turn off precompiled headers from the command line.
stefank@2325 48 ifneq ($(USE_PRECOMPILED_HEADER),0)
duke@435 49 USE_PRECOMPILED_HEADER=1
duke@435 50 PRECOMPILED_HEADER_DIR=.
stefank@2314 51 PRECOMPILED_HEADER_SRC=$(GAMMADIR)/src/share/vm/precompiled.hpp
stefank@2314 52 PRECOMPILED_HEADER=$(PRECOMPILED_HEADER_DIR)/precompiled.hpp.gch
duke@435 53 endif
stefank@2325 54 endif
duke@435 55
duke@435 56
duke@435 57 #------------------------------------------------------------------------
duke@435 58 # Compiler flags
duke@435 59
duke@435 60 # position-independent code
duke@435 61 PICFLAG = -fPIC
duke@435 62
duke@435 63 VM_PICFLAG/LIBJVM = $(PICFLAG)
duke@435 64 VM_PICFLAG/AOUT =
duke@435 65 VM_PICFLAG = $(VM_PICFLAG/$(LINK_INTO))
duke@435 66
never@1445 67 ifeq ($(ZERO_BUILD), true)
never@1445 68 CFLAGS += $(LIBFFI_CFLAGS)
never@1445 69 endif
twisti@2047 70 ifeq ($(SHARK_BUILD), true)
twisti@2047 71 CFLAGS += $(LLVM_CFLAGS)
twisti@2047 72 endif
duke@435 73 CFLAGS += $(VM_PICFLAG)
duke@435 74 CFLAGS += -fno-rtti
duke@435 75 CFLAGS += -fno-exceptions
duke@435 76 CFLAGS += -D_REENTRANT
duke@435 77 CFLAGS += -fcheck-new
duke@435 78
duke@435 79 ARCHFLAG = $(ARCHFLAG/$(BUILDARCH))
duke@435 80 ARCHFLAG/i486 = -m32 -march=i586
duke@435 81 ARCHFLAG/amd64 = -m64
duke@435 82 ARCHFLAG/ia64 =
duke@435 83 ARCHFLAG/sparc = -m32 -mcpu=v9
duke@435 84 ARCHFLAG/sparcv9 = -m64 -mcpu=v9
bobv@2036 85 ARCHFLAG/arm = -fsigned-char
never@1445 86 ARCHFLAG/zero = $(ZERO_ARCHFLAG)
bobv@2036 87 ifndef E500V2
bobv@2036 88 ARCHFLAG/ppc = -mcpu=powerpc
bobv@2036 89 endif
duke@435 90
duke@435 91 CFLAGS += $(ARCHFLAG)
duke@435 92 AOUT_FLAGS += $(ARCHFLAG)
duke@435 93 LFLAGS += $(ARCHFLAG)
duke@435 94 ASFLAGS += $(ARCHFLAG)
duke@435 95
bobv@2036 96 ifdef E500V2
bobv@2036 97 CFLAGS += -DE500V2
bobv@2036 98 endif
bobv@2036 99
duke@435 100 # Use C++ Interpreter
duke@435 101 ifdef CC_INTERP
duke@435 102 CFLAGS += -DCC_INTERP
duke@435 103 endif
duke@435 104
bobv@2036 105 # Build for embedded targets
bobv@2036 106 ifdef JAVASE_EMBEDDED
bobv@2036 107 CFLAGS += -DJAVASE_EMBEDDED
bobv@2036 108 endif
bobv@2036 109
duke@435 110 # Keep temporary files (.ii, .s)
duke@435 111 ifdef NEED_ASM
duke@435 112 CFLAGS += -save-temps
duke@435 113 else
duke@435 114 CFLAGS += -pipe
duke@435 115 endif
duke@435 116
duke@435 117 # Compiler warnings are treated as errors
duke@435 118 WARNINGS_ARE_ERRORS = -Werror
xlu@664 119
duke@435 120 # Except for a few acceptable ones
xlu@664 121 # Since GCC 4.3, -Wconversion has changed its meanings to warn these implicit
xlu@664 122 # conversions which might affect the values. To avoid that, we need to turn
xlu@664 123 # it off explicitly.
xlu@664 124 ifneq "$(shell expr \( $(CC_VER_MAJOR) \> 4 \) \| \( \( $(CC_VER_MAJOR) = 4 \) \& \( $(CC_VER_MINOR) \>= 3 \) \))" "0"
xlu@664 125 ACCEPTABLE_WARNINGS = -Wpointer-arith -Wsign-compare
xlu@664 126 else
duke@435 127 ACCEPTABLE_WARNINGS = -Wpointer-arith -Wconversion -Wsign-compare
xlu@664 128 endif
xlu@664 129
duke@435 130 CFLAGS_WARN/DEFAULT = $(WARNINGS_ARE_ERRORS) $(ACCEPTABLE_WARNINGS)
duke@435 131 # Special cases
duke@435 132 CFLAGS_WARN/BYFILE = $(CFLAGS_WARN/$@)$(CFLAGS_WARN/DEFAULT$(CFLAGS_WARN/$@))
duke@435 133
duke@435 134 # The flags to use for an Optimized g++ build
duke@435 135 OPT_CFLAGS += -O3
duke@435 136
duke@435 137 # Hotspot uses very unstrict aliasing turn this optimization off
duke@435 138 OPT_CFLAGS += -fno-strict-aliasing
duke@435 139
duke@435 140 # The gcc compiler segv's on ia64 when compiling bytecodeInterpreter.cpp
duke@435 141 # if we use expensive-optimizations
duke@435 142 ifeq ($(BUILDARCH), ia64)
duke@435 143 OPT_CFLAGS += -fno-expensive-optimizations
duke@435 144 endif
duke@435 145
duke@435 146 OPT_CFLAGS/NOOPT=-O0
duke@435 147
kvn@1179 148 # 6835796. Problem in GCC 4.3.0 with mulnode.o optimized compilation.
kvn@1179 149 ifneq "$(shell expr \( \( $(CC_VER_MAJOR) = 4 \) \& \( $(CC_VER_MINOR) = 3 \) \))" "0"
kvn@1179 150 OPT_CFLAGS/mulnode.o += -O0
kvn@1179 151 endif
kvn@1179 152
stefank@2314 153 # Flags for generating make dependency flags.
stefank@2314 154 ifneq ("${CC_VER_MAJOR}", "2")
stefank@2314 155 DEPFLAGS = -MMD -MP -MF $(DEP_DIR)/$(@:%=%.d)
stefank@2314 156 endif
stefank@2314 157
stefank@2325 158 # -DDONT_USE_PRECOMPILED_HEADER will exclude all includes in precompiled.hpp.
stefank@2325 159 ifneq ($(USE_PRECOMPILED_HEADER),1)
stefank@2325 160 CFLAGS += -DDONT_USE_PRECOMPILED_HEADER
stefank@2325 161 endif
stefank@2325 162
duke@435 163 #------------------------------------------------------------------------
duke@435 164 # Linker flags
duke@435 165
duke@435 166 # statically link libstdc++.so, work with gcc but ignored by g++
duke@435 167 STATIC_STDCXX = -Wl,-Bstatic -lstdc++ -Wl,-Bdynamic
duke@435 168
duke@435 169 # statically link libgcc and/or libgcc_s, libgcc does not exist before gcc-3.x.
duke@435 170 ifneq ("${CC_VER_MAJOR}", "2")
duke@435 171 STATIC_LIBGCC += -static-libgcc
duke@435 172 endif
duke@435 173
duke@435 174 ifeq ($(BUILDARCH), ia64)
duke@435 175 LFLAGS += -Wl,-relax
duke@435 176 endif
duke@435 177
duke@435 178 # Enable linker optimization
duke@435 179 LFLAGS += -Xlinker -O1
duke@435 180
ohair@1011 181 # If this is a --hash-style=gnu system, use --hash-style=both
ohair@1011 182 # The gnu .hash section won't work on some Linux systems like SuSE 10.
ohair@1011 183 _HAS_HASH_STYLE_GNU:=$(shell $(CC) -dumpspecs | grep -- '--hash-style=gnu')
ohair@1011 184 ifneq ($(_HAS_HASH_STYLE_GNU),)
ohair@1011 185 LDFLAGS_HASH_STYLE = -Wl,--hash-style=both
ohair@1011 186 endif
ohair@1011 187 LFLAGS += $(LDFLAGS_HASH_STYLE)
ohair@1011 188
duke@435 189 # Use $(MAPFLAG:FILENAME=real_file_name) to specify a map file.
duke@435 190 MAPFLAG = -Xlinker --version-script=FILENAME
duke@435 191
duke@435 192 # Use $(SONAMEFLAG:SONAME=soname) to specify the intrinsic name of a shared obj
duke@435 193 SONAMEFLAG = -Xlinker -soname=SONAME
duke@435 194
duke@435 195 # Build shared library
duke@435 196 SHARED_FLAG = -shared
duke@435 197
duke@435 198 # Keep symbols even they are not used
duke@435 199 AOUT_FLAGS += -export-dynamic
duke@435 200
duke@435 201 #------------------------------------------------------------------------
duke@435 202 # Debug flags
duke@435 203
duke@435 204 # Use the stabs format for debugging information (this is the default
duke@435 205 # on gcc-2.91). It's good enough, has all the information about line
duke@435 206 # numbers and local variables, and libjvm_g.so is only about 16M.
duke@435 207 # Change this back to "-g" if you want the most expressive format.
duke@435 208 # (warning: that could easily inflate libjvm_g.so to 150M!)
duke@435 209 # Note: The Itanium gcc compiler crashes when using -gstabs.
duke@435 210 DEBUG_CFLAGS/ia64 = -g
duke@435 211 DEBUG_CFLAGS/amd64 = -g
bobv@2036 212 DEBUG_CFLAGS/arm = -g
bobv@2036 213 DEBUG_CFLAGS/ppc = -g
duke@435 214 DEBUG_CFLAGS += $(DEBUG_CFLAGS/$(BUILDARCH))
duke@435 215 ifeq ($(DEBUG_CFLAGS/$(BUILDARCH)),)
duke@435 216 DEBUG_CFLAGS += -gstabs
duke@435 217 endif
aph@1202 218
aph@1202 219 # DEBUG_BINARIES overrides everything, use full -g debug information
aph@1202 220 ifeq ($(DEBUG_BINARIES), true)
aph@1202 221 DEBUG_CFLAGS = -g
aph@1202 222 CFLAGS += $(DEBUG_CFLAGS)
aph@1202 223 endif
bobv@2036 224
bobv@2036 225 # If we are building HEADLESS, pass on to VM
bobv@2036 226 # so it can set the java.awt.headless property
bobv@2036 227 ifdef HEADLESS
bobv@2036 228 CFLAGS += -DHEADLESS
bobv@2036 229 endif
bobv@2036 230
bobv@2036 231 # We are building Embedded for a small device
bobv@2036 232 # favor code space over speed
bobv@2036 233 ifdef MINIMIZE_RAM_USAGE
bobv@2036 234 CFLAGS += -DMINIMIZE_RAM_USAGE
bobv@2036 235 endif

mercurial