Thu, 25 Jul 2013 21:05:29 -0400
8021314: minimal1.make needs to force off components not supported by the minimal VM
Reviewed-by: coleenp, bpittore
1 #
2 # Copyright (c) 1999, 2013, 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 #
25 OS_VENDOR = $(shell uname -s)
27 #------------------------------------------------------------------------
28 # CC, CXX & AS
30 # If a SPEC is not set already, then use these defaults.
31 ifeq ($(SPEC),)
32 # When cross-compiling the ALT_COMPILER_PATH points
33 # to the cross-compilation toolset
34 ifdef CROSS_COMPILE_ARCH
35 CXX = $(ALT_COMPILER_PATH)/g++
36 CC = $(ALT_COMPILER_PATH)/gcc
37 HOSTCXX = g++
38 HOSTCC = gcc
39 else ifneq ($(OS_VENDOR), Darwin)
40 CXX = g++
41 CC = gcc
42 HOSTCXX = $(CXX)
43 HOSTCC = $(CC)
44 endif
46 # i486 hotspot requires -mstackrealign on Darwin.
47 # llvm-gcc supports this in Xcode 3.2.6 and 4.0.
48 # gcc-4.0 supports this on earlier versions.
49 # Prefer llvm-gcc where available.
50 ifeq ($(OS_VENDOR), Darwin)
51 ifeq ($(origin CXX), default)
52 CXX = llvm-g++
53 endif
54 ifeq ($(origin CC), default)
55 CC = llvm-gcc
56 endif
58 ifeq ($(ARCH), i486)
59 LLVM_SUPPORTS_STACKREALIGN := $(shell \
60 [ "0"`llvm-gcc -v 2>&1 | grep LLVM | sed -E "s/.*LLVM build ([0-9]+).*/\1/"` -gt "2333" ] \
61 && echo true || echo false)
63 ifeq ($(LLVM_SUPPORTS_STACKREALIGN), true)
64 CXX32 ?= llvm-g++
65 CC32 ?= llvm-gcc
66 else
67 CXX32 ?= g++-4.0
68 CC32 ?= gcc-4.0
69 endif
70 CXX = $(CXX32)
71 CC = $(CC32)
72 endif
74 ifeq ($(USE_CLANG), true)
75 CXX = clang++
76 CC = clang
77 endif
79 HOSTCXX = $(CXX)
80 HOSTCC = $(CC)
81 endif
83 AS = $(CC) -c -x assembler-with-cpp
84 endif
87 ifeq ($(USE_CLANG), true)
88 CC_VER_MAJOR := $(shell $(CC) -v 2>&1 | grep version | sed "s/.*version \([0-9]*\.[0-9]*\).*/\1/" | cut -d'.' -f1)
89 CC_VER_MINOR := $(shell $(CC) -v 2>&1 | grep version | sed "s/.*version \([0-9]*\.[0-9]*\).*/\1/" | cut -d'.' -f2)
90 else
91 # -dumpversion in gcc-2.91 shows "egcs-2.91.66". In later version, it only
92 # prints the numbers (e.g. "2.95", "3.2.1")
93 CC_VER_MAJOR := $(shell $(CC) -dumpversion | sed 's/egcs-//' | cut -d'.' -f1)
94 CC_VER_MINOR := $(shell $(CC) -dumpversion | sed 's/egcs-//' | cut -d'.' -f2)
95 endif
97 ifeq ($(USE_CLANG), true)
98 # clang has precompiled headers support by default, but the user can switch
99 # it off by using 'USE_PRECOMPILED_HEADER=0'.
100 ifdef LP64
101 ifeq ($(USE_PRECOMPILED_HEADER),)
102 USE_PRECOMPILED_HEADER=1
103 endif
104 else
105 # We don't support precompiled headers on 32-bit builds because there some files are
106 # compiled with -fPIC while others are compiled without (see 'NONPIC_OBJ_FILES' rules.make)
107 # Clang produces an error if the PCH file was compiled with other options than the actual compilation unit.
108 USE_PRECOMPILED_HEADER=0
109 endif
111 ifeq ($(USE_PRECOMPILED_HEADER),1)
113 ifndef LP64
114 $(error " Precompiled Headers only supported on 64-bit platforms!")
115 endif
117 PRECOMPILED_HEADER_DIR=.
118 PRECOMPILED_HEADER_SRC=$(GAMMADIR)/src/share/vm/precompiled/precompiled.hpp
119 PRECOMPILED_HEADER=$(PRECOMPILED_HEADER_DIR)/precompiled.hpp.pch
121 PCH_FLAG = -include precompiled.hpp
122 PCH_FLAG/DEFAULT = $(PCH_FLAG)
123 PCH_FLAG/NO_PCH = -DNO_PCH
124 PCH_FLAG/BY_FILE = $(PCH_FLAG/$@)$(PCH_FLAG/DEFAULT$(PCH_FLAG/$@))
126 VM_PCH_FLAG/LIBJVM = $(PCH_FLAG/BY_FILE)
127 VM_PCH_FLAG/AOUT =
128 VM_PCH_FLAG = $(VM_PCH_FLAG/$(LINK_INTO))
130 # We only use precompiled headers for the JVM build
131 CFLAGS += $(VM_PCH_FLAG)
133 # There are some files which don't like precompiled headers
134 # The following files are build with 'OPT_CFLAGS/NOOPT' (-O0) in the opt build.
135 # But Clang doesn't support a precompiled header which was compiled with -O3
136 # to be used in a compilation unit which uses '-O0'. We could also prepare an
137 # extra '-O0' PCH file for the opt build and use it here, but it's probably
138 # not worth the effort as long as only two files need this special handling.
139 PCH_FLAG/loopTransform.o = $(PCH_FLAG/NO_PCH)
140 PCH_FLAG/sharedRuntimeTrig.o = $(PCH_FLAG/NO_PCH)
141 PCH_FLAG/sharedRuntimeTrans.o = $(PCH_FLAG/NO_PCH)
143 endif
144 else # ($(USE_CLANG), true)
145 # check for precompiled headers support
146 ifneq "$(shell expr \( $(CC_VER_MAJOR) \> 3 \) \| \( \( $(CC_VER_MAJOR) = 3 \) \& \( $(CC_VER_MINOR) \>= 4 \) \))" "0"
147 # Allow the user to turn off precompiled headers from the command line.
148 ifneq ($(USE_PRECOMPILED_HEADER),0)
149 PRECOMPILED_HEADER_DIR=.
150 PRECOMPILED_HEADER_SRC=$(GAMMADIR)/src/share/vm/precompiled/precompiled.hpp
151 PRECOMPILED_HEADER=$(PRECOMPILED_HEADER_DIR)/precompiled.hpp.gch
152 endif
153 endif
154 endif
156 # -DDONT_USE_PRECOMPILED_HEADER will exclude all includes in precompiled.hpp.
157 ifeq ($(USE_PRECOMPILED_HEADER),0)
158 CFLAGS += -DDONT_USE_PRECOMPILED_HEADER
159 endif
161 #------------------------------------------------------------------------
162 # Compiler flags
164 # position-independent code
165 PICFLAG = -fPIC
167 VM_PICFLAG/LIBJVM = $(PICFLAG)
168 VM_PICFLAG/AOUT =
169 VM_PICFLAG = $(VM_PICFLAG/$(LINK_INTO))
171 ifeq ($(JVM_VARIANT_ZERO), true)
172 CFLAGS += $(LIBFFI_CFLAGS)
173 endif
174 ifeq ($(JVM_VARIANT_ZEROSHARK), true)
175 CFLAGS += $(LIBFFI_CFLAGS)
176 CFLAGS += $(LLVM_CFLAGS)
177 endif
178 CFLAGS += $(VM_PICFLAG)
179 CFLAGS += -fno-rtti
180 CFLAGS += -fno-exceptions
181 ifeq ($(USE_CLANG),)
182 CFLAGS += -pthread
183 CFLAGS += -fcheck-new
184 # version 4 and above support fvisibility=hidden (matches jni_x86.h file)
185 # except 4.1.2 gives pointless warnings that can't be disabled (afaik)
186 ifneq "$(shell expr \( $(CC_VER_MAJOR) \> 4 \) \| \( \( $(CC_VER_MAJOR) = 4 \) \& \( $(CC_VER_MINOR) \>= 3 \) \))" "0"
187 CFLAGS += -fvisibility=hidden
188 endif
189 else
190 CFLAGS += -fvisibility=hidden
191 endif
193 ifeq ($(USE_CLANG), true)
194 # Before Clang 3.1, we had to pass the stack alignment specification directly to llvm with the help of '-mllvm'
195 # Starting with version 3.1, Clang understands the '-mstack-alignment' (and rejects '-mllvm -stack-alignment')
196 ifneq "$(shell expr \( $(CC_VER_MAJOR) \> 3 \) \| \( \( $(CC_VER_MAJOR) = 3 \) \& \( $(CC_VER_MINOR) \>= 1 \) \))" "0"
197 STACK_ALIGNMENT_OPT = -mno-omit-leaf-frame-pointer -mstack-alignment=16
198 else
199 STACK_ALIGNMENT_OPT = -mno-omit-leaf-frame-pointer -mllvm -stack-alignment=16
200 endif
201 endif
203 ARCHFLAG = $(ARCHFLAG/$(BUILDARCH))
204 ARCHFLAG/i486 = -m32 -march=i586
205 ARCHFLAG/amd64 = -m64 $(STACK_ALIGNMENT_OPT)
206 ARCHFLAG/ia64 =
207 ARCHFLAG/sparc = -m32 -mcpu=v9
208 ARCHFLAG/sparcv9 = -m64 -mcpu=v9
209 ARCHFLAG/zero = $(ZERO_ARCHFLAG)
211 # Darwin-specific build flags
212 ifeq ($(OS_VENDOR), Darwin)
213 # Ineffecient 16-byte stack re-alignment on Darwin/IA32
214 ARCHFLAG/i486 += -mstackrealign
215 endif
217 CFLAGS += $(ARCHFLAG)
218 AOUT_FLAGS += $(ARCHFLAG)
219 LFLAGS += $(ARCHFLAG)
220 ASFLAGS += $(ARCHFLAG)
222 ifdef E500V2
223 CFLAGS += -DE500V2
224 endif
226 # Use C++ Interpreter
227 ifdef CC_INTERP
228 CFLAGS += -DCC_INTERP
229 endif
231 # Keep temporary files (.ii, .s)
232 ifdef NEED_ASM
233 CFLAGS += -save-temps
234 else
235 CFLAGS += -pipe
236 endif
238 # Compiler warnings are treated as errors
239 ifneq ($(COMPILER_WARNINGS_FATAL),false)
240 WARNINGS_ARE_ERRORS = -Werror
241 endif
243 ifeq ($(USE_CLANG), true)
244 # However we need to clean the code up before we can unrestrictedly enable this option with Clang
245 WARNINGS_ARE_ERRORS += -Wno-unused-value -Wno-logical-op-parentheses -Wno-parentheses-equality -Wno-parentheses
246 WARNINGS_ARE_ERRORS += -Wno-switch -Wno-tautological-compare
247 # Not yet supported by clang in Xcode 4.6.2
248 # WARNINGS_ARE_ERRORS += -Wno-tautological-constant-out-of-range-compare
249 WARNINGS_ARE_ERRORS += -Wno-delete-non-virtual-dtor -Wno-deprecated -Wno-format -Wno-dynamic-class-memaccess
250 WARNINGS_ARE_ERRORS += -Wno-return-type -Wno-empty-body
251 endif
253 WARNING_FLAGS = -Wpointer-arith -Wsign-compare -Wundef
255 ifeq "$(shell expr \( $(CC_VER_MAJOR) \> 4 \) \| \( \( $(CC_VER_MAJOR) = 4 \) \& \( $(CC_VER_MINOR) \>= 3 \) \))" "0"
256 # Since GCC 4.3, -Wconversion has changed its meanings to warn these implicit
257 # conversions which might affect the values. Only enable it in earlier versions.
258 WARNING_FLAGS = -Wunused-function
259 ifeq ($(USE_CLANG),)
260 WARNINGS_FLAGS += -Wconversion
261 endif
262 endif
264 CFLAGS_WARN/DEFAULT = $(WARNINGS_ARE_ERRORS) $(WARNING_FLAGS)
265 # Special cases
266 CFLAGS_WARN/BYFILE = $(CFLAGS_WARN/$@)$(CFLAGS_WARN/DEFAULT$(CFLAGS_WARN/$@))
267 # XXXDARWIN: for _dyld_bind_fully_image_containing_address
268 ifeq ($(OS_VENDOR), Darwin)
269 CFLAGS_WARN/os_bsd.o = $(CFLAGS_WARN/DEFAULT) -Wno-deprecated-declarations
270 endif
272 OPT_CFLAGS/SIZE=-Os
273 OPT_CFLAGS/SPEED=-O3
275 # Hotspot uses very unstrict aliasing turn this optimization off
276 # This option is added to CFLAGS rather than OPT_CFLAGS
277 # so that OPT_CFLAGS overrides get this option too.
278 CFLAGS += -fno-strict-aliasing
280 # The flags to use for an Optimized g++ build
281 ifeq ($(OS_VENDOR), Darwin)
282 # use -Os by default, unless -O3 can be proved to be worth the cost, as per policy
283 # <http://wikis.sun.com/display/OpenJDK/Mac+OS+X+Port+Compilers>
284 OPT_CFLAGS_DEFAULT ?= SIZE
285 else
286 OPT_CFLAGS_DEFAULT ?= SPEED
287 endif
289 ifdef OPT_CFLAGS
290 ifneq ("$(origin OPT_CFLAGS)", "command line")
291 $(error " Use OPT_EXTRAS instead of OPT_CFLAGS to add extra flags to OPT_CFLAGS.")
292 endif
293 endif
295 OPT_CFLAGS = $(OPT_CFLAGS/$(OPT_CFLAGS_DEFAULT)) $(OPT_EXTRAS)
297 # The gcc compiler segv's on ia64 when compiling bytecodeInterpreter.cpp
298 # if we use expensive-optimizations
299 ifeq ($(BUILDARCH), ia64)
300 OPT_CFLAGS += -fno-expensive-optimizations
301 endif
303 OPT_CFLAGS/NOOPT=-O0
305 # Work around some compiler bugs.
306 ifeq ($(USE_CLANG), true)
307 ifeq ($(shell expr $(CC_VER_MAJOR) = 4 \& $(CC_VER_MINOR) = 2), 1)
308 OPT_CFLAGS/loopTransform.o += $(OPT_CFLAGS/NOOPT)
309 endif
310 else
311 # 6835796. Problem in GCC 4.3.0 with mulnode.o optimized compilation.
312 ifeq ($(shell expr $(CC_VER_MAJOR) = 4 \& $(CC_VER_MINOR) = 3), 1)
313 OPT_CFLAGS/mulnode.o += $(OPT_CFLAGS/NOOPT)
314 endif
315 endif
317 # Flags for generating make dependency flags.
318 DEPFLAGS = -MMD -MP -MF $(DEP_DIR)/$(@:%=%.d)
319 ifeq ($(USE_CLANG),)
320 ifneq ($(CC_VER_MAJOR), 2)
321 DEPFLAGS += -fpch-deps
322 endif
323 endif
325 # -DDONT_USE_PRECOMPILED_HEADER will exclude all includes in precompiled.hpp.
326 ifeq ($(USE_PRECOMPILED_HEADER),0)
327 CFLAGS += -DDONT_USE_PRECOMPILED_HEADER
328 endif
330 ifeq ($(OS_VENDOR), Darwin)
331 # Setting these parameters makes it an error to link to macosx APIs that are
332 # newer than the given OS version and makes the linked binaries compatible even
333 # if built on a newer version of the OS.
334 # The expected format is X.Y.Z
335 ifeq ($(MACOSX_VERSION_MIN),)
336 MACOSX_VERSION_MIN=10.7.0
337 endif
338 # The macro takes the version with no dots, ex: 1070
339 CFLAGS += -DMAC_OS_X_VERSION_MAX_ALLOWED=$(subst .,,$(MACOSX_VERSION_MIN)) \
340 -mmacosx-version-min=$(MACOSX_VERSION_MIN)
341 LDFLAGS += -mmacosx-version-min=$(MACOSX_VERSION_MIN)
342 endif
344 #------------------------------------------------------------------------
345 # Linker flags
347 # statically link libstdc++.so, work with gcc but ignored by g++
348 STATIC_STDCXX = -Wl,-Bstatic -lstdc++ -Wl,-Bdynamic
350 ifeq ($(USE_CLANG),)
351 # statically link libgcc and/or libgcc_s, libgcc does not exist before gcc-3.x.
352 ifneq ("${CC_VER_MAJOR}", "2")
353 STATIC_LIBGCC += -static-libgcc
354 endif
356 ifeq ($(BUILDARCH), ia64)
357 LFLAGS += -Wl,-relax
358 endif
359 endif
361 # Use $(MAPFLAG:FILENAME=real_file_name) to specify a map file.
362 MAPFLAG = -Xlinker --version-script=FILENAME
364 #
365 # Shared Library
366 #
367 ifeq ($(OS_VENDOR), Darwin)
368 # Standard linker flags
369 LFLAGS +=
371 # The apple linker has its own variant of mapfiles/version-scripts
372 MAPFLAG = -Xlinker -exported_symbols_list -Xlinker FILENAME
374 # Use $(SONAMEFLAG:SONAME=soname) to specify the intrinsic name of a shared obj
375 SONAMEFLAG =
377 # Build shared library
378 SHARED_FLAG = -Wl,-install_name,@rpath/$(@F) -dynamiclib -compatibility_version 1.0.0 -current_version 1.0.0 $(VM_PICFLAG)
380 # Keep symbols even they are not used
381 #AOUT_FLAGS += -Xlinker -export-dynamic
382 else
383 # Enable linker optimization
384 LFLAGS += -Xlinker -O1
386 # Use $(SONAMEFLAG:SONAME=soname) to specify the intrinsic name of a shared obj
387 SONAMEFLAG = -Xlinker -soname=SONAME
389 # Build shared library
390 SHARED_FLAG = -shared $(VM_PICFLAG)
392 # Keep symbols even they are not used
393 AOUT_FLAGS += -Xlinker -export-dynamic
394 endif
396 #------------------------------------------------------------------------
397 # Debug flags
399 ifeq ($(USE_CLANG), true)
400 # Restrict the debug information created by Clang to avoid
401 # too big object files and speed the build up a little bit
402 # (see http://llvm.org/bugs/show_bug.cgi?id=7554)
403 CFLAGS += -flimit-debug-info
404 endif
406 # DEBUG_BINARIES uses full -g debug information for all configs
407 ifeq ($(DEBUG_BINARIES), true)
408 CFLAGS += -g
409 else
410 # Use the stabs format for debugging information (this is the default
411 # on gcc-2.91). It's good enough, has all the information about line
412 # numbers and local variables, and libjvm.so is only about 16M.
413 # Change this back to "-g" if you want the most expressive format.
414 # (warning: that could easily inflate libjvm.so to 150M!)
415 # Note: The Itanium gcc compiler crashes when using -gstabs.
416 DEBUG_CFLAGS/ia64 = -g
417 DEBUG_CFLAGS/amd64 = -g
418 DEBUG_CFLAGS/arm = -g
419 DEBUG_CFLAGS/ppc = -g
420 DEBUG_CFLAGS += $(DEBUG_CFLAGS/$(BUILDARCH))
421 ifeq ($(DEBUG_CFLAGS/$(BUILDARCH)),)
422 DEBUG_CFLAGS += -gstabs
423 endif
424 endif
426 # If we are building HEADLESS, pass on to VM
427 # so it can set the java.awt.headless property
428 ifdef HEADLESS
429 CFLAGS += -DHEADLESS
430 endif
432 # We are building Embedded for a small device
433 # favor code space over speed
434 ifdef MINIMIZE_RAM_USAGE
435 CFLAGS += -DMINIMIZE_RAM_USAGE
436 endif