make/linux/makefiles/gcc.make

Fri, 17 Apr 2009 15:50:12 +0100

author
aph
date
Fri, 17 Apr 2009 15:50:12 +0100
changeset 1202
5d4dd2f5f6a1
parent 1014
0fbdb4381b99
child 1205
f5ee65f94d9a
permissions
-rw-r--r--

6829575: 100028: Debug information is incomplete or missing
Summary: Enable debugging in many places
Reviewed-by: ohair
Contributed-by: Andrew Haley <aph@redhat.com>

duke@435 1 #
xdono@1014 2 # Copyright 1999-2009 Sun Microsystems, Inc. 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 #
duke@435 19 # Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
duke@435 20 # CA 95054 USA or visit www.sun.com if you need additional information or
duke@435 21 # have any questions.
duke@435 22 #
duke@435 23 #
duke@435 24
duke@435 25 #------------------------------------------------------------------------
duke@435 26 # CC, CPP & AS
duke@435 27
duke@435 28 CPP = g++
duke@435 29 CC = gcc
duke@435 30 AS = $(CC) -c
duke@435 31
duke@435 32 # -dumpversion in gcc-2.91 shows "egcs-2.91.66". In later version, it only
duke@435 33 # prints the numbers (e.g. "2.95", "3.2.1")
duke@435 34 CC_VER_MAJOR := $(shell $(CC) -dumpversion | sed 's/egcs-//' | cut -d'.' -f1)
duke@435 35 CC_VER_MINOR := $(shell $(CC) -dumpversion | sed 's/egcs-//' | cut -d'.' -f2)
duke@435 36
duke@435 37 # check for precompiled headers support
duke@435 38 ifneq "$(shell expr \( $(CC_VER_MAJOR) \> 3 \) \| \( \( $(CC_VER_MAJOR) = 3 \) \& \( $(CC_VER_MINOR) \>= 4 \) \))" "0"
duke@435 39 USE_PRECOMPILED_HEADER=1
duke@435 40 PRECOMPILED_HEADER_DIR=.
duke@435 41 PRECOMPILED_HEADER=$(PRECOMPILED_HEADER_DIR)/incls/_precompiled.incl.gch
duke@435 42 endif
duke@435 43
duke@435 44
duke@435 45 #------------------------------------------------------------------------
duke@435 46 # Compiler flags
duke@435 47
duke@435 48 # position-independent code
duke@435 49 PICFLAG = -fPIC
duke@435 50
duke@435 51 VM_PICFLAG/LIBJVM = $(PICFLAG)
duke@435 52 VM_PICFLAG/AOUT =
duke@435 53 VM_PICFLAG = $(VM_PICFLAG/$(LINK_INTO))
duke@435 54
duke@435 55 CFLAGS += $(VM_PICFLAG)
duke@435 56 CFLAGS += -fno-rtti
duke@435 57 CFLAGS += -fno-exceptions
duke@435 58 CFLAGS += -D_REENTRANT
duke@435 59 CFLAGS += -fcheck-new
duke@435 60
duke@435 61 ARCHFLAG = $(ARCHFLAG/$(BUILDARCH))
duke@435 62 ARCHFLAG/i486 = -m32 -march=i586
duke@435 63 ARCHFLAG/amd64 = -m64
duke@435 64 ARCHFLAG/ia64 =
duke@435 65 ARCHFLAG/sparc = -m32 -mcpu=v9
duke@435 66 ARCHFLAG/sparcv9 = -m64 -mcpu=v9
duke@435 67
duke@435 68 CFLAGS += $(ARCHFLAG)
duke@435 69 AOUT_FLAGS += $(ARCHFLAG)
duke@435 70 LFLAGS += $(ARCHFLAG)
duke@435 71 ASFLAGS += $(ARCHFLAG)
duke@435 72
duke@435 73 # Use C++ Interpreter
duke@435 74 ifdef CC_INTERP
duke@435 75 CFLAGS += -DCC_INTERP
duke@435 76 endif
duke@435 77
duke@435 78 # Keep temporary files (.ii, .s)
duke@435 79 ifdef NEED_ASM
duke@435 80 CFLAGS += -save-temps
duke@435 81 else
duke@435 82 CFLAGS += -pipe
duke@435 83 endif
duke@435 84
duke@435 85 # Compiler warnings are treated as errors
duke@435 86 WARNINGS_ARE_ERRORS = -Werror
xlu@664 87
duke@435 88 # Except for a few acceptable ones
xlu@664 89 # Since GCC 4.3, -Wconversion has changed its meanings to warn these implicit
xlu@664 90 # conversions which might affect the values. To avoid that, we need to turn
xlu@664 91 # it off explicitly.
xlu@664 92 ifneq "$(shell expr \( $(CC_VER_MAJOR) \> 4 \) \| \( \( $(CC_VER_MAJOR) = 4 \) \& \( $(CC_VER_MINOR) \>= 3 \) \))" "0"
xlu@664 93 ACCEPTABLE_WARNINGS = -Wpointer-arith -Wsign-compare
xlu@664 94 else
duke@435 95 ACCEPTABLE_WARNINGS = -Wpointer-arith -Wconversion -Wsign-compare
xlu@664 96 endif
xlu@664 97
duke@435 98 CFLAGS_WARN/DEFAULT = $(WARNINGS_ARE_ERRORS) $(ACCEPTABLE_WARNINGS)
duke@435 99 # Special cases
duke@435 100 CFLAGS_WARN/BYFILE = $(CFLAGS_WARN/$@)$(CFLAGS_WARN/DEFAULT$(CFLAGS_WARN/$@))
duke@435 101
duke@435 102 # The flags to use for an Optimized g++ build
duke@435 103 OPT_CFLAGS += -O3
duke@435 104
duke@435 105 # Hotspot uses very unstrict aliasing turn this optimization off
duke@435 106 OPT_CFLAGS += -fno-strict-aliasing
duke@435 107
duke@435 108 # The gcc compiler segv's on ia64 when compiling bytecodeInterpreter.cpp
duke@435 109 # if we use expensive-optimizations
duke@435 110 ifeq ($(BUILDARCH), ia64)
duke@435 111 OPT_CFLAGS += -fno-expensive-optimizations
duke@435 112 endif
duke@435 113
duke@435 114 OPT_CFLAGS/NOOPT=-O0
duke@435 115
duke@435 116 #------------------------------------------------------------------------
duke@435 117 # Linker flags
duke@435 118
duke@435 119 # statically link libstdc++.so, work with gcc but ignored by g++
duke@435 120 STATIC_STDCXX = -Wl,-Bstatic -lstdc++ -Wl,-Bdynamic
duke@435 121
duke@435 122 # statically link libgcc and/or libgcc_s, libgcc does not exist before gcc-3.x.
duke@435 123 ifneq ("${CC_VER_MAJOR}", "2")
duke@435 124 STATIC_LIBGCC += -static-libgcc
duke@435 125 endif
duke@435 126
duke@435 127 ifeq ($(BUILDARCH), ia64)
duke@435 128 LFLAGS += -Wl,-relax
duke@435 129 endif
duke@435 130
duke@435 131 # Enable linker optimization
duke@435 132 LFLAGS += -Xlinker -O1
duke@435 133
ohair@1011 134 # If this is a --hash-style=gnu system, use --hash-style=both
ohair@1011 135 # The gnu .hash section won't work on some Linux systems like SuSE 10.
ohair@1011 136 _HAS_HASH_STYLE_GNU:=$(shell $(CC) -dumpspecs | grep -- '--hash-style=gnu')
ohair@1011 137 ifneq ($(_HAS_HASH_STYLE_GNU),)
ohair@1011 138 LDFLAGS_HASH_STYLE = -Wl,--hash-style=both
ohair@1011 139 endif
ohair@1011 140 LFLAGS += $(LDFLAGS_HASH_STYLE)
ohair@1011 141
duke@435 142 # Use $(MAPFLAG:FILENAME=real_file_name) to specify a map file.
duke@435 143 MAPFLAG = -Xlinker --version-script=FILENAME
duke@435 144
duke@435 145 # Use $(SONAMEFLAG:SONAME=soname) to specify the intrinsic name of a shared obj
duke@435 146 SONAMEFLAG = -Xlinker -soname=SONAME
duke@435 147
duke@435 148 # Build shared library
duke@435 149 SHARED_FLAG = -shared
duke@435 150
duke@435 151 # Keep symbols even they are not used
duke@435 152 AOUT_FLAGS += -export-dynamic
duke@435 153
duke@435 154 #------------------------------------------------------------------------
duke@435 155 # Debug flags
duke@435 156
duke@435 157 # Use the stabs format for debugging information (this is the default
duke@435 158 # on gcc-2.91). It's good enough, has all the information about line
duke@435 159 # numbers and local variables, and libjvm_g.so is only about 16M.
duke@435 160 # Change this back to "-g" if you want the most expressive format.
duke@435 161 # (warning: that could easily inflate libjvm_g.so to 150M!)
duke@435 162 # Note: The Itanium gcc compiler crashes when using -gstabs.
duke@435 163 DEBUG_CFLAGS/ia64 = -g
duke@435 164 DEBUG_CFLAGS/amd64 = -g
duke@435 165 DEBUG_CFLAGS += $(DEBUG_CFLAGS/$(BUILDARCH))
duke@435 166 ifeq ($(DEBUG_CFLAGS/$(BUILDARCH)),)
duke@435 167 DEBUG_CFLAGS += -gstabs
duke@435 168 endif
aph@1202 169
aph@1202 170 # DEBUG_BINARIES overrides everything, use full -g debug information
aph@1202 171 ifeq ($(DEBUG_BINARIES), true)
aph@1202 172 DEBUG_CFLAGS = -g
aph@1202 173 CFLAGS += $(DEBUG_CFLAGS)
aph@1202 174 endif

mercurial