comparison make/bsd/makefiles/gcc.make @ 3960:f08d439fab8c

7089790: integrate bsd-port changes Reviewed-by: kvn, twisti, jrose Contributed-by: Kurt Miller <kurt@intricatesoftware.com>, Greg Lewis <glewis@eyesbeyond.com>, Jung-uk Kim <jkim@freebsd.org>, Christos Zoulas <christos@zoulas.com>, Landon Fuller <landonf@plausible.coop>, The FreeBSD Foundation <board@freebsdfoundation.org>, Michael Franz <mvfranz@gmail.com>, Roger Hoover <rhoover@apple.com>, Alexander Strange <astrange@apple.com>
author never
date Sun, 25 Sep 2011 16:03:29 -0700
parents
children 436b4a3231bf
comparison
equal deleted inserted replaced
3959:eda6988c0d81 3960:f08d439fab8c
1 #
2 # Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
3 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 #
5 # This code is free software; you can redistribute it and/or modify it
6 # under the terms of the GNU General Public License version 2 only, as
7 # published by the Free Software Foundation.
8 #
9 # This code is distributed in the hope that it will be useful, but WITHOUT
10 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 # version 2 for more details (a copy is included in the LICENSE file that
13 # accompanied this code).
14 #
15 # You should have received a copy of the GNU General Public License version
16 # 2 along with this work; if not, write to the Free Software Foundation,
17 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 #
19 # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 # or visit www.oracle.com if you need additional information or have any
21 # questions.
22 #
23 #
24
25 OS_VENDOR = $(shell uname -s)
26
27 #------------------------------------------------------------------------
28 # CC, CPP & AS
29
30 # When cross-compiling the ALT_COMPILER_PATH points
31 # to the cross-compilation toolset
32 ifdef CROSS_COMPILE_ARCH
33 CXX = $(ALT_COMPILER_PATH)/g++
34 CPP = $(ALT_COMPILER_PATH)/g++
35 CC = $(ALT_COMPILER_PATH)/gcc
36 HOSTCPP = g++
37 HOSTCC = gcc
38 else
39 CXX ?= g++
40 CPP = $(CXX)
41 CC ?= gcc
42 HOSTCPP = $(CPP)
43 HOSTCC = $(CPP)
44 endif
45
46 AS = $(CC) -c -x assembler-with-cpp
47
48 # -dumpversion in gcc-2.91 shows "egcs-2.91.66". In later version, it only
49 # prints the numbers (e.g. "2.95", "3.2.1")
50 CC_VER_MAJOR := $(shell $(CC) -dumpversion | sed 's/egcs-//' | cut -d'.' -f1)
51 CC_VER_MINOR := $(shell $(CC) -dumpversion | sed 's/egcs-//' | cut -d'.' -f2)
52
53 # check for precompiled headers support
54 ifneq "$(shell expr \( $(CC_VER_MAJOR) \> 3 \) \| \( \( $(CC_VER_MAJOR) = 3 \) \& \( $(CC_VER_MINOR) \>= 4 \) \))" "0"
55 # Allow the user to turn off precompiled headers from the command line.
56 ifneq ($(USE_PRECOMPILED_HEADER),0)
57 USE_PRECOMPILED_HEADER=1
58 PRECOMPILED_HEADER_DIR=.
59 PRECOMPILED_HEADER_SRC=$(GAMMADIR)/src/share/vm/precompiled.hpp
60 PRECOMPILED_HEADER=$(PRECOMPILED_HEADER_DIR)/precompiled.hpp.gch
61 endif
62 endif
63
64
65 #------------------------------------------------------------------------
66 # Compiler flags
67
68 # position-independent code
69 PICFLAG = -fPIC
70
71 VM_PICFLAG/LIBJVM = $(PICFLAG)
72 VM_PICFLAG/AOUT =
73 VM_PICFLAG = $(VM_PICFLAG/$(LINK_INTO))
74
75 ifeq ($(ZERO_BUILD), true)
76 CFLAGS += $(LIBFFI_CFLAGS)
77 endif
78 ifeq ($(SHARK_BUILD), true)
79 CFLAGS += $(LLVM_CFLAGS)
80 endif
81 CFLAGS += $(VM_PICFLAG)
82 CFLAGS += -fno-rtti
83 CFLAGS += -fno-exceptions
84 CFLAGS += -pthread
85 CFLAGS += -fcheck-new
86 # version 4 and above support fvisibility=hidden (matches jni_x86.h file)
87 # except 4.1.2 gives pointless warnings that can't be disabled (afaik)
88 ifneq "$(shell expr \( $(CC_VER_MAJOR) \> 4 \) \| \( \( $(CC_VER_MAJOR) = 4 \) \& \( $(CC_VER_MINOR) \>= 3 \) \))" "0"
89 CFLAGS += -fvisibility=hidden
90 endif
91
92 ARCHFLAG = $(ARCHFLAG/$(BUILDARCH))
93 ARCHFLAG/i486 = -m32 -march=i586
94 ARCHFLAG/amd64 = -m64
95 ARCHFLAG/ia64 =
96 ARCHFLAG/sparc = -m32 -mcpu=v9
97 ARCHFLAG/sparcv9 = -m64 -mcpu=v9
98 ARCHFLAG/zero = $(ZERO_ARCHFLAG)
99
100 # Darwin-specific build flags
101 ifeq ($(OS_VENDOR), Darwin)
102 # Ineffecient 16-byte stack re-alignment on Darwin/IA32
103 ARCHFLAG/i486 += -mstackrealign
104 endif
105
106 CFLAGS += $(ARCHFLAG)
107 AOUT_FLAGS += $(ARCHFLAG)
108 LFLAGS += $(ARCHFLAG)
109 ASFLAGS += $(ARCHFLAG)
110
111 ifdef E500V2
112 CFLAGS += -DE500V2
113 endif
114
115 # Use C++ Interpreter
116 ifdef CC_INTERP
117 CFLAGS += -DCC_INTERP
118 endif
119
120 # Build for embedded targets
121 ifdef JAVASE_EMBEDDED
122 CFLAGS += -DJAVASE_EMBEDDED
123 endif
124
125 # Keep temporary files (.ii, .s)
126 ifdef NEED_ASM
127 CFLAGS += -save-temps
128 else
129 CFLAGS += -pipe
130 endif
131
132 # Compiler warnings are treated as errors
133 WARNINGS_ARE_ERRORS = -Werror
134
135 # Except for a few acceptable ones
136 # Since GCC 4.3, -Wconversion has changed its meanings to warn these implicit
137 # conversions which might affect the values. To avoid that, we need to turn
138 # it off explicitly.
139 ifneq "$(shell expr \( $(CC_VER_MAJOR) \> 4 \) \| \( \( $(CC_VER_MAJOR) = 4 \) \& \( $(CC_VER_MINOR) \>= 3 \) \))" "0"
140 ACCEPTABLE_WARNINGS = -Wpointer-arith -Wsign-compare
141 else
142 ACCEPTABLE_WARNINGS = -Wpointer-arith -Wconversion -Wsign-compare
143 endif
144
145 CFLAGS_WARN/DEFAULT = $(WARNINGS_ARE_ERRORS) $(ACCEPTABLE_WARNINGS)
146 # Special cases
147 CFLAGS_WARN/BYFILE = $(CFLAGS_WARN/$@)$(CFLAGS_WARN/DEFAULT$(CFLAGS_WARN/$@))
148 # XXXDARWIN: for _dyld_bind_fully_image_containing_address
149 ifeq ($(OS_VENDOR), Darwin)
150 CFLAGS_WARN/os_bsd.o = $(CFLAGS_WARN/DEFAULT) -Wno-deprecated-declarations
151 endif
152
153
154 # The flags to use for an Optimized g++ build
155 OPT_CFLAGS += -O3
156
157 # Hotspot uses very unstrict aliasing turn this optimization off
158 OPT_CFLAGS += -fno-strict-aliasing
159
160 # The gcc compiler segv's on ia64 when compiling bytecodeInterpreter.cpp
161 # if we use expensive-optimizations
162 ifeq ($(BUILDARCH), ia64)
163 OPT_CFLAGS += -fno-expensive-optimizations
164 endif
165
166 OPT_CFLAGS/NOOPT=-O0
167
168 # 6835796. Problem in GCC 4.3.0 with mulnode.o optimized compilation.
169 ifneq "$(shell expr \( \( $(CC_VER_MAJOR) = 4 \) \& \( $(CC_VER_MINOR) = 3 \) \))" "0"
170 OPT_CFLAGS/mulnode.o += -O0
171 endif
172
173 # Flags for generating make dependency flags.
174 ifneq ("${CC_VER_MAJOR}", "2")
175 DEPFLAGS = -MMD -MP -MF $(DEP_DIR)/$(@:%=%.d)
176 endif
177
178 # -DDONT_USE_PRECOMPILED_HEADER will exclude all includes in precompiled.hpp.
179 ifneq ($(USE_PRECOMPILED_HEADER),1)
180 CFLAGS += -DDONT_USE_PRECOMPILED_HEADER
181 endif
182
183 #------------------------------------------------------------------------
184 # Linker flags
185
186 # statically link libstdc++.so, work with gcc but ignored by g++
187 STATIC_STDCXX = -Wl,-Bstatic -lstdc++ -Wl,-Bdynamic
188
189 # statically link libgcc and/or libgcc_s, libgcc does not exist before gcc-3.x.
190 ifneq ("${CC_VER_MAJOR}", "2")
191 STATIC_LIBGCC += -static-libgcc
192 endif
193
194 ifeq ($(BUILDARCH), ia64)
195 LFLAGS += -Wl,-relax
196 endif
197
198 # Use $(MAPFLAG:FILENAME=real_file_name) to specify a map file.
199 MAPFLAG = -Xlinker --version-script=FILENAME
200
201 #
202 # Shared Library
203 #
204 ifeq ($(OS_VENDOR), Darwin)
205 # Standard linker flags
206 LFLAGS +=
207
208 # Darwin doesn't use ELF and doesn't support version scripts
209 LDNOMAP = true
210
211 # Use $(SONAMEFLAG:SONAME=soname) to specify the intrinsic name of a shared obj
212 SONAMEFLAG =
213
214 # Build shared library
215 SHARED_FLAG = -dynamiclib $(VM_PICFLAG)
216
217 # Keep symbols even they are not used
218 #AOUT_FLAGS += -Xlinker -export-dynamic
219 else
220 # Enable linker optimization
221 LFLAGS += -Xlinker -O1
222
223 # Use $(SONAMEFLAG:SONAME=soname) to specify the intrinsic name of a shared obj
224 SONAMEFLAG = -Xlinker -soname=SONAME
225
226 # Build shared library
227 SHARED_FLAG = -shared $(VM_PICFLAG)
228
229 # Keep symbols even they are not used
230 AOUT_FLAGS += -Xlinker -export-dynamic
231 endif
232
233 #------------------------------------------------------------------------
234 # Debug flags
235
236 # Use the stabs format for debugging information (this is the default
237 # on gcc-2.91). It's good enough, has all the information about line
238 # numbers and local variables, and libjvm_g.so is only about 16M.
239 # Change this back to "-g" if you want the most expressive format.
240 # (warning: that could easily inflate libjvm_g.so to 150M!)
241 # Note: The Itanium gcc compiler crashes when using -gstabs.
242 DEBUG_CFLAGS/ia64 = -g
243 DEBUG_CFLAGS/amd64 = -g
244 DEBUG_CFLAGS/arm = -g
245 DEBUG_CFLAGS/ppc = -g
246 DEBUG_CFLAGS += $(DEBUG_CFLAGS/$(BUILDARCH))
247 ifeq ($(DEBUG_CFLAGS/$(BUILDARCH)),)
248 DEBUG_CFLAGS += -gstabs
249 endif
250
251 # DEBUG_BINARIES overrides everything, use full -g debug information
252 ifeq ($(DEBUG_BINARIES), true)
253 DEBUG_CFLAGS = -g
254 CFLAGS += $(DEBUG_CFLAGS)
255 endif
256
257 # If we are building HEADLESS, pass on to VM
258 # so it can set the java.awt.headless property
259 ifdef HEADLESS
260 CFLAGS += -DHEADLESS
261 endif
262
263 # We are building Embedded for a small device
264 # favor code space over speed
265 ifdef MINIMIZE_RAM_USAGE
266 CFLAGS += -DMINIMIZE_RAM_USAGE
267 endif