make/linux/makefiles/gcc.make

Wed, 11 Aug 2010 05:51:21 -0700

author
twisti
date
Wed, 11 Aug 2010 05:51:21 -0700
changeset 2047
d2ede61b7a12
parent 2036
126ea7725993
child 2314
f95d63e2154a
permissions
-rw-r--r--

6976186: integrate Shark HotSpot changes
Summary: Shark is a JIT compiler for Zero that uses the LLVM compiler infrastructure.
Reviewed-by: kvn, twisti
Contributed-by: Gary Benson <gbenson@redhat.com>

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

mercurial