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