Thu, 19 Feb 2009 14:08:00 -0800
Added tag jdk7-b48 for changeset bcb33806d186
1 #
2 # Copyright 1998-2008 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
20 # CA 95054 USA or visit www.sun.com if you need additional information or
21 # have any questions.
22 #
23 #
25 # Compiler-specific flags for sparcworks.
27 # tell make which C and C++ compilers to use
28 CC = cc
29 CPP = CC
31 # Note that this 'as' is an older version of the Sun Studio 'fbe', and will
32 # use the older style options. The 'fbe' options will match 'cc' and 'CC'.
33 AS = /usr/ccs/bin/as
35 NM = /usr/ccs/bin/nm
36 NAWK = /bin/nawk
38 REORDER_FLAG = -xF
40 # Check for the versions of C++ and C compilers ($CPP and $CC) used.
42 # Get the last thing on the line that looks like x.x+ (x is a digit).
43 COMPILER_REV := \
44 $(shell $(CPP) -V 2>&1 | sed -n 's/^.*[ ,\t]C++[ ,\t]\([1-9]\.[0-9][0-9]*\).*/\1/p')
45 C_COMPILER_REV := \
46 $(shell $(CC) -V 2>&1 | sed -n 's/^.*[ ,\t]C[ ,\t]\([1-9]\.[0-9][0-9]*\).*/\1/p')
48 # Pick which compiler is validated
49 ifeq ($(JDK_MINOR_VERSION),6)
50 # Validated compiler for JDK6 is SS11 (5.8)
51 VALIDATED_COMPILER_REV := 5.8
52 VALIDATED_C_COMPILER_REV := 5.8
53 else
54 # Validated compiler for JDK7 is SS12 (5.9)
55 VALIDATED_COMPILER_REV := 5.9
56 VALIDATED_C_COMPILER_REV := 5.9
57 endif
59 # Warning messages about not using the above validated version
60 ENFORCE_COMPILER_REV${ENFORCE_COMPILER_REV} := ${VALIDATED_COMPILER_REV}
61 ifneq (${COMPILER_REV},${ENFORCE_COMPILER_REV})
62 dummy_target_to_enforce_compiler_rev:=\
63 $(shell echo >&2 WARNING: You are using CC version ${COMPILER_REV} \
64 and should be using version ${ENFORCE_COMPILER_REV}. Set ENFORCE_COMPILER_REV=${COMPILER_REV} to avoid this warning.)
65 endif
67 ENFORCE_C_COMPILER_REV${ENFORCE_C_COMPILER_REV} := ${VALIDATED_C_COMPILER_REV}
68 ifneq (${C_COMPILER_REV},${ENFORCE_C_COMPILER_REV})
69 dummy_target_to_enforce_c_compiler_rev:=\
70 $(shell echo >&2 WARNING: You are using cc version ${C_COMPILER_REV} \
71 and should be using version ${ENFORCE_C_COMPILER_REV}. Set ENFORCE_C_COMPILER_REV=${C_COMPILER_REV} to avoid this warning.)
72 endif
74 COMPILER_REV_NUMERIC := $(shell echo $(COMPILER_REV) | awk -F. '{ print $$1 * 100 + $$2 }')
76 # Fail the build if __fabsf is used. __fabsf exists only in Solaris 8 2/04
77 # and newer; objects with a dependency on this symbol will not run on older
78 # Solaris 8.
79 JVM_FAIL_IF_UNDEFINED = __fabsf
81 JVM_CHECK_SYMBOLS = $(NM) -u -p $(LIBJVM.o) | \
82 $(NAWK) -v f="${JVM_FAIL_IF_UNDEFINED}" \
83 'BEGIN { c=split(f,s); rc=0; } \
84 /:$$/ { file = $$1; } \
85 /[^:]$$/ { for(n=1;n<=c;++n) { \
86 if($$1==s[n]) { \
87 printf("JVM_CHECK_SYMBOLS: %s contains illegal symbol %s\n", \
88 file,$$1); \
89 rc=1; \
90 } \
91 } \
92 } \
93 END { exit rc; }'
95 LINK_LIB.CC/PRE_HOOK += $(JVM_CHECK_SYMBOLS) || exit 1;
97 # Some interfaces (_lwp_create) changed with LP64 and Solaris 7
98 SOLARIS_7_OR_LATER := \
99 $(shell uname -r | awk -F. '{ if ($$2 >= 7) print "-DSOLARIS_7_OR_LATER"; }')
100 CFLAGS += ${SOLARIS_7_OR_LATER}
102 # New architecture options started in SS12 (5.9), we need both styles to build.
103 # The older arch options for SS11 (5.8) or older and also for /usr/ccs/bin/as.
104 # Note: SS12 default for 32bit sparc is now the same as v8plus, so the
105 # settings below have changed all SS12 32bit sparc builds to be v8plus.
106 # The older SS11 (5.8) settings have remained as they always have been.
107 ifeq ($(TYPE),COMPILER2)
108 ARCHFLAG_OLD/sparc = -xarch=v8plus
109 else
110 ifeq ($(TYPE),TIERED)
111 ARCHFLAG_OLD/sparc = -xarch=v8plus
112 else
113 ARCHFLAG_OLD/sparc = -xarch=v8
114 endif
115 endif
116 ARCHFLAG_NEW/sparc = -m32 -xarch=sparc
117 ARCHFLAG_OLD/sparcv9 = -xarch=v9
118 ARCHFLAG_NEW/sparcv9 = -m64 -xarch=sparc
119 ARCHFLAG_OLD/i486 =
120 ARCHFLAG_NEW/i486 = -m32
121 ARCHFLAG_OLD/amd64 = -xarch=amd64
122 ARCHFLAG_NEW/amd64 = -m64
124 # Select the ARCHFLAGs and other SS12 (5.9) options
125 ifeq ($(shell expr $(COMPILER_REV_NUMERIC) \>= 509), 1)
126 ARCHFLAG/sparc = $(ARCHFLAG_NEW/sparc)
127 ARCHFLAG/sparcv9 = $(ARCHFLAG_NEW/sparcv9)
128 ARCHFLAG/i486 = $(ARCHFLAG_NEW/i486)
129 ARCHFLAG/amd64 = $(ARCHFLAG_NEW/amd64)
130 else
131 ARCHFLAG/sparc = $(ARCHFLAG_OLD/sparc)
132 ARCHFLAG/sparcv9 = $(ARCHFLAG_OLD/sparcv9)
133 ARCHFLAG/i486 = $(ARCHFLAG_OLD/i486)
134 ARCHFLAG/amd64 = $(ARCHFLAG_OLD/amd64)
135 endif
137 # ARCHFLAGS for the current build arch
138 ARCHFLAG = $(ARCHFLAG/$(BUILDARCH))
139 AS_ARCHFLAG = $(ARCHFLAG_OLD/$(BUILDARCH))
141 # Optional sub-directory in /usr/lib where BUILDARCH libraries are kept.
142 ISA_DIR=$(ISA_DIR/$(BUILDARCH))
143 ISA_DIR/sparcv9=/sparcv9
144 ISA_DIR/amd64=/amd64
146 # Use these to work around compiler bugs:
147 OPT_CFLAGS/SLOWER=-xO3
148 OPT_CFLAGS/O2=-xO2
149 OPT_CFLAGS/NOOPT=-xO1
151 #################################################
152 # Begin current (>=5.6) Forte compiler options #
153 #################################################
155 ifeq ($(shell expr $(COMPILER_REV_NUMERIC) \>= 506), 1)
157 ifeq ("${Platform_arch}", "sparc")
159 # We MUST allow data alignment of 4 for sparc (sparcv9 is ok at 8s)
160 ifndef LP64
161 CFLAGS += -xmemalign=4s
162 endif
164 endif
166 endif
168 #################################################
169 # Begin current (>=5.5) Forte compiler options #
170 #################################################
172 ifeq ($(shell expr $(COMPILER_REV_NUMERIC) \>= 505), 1)
174 CFLAGS += $(ARCHFLAG)
175 AOUT_FLAGS += $(ARCHFLAG)
176 LIB_FLAGS += $(ARCHFLAG)
177 LFLAGS += $(ARCHFLAG)
179 ifeq ("${Platform_arch}", "sparc")
181 # Flags for Optimization
183 # [phh] Commented out pending verification that we do indeed want
184 # to potentially bias against u1 and u3 targets.
185 #CFLAGS += -xchip=ultra2
187 OPT_CFLAGS=-xO4 $(EXTRA_OPT_CFLAGS)
189 endif # sparc
191 ifeq ("${Platform_arch_model}", "x86_32")
193 OPT_CFLAGS=-xtarget=pentium $(EXTRA_OPT_CFLAGS)
195 # UBE (CC 5.5) has bug 4923569 with -xO4
196 OPT_CFLAGS+=-xO3
198 endif # 32bit x86
200 ifeq ("${Platform_arch_model}", "x86_64")
202 ASFLAGS += $(AS_ARCHFLAG)
203 CFLAGS += $(ARCHFLAG/amd64)
204 # this one seemed useless
205 LFLAGS_VM += $(ARCHFLAG/amd64)
206 # this one worked
207 LFLAGS += $(ARCHFLAG/amd64)
208 AOUT_FLAGS += $(ARCHFLAG/amd64)
210 # -xO3 is faster than -xO4 on specjbb with SS10 compiler
211 OPT_CFLAGS=-xO4 $(EXTRA_OPT_CFLAGS)
213 endif # 64bit x86
215 # Inline functions
216 CFLAGS += $(GAMMADIR)/src/os_cpu/solaris_${Platform_arch}/vm/solaris_${Platform_arch_model}.il
218 # no more exceptions
219 CFLAGS/NOEX=-features=no%except
222 # avoid compilation problems arising from fact that C++ compiler tries
223 # to search for external template definition by just compiling additional
224 # source files in th same context
225 CFLAGS += -template=no%extdef
227 # Reduce code bloat by reverting back to 5.0 behavior for static initializers
228 CFLAGS += -features=no%split_init
230 # Use -D_Crun_inline_placement so we don't get references to
231 # __1c2n6FIpv_0_ or void*operator new(unsigned,void*)
232 # This avoids the hard requirement of the newer Solaris C++ runtime patches.
233 # NOTE: This is an undocumented feature of the SS10 compiler. See 6306698.
234 CFLAGS += -D_Crun_inline_placement
236 # PIC is safer for SPARC, and is considerably slower
237 # a file foo.o which wants to compile -pic can set "PICFLAG/foo.o = -PIC"
238 PICFLAG = -KPIC
239 PICFLAG/DEFAULT = $(PICFLAG)
240 # [RGV] Need to figure which files to remove to get link to work
241 #PICFLAG/BETTER = -pic
242 PICFLAG/BETTER = $(PICFLAG/DEFAULT)
243 PICFLAG/BYFILE = $(PICFLAG/$@)$(PICFLAG/DEFAULT$(PICFLAG/$@))
245 # Use $(MAPFLAG:FILENAME=real_file_name) to specify a map file.
246 MAPFLAG = -M FILENAME
248 # Use $(SONAMEFLAG:SONAME=soname) to specify the intrinsic name of a shared obj
249 SONAMEFLAG = -h SONAME
251 # Build shared library
252 SHARED_FLAG = -G
254 # We don't need libCstd.so and librwtools7.so, only libCrun.so
255 CFLAGS += -library=%none
256 LFLAGS += -library=%none
258 LFLAGS += -mt
260 endif # COMPILER_REV_NUMERIC >= 505
262 ######################################
263 # End 5.5 Forte compiler options #
264 ######################################
266 ######################################
267 # Begin 5.2 Forte compiler options #
268 ######################################
270 ifeq ($(COMPILER_REV_NUMERIC), 502)
272 CFLAGS += $(ARCHFLAG)
273 AOUT_FLAGS += $(ARCHFLAG)
274 LIB_FLAGS += $(ARCHFLAG)
275 LFLAGS += $(ARCHFLAG)
277 ifeq ("${Platform_arch}", "sparc")
279 # Flags for Optimization
281 # [phh] Commented out pending verification that we do indeed want
282 # to potentially bias against u1 and u3 targets.
283 #CFLAGS += -xchip=ultra2
285 ifdef LP64
286 # SC5.0 tools on v9 are flakey at -xO4
287 # [phh] Is this still true for 6.1?
288 OPT_CFLAGS=-xO3 $(EXTRA_OPT_CFLAGS)
289 else
290 OPT_CFLAGS=-xO4 $(EXTRA_OPT_CFLAGS)
291 endif
293 CFLAGS += $(GAMMADIR)/src/os_cpu/solaris_sparc/vm/solaris_sparc.il
295 endif # sparc
297 ifeq ("${Platform_arch_model}", "x86_32")
299 OPT_CFLAGS=-xtarget=pentium $(EXTRA_OPT_CFLAGS)
301 # SC5.0 tools on x86 are flakey at -xO4
302 # [phh] Is this still true for 6.1?
303 OPT_CFLAGS+=-xO3
305 CFLAGS += $(GAMMADIR)/src/os_cpu/solaris_x86/vm/solaris_x86_32.il
307 endif # 32bit x86
309 # no more exceptions
310 CFLAGS/NOEX=-noex
312 # Reduce code bloat by reverting back to 5.0 behavior for static initializers
313 CFLAGS += -Qoption ccfe -one_static_init
315 # PIC is safer for SPARC, and is considerably slower
316 # a file foo.o which wants to compile -pic can set "PICFLAG/foo.o = -PIC"
317 PICFLAG = -KPIC
318 PICFLAG/DEFAULT = $(PICFLAG)
319 # [RGV] Need to figure which files to remove to get link to work
320 #PICFLAG/BETTER = -pic
321 PICFLAG/BETTER = $(PICFLAG/DEFAULT)
322 PICFLAG/BYFILE = $(PICFLAG/$@)$(PICFLAG/DEFAULT$(PICFLAG/$@))
324 # Would be better if these weren't needed, since we link with CC, but
325 # at present removing them causes run-time errors
326 LFLAGS += -library=Crun
327 LIBS += -library=Crun -lCrun
329 endif # COMPILER_REV_NUMERIC == 502
331 ##################################
332 # End 5.2 Forte compiler options #
333 ##################################
335 ##################################
336 # Begin old 5.1 compiler options #
337 ##################################
338 ifeq ($(COMPILER_REV_NUMERIC), 501)
340 _JUNK_ := $(shell echo >&2 \
341 "*** ERROR: sparkWorks.make incomplete for 5.1 compiler")
342 @exit 1
343 endif
344 ##################################
345 # End old 5.1 compiler options #
346 ##################################
348 ##################################
349 # Begin old 5.0 compiler options #
350 ##################################
352 ifeq (${COMPILER_REV_NUMERIC}, 500)
354 # Had to hoist this higher apparently because of other changes. Must
355 # come before -xarch specification.
356 # NOTE: native says optimize for the machine doing the compile, bad news.
357 CFLAGS += -xtarget=native
359 CFLAGS += $(ARCHFLAG)
360 AOUT_FLAGS += $(ARCHFLAG)
361 LIB_FLAGS += $(ARCHFLAG)
362 LFLAGS += $(ARCHFLAG)
364 CFLAGS += -library=iostream
365 LFLAGS += -library=iostream -library=Crun
366 LIBS += -library=iostream -library=Crun -lCrun
368 # Flags for Optimization
369 ifdef LP64
370 # SC5.0 tools on v9 are flakey at -xO4
371 OPT_CFLAGS=-xO3 $(EXTRA_OPT_CFLAGS)
372 else
373 OPT_CFLAGS=-xO4 $(EXTRA_OPT_CFLAGS)
374 endif
376 ifeq ("${Platform_arch}", "sparc")
378 CFLAGS += $(GAMMADIR)/src/os_cpu/solaris_sparc/vm/atomic_solaris_sparc.il
380 endif # sparc
382 ifeq ("${Platform_arch_model}", "x86_32")
383 OPT_CFLAGS=-xtarget=pentium $(EXTRA_OPT_CFLAGS)
384 ifeq ("${COMPILER_REV_NUMERIC}", "500")
385 # SC5.0 tools on x86 are flakey at -xO4
386 OPT_CFLAGS+=-xO3
387 else
388 OPT_CFLAGS+=-xO4
389 endif
391 CFLAGS += $(GAMMADIR)/src/os_cpu/solaris_x86/vm/solaris_x86_32.il
393 endif # 32bit x86
395 # The following options run into misaligned ldd problem (raj)
396 #OPT_CFLAGS = -fast -O4 $(ARCHFLAG/sparc) -xchip=ultra
398 # no more exceptions
399 CFLAGS/NOEX=-noex
401 # PIC is safer for SPARC, and is considerably slower
402 # a file foo.o which wants to compile -pic can set "PICFLAG/foo.o = -PIC"
403 PICFLAG = -PIC
404 PICFLAG/DEFAULT = $(PICFLAG)
405 # [RGV] Need to figure which files to remove to get link to work
406 #PICFLAG/BETTER = -pic
407 PICFLAG/BETTER = $(PICFLAG/DEFAULT)
408 PICFLAG/BYFILE = $(PICFLAG/$@)$(PICFLAG/DEFAULT$(PICFLAG/$@))
410 endif # COMPILER_REV_NUMERIC = 500
412 ################################
413 # End old 5.0 compiler options #
414 ################################
416 ifeq ("${COMPILER_REV_NUMERIC}", "402")
417 # 4.2 COMPILERS SHOULD NO LONGER BE USED
418 _JUNK_ := $(shell echo >&2 \
419 "*** ERROR: SC4.2 compilers are not supported by this code base!")
420 @exit 1
421 endif
423 # do not include shared lib path in a.outs
424 AOUT_FLAGS += -norunpath
425 LFLAGS_VM = -norunpath -z noversion
427 # need position-indep-code for shared libraries
428 # (ild appears to get errors on PIC code, so we'll try non-PIC for debug)
429 ifeq ($(PICFLAGS),DEFAULT)
430 VM_PICFLAG/LIBJVM = $(PICFLAG/DEFAULT)
431 else
432 VM_PICFLAG/LIBJVM = $(PICFLAG/BYFILE)
433 endif
434 VM_PICFLAG/AOUT =
436 VM_PICFLAG = $(VM_PICFLAG/$(LINK_INTO))
437 CFLAGS += $(VM_PICFLAG)
439 # less dynamic linking (no PLTs, please)
440 #LIB_FLAGS += $(LINK_MODE)
441 # %%%%% despite -znodefs, -Bsymbolic gets link errors -- Rose
443 LINK_MODE = $(LINK_MODE/$(VERSION))
444 LINK_MODE/debug =
445 LINK_MODE/optimized = -Bsymbolic -znodefs
447 # Have thread local errnos
448 ifeq ($(shell expr $(COMPILER_REV_NUMERIC) \>= 505), 1)
449 CFLAGS += -mt
450 else
451 CFLAGS += -D_REENTRANT
452 endif
454 ifdef CC_INTERP
455 # C++ Interpreter
456 CFLAGS += -DCC_INTERP
457 endif
459 # Flags for Debugging
460 DEBUG_CFLAGS = -g
461 FASTDEBUG_CFLAGS = -g0
462 # The -g0 setting allows the C++ frontend to inline, which is a big win.
464 # Special global options for SS12
465 ifeq ($(COMPILER_REV_NUMERIC),509)
466 # There appears to be multiple issues with the new Dwarf2 debug format, so
467 # we tell the compiler to use the older 'stabs' debug format all the time.
468 # Note that this needs to be used in optimized compiles too to be 100%.
469 # This is a workaround for SS12 (5.9) bug 6694600
470 CFLAGS += -xdebugformat=stabs
471 endif
473 # Enable the following CFLAGS additions if you need to compare the
474 # built ELF objects.
475 #
476 # The -g option makes static data global and the "-Qoption ccfe
477 # -xglobalstatic" option tells the compiler to not globalize static
478 # data using a unique globalization prefix. Instead force the use of
479 # a static globalization prefix based on the source filepath so the
480 # objects from two identical compilations are the same.
481 #DEBUG_CFLAGS += -Qoption ccfe -xglobalstatic
482 #FASTDEBUG_CFLAGS += -Qoption ccfe -xglobalstatic
484 ifeq (${COMPILER_REV_NUMERIC}, 502)
485 COMPILER_DATE := $(shell $(CPP) -V 2>&1 | sed -n '/^.*[ ]C++[ ]\([1-9]\.[0-9][0-9]*\)/p' | awk '{ print $$NF; }')
486 ifeq (${COMPILER_DATE}, 2001/01/31)
487 # disable -g0 in fastdebug since SC6.1 dated 2001/01/31 seems to be buggy
488 # use an innocuous value because it will get -g if it's empty
489 FASTDEBUG_CFLAGS = -c
490 endif
491 endif
493 # Uncomment or 'gmake CFLAGS_BROWSE=-sbfast' to get source browser information.
494 # CFLAGS_BROWSE = -sbfast
495 CFLAGS += $(CFLAGS_BROWSE)
497 # ILD is gone as of SS11 (5.8), not supportted in SS10 (5.7)
498 ifeq ($(shell expr $(COMPILER_REV_NUMERIC) \< 507), 1)
499 # use ild when debugging (but when optimizing we want reproducible results)
500 ILDFLAG = $(ILDFLAG/$(VERSION))
501 ILDFLAG/debug = -xildon
502 ILDFLAG/optimized =
503 AOUT_FLAGS += $(ILDFLAG)
504 endif
506 # Where to put the *.o files (a.out, or shared library)?
507 LINK_INTO = $(LINK_INTO/$(VERSION))
508 LINK_INTO/debug = LIBJVM
509 LINK_INTO/optimized = LIBJVM
511 # We link the debug version into the a.out because:
512 # 1. ild works on a.out but not shared libraries, and using ild
513 # can cut rebuild times by 25% for small changes. (ILD is gone in SS11)
514 # 2. dbx cannot gracefully set breakpoints in shared libraries
515 #
517 # apply this setting to link into the shared library even in the debug version:
518 ifdef LP64
519 LINK_INTO = LIBJVM
520 else
521 #LINK_INTO = LIBJVM
522 endif
524 MCS = /usr/ccs/bin/mcs
525 STRIP = /usr/ccs/bin/strip
527 # Solaris platforms collect lots of redundant file-ident lines,
528 # to the point of wasting a significant percentage of file space.
529 # (The text is stored in ELF .comment sections, contributed by
530 # all "#pragma ident" directives in header and source files.)
531 # This command "compresses" the .comment sections simply by
532 # removing repeated lines. The data can be extracted from
533 # binaries in the field by using "mcs -p libjvm.so" or the older
534 # command "what libjvm.so".
535 LINK_LIB.CC/POST_HOOK += $(MCS) -c $@ || exit 1;
536 # (The exit 1 is necessary to cause a build failure if the command fails and
537 # multiple commands are strung together, and the final semicolon is necessary
538 # since the hook must terminate itself as a valid command.)
540 # Also, strip debug and line number information (worth about 1.7Mb).
541 STRIP_LIB.CC/POST_HOOK = $(STRIP) -x $@ || exit 1;
542 # STRIP_LIB.CC/POST_HOOK is incorporated into LINK_LIB.CC/POST_HOOK
543 # in certain configurations, such as product.make. Other configurations,
544 # such as debug.make, do not include the strip operation.