blob: 892cb36fa7bcdc432847c5b0215581eda25514a3 [file] [log] [blame]
duke6e45e102007-12-01 00:00:00 +00001#
ohairbf91ea12011-04-06 22:06:11 -07002# Copyright (c) 1995, 2011, Oracle and/or its affiliates. All rights reserved.
duke6e45e102007-12-01 00:00:00 +00003# 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
ohair2283b9d2010-05-25 15:58:33 -07007# published by the Free Software Foundation. Oracle designates this
duke6e45e102007-12-01 00:00:00 +00008# particular file as subject to the "Classpath" exception as provided
ohair2283b9d2010-05-25 15:58:33 -07009# by Oracle in the LICENSE file that accompanied this code.
duke6e45e102007-12-01 00:00:00 +000010#
11# This code is distributed in the hope that it will be useful, but WITHOUT
12# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14# version 2 for more details (a copy is included in the LICENSE file that
15# accompanied this code).
16#
17# You should have received a copy of the GNU General Public License version
18# 2 along with this work; if not, write to the Free Software Foundation,
19# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20#
ohair2283b9d2010-05-25 15:58:33 -070021# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22# or visit www.oracle.com if you need additional information or have any
23# questions.
duke6e45e102007-12-01 00:00:00 +000024#
25
26#
27# Makefile to specify compiler flags for programs and libraries
28# targeted to Solaris. Should not contain any rules.
29#
30# WARNING: This file is shared with other workspaces.
31# So when it includes other files, it must use JDK_TOPDIR.
32#
33
34# Warning: the following variables are overridden by Defs.gmk. Set
35# values will be silently ignored:
36# CFLAGS (set $(OTHER_CFLAGS) instead)
37# CPPFLAGS (set $(OTHER_CPPFLAGS) instead)
38# CXXFLAGS (set $(OTHER_CXXFLAGS) instead)
39# LDFLAGS (set $(OTHER_LDFAGS) instead)
40# LDLIBS (set $(EXTRA_LIBS) instead)
41# LDLIBS_COMMON (set $(EXTRA_LIBS) instead)
42# LINTFLAGS (set $(OTHER_LINTFLAGS) instead)
ohairab4f1212008-07-27 18:42:57 -070043#
44# Note: CPPFLAGS are used in C and C++ compiles.
45#
duke6e45e102007-12-01 00:00:00 +000046
47# Get shared JDK settings
48include $(JDK_MAKE_SHARED_DIR)/Defs.gmk
49
50ifndef PLATFORM_SRC
ohair26e0af62008-03-04 09:52:54 -080051PLATFORM_SRC = $(BUILDDIR)/../src/solaris
duke6e45e102007-12-01 00:00:00 +000052endif # PLATFORM_SRC
53
54# Platform specific closed sources
55ifndef OPENJDK
56 ifndef CLOSED_PLATFORM_SRC
ohair26e0af62008-03-04 09:52:54 -080057 CLOSED_PLATFORM_SRC = $(BUILDDIR)/../src/closed/solaris
duke6e45e102007-12-01 00:00:00 +000058 endif
59endif
60
61# platform specific include files
62PLATFORM_INCLUDE_NAME = $(PLATFORM)
63PLATFORM_INCLUDE = $(INCLUDEDIR)/$(PLATFORM_INCLUDE_NAME)
64
65# suffix used for make dependencies files
66DEPEND_SUFFIX = d
67# suffix used for lint files
68LINT_SUFFIX = ln
69# The suffix applied to the library name for FDLIBM
70FDDLIBM_SUFFIX = a
71# The suffix applied to scripts (.bat for windows, nothing for unix)
72SCRIPT_SUFFIX =
73# CC compiler object code output directive flag value
74CC_OBJECT_OUTPUT_FLAG = -o #trailing blank required!
75CC_PROGRAM_OUTPUT_FLAG = -o #trailing blank required!
76
dcubed46b99222011-09-20 19:16:21 -070077ifdef ENABLE_FULL_DEBUG_SYMBOLS
78# Only check for Full Debug Symbols support on Solaris if it is
79# specifically enabled. Hopefully, it can be enabled by default
80# once the .debuginfo size issues are worked out.
81
82# Default OBJCOPY comes from the SUNWbinutils package:
83DEF_OBJCOPY=/usr/sfw/bin/gobjcopy
84ifeq ($(PLATFORM)-$(LIBARCH), solaris-amd64)
85 # On Solaris AMD64/X64, gobjcopy is not happy and fails:
86 #
87 # usr/sfw/bin/gobjcopy --add-gnu-debuglink=<lib>.debuginfo <lib>.so
88 # BFD: stKPaiop: Not enough room for program headers, try linking with -N
89 # /usr/sfw/bin/gobjcopy: stKPaiop: Bad value
90 # BFD: stKPaiop: Not enough room for program headers, try linking with -N
91 # /usr/sfw/bin/gobjcopy: libsaproc.debuginfo: Bad value
92 # BFD: stKPaiop: Not enough room for program headers, try linking with -N
93 # /usr/sfw/bin/gobjcopy: stKPaiop: Bad value
94 _JUNK_ := $(shell \
95 echo >&2 "INFO: $(DEF_OBJCOPY) is not working on Solaris AMD64/X64")
96 OBJCOPY=
97else
98 OBJCOPY=$(shell test -x $(DEF_OBJCOPY) && echo $(DEF_OBJCOPY))
99 ifneq ($(ALT_OBJCOPY),)
100 _JUNK_ := $(shell echo >&2 "INFO: ALT_OBJCOPY=$(ALT_OBJCOPY)")
101 # disable .debuginfo support by setting ALT_OBJCOPY to a non-existent path
102 OBJCOPY=$(shell test -x $(ALT_OBJCOPY) && echo $(ALT_OBJCOPY))
103 endif
104endif
105
106ifdef LIBRARY_SUPPORTS_FULL_DEBUG_SYMBOLS
107# The setting of OBJCOPY above enables the JDK build to import
108# .debuginfo files from the HotSpot build. However, adding FDS
109# support to the JDK build will occur in phases so a different
110# make variable is used to indicate that a particular library
111# supports FDS.
112
113ifeq ($(OBJCOPY),)
114 _JUNK_ := $(shell \
115 echo >&2 "INFO: no objcopy cmd found so cannot create .debuginfo files.")
116else
117 _JUNK_ := $(shell \
118 echo >&2 "INFO: $(OBJCOPY) cmd found so will create .debuginfo files.")
119
120 # Library stripping policies for .debuginfo configs:
121 # all_strip - strips everything from the library
122 # min_strip - strips most stuff from the library; leaves minimum symbols
123 # no_strip - does not strip the library at all
124 #
125 # Oracle security policy requires "all_strip". A waiver was granted on
126 # 2011.09.01 that permits using "min_strip" in the Java JDK and Java JRE.
127 #
128 DEF_STRIP_POLICY="min_strip"
129 ifeq ($(ALT_STRIP_POLICY),)
130 STRIP_POLICY=$(DEF_STRIP_POLICY)
131 else
132 STRIP_POLICY=$(ALT_STRIP_POLICY)
133 endif
134 _JUNK_ := $(shell \
135 echo >&2 "INFO: STRIP_POLICY=$(STRIP_POLICY)")
136endif
137endif
138endif
139
duke6e45e102007-12-01 00:00:00 +0000140#
duke6e45e102007-12-01 00:00:00 +0000141# Java default optimization (-x04/-O2) etc. Applies to the VM.
142#
ohair850fb252008-07-30 19:40:57 -0700143ifndef OPTIMIZATION_LEVEL
144 ifeq ($(PRODUCT), java)
145 OPTIMIZATION_LEVEL = HIGHER
146 else
147 OPTIMIZATION_LEVEL = LOWER
148 endif
duke6e45e102007-12-01 00:00:00 +0000149endif
ohairb99e3e32009-03-31 16:10:31 -0700150ifndef FASTDEBUG_OPTIMIZATION_LEVEL
151 FASTDEBUG_OPTIMIZATION_LEVEL = LOWER
152endif
duke6e45e102007-12-01 00:00:00 +0000153
154#
ohair850fb252008-07-30 19:40:57 -0700155# If -Xa is in CFLAGS_COMMON it will end up ahead of $(CC_OPT) for the
duke6e45e102007-12-01 00:00:00 +0000156# optimized build, and that ordering of the flags completely freaks
157# out cc. Hence, -Xa is instead in each CFLAGS variant.
158#
159# The more unusual options to the Sun C compiler:
160# -v Stricter type checking, more error checking
161# (To turn ALL warnings into fatals, use -errwarn=%all)
162# -xstrconst Place string literals and constants in read-only area
163# (means you can't write on your string literals)
164# -xs Force debug information (stabs) into the .so or a.out
165# (makes the library/executable debuggable without the
166# .o files needing to be around, but at a space cost)
167# -g & -O If you add the -g option to the optimized compiles
168# you will get better stack retraces, the code is
169# still optimized. This includes a space cost too.
170# -xc99=%none Do NOT allow for c99 extensions to be used.
171# e.g. declarations must precede statements
172# -xCC Allow the C++ style of comments in C: //
173# Required with many of the source files.
174# -mt Assume multi-threaded (important)
175#
ohairab4f1212008-07-27 18:42:57 -0700176# The more unusual options to the Sun C compiler:
177# +w Print more warnings
178# +w2 Maximum warnings
179#
duke6e45e102007-12-01 00:00:00 +0000180
181#
182# Debug flag for C and C++ compiler
183#
ohair850fb252008-07-30 19:40:57 -0700184CFLAGS_DEBUG_OPTION = -g $(CC_OPT/NONE)
185CXXFLAGS_DEBUG_OPTION = -g $(CXX_OPT/NONE)
duke6e45e102007-12-01 00:00:00 +0000186
187# Turn off -g if we are doing tcov build
188ifdef TCOV_BUILD
189 CFLAGS_DEBUG_OPTION=
190 CXXFLAGS_DEBUG_OPTION=
191endif
192
193# FASTDEBUG: Optimize the -g builds, gives us a faster debug java
194# If true adds -O to the debug compiles. This allows for any assert
195# tests to remain and debug checking. The resulting code is faster
196# but less debuggable. Stack traces are still valid, although only
197# approximate line numbers are given. Printing of local variables
198# during a debugging session is not possible, but stepping and
199# printing of global or static variables should be possible.
200# Performance/size of files should be about the same, maybe smaller.
201#
202ifeq ($(FASTDEBUG), true)
ohairb99e3e32009-03-31 16:10:31 -0700203 CFLAGS_DEBUG_OPTION = -g $(CC_OPT/$(FASTDEBUG_OPTIMIZATION_LEVEL))
204 CXXFLAGS_DEBUG_OPTION = -g0 $(CXX_OPT/$(FASTDEBUG_OPTIMIZATION_LEVEL))
duke6e45e102007-12-01 00:00:00 +0000205endif
206
ohairab4f1212008-07-27 18:42:57 -0700207CFLAGS_COMMON = -L$(OBJDIR)
208
209# Do not allow C99 language features like declarations in code etc.
210CFLAGS_COMMON += -xc99=%none
211
212# Allow C++ comments in C code
duke6e45e102007-12-01 00:00:00 +0000213CFLAGS_COMMON += -xCC
ohairab4f1212008-07-27 18:42:57 -0700214
215# Show error message tags on errors
216CFLAGS_COMMON += -errshort=tags
217CXXFLAGS_COMMON += -errtags=yes
218
219# Optimization flags
ohair850fb252008-07-30 19:40:57 -0700220CFLAGS_OPT = $(CC_OPT)
ohairab4f1212008-07-27 18:42:57 -0700221
222# Debug version flags
duke6e45e102007-12-01 00:00:00 +0000223CFLAGS_DBG = $(CFLAGS_DEBUG_OPTION)
ohairab4f1212008-07-27 18:42:57 -0700224
225# Required C compiler flags
226CFLAGS_COMMON += -Xa $(CFLAGS_REQUIRED)
227
228# Maximum warnings all the time
229CXXFLAGS_COMMON += +w
230CFLAGS_COMMON += -v
duke6e45e102007-12-01 00:00:00 +0000231
232# Assume MT behavior all the time (important)
ohairab4f1212008-07-27 18:42:57 -0700233CXXFLAGS_COMMON += -mt
234CFLAGS_COMMON += -mt
duke6e45e102007-12-01 00:00:00 +0000235
236# Assume no C++ exceptions are used
237CXXFLAGS_COMMON += -features=no%except -DCC_NOEX
238
239# For C++, these options tell it to assume nothing about locating libraries
240# either at compile time, or at runtime. Use of these options will likely
241# require the use of -L and -R options to indicate where libraries will
242# be found at compile time (-L) and at runtime (-R).
243# The /usr/lib location comes for free, so no need to specify that one.
244# Note: C is much simplier and there is no need for these options. This
245# is mostly needed to avoid dependencies on libraries in the
246# Compiler install area, also see LIBCXX and LIBM.
247CXXFLAGS_COMMON += -norunpath -xnolib
248
249#
250# Treat compiler warnings as errors, if requested
251#
252ifeq ($(COMPILER_WARNINGS_FATAL),true)
253 CFLAGS_COMMON += -errwarn=%all
254 CXXFLAGS_COMMON += -errwarn=%all
255endif
256
ohair850fb252008-07-30 19:40:57 -0700257CXXFLAGS_OPT = $(CXX_OPT)
duke6e45e102007-12-01 00:00:00 +0000258CXXFLAGS_DBG = $(CXXFLAGS_DEBUG_OPTION)
259CXXFLAGS_COMMON += $(CFLAGS_REQUIRED)
260
261# Add -xstrconst to the library compiles. This forces all string
262# literals into the read-only data section, which prevents them from
263# being written to and increases the runtime pages shared on the system.
264#
265ifdef LIBRARY
266 CFLAGS_COMMON +=-xstrconst
267endif
268
269# Source browser database
270#
271# COMPILE_WITH_SB
272# If defined adds -xsb to compiles and creates a
273# source browsing database during compilation.
274#
275ifdef COMPILE_WITH_SB
276 ifeq ($(LIBRARY), java)
277 CFLAGS_DBG += -xsb
278 endif
279endif
280
281# Lint Flags:
282# -Xa ANSI C plus K&R, favor ANSI rules
duke6e45e102007-12-01 00:00:00 +0000283# -fd report on old style func defs
284# -errchk=structarg report on 64bit struct args by value
285# -errchk=longptr64 report on 64bit to 32bit issues (ignores casts)
286# -errchk=parentheses report on suggested use of extra parens
287# -v suppress unused args
288# -x suppress unused externs
289# -u suppress extern func/vars used/defined
290# -errfmt=simple use one line errors with position info
ohair3f083862008-06-04 09:38:18 -0700291# $(LINT_XARCH_OPTION) See Compiler-sun.gwk
duke6e45e102007-12-01 00:00:00 +0000292
293LINTFLAGS_COMMON = -Xa
294LINTFLAGS_COMMON += -fd
295LINTFLAGS_COMMON += -errchk=structarg,longptr64,parentheses
296LINTFLAGS_COMMON += -v
297LINTFLAGS_COMMON += -x
298LINTFLAGS_COMMON += -u
299LINTFLAGS_COMMON += -errfmt=simple
300LINTFLAGS_OPT =
301LINTFLAGS_DBG =
302
303# The -W0,-noglobal tells the compiler to NOT generate mangled global
304# ELF data symbols for file local static data.
305# This can break fix&continue, but we'd rather do the same compilations
306# for deliverable bits as we do for non-deliverable bits
307# Tell the compilers to never generate globalized names, all the time.
308CFLAGS_COMMON += -W0,-noglobal
309
ohair3f083862008-06-04 09:38:18 -0700310# If we have a specific arch value to use, add it
311CFLAGS_COMMON += $(XARCH_OPTION)
312CXXFLAGS_COMMON += $(XARCH_OPTION)
313ASFLAGS_COMMON += $(AS_XARCH_OPTION)
314EXTRA_LIBS += $(XARCH_OPTION)
315LINTFLAGS_COMMON += $(LINT_XARCH_OPTION)
duke6e45e102007-12-01 00:00:00 +0000316
317#
318# uncomment the following to build with PERTURBALOT set
319#
320# OTHER_CFLAGS += -DPERTURBALOT
321#
322
ohairab4f1212008-07-27 18:42:57 -0700323CPPFLAGS_COMMON = -D__solaris__ -D$(ARCH_FAMILY)
324CPPFLAGS_OPT = -DNDEBUG
duke6e45e102007-12-01 00:00:00 +0000325CPPFLAGS_DBG = -DDEBUG
326
ohair850fb252008-07-30 19:40:57 -0700327ifneq ($(PRODUCT), java)
328 CPPFLAGS_DBG += -DLOGGING -DDBINFO
329endif
330
duke6e45e102007-12-01 00:00:00 +0000331ifeq ($(ARCH_FAMILY), i586)
332 # The macro _LITTLE_ENDIAN needs to be defined the same to avoid the
333 # Sun C compiler warning message: warning: macro redefined: _LITTLE_ENDIAN
334 # (The Solaris X86 system defines this in file /usr/include/sys/isa_defs.h).
335 # Note: -Dmacro is the same as #define macro 1
336 # -Dmacro= is the same as #define macro
337 #
338 CPPFLAGS_COMMON += -DcpuIntel -D_LITTLE_ENDIAN= -D$(LIBARCH)
339 # Turn off a superfluous compiler error message on Intel
340 CFLAGS_COMMON += -erroff=E_BAD_PRAGMA_PACK_VALUE
341endif
342
343# Java memory management is based on memory mapping by default, but a
344# system only assuming malloc/free can be built by adding -DUSE_MALLOC
345
346CPPFLAGS_COMMON += -DTRACING -DMACRO_MEMSYS_OPS -DBREAKPTS
347CPPFLAGS_OPT += -DTRIMMED
348
349LDFLAGS_DEFS_OPTION = -z defs
350LDFLAGS_COMMON += $(LDFLAGS_DEFS_OPTION)
351
352#
353# -L paths for finding and -ljava
354#
355LDFLAGS_COMMON += -L$(LIBDIR)/$(LIBARCH)
356LDFLAGS_OPT =
357LDFLAGS_DBG =
358
359#
360# We never really want the incremental linker, ever
361# The -xildoff option tells Sun's compilers to NOT use incremental linker
362#
363LDFLAGS_COMMON += -xildoff
364
365ifdef LIBRARY
366 # Libraries need to locate other libraries at runtime, and you can tell
367 # a library where to look by way of the dynamic runpaths (RPATH or RUNPATH)
368 # buried inside the .so. The $ORIGIN says to look relative to where
369 # the library itself is and it can be followed with relative paths from
370 # that. By default we always look in $ORIGIN, optionally we add relative
371 # paths if the Makefile sets LD_RUNPATH_EXTRAS to those relative paths.
372 # The environment variable LD_LIBRARY_PATH will over-ride these runpaths.
373 # Try: 'dump -Lv lib*.so' to see these settings in a library.
374 #
375 LDFLAGS_COMMON += -R\$$ORIGIN
376 LDFLAGS_COMMON += $(LD_RUNPATH_EXTRAS:%=-R\$$ORIGIN/%)
377endif
378
379EXTRA_LIBS += -lc
380
381# Postprocessing is done on the images directories only
382#
383ifeq ($(VARIANT), OPT)
384 ifeq ($(PARTIAL_GPROF), true)
385 NO_STRIP = true
386 endif
387 ifeq ($(GPROF), true)
388 NO_STRIP = true
389 endif
390 ifneq ($(NO_STRIP), true)
391 # Debug 'strip -x' leaves local function Elf symbols (better stack traces)
392 POST_STRIP_PROCESS = $(STRIP) -x
393 endif
394endif
395POST_MCS_PROCESS=$(MCS) -d -a "JDK $(FULL_VERSION)"
396
397#
398# Sun C compiler will take -M and pass it on to ld.
399# Usage: ld $(LD_MAPFILE_FLAG) mapfile *.o
400#
401ifeq ($(CC_VERSION),gcc)
402LD_MAPFILE_FLAG = -Xlinker -M -Xlinker
403else
404LD_MAPFILE_FLAG = -M
405endif
406
407#
408# Variables globally settable from the make command line (default
409# values in brackets):
410# GPROF (false)
411# Eg: % gnumake GPROF=true
412GPROF = false
413ifeq ($(GPROF), true)
414 CFLAGS_COMMON += -DGPROF -xpg
415 EXTRA_LIBS += -xpg
416endif
417
418# PARTIAL_GPROF is to be used ONLY during compilation - it should not
419# appear during linking of libraries or programs. It also should
420# prevent linking with -z defs to allow a symbol to remain undefined.
421#
422PARTIAL_GPROF = false
423ifeq ($(PARTIAL_GPROF), true)
424 CFLAGS_GPROF += -xpg
425 LDFLAGS_DEFS_OPTION = -z nodefs
426endif
427
428#
429# For a TCOV build we add in the TCOV_OPTION
430#
431ifdef TCOV_BUILD
432 TCOV_OPTION = -xprofile=tcov
433 LDFLAGS_COMMON += $(TCOV_OPTION) -Kpic
434 CFLAGS_COMMON += $(TCOV_OPTION)
435 CXXFLAGS_COMMON += $(TCOV_OPTION)
436 EXTRA_LIBS += $(TCOV_OPTION)
437 LDNOMAP=true
438endif
439
440#
441# Solaris only uses native threads.
442#
443THREADS_FLAG= native
444THREADS_DIR= threads
445
446#
447# Support for Quantify.
448#
449ifdef QUANTIFY
450 QUANTIFY_CMD = quantify
451 QUANTIFY_OPTIONS = -cache-dir=/tmp/quantify -always-use-cache-dir=yes
452 LINK_PRE_CMD = $(QUANTIFY_CMD) $(QUANTIFY_OPTIONS)
453 ifdef LIBRARY
454 CFLAGS_COMMON += -K PIC
455 endif
456endif
457
458#
459# Support for Purify.
460#
461ifdef PURIFY
462 PURIFY_CMD = /net/suntools.eng/export/tools/sparc/bin/purify
463 PURIFY_OPTIONS = -cache-dir=/tmp/quantify -always-use-cache-dir=yes
464 LINK_PRE_CMD = $(PURIFY_CMD) $(PURIFY_OPTIONS)
465 ifdef LIBRARY
466 CFLAGS_COMMON += -K PIC
467 endif
468endif
469
470#
471# Different "levels" of optimization.
472#
473ifeq ($(CC_VERSION),gcc)
ohair850fb252008-07-30 19:40:57 -0700474
475 CC_OPT/NONE =
476 CC_OPT/LOWER = -O2
477 CC_OPT/HIGHER = -O3
478 CC_OPT/HIGHEST = -O3
479
480 CXX_OPT/NONE =
481 CXX_OPT/LOWER = -O2
482 CXX_OPT/HIGHER = -O3
483 CXX_OPT/HIGHEST = -O3
484
duke6e45e102007-12-01 00:00:00 +0000485 CFLAGS_REQUIRED_i586 += -fno-omit-frame-pointer
486 CFLAGS_REQUIRED_amd64 += -fno-omit-frame-pointer
ohair850fb252008-07-30 19:40:57 -0700487
duke6e45e102007-12-01 00:00:00 +0000488 # Automatic precompiled header option to use (if COMPILE_APPROACH=batch)
489 # (See Rules.gmk) May need to wait for gcc 5?
490 AUTOMATIC_PCH_OPTION =
ohair850fb252008-07-30 19:40:57 -0700491
duke6e45e102007-12-01 00:00:00 +0000492else
ohair850fb252008-07-30 19:40:57 -0700493
duke6e45e102007-12-01 00:00:00 +0000494 # Highest could be -xO5, but indications are that -xO5 should be reserved
495 # for a per-file use, on sources with known performance impacts.
ohair850fb252008-07-30 19:40:57 -0700496 OPT_LEVEL/LOWER = 2
497 OPT_LEVEL/HIGHER = 4
498 OPT_LEVEL/HIGHEST = 4
499
500 CC_OPT/NONE =
501 CC_OPT/LOWER = $(OPT_LEVEL/LOWER:%=-xO%)
502 CC_OPT/HIGHER = $(OPT_LEVEL/HIGHER:%=-xO%)
503 CC_OPT/HIGHEST = $(OPT_LEVEL/HIGHEST:%=-xO%)
504
505 CXX_OPT/NONE =
506 CXX_OPT/LOWER = $(OPT_LEVEL/LOWER:%=-xO%)
507 CXX_OPT/HIGHER = $(OPT_LEVEL/HIGHER:%=-xO%)
508 CXX_OPT/HIGHEST = $(OPT_LEVEL/HIGHEST:%=-xO%)
509
510 # We need stack frames at all times
511 USE_XKEEPFRAME_OPTION = false
512 ifeq ($(USE_XKEEPFRAME_OPTION),true)
513
514 # Unknown spelling on this option at this time (Maybe in SS13?)
515 CC_XKEEPFRAME_OPTIONS = -xkeepframe
516 CXX_XKEEPFRAME_OPTIONS = -xkeepframe
517
518 else
519
520 # On X86, make sure tail call optimization is off
521 # The z and y are the tail call optimizations.
522 ifeq ($(ARCH_FAMILY), i586)
ohaire74b8592011-04-21 18:26:04 -0700523 CC_NEWER_THAN_58 := \
524 $(shell $(EXPR) $(CC_MAJORVER) \> 5 \| \
525 \( $(CC_MAJORVER) = 5 \& $(CC_MINORVER) \> 8 \) )
526 ifeq ($(CC_NEWER_THAN_58),1)
527 # Somehow, tail call optimization is creeping in.
528 # Make sure it is off.
529 # WARNING: These may cause compiler warnings about duplicate -O options
530 CC_XKEEPFRAME_OPTIONS += -Wu,-O$(OPT_LEVEL/$(OPTIMIZATION_LEVEL))~yz
531 CXX_XKEEPFRAME_OPTIONS += -Qoption ube -O$(OPT_LEVEL/$(OPTIMIZATION_LEVEL))~yz
ohair850fb252008-07-30 19:40:57 -0700532 endif
533 endif
534
535 # On i586 we need to tell the code generator to ALWAYS use a
536 # frame pointer.
537 ifeq ($(ARCH_FAMILY), i586)
538 # Note that in 5.7, this is done with -xregs=no%frameptr
539 ifeq ($(CC_VER), 5.5)
540 # It's not exactly clear when this optimization kicks in, the
541 # current assumption is -xO4 or greater and for C++ with
542 # the -features=no%except option and -xO4 and greater.
543 # Bottom line is, we ALWAYS want a frame pointer!
544 CC_XKEEPFRAME_OPTIONS += -Wu,-Z~B
545 CXX_XKEEPFRAME_OPTIONS += -Qoption ube -Z~B
546 endif
bae39abd752010-12-05 15:51:31 +0300547
ohaire74b8592011-04-21 18:26:04 -0700548 CC_NEWER_THAN_56 := \
549 $(shell $(EXPR) $(CC_MAJORVER) \> 5 \| \
550 \( $(CC_MAJORVER) = 5 \& $(CC_MINORVER) \> 6 \) )
551 ifeq ($(CC_NEWER_THAN_56),1)
552 # Do NOT use frame pointer register as a general purpose opt register
553 CC_OPT/NONE += -xregs=no%frameptr
554 CXX_OPT/NONE += -xregs=no%frameptr
555 CC_XKEEPFRAME_OPTIONS += -xregs=no%frameptr
556 CXX_XKEEPFRAME_OPTIONS += -xregs=no%frameptr
ohair850fb252008-07-30 19:40:57 -0700557 endif
558 endif
559
560 # Optimizer for sparc needs to be told not to do certain things
561 # related to frames or save instructions.
562 ifeq ($(ARCH_FAMILY), sparc)
563 # Do not use save instructions instead of add instructions
564 # This was an optimization starting in SC5.0 that made it hard for us to
565 # find the "save" instruction (which got turned into an "add")
566 CC_XKEEPFRAME_OPTIONS += -Wc,-Qrm-s
567 CXX_XKEEPFRAME_OPTIONS += -Qoption cg -Qrm-s
568 # Don't allow tail call code optimization. Started in SC5.0.
569 # We don't like code of this form:
570 # save
571 # <code>
572 # call foo
573 # restore
574 # because we can't tell if the method will have a stack frame
575 # and register windows or not.
576 CC_XKEEPFRAME_OPTIONS += -Wc,-Qiselect-T0
577 CXX_XKEEPFRAME_OPTIONS += -Qoption cg -Qiselect-T0
578 endif
579
580 endif
581
582 # Extra options used with HIGHEST
duke6e45e102007-12-01 00:00:00 +0000583 #
ohair850fb252008-07-30 19:40:57 -0700584 # WARNING: Use of OPTIMIZATION_LEVEL=HIGHEST in your Makefile needs to be
duke6e45e102007-12-01 00:00:00 +0000585 # done with care, there are some assumptions below that need to
586 # be understood about the use of pointers, and IEEE behavior.
587 #
588 # Use non-standard floating point mode (not IEEE 754)
ohair850fb252008-07-30 19:40:57 -0700589 CC_HIGHEST_EXTRAS += -fns
duke6e45e102007-12-01 00:00:00 +0000590 # Do some simplification of floating point arithmetic (not IEEE 754)
ohair850fb252008-07-30 19:40:57 -0700591 CC_HIGHEST_EXTRAS += -fsimple
duke6e45e102007-12-01 00:00:00 +0000592 # Use single precision floating point with 'float'
ohair850fb252008-07-30 19:40:57 -0700593 CC_HIGHEST_EXTRAS += -fsingle
duke6e45e102007-12-01 00:00:00 +0000594 # Assume memory references via basic pointer types do not alias
595 # (Source with excessing pointer casting and data access with mixed
596 # pointer types are not recommended)
ohair850fb252008-07-30 19:40:57 -0700597 CC_HIGHEST_EXTRAS += -xalias_level=basic
duke6e45e102007-12-01 00:00:00 +0000598 # Use intrinsic or inline versions for math/std functions
599 # (If you expect perfect errno behavior, do not use this)
ohair850fb252008-07-30 19:40:57 -0700600 CC_HIGHEST_EXTRAS += -xbuiltin=%all
duke6e45e102007-12-01 00:00:00 +0000601 # Loop data dependency optimizations (need -xO3 or higher)
ohair850fb252008-07-30 19:40:57 -0700602 CC_HIGHEST_EXTRAS += -xdepend
duke6e45e102007-12-01 00:00:00 +0000603 # Pointer parameters to functions do not overlap
604 # (Similar to -xalias_level=basic usage, but less obvious sometimes.
605 # If you pass in multiple pointers to the same data, do not use this)
ohair850fb252008-07-30 19:40:57 -0700606 CC_HIGHEST_EXTRAS += -xrestrict
duke6e45e102007-12-01 00:00:00 +0000607 # Inline some library routines
608 # (If you expect perfect errno behavior, do not use this)
ohair850fb252008-07-30 19:40:57 -0700609 CC_HIGHEST_EXTRAS += -xlibmil
duke6e45e102007-12-01 00:00:00 +0000610 # Use optimized math routines
611 # (If you expect perfect errno behavior, do not use this)
612 # Can cause undefined external on Solaris 8 X86 on __sincos, removing for now
ohair850fb252008-07-30 19:40:57 -0700613 # CC_HIGHEST_EXTRAS += -xlibmopt
duke6e45e102007-12-01 00:00:00 +0000614 ifeq ($(ARCH_FAMILY), sparc)
615 # Assume at most 8byte alignment, raise SIGBUS on error
616 ### Presents an ABI issue with customer JNI libs?
ohair850fb252008-07-30 19:40:57 -0700617 ####CC_HIGHEST_EXTRAS += -xmemalign=8s
duke6e45e102007-12-01 00:00:00 +0000618 # Automatic prefetch instructions, explicit prefetch macros
ohair850fb252008-07-30 19:40:57 -0700619 CC_HIGHEST_EXTRAS += -xprefetch=auto,explicit
duke6e45e102007-12-01 00:00:00 +0000620 # Pick ultra as the chip to optimize to
ohair850fb252008-07-30 19:40:57 -0700621 CC_HIGHEST_EXTRAS += -xchip=ultra
duke6e45e102007-12-01 00:00:00 +0000622 endif
623 ifeq ($(ARCH), i586)
624 # Pick pentium as the chip to optimize to
ohair850fb252008-07-30 19:40:57 -0700625 CC_HIGHEST_EXTRAS += -xchip=pentium
duke6e45e102007-12-01 00:00:00 +0000626 endif
627 ifdef LIBRARY
628 # The Solaris CBE (Common Build Environment) requires that the use
629 # of appl registers be disabled when compiling a public library (or
630 # a library that's loaded by a public library) on sparc.
631 CFLAGS_REQUIRED_sparc += -xregs=no%appl
632 CFLAGS_REQUIRED_sparcv9 += -xregs=no%appl
633 endif
ohaire74b8592011-04-21 18:26:04 -0700634 CC_NEWER_THAN_56 := \
635 $(shell $(EXPR) $(CC_MAJORVER) \> 5 \| \
636 \( $(CC_MAJORVER) = 5 \& $(CC_MINORVER) \> 6 \) )
637 ifeq ($(CC_NEWER_THAN_56),1)
duke6e45e102007-12-01 00:00:00 +0000638 # Presents an ABI issue with customer JNI libs? We must be able to
639 # to handle 4byte aligned objects? (rare occurance, but possible?)
640 CFLAGS_REQUIRED_sparc += -xmemalign=4s
641 endif
642 # Just incase someone trys to use the SOS9 compilers
643 ifeq ($(CC_VER), 5.6)
644 # We MUST allow data alignment of 4 for sparc (sparcv9 is ok at 8s)
645 CFLAGS_REQUIRED_sparc += -xmemalign=4s
646 endif
647 # Automatic precompiled header option to use (if COMPILE_APPROACH=batch)
648 # (See Rules.gmk) The SS11 -xpch=auto* options appear to be broken.
649 AUTOMATIC_PCH_OPTION =
ohair850fb252008-07-30 19:40:57 -0700650
651 # Add in keep frame options
652 CC_OPT/LOWER += $(CC_XKEEPFRAME_OPTIONS)
653 CC_OPT/HIGHER += $(CC_XKEEPFRAME_OPTIONS)
654 CC_OPT/HIGHEST += $(CC_XKEEPFRAME_OPTIONS)
655 CXX_OPT/LOWER += $(CXX_XKEEPFRAME_OPTIONS)
656 CXX_OPT/HIGHER += $(CXX_XKEEPFRAME_OPTIONS)
657 CXX_OPT/HIGHEST += $(CXX_XKEEPFRAME_OPTIONS)
658
659 # Add in highest optimization settings
660 CC_OPT/HIGHEST += $(CC_HIGHEST_EXTRAS)
661 CXX_OPT/HIGHEST += $(CC_HIGHEST_EXTRAS)
662
duke6e45e102007-12-01 00:00:00 +0000663endif
duke6e45e102007-12-01 00:00:00 +0000664
ohair850fb252008-07-30 19:40:57 -0700665# Default optimization settings based on level.
666CC_OPT = $(CC_OPT/$(OPTIMIZATION_LEVEL))
667CXX_OPT = $(CXX_OPT/$(OPTIMIZATION_LEVEL))
duke6e45e102007-12-01 00:00:00 +0000668
669# Flags required all the time
670CFLAGS_REQUIRED = $(CFLAGS_REQUIRED_$(ARCH))
671
duke6e45e102007-12-01 00:00:00 +0000672#
673# Path and option to link against the VM, if you have to. Note that
674# there are libraries that link against only -ljava, but they do get
675# -L to the -ljvm, this is because -ljava depends on -ljvm, whereas
676# the library itself should not.
677#
678VM_NAME = server
679JVMLIB = -L$(LIBDIR)/$(LIBARCH)/$(VM_NAME) -ljvm
680JAVALIB = -ljava $(JVMLIB)
681
682# Part of INCREMENTAL_BUILD mechanism.
683# Compiler emits things like: path/file.o: file.h
684# We want something like: relative_path/file.o relative_path/file.d: file.h
685# In addition on Solaris, any include file starting with / is deleted,
686# this gets rid of things like /usr/include files, which never change.
687CC_DEPEND = -xM1
688CC_DEPEND_FILTER = $(SED) -e '/:[ ]*[/]/d' -e 's!$*\.$(OBJECT_SUFFIX)!$(dir $@)& $(dir $@)$*.$(DEPEND_SUFFIX)!g' | $(SORT) -u
689
690# Location of openwin libraries (do we really need this anymore?)
691OPENWIN_HOME = /usr/openwin
692OPENWIN_LIB = $(OPENWIN_HOME)/lib$(ISA_DIR)
693
694# Runtime graphics library search paths...
695OPENWIN_RUNTIME_LIB = /usr/openwin/lib$(ISA_DIR)
696AWT_RUNPATH = -R/usr/dt/lib$(ISA_DIR) -R$(OPENWIN_RUNTIME_LIB)
697
698# C++ Runtime library (libCrun.so), use instead of -lCrun.
699# Originally used instead of -lCrun to guarantee use of the system
700# .so version and not the .a or .so that came with the compilers.
701# With the newer compilers this could probably change back to -lCrun but
702# in general this is ok to continue to do.
703LIBCXX = /usr/lib$(ISA_DIR)/libCrun.so.1
704
ceisserer93956ca2010-05-28 11:37:44 -0700705# JDK now requires Solaris 10, so pick up libm.so.2
706LIBM = /usr/lib$(ISA_DIR)/libm.so.2
duke6e45e102007-12-01 00:00:00 +0000707
708# Socket library
709LIBSOCKET = -lsocket
710
martind5089e02010-06-10 15:54:25 -0700711# Network Services library
712LIBNSL = -lnsl
713
duke6e45e102007-12-01 00:00:00 +0000714# GLOBAL_KPIC: If set means all libraries are PIC, position independent code
715# EXCEPT for select compiles
716# If a .o file is compiled non-PIC then it should be forced
717# into the RW data segment with a mapfile option. This is done
718# with object files which generated from .s files.
719# The -ztext enforces that no relocations remain in the text segment
720# so that it remains purely read-only for optimum system performance.
721# Some libraries may use a smaller size (13bit -Kpic) on sparc instead of
722# (32 bit -KPIC) and will override GLOBAL_KPIC appropriately.
723#
724PIC_CODE_LARGE = -KPIC
725PIC_CODE_SMALL = -Kpic
726ifndef TCOV_BUILD
727 GLOBAL_KPIC = $(PIC_CODE_LARGE)
728 CXXFLAGS_COMMON += $(GLOBAL_KPIC)
729 CFLAGS_COMMON += $(GLOBAL_KPIC)
730 LDFLAGS_COMMON += -ztext
731endif # TCOV_BUILD
732
733# If your platform has DPS, it will have Type1 fonts too, in which case
734# it is best to enable DPS support until such time as 2D's rasteriser
735# can fully handle Type1 fonts in all cases. Default is "yes".
736# HAVE_DPS should only be "no" if the platform has no DPS headers or libs
737# DPS (Displayable PostScript) is available on Solaris machines
738
739HAVE_DPS = yes
740
741#
742# Japanese manpages
743#
744JA_SOURCE_ENCODING = eucJP
745JA_TARGET_ENCODINGS = eucJP UTF-8 PCK
746
747# Settings for the JDI - Serviceability Agent binding.
748HOTSPOT_SALIB_PATH = $(HOTSPOT_IMPORT_PATH)/jre/lib/$(LIBARCH)
749SALIB_NAME = $(LIB_PREFIX)saproc.$(LIBRARY_SUFFIX)
dcubed46b99222011-09-20 19:16:21 -0700750SA_DEBUGINFO_NAME = $(LIB_PREFIX)saproc.debuginfo
duke6e45e102007-12-01 00:00:00 +0000751INCLUDE_SA=true
752