make/linux/makefiles/gcc.make

Tue, 14 May 2013 07:24:50 -0400

author
dholmes
date
Tue, 14 May 2013 07:24:50 -0400
changeset 5147
293b99787401
parent 4889
cc32ccaaf47f
child 5230
2cb5d5f6d5e5
permissions
-rw-r--r--

8014460: Need to check for non-empty EXT_LIBS_PATH before using it
Reviewed-by: tbell, collins, sla, coleenp

duke@435 1 #
dcubed@3724 2 # Copyright (c) 1999, 2012, 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
erikj@3600 28 # If a SPEC is not set already, then use these defaults.
erikj@3600 29 ifeq ($(SPEC),)
erikj@3600 30 # When cross-compiling the ALT_COMPILER_PATH points
erikj@3600 31 # to the cross-compilation toolset
erikj@3600 32 ifdef CROSS_COMPILE_ARCH
erikj@3600 33 CXX = $(ALT_COMPILER_PATH)/g++
erikj@3600 34 CC = $(ALT_COMPILER_PATH)/gcc
erikj@3600 35 HOSTCXX = g++
erikj@3600 36 HOSTCC = gcc
erikj@3600 37 STRIP = $(ALT_COMPILER_PATH)/strip
erikj@3600 38 else
erikj@3600 39 CXX = g++
erikj@3600 40 CC = gcc
erikj@3600 41 HOSTCXX = $(CXX)
erikj@3600 42 HOSTCC = $(CC)
erikj@3600 43 STRIP = strip
erikj@3600 44 endif
erikj@3600 45 AS = $(CC) -c
bobv@2036 46 endif
bobv@2036 47
duke@435 48
duke@435 49 # -dumpversion in gcc-2.91 shows "egcs-2.91.66". In later version, it only
duke@435 50 # prints the numbers (e.g. "2.95", "3.2.1")
duke@435 51 CC_VER_MAJOR := $(shell $(CC) -dumpversion | sed 's/egcs-//' | cut -d'.' -f1)
duke@435 52 CC_VER_MINOR := $(shell $(CC) -dumpversion | sed 's/egcs-//' | cut -d'.' -f2)
duke@435 53
duke@435 54 # check for precompiled headers support
duke@435 55 ifneq "$(shell expr \( $(CC_VER_MAJOR) \> 3 \) \| \( \( $(CC_VER_MAJOR) = 3 \) \& \( $(CC_VER_MINOR) \>= 4 \) \))" "0"
stefank@2325 56 # Allow the user to turn off precompiled headers from the command line.
stefank@2325 57 ifneq ($(USE_PRECOMPILED_HEADER),0)
duke@435 58 PRECOMPILED_HEADER_DIR=.
brutisso@3229 59 PRECOMPILED_HEADER_SRC=$(GAMMADIR)/src/share/vm/precompiled/precompiled.hpp
stefank@2314 60 PRECOMPILED_HEADER=$(PRECOMPILED_HEADER_DIR)/precompiled.hpp.gch
duke@435 61 endif
stefank@2325 62 endif
duke@435 63
duke@435 64
duke@435 65 #------------------------------------------------------------------------
duke@435 66 # Compiler flags
duke@435 67
duke@435 68 # position-independent code
duke@435 69 PICFLAG = -fPIC
duke@435 70
duke@435 71 VM_PICFLAG/LIBJVM = $(PICFLAG)
duke@435 72 VM_PICFLAG/AOUT =
duke@435 73 VM_PICFLAG = $(VM_PICFLAG/$(LINK_INTO))
duke@435 74
erikj@3649 75 ifeq ($(JVM_VARIANT_ZERO), true)
never@1445 76 CFLAGS += $(LIBFFI_CFLAGS)
never@1445 77 endif
erikj@3649 78 ifeq ($(JVM_VARIANT_ZEROSHARK), true)
erikj@3649 79 CFLAGS += $(LIBFFI_CFLAGS)
twisti@2047 80 CFLAGS += $(LLVM_CFLAGS)
twisti@2047 81 endif
duke@435 82 CFLAGS += $(VM_PICFLAG)
duke@435 83 CFLAGS += -fno-rtti
duke@435 84 CFLAGS += -fno-exceptions
duke@435 85 CFLAGS += -D_REENTRANT
duke@435 86 CFLAGS += -fcheck-new
coleenp@2507 87 # version 4 and above support fvisibility=hidden (matches jni_x86.h file)
coleenp@2507 88 # except 4.1.2 gives pointless warnings that can't be disabled (afaik)
coleenp@2507 89 ifneq "$(shell expr \( $(CC_VER_MAJOR) \> 4 \) \| \( \( $(CC_VER_MAJOR) = 4 \) \& \( $(CC_VER_MINOR) \>= 3 \) \))" "0"
coleenp@2507 90 CFLAGS += -fvisibility=hidden
coleenp@2507 91 endif
duke@435 92
duke@435 93 ARCHFLAG = $(ARCHFLAG/$(BUILDARCH))
duke@435 94 ARCHFLAG/i486 = -m32 -march=i586
duke@435 95 ARCHFLAG/amd64 = -m64
duke@435 96 ARCHFLAG/ia64 =
duke@435 97 ARCHFLAG/sparc = -m32 -mcpu=v9
duke@435 98 ARCHFLAG/sparcv9 = -m64 -mcpu=v9
bobv@2036 99 ARCHFLAG/arm = -fsigned-char
never@1445 100 ARCHFLAG/zero = $(ZERO_ARCHFLAG)
bobv@2036 101 ifndef E500V2
bobv@2036 102 ARCHFLAG/ppc = -mcpu=powerpc
bobv@2036 103 endif
duke@435 104
duke@435 105 CFLAGS += $(ARCHFLAG)
duke@435 106 AOUT_FLAGS += $(ARCHFLAG)
duke@435 107 LFLAGS += $(ARCHFLAG)
duke@435 108 ASFLAGS += $(ARCHFLAG)
duke@435 109
bobv@2036 110 ifdef E500V2
bobv@2036 111 CFLAGS += -DE500V2
bobv@2036 112 endif
bobv@2036 113
duke@435 114 # Use C++ Interpreter
duke@435 115 ifdef CC_INTERP
duke@435 116 CFLAGS += -DCC_INTERP
duke@435 117 endif
duke@435 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
mikael@4889 129 WARNING_FLAGS = -Wpointer-arith -Wsign-compare -Wundef -Wunused-function
mikael@4889 130
xlu@664 131 # Since GCC 4.3, -Wconversion has changed its meanings to warn these implicit
mikael@4889 132 # conversions which might affect the values. Only enable it in earlier versions.
mikael@4889 133 ifeq "$(shell expr \( $(CC_VER_MAJOR) \> 4 \) \| \( \( $(CC_VER_MAJOR) = 4 \) \& \( $(CC_VER_MINOR) \>= 3 \) \))" "0"
mikael@4889 134 WARNING_FLAGS += -Wconversion
xlu@664 135 endif
xlu@664 136
jprovino@4722 137 CFLAGS_WARN/DEFAULT = $(WARNINGS_ARE_ERRORS) $(WARNING_FLAGS)
duke@435 138 # Special cases
duke@435 139 CFLAGS_WARN/BYFILE = $(CFLAGS_WARN/$@)$(CFLAGS_WARN/DEFAULT$(CFLAGS_WARN/$@))
duke@435 140
duke@435 141 # The flags to use for an Optimized g++ build
jprovino@4165 142 OPT_CFLAGS/SIZE=-Os
jprovino@4165 143 OPT_CFLAGS/SPEED=-O3
duke@435 144
duke@435 145 # Hotspot uses very unstrict aliasing turn this optimization off
jprovino@4165 146 # This option is added to CFLAGS rather than OPT_CFLAGS
jprovino@4165 147 # so that OPT_CFLAGS overrides get this option too.
jprovino@4165 148 CFLAGS += -fno-strict-aliasing
jprovino@4165 149
jprovino@4165 150 OPT_CFLAGS_DEFAULT ?= SPEED
jprovino@4165 151
jprovino@4165 152 ifdef OPT_CFLAGS
jprovino@4165 153 ifneq ("$(origin OPT_CFLAGS)", "command line")
jprovino@4165 154 $(error " Use OPT_EXTRAS instead of OPT_CFLAGS to add extra flags to OPT_CFLAGS.")
jprovino@4165 155 endif
jprovino@4165 156 endif
jprovino@4165 157
jprovino@4165 158 OPT_CFLAGS = $(OPT_CFLAGS/$(OPT_CFLAGS_DEFAULT)) $(OPT_EXTRAS)
duke@435 159
duke@435 160 # The gcc compiler segv's on ia64 when compiling bytecodeInterpreter.cpp
duke@435 161 # if we use expensive-optimizations
duke@435 162 ifeq ($(BUILDARCH), ia64)
duke@435 163 OPT_CFLAGS += -fno-expensive-optimizations
duke@435 164 endif
duke@435 165
duke@435 166 OPT_CFLAGS/NOOPT=-O0
duke@435 167
kvn@1179 168 # 6835796. Problem in GCC 4.3.0 with mulnode.o optimized compilation.
kvn@1179 169 ifneq "$(shell expr \( \( $(CC_VER_MAJOR) = 4 \) \& \( $(CC_VER_MINOR) = 3 \) \))" "0"
kvn@1179 170 OPT_CFLAGS/mulnode.o += -O0
kvn@1179 171 endif
kvn@1179 172
stefank@2314 173 # Flags for generating make dependency flags.
stefank@2314 174 ifneq ("${CC_VER_MAJOR}", "2")
kamg@3832 175 DEPFLAGS = -fpch-deps -MMD -MP -MF $(DEP_DIR)/$(@:%=%.d)
stefank@2314 176 endif
stefank@2314 177
stefank@2325 178 # -DDONT_USE_PRECOMPILED_HEADER will exclude all includes in precompiled.hpp.
stefank@3325 179 ifeq ($(USE_PRECOMPILED_HEADER),0)
stefank@2325 180 CFLAGS += -DDONT_USE_PRECOMPILED_HEADER
stefank@2325 181 endif
stefank@2325 182
duke@435 183 #------------------------------------------------------------------------
duke@435 184 # Linker flags
duke@435 185
duke@435 186 # statically link libstdc++.so, work with gcc but ignored by g++
duke@435 187 STATIC_STDCXX = -Wl,-Bstatic -lstdc++ -Wl,-Bdynamic
duke@435 188
duke@435 189 # statically link libgcc and/or libgcc_s, libgcc does not exist before gcc-3.x.
duke@435 190 ifneq ("${CC_VER_MAJOR}", "2")
duke@435 191 STATIC_LIBGCC += -static-libgcc
duke@435 192 endif
duke@435 193
duke@435 194 ifeq ($(BUILDARCH), ia64)
duke@435 195 LFLAGS += -Wl,-relax
duke@435 196 endif
duke@435 197
duke@435 198 # Enable linker optimization
duke@435 199 LFLAGS += -Xlinker -O1
duke@435 200
ohair@1011 201 # If this is a --hash-style=gnu system, use --hash-style=both
ohair@1011 202 # The gnu .hash section won't work on some Linux systems like SuSE 10.
ohair@1011 203 _HAS_HASH_STYLE_GNU:=$(shell $(CC) -dumpspecs | grep -- '--hash-style=gnu')
ohair@1011 204 ifneq ($(_HAS_HASH_STYLE_GNU),)
ohair@1011 205 LDFLAGS_HASH_STYLE = -Wl,--hash-style=both
ohair@1011 206 endif
ohair@1011 207 LFLAGS += $(LDFLAGS_HASH_STYLE)
ohair@1011 208
duke@435 209 # Use $(MAPFLAG:FILENAME=real_file_name) to specify a map file.
duke@435 210 MAPFLAG = -Xlinker --version-script=FILENAME
duke@435 211
duke@435 212 # Use $(SONAMEFLAG:SONAME=soname) to specify the intrinsic name of a shared obj
duke@435 213 SONAMEFLAG = -Xlinker -soname=SONAME
duke@435 214
duke@435 215 # Build shared library
duke@435 216 SHARED_FLAG = -shared
duke@435 217
duke@435 218 # Keep symbols even they are not used
dsamersoff@2839 219 AOUT_FLAGS += -Xlinker -export-dynamic
duke@435 220
duke@435 221 #------------------------------------------------------------------------
duke@435 222 # Debug flags
duke@435 223
dcubed@3989 224 # DEBUG_BINARIES uses full -g debug information for all configs
dcubed@3989 225 ifeq ($(DEBUG_BINARIES), true)
dcubed@3989 226 CFLAGS += -g
dcubed@3989 227 else
dcubed@3989 228 # Use the stabs format for debugging information (this is the default
dcubed@3989 229 # on gcc-2.91). It's good enough, has all the information about line
dcubed@4344 230 # numbers and local variables, and libjvm.so is only about 16M.
dcubed@3989 231 # Change this back to "-g" if you want the most expressive format.
dcubed@4344 232 # (warning: that could easily inflate libjvm.so to 150M!)
dcubed@3989 233 # Note: The Itanium gcc compiler crashes when using -gstabs.
dcubed@3989 234 DEBUG_CFLAGS/ia64 = -g
dcubed@3989 235 DEBUG_CFLAGS/amd64 = -g
dcubed@3989 236 DEBUG_CFLAGS/arm = -g
dcubed@3989 237 DEBUG_CFLAGS/ppc = -g
dcubed@3989 238 DEBUG_CFLAGS += $(DEBUG_CFLAGS/$(BUILDARCH))
dcubed@3989 239 ifeq ($(DEBUG_CFLAGS/$(BUILDARCH)),)
dcubed@3989 240 DEBUG_CFLAGS += -gstabs
dcubed@3150 241 endif
dcubed@3989 242
dcubed@3989 243 ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1)
dcubed@3989 244 FASTDEBUG_CFLAGS/ia64 = -g
dcubed@3989 245 FASTDEBUG_CFLAGS/amd64 = -g
dcubed@3989 246 FASTDEBUG_CFLAGS/arm = -g
dcubed@3989 247 FASTDEBUG_CFLAGS/ppc = -g
dcubed@3989 248 FASTDEBUG_CFLAGS += $(DEBUG_CFLAGS/$(BUILDARCH))
dcubed@3989 249 ifeq ($(FASTDEBUG_CFLAGS/$(BUILDARCH)),)
dcubed@3989 250 FASTDEBUG_CFLAGS += -gstabs
dcubed@3989 251 endif
dcubed@3989 252
dcubed@3989 253 OPT_CFLAGS/ia64 = -g
dcubed@3989 254 OPT_CFLAGS/amd64 = -g
dcubed@3989 255 OPT_CFLAGS/arm = -g
dcubed@3989 256 OPT_CFLAGS/ppc = -g
dcubed@3989 257 OPT_CFLAGS += $(OPT_CFLAGS/$(BUILDARCH))
dcubed@3989 258 ifeq ($(OPT_CFLAGS/$(BUILDARCH)),)
dcubed@3989 259 OPT_CFLAGS += -gstabs
dcubed@3989 260 endif
dcubed@3150 261 endif
dcubed@3150 262 endif
dcubed@3150 263
bobv@2036 264 # If we are building HEADLESS, pass on to VM
bobv@2036 265 # so it can set the java.awt.headless property
bobv@2036 266 ifdef HEADLESS
bobv@2036 267 CFLAGS += -DHEADLESS
bobv@2036 268 endif
bobv@2036 269
bobv@2036 270 # We are building Embedded for a small device
bobv@2036 271 # favor code space over speed
bobv@2036 272 ifdef MINIMIZE_RAM_USAGE
bobv@2036 273 CFLAGS += -DMINIMIZE_RAM_USAGE
bobv@2036 274 endif

mercurial