author | ihse |
Mon, 11 Jun 2018 12:10:55 +0200 | |
branch | ihse-cflags-rewrite-branch |
changeset 56726 | 3a9b7a1f9197 |
parent 56312 | a52bcf4118eb |
parent 49907 | 1ca3406a2101 |
child 56760 | 8a18c7457c88 |
permissions | -rw-r--r-- |
49120 | 1 |
# |
2 |
# Copyright (c) 2011, 2018, 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. Oracle designates this |
|
8 |
# particular file as subject to the "Classpath" exception as provided |
|
9 |
# by Oracle in the LICENSE file that accompanied this code. |
|
10 |
# |
|
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 |
# |
|
21 |
# 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. |
|
24 |
# |
|
25 |
||
26 |
################################################################################ |
|
27 |
# |
|
28 |
# Setup flags for C/C++ compiler |
|
29 |
# |
|
30 |
||
31 |
############################################################################### |
|
32 |
# |
|
33 |
# How to compile shared libraries. |
|
34 |
# |
|
35 |
AC_DEFUN([FLAGS_SETUP_SHARED_LIBS], |
|
36 |
[ |
|
37 |
if test "x$TOOLCHAIN_TYPE" = xgcc; then |
|
38 |
C_FLAG_REORDER='' |
|
39 |
||
40 |
# Default works for linux, might work on other platforms as well. |
|
41 |
SHARED_LIBRARY_FLAGS='-shared' |
|
42 |
SET_EXECUTABLE_ORIGIN='-Wl,-rpath,\$$ORIGIN[$]1' |
|
43 |
SET_SHARED_LIBRARY_ORIGIN="-Wl,-z,origin $SET_EXECUTABLE_ORIGIN" |
|
44 |
SET_SHARED_LIBRARY_NAME='-Wl,-soname=[$]1' |
|
45 |
SET_SHARED_LIBRARY_MAPFILE='-Wl,-version-script=[$]1' |
|
46 |
||
47 |
elif test "x$TOOLCHAIN_TYPE" = xclang; then |
|
48 |
C_FLAG_REORDER='' |
|
49 |
||
50 |
if test "x$OPENJDK_TARGET_OS" = xmacosx; then |
|
51 |
# Linking is different on MacOSX |
|
52 |
SHARED_LIBRARY_FLAGS="-dynamiclib -compatibility_version 1.0.0 -current_version 1.0.0" |
|
53 |
SET_EXECUTABLE_ORIGIN='-Wl,-rpath,@loader_path$(or [$]1,/.)' |
|
54 |
SET_SHARED_LIBRARY_ORIGIN="$SET_EXECUTABLE_ORIGIN" |
|
55 |
SET_SHARED_LIBRARY_NAME='-Wl,-install_name,@rpath/[$]1' |
|
56 |
SET_SHARED_LIBRARY_MAPFILE='-Wl,-exported_symbols_list,[$]1' |
|
57 |
||
58 |
else |
|
59 |
# Default works for linux, might work on other platforms as well. |
|
60 |
SHARED_LIBRARY_FLAGS='-shared' |
|
61 |
SET_EXECUTABLE_ORIGIN='-Wl,-rpath,\$$ORIGIN[$]1' |
|
62 |
SET_SHARED_LIBRARY_NAME='-Wl,-soname=[$]1' |
|
63 |
SET_SHARED_LIBRARY_MAPFILE='-Wl,-version-script=[$]1' |
|
64 |
||
65 |
# arm specific settings |
|
66 |
if test "x$OPENJDK_TARGET_CPU" = "xarm"; then |
|
67 |
# '-Wl,-z,origin' isn't used on arm. |
|
68 |
SET_SHARED_LIBRARY_ORIGIN='-Wl,-rpath,\$$$$ORIGIN[$]1' |
|
69 |
else |
|
70 |
SET_SHARED_LIBRARY_ORIGIN="-Wl,-z,origin $SET_EXECUTABLE_ORIGIN" |
|
71 |
fi |
|
72 |
fi |
|
73 |
||
74 |
elif test "x$TOOLCHAIN_TYPE" = xsolstudio; then |
|
75 |
C_FLAG_REORDER='-xF' |
|
76 |
SHARED_LIBRARY_FLAGS="-G" |
|
77 |
SET_EXECUTABLE_ORIGIN='-R\$$ORIGIN[$]1' |
|
78 |
SET_SHARED_LIBRARY_ORIGIN="$SET_EXECUTABLE_ORIGIN" |
|
79 |
SET_SHARED_LIBRARY_NAME='-h [$]1' |
|
80 |
SET_SHARED_LIBRARY_MAPFILE='-M[$]1' |
|
81 |
||
82 |
elif test "x$TOOLCHAIN_TYPE" = xxlc; then |
|
83 |
C_FLAG_REORDER='' |
|
84 |
SHARED_LIBRARY_FLAGS="-qmkshrobj -bM:SRE -bnoentry" |
|
85 |
SET_EXECUTABLE_ORIGIN="" |
|
86 |
SET_SHARED_LIBRARY_ORIGIN='' |
|
87 |
SET_SHARED_LIBRARY_NAME='' |
|
88 |
SET_SHARED_LIBRARY_MAPFILE='' |
|
89 |
||
90 |
elif test "x$TOOLCHAIN_TYPE" = xmicrosoft; then |
|
91 |
C_FLAG_REORDER='' |
|
92 |
SHARED_LIBRARY_FLAGS="-dll" |
|
93 |
SET_EXECUTABLE_ORIGIN='' |
|
94 |
SET_SHARED_LIBRARY_ORIGIN='' |
|
95 |
SET_SHARED_LIBRARY_NAME='' |
|
96 |
SET_SHARED_LIBRARY_MAPFILE='-def:[$]1' |
|
97 |
fi |
|
98 |
||
99 |
AC_SUBST(C_FLAG_REORDER) |
|
100 |
AC_SUBST(SET_EXECUTABLE_ORIGIN) |
|
101 |
AC_SUBST(SET_SHARED_LIBRARY_ORIGIN) |
|
102 |
AC_SUBST(SET_SHARED_LIBRARY_NAME) |
|
103 |
AC_SUBST(SET_SHARED_LIBRARY_MAPFILE) |
|
104 |
AC_SUBST(SHARED_LIBRARY_FLAGS) |
|
105 |
]) |
|
106 |
||
107 |
AC_DEFUN([FLAGS_SETUP_DEBUG_SYMBOLS], |
|
108 |
[ |
|
109 |
# Debug symbols |
|
110 |
if test "x$TOOLCHAIN_TYPE" = xgcc; then |
|
49156
6aaf3aef2d67
8199331: Don't limit debug information for fastdebug JDK native libraries
ihse
parents:
49155
diff
changeset
|
111 |
CFLAGS_DEBUG_SYMBOLS="-g" |
49120 | 112 |
elif test "x$TOOLCHAIN_TYPE" = xclang; then |
113 |
CFLAGS_DEBUG_SYMBOLS="-g" |
|
114 |
elif test "x$TOOLCHAIN_TYPE" = xsolstudio; then |
|
115 |
# -g0 enables debug symbols without disabling inlining. |
|
49155
7cd937277d5e
8199338: Use -g0 on solstudio also for compiling C programs
ihse
parents:
49120
diff
changeset
|
116 |
CFLAGS_DEBUG_SYMBOLS="-g0 -xs" |
49120 | 117 |
elif test "x$TOOLCHAIN_TYPE" = xxlc; then |
118 |
CFLAGS_DEBUG_SYMBOLS="-g" |
|
119 |
elif test "x$TOOLCHAIN_TYPE" = xmicrosoft; then |
|
49160
cefb7b496d17
8199347: Always use -Z7 for debug symbols when compiling on Windows
ihse
parents:
49156
diff
changeset
|
120 |
CFLAGS_DEBUG_SYMBOLS="-Z7 -d2Zi+" |
49120 | 121 |
fi |
122 |
||
123 |
AC_SUBST(CFLAGS_DEBUG_SYMBOLS) |
|
124 |
]) |
|
125 |
||
126 |
AC_DEFUN([FLAGS_SETUP_WARNINGS], |
|
127 |
[ |
|
128 |
AC_ARG_ENABLE([warnings-as-errors], [AS_HELP_STRING([--disable-warnings-as-errors], |
|
129 |
[do not consider native warnings to be an error @<:@enabled@:>@])]) |
|
130 |
||
49907
1ca3406a2101
8202325: [aix] disable warnings-as-errors by default
stuefe
parents:
49726
diff
changeset
|
131 |
# Set default value. |
1ca3406a2101
8202325: [aix] disable warnings-as-errors by default
stuefe
parents:
49726
diff
changeset
|
132 |
if test "x$TOOLCHAIN_TYPE" = xxlc; then |
1ca3406a2101
8202325: [aix] disable warnings-as-errors by default
stuefe
parents:
49726
diff
changeset
|
133 |
WARNINGS_AS_ERRORS=false |
1ca3406a2101
8202325: [aix] disable warnings-as-errors by default
stuefe
parents:
49726
diff
changeset
|
134 |
else |
1ca3406a2101
8202325: [aix] disable warnings-as-errors by default
stuefe
parents:
49726
diff
changeset
|
135 |
WARNINGS_AS_ERRORS=true |
1ca3406a2101
8202325: [aix] disable warnings-as-errors by default
stuefe
parents:
49726
diff
changeset
|
136 |
fi |
1ca3406a2101
8202325: [aix] disable warnings-as-errors by default
stuefe
parents:
49726
diff
changeset
|
137 |
|
49120 | 138 |
AC_MSG_CHECKING([if native warnings are errors]) |
139 |
if test "x$enable_warnings_as_errors" = "xyes"; then |
|
140 |
AC_MSG_RESULT([yes (explicitly set)]) |
|
141 |
WARNINGS_AS_ERRORS=true |
|
142 |
elif test "x$enable_warnings_as_errors" = "xno"; then |
|
49907
1ca3406a2101
8202325: [aix] disable warnings-as-errors by default
stuefe
parents:
49726
diff
changeset
|
143 |
AC_MSG_RESULT([no (explicitly set)]) |
49120 | 144 |
WARNINGS_AS_ERRORS=false |
145 |
elif test "x$enable_warnings_as_errors" = "x"; then |
|
49907
1ca3406a2101
8202325: [aix] disable warnings-as-errors by default
stuefe
parents:
49726
diff
changeset
|
146 |
AC_MSG_RESULT([${WARNINGS_AS_ERRORS} (default)]) |
49120 | 147 |
else |
148 |
AC_MSG_ERROR([--enable-warnings-as-errors accepts no argument]) |
|
149 |
fi |
|
150 |
||
151 |
AC_SUBST(WARNINGS_AS_ERRORS) |
|
152 |
||
56217 | 153 |
LDFLAGS_WARNINGS_ARE_ERRORS="" |
49120 | 154 |
case "${TOOLCHAIN_TYPE}" in |
155 |
microsoft) |
|
156 |
DISABLE_WARNING_PREFIX="-wd" |
|
157 |
CFLAGS_WARNINGS_ARE_ERRORS="-WX" |
|
56250
d64ab781c927
Back away from -Wall to -W4 on windows, at least initially.
ihse
parents:
56249
diff
changeset
|
158 |
|
d64ab781c927
Back away from -Wall to -W4 on windows, at least initially.
ihse
parents:
56249
diff
changeset
|
159 |
# 4061 |
d64ab781c927
Back away from -Wall to -W4 on windows, at least initially.
ihse
parents:
56249
diff
changeset
|
160 |
#WARNINGS_ENABLE_ALL="-Wall" |
d64ab781c927
Back away from -Wall to -W4 on windows, at least initially.
ihse
parents:
56249
diff
changeset
|
161 |
WARNINGS_ENABLE_ALL="-W4" |
d64ab781c927
Back away from -Wall to -W4 on windows, at least initially.
ihse
parents:
56249
diff
changeset
|
162 |
# 4061, 4062 = enum not handled |
d64ab781c927
Back away from -Wall to -W4 on windows, at least initially.
ihse
parents:
56249
diff
changeset
|
163 |
# 4130 |
d64ab781c927
Back away from -Wall to -W4 on windows, at least initially.
ihse
parents:
56249
diff
changeset
|
164 |
#EVEN_MORE="4054 4055 4057 4100 4127 4131 4132 4152 4201 4204 4206 4210 4232 4244 4255 4263 4264 4295 4302 4306 4311 4324 4366 4388 4512 4548 4555 4574 4800 4986 4987" |
d64ab781c927
Back away from -Wall to -W4 on windows, at least initially.
ihse
parents:
56249
diff
changeset
|
165 |
#INIT_DISABLE=" 4189 4191 4211 4242 4245 4265 4287 4296 4310 4312 4350 4355 4365 4389 4505 4510 4514 4571 4610 4619 4623 4625 4626 4640 4668 4701 4702 4703 4706 4710 4711 4820 4917 4946 $EVEN_MORE" |
d64ab781c927
Back away from -Wall to -W4 on windows, at least initially.
ihse
parents:
56249
diff
changeset
|
166 |
#DISABLED_WARNINGS_WALL="4061 4062 $INIT_DISABLE" |
d64ab781c927
Back away from -Wall to -W4 on windows, at least initially.
ihse
parents:
56249
diff
changeset
|
167 |
RETRY_W4_HOTSPOT="4189 4211 4245 4310 4389 4505 4510 4610 4701 4702 4703 4706" |
d64ab781c927
Back away from -Wall to -W4 on windows, at least initially.
ihse
parents:
56249
diff
changeset
|
168 |
RETRY_W4_JDK="4054 4055 4057 4100 4127 4130 4131 4132 4152 4201 4204 4206 4210 4232 4244 4295 4306 4324 4366 4512 4800" |
d64ab781c927
Back away from -Wall to -W4 on windows, at least initially.
ihse
parents:
56249
diff
changeset
|
169 |
DISABLED_WARNINGS="$RETRY_W4_HOTSPOT $RETRY_W4_JDK" |
49120 | 170 |
;; |
171 |
solstudio) |
|
172 |
DISABLE_WARNING_PREFIX="-erroff=" |
|
56219 | 173 |
CFLAGS_WARNINGS_ARE_ERRORS="-errwarn=%all" |
56217 | 174 |
LDFLAGS_WARNINGS_ARE_ERRORS="-Wl,-z,fatal-warnings" |
56219 | 175 |
|
176 |
WARNINGS_ENABLE_ALL_CFLAGS="-v -fd -xtransition" |
|
56222 | 177 |
WARNINGS_ENABLE_ALL_CXXFLAGS="+w +w2" |
56219 | 178 |
|
56249
4141c47bb309
Promote E_DECLARATION_IN_CODE to global disable on solaris.
ihse
parents:
56242
diff
changeset
|
179 |
DISABLED_WARNINGS_C="E_OLD_STYLE_FUNC_DECL E_OLD_STYLE_FUNC_DEF E_SEMANTICS_OF_OP_CHG_IN_ANSI_C E_NO_REPLACEMENT_IN_STRING E_DECLARATION_IN_CODE" |
56240 | 180 |
DISABLED_WARNINGS_CXX="inllargeuse inllargeint notused wemptydecl notemsource" |
181 |
# helpful quality checks, should not be disabled: inllargeuse inllargeint |
|
49120 | 182 |
;; |
183 |
gcc) |
|
49200 | 184 |
DISABLE_WARNING_PREFIX="-Wno-" |
49120 | 185 |
CFLAGS_WARNINGS_ARE_ERRORS="-Werror" |
56221 | 186 |
|
187 |
# -Wall -Wextra does not enable all warnings. We add some more that we |
|
188 |
# consider relevant: |
|
56238 | 189 |
WARNINGS_ENABLE_ADDITIONAL="-Wpointer-arith -Wundef -Wlogical-op -Winit-self -Wpacked -Wdisabled-optimization -Wtrampolines" |
190 |
WARNINGS_ENABLE_ADDITIONAL_CXX="-Wc++0x-compat -Wreorder -Wnoexcept -Woverloaded-virtual -Wdelete-non-virtual-dtor -Wwrite-strings -Wstrict-null-sentinel" |
|
191 |
||
56221 | 192 |
WARNINGS_ENABLE_ALL="-Wall -Wextra -Wformat=2 $WARNINGS_ENABLE_ADDITIONAL" |
193 |
WARNINGS_ENABLE_ALL_CXXFLAGS="$WARNINGS_ENABLE_ADDITIONAL_CXX" |
|
194 |
||
56238 | 195 |
DISABLED_WARNINGS_JUST_GET_THIS_PASS="unused-variable unused-function unused-but-set-variable undef unused-value unused-label pointer-arith" |
196 |
DISABLED_WARNINGS="unknown-warning unused-parameter $DISABLED_WARNINGS_JUST_GET_THIS_PASS" |
|
197 |
||
49120 | 198 |
# Repeate the check for the BUILD_CC and BUILD_CXX. Need to also reset |
199 |
# CFLAGS since any target specific flags will likely not work with the |
|
200 |
# build compiler |
|
201 |
CC_OLD="$CC" |
|
202 |
CXX_OLD="$CXX" |
|
203 |
CC="$BUILD_CC" |
|
204 |
CXX="$BUILD_CXX" |
|
205 |
CFLAGS_OLD="$CFLAGS" |
|
206 |
CFLAGS="" |
|
49200 | 207 |
BUILD_CC_DISABLE_WARNING_PREFIX="-Wno-" |
49120 | 208 |
CC="$CC_OLD" |
209 |
CXX="$CXX_OLD" |
|
210 |
CFLAGS="$CFLAGS_OLD" |
|
211 |
;; |
|
212 |
clang) |
|
213 |
DISABLE_WARNING_PREFIX="-Wno-" |
|
214 |
CFLAGS_WARNINGS_ARE_ERRORS="-Werror" |
|
215 |
;; |
|
216 |
xlc) |
|
217 |
DISABLE_WARNING_PREFIX="-qsuppress=" |
|
218 |
CFLAGS_WARNINGS_ARE_ERRORS="-qhalt=w" |
|
219 |
;; |
|
220 |
esac |
|
221 |
AC_SUBST(DISABLE_WARNING_PREFIX) |
|
222 |
AC_SUBST(BUILD_CC_DISABLE_WARNING_PREFIX) |
|
223 |
AC_SUBST(CFLAGS_WARNINGS_ARE_ERRORS) |
|
56217 | 224 |
AC_SUBST(LDFLAGS_WARNINGS_ARE_ERRORS) |
56238 | 225 |
AC_SUBST(DISABLED_WARNINGS) |
56219 | 226 |
AC_SUBST(DISABLED_WARNINGS_C) |
227 |
AC_SUBST(DISABLED_WARNINGS_CXX) |
|
49120 | 228 |
]) |
229 |
||
230 |
AC_DEFUN([FLAGS_SETUP_QUALITY_CHECKS], |
|
231 |
[ |
|
232 |
# bounds, memory and behavior checking options |
|
233 |
if test "x$TOOLCHAIN_TYPE" = xgcc; then |
|
234 |
case $DEBUG_LEVEL in |
|
235 |
release ) |
|
236 |
# no adjustment |
|
237 |
;; |
|
238 |
fastdebug ) |
|
239 |
# no adjustment |
|
240 |
;; |
|
241 |
slowdebug ) |
|
242 |
# FIXME: By adding this to C(XX)FLAGS_DEBUG_OPTIONS/JVM_CFLAGS_SYMBOLS it |
|
243 |
# get's added conditionally on whether we produce debug symbols or not. |
|
244 |
# This is most likely not really correct. |
|
245 |
||
246 |
# Add runtime stack smashing and undefined behavior checks. |
|
56312 | 247 |
CFLAGS_DEBUG_OPTIONS="-fstack-protector-all --param ssp-buffer-size=1 -Wstack-protector" |
248 |
CXXFLAGS_DEBUG_OPTIONS="-fstack-protector-all --param ssp-buffer-size=1 -Wstack-protector" |
|
49120 | 249 |
|
56312 | 250 |
JVM_CFLAGS_SYMBOLS="$JVM_CFLAGS_SYMBOLS -fstack-protector-all --param ssp-buffer-size=1 -Wstack-protector" |
49120 | 251 |
;; |
252 |
esac |
|
253 |
fi |
|
254 |
]) |
|
255 |
||
256 |
AC_DEFUN([FLAGS_SETUP_OPTIMIZATION], |
|
257 |
[ |
|
258 |
if test "x$TOOLCHAIN_TYPE" = xsolstudio; then |
|
259 |
CC_HIGHEST="-fns -fsimple -fsingle -xbuiltin=%all -xdepend -xrestrict -xlibmil" |
|
260 |
||
261 |
C_O_FLAG_HIGHEST_JVM="-xO4" |
|
262 |
C_O_FLAG_DEBUG_JVM="" |
|
263 |
C_O_FLAG_SIZE="" |
|
264 |
C_O_FLAG_DEBUG="" |
|
265 |
C_O_FLAG_NONE="" |
|
266 |
if test "x$OPENJDK_TARGET_CPU_ARCH" = "xx86"; then |
|
267 |
C_O_FLAG_HIGHEST="-xO4 -Wu,-O4~yz $CC_HIGHEST" |
|
268 |
C_O_FLAG_HI="-xO4 -Wu,-O4~yz" |
|
269 |
C_O_FLAG_NORM="-xO2 -Wu,-O2~yz" |
|
270 |
elif test "x$OPENJDK_TARGET_CPU_ARCH" = "xsparc"; then |
|
271 |
C_O_FLAG_HIGHEST="-xO4 -Wc,-Qrm-s -Wc,-Qiselect-T0 \ |
|
272 |
-xprefetch=auto,explicit -xchip=ultra $CC_HIGHEST" |
|
273 |
C_O_FLAG_HI="-xO4 -Wc,-Qrm-s -Wc,-Qiselect-T0" |
|
274 |
C_O_FLAG_NORM="-xO2 -Wc,-Qrm-s -Wc,-Qiselect-T0" |
|
275 |
fi |
|
276 |
elif test "x$TOOLCHAIN_TYPE" = xgcc; then |
|
277 |
C_O_FLAG_HIGHEST_JVM="-O3" |
|
278 |
C_O_FLAG_HIGHEST="-O3" |
|
279 |
C_O_FLAG_HI="-O3" |
|
280 |
C_O_FLAG_NORM="-O2" |
|
281 |
C_O_FLAG_SIZE="-Os" |
|
282 |
C_O_FLAG_DEBUG="-O0" |
|
283 |
C_O_FLAG_DEBUG_JVM="-O0" |
|
284 |
C_O_FLAG_NONE="-O0" |
|
285 |
elif test "x$TOOLCHAIN_TYPE" = xclang; then |
|
286 |
if test "x$OPENJDK_TARGET_OS" = xmacosx; then |
|
287 |
# On MacOSX we optimize for size, something |
|
288 |
# we should do for all platforms? |
|
289 |
C_O_FLAG_HIGHEST_JVM="-Os" |
|
290 |
C_O_FLAG_HIGHEST="-Os" |
|
291 |
C_O_FLAG_HI="-Os" |
|
292 |
C_O_FLAG_NORM="-Os" |
|
293 |
C_O_FLAG_DEBUG_JVM="" |
|
294 |
else |
|
295 |
C_O_FLAG_HIGHEST_JVM="-O3" |
|
296 |
C_O_FLAG_HIGHEST="-O3" |
|
297 |
C_O_FLAG_HI="-O3" |
|
298 |
C_O_FLAG_NORM="-O2" |
|
299 |
C_O_FLAG_DEBUG_JVM="-O0" |
|
300 |
fi |
|
301 |
C_O_FLAG_SIZE="-Os" |
|
302 |
C_O_FLAG_DEBUG="-O0" |
|
303 |
C_O_FLAG_NONE="-O0" |
|
304 |
elif test "x$TOOLCHAIN_TYPE" = xxlc; then |
|
305 |
C_O_FLAG_HIGHEST_JVM="-O3 -qhot=level=1 -qinline -qinlglue" |
|
306 |
C_O_FLAG_HIGHEST="-O3 -qhot=level=1 -qinline -qinlglue" |
|
307 |
C_O_FLAG_HI="-O3 -qinline -qinlglue" |
|
308 |
C_O_FLAG_NORM="-O2" |
|
309 |
C_O_FLAG_DEBUG="-qnoopt" |
|
310 |
# FIXME: Value below not verified. |
|
311 |
C_O_FLAG_DEBUG_JVM="" |
|
312 |
C_O_FLAG_NONE="-qnoopt" |
|
313 |
elif test "x$TOOLCHAIN_TYPE" = xmicrosoft; then |
|
314 |
C_O_FLAG_HIGHEST_JVM="-O2 -Oy-" |
|
315 |
C_O_FLAG_HIGHEST="-O2" |
|
316 |
C_O_FLAG_HI="-O1" |
|
317 |
C_O_FLAG_NORM="-O1" |
|
318 |
C_O_FLAG_DEBUG="-Od" |
|
319 |
C_O_FLAG_DEBUG_JVM="" |
|
320 |
C_O_FLAG_NONE="-Od" |
|
321 |
C_O_FLAG_SIZE="-Os" |
|
322 |
fi |
|
323 |
||
324 |
# Now copy to C++ flags |
|
325 |
CXX_O_FLAG_HIGHEST_JVM="$C_O_FLAG_HIGHEST_JVM" |
|
326 |
CXX_O_FLAG_HIGHEST="$C_O_FLAG_HIGHEST" |
|
327 |
CXX_O_FLAG_HI="$C_O_FLAG_HI" |
|
328 |
CXX_O_FLAG_NORM="$C_O_FLAG_NORM" |
|
329 |
CXX_O_FLAG_DEBUG="$C_O_FLAG_DEBUG" |
|
330 |
CXX_O_FLAG_DEBUG_JVM="$C_O_FLAG_DEBUG_JVM" |
|
331 |
CXX_O_FLAG_NONE="$C_O_FLAG_NONE" |
|
332 |
CXX_O_FLAG_SIZE="$C_O_FLAG_SIZE" |
|
333 |
||
334 |
if test "x$TOOLCHAIN_TYPE" = xsolstudio; then |
|
335 |
# In solstudio, also add this to C (but not C++) flags... |
|
336 |
C_O_FLAG_HIGHEST="$C_O_FLAG_HIGHEST -xalias_level=basic" |
|
337 |
fi |
|
338 |
||
339 |
# Adjust optimization flags according to debug level. |
|
340 |
case $DEBUG_LEVEL in |
|
341 |
release ) |
|
342 |
# no adjustment |
|
343 |
;; |
|
344 |
fastdebug ) |
|
345 |
# Not quite so much optimization |
|
346 |
C_O_FLAG_HI="$C_O_FLAG_NORM" |
|
347 |
CXX_O_FLAG_HI="$CXX_O_FLAG_NORM" |
|
348 |
;; |
|
349 |
slowdebug ) |
|
350 |
# Disable optimization |
|
351 |
C_O_FLAG_HIGHEST_JVM="$C_O_FLAG_DEBUG_JVM" |
|
352 |
C_O_FLAG_HIGHEST="$C_O_FLAG_DEBUG" |
|
353 |
C_O_FLAG_HI="$C_O_FLAG_DEBUG" |
|
354 |
C_O_FLAG_NORM="$C_O_FLAG_DEBUG" |
|
355 |
C_O_FLAG_SIZE="$C_O_FLAG_DEBUG" |
|
356 |
CXX_O_FLAG_HIGHEST_JVM="$CXX_O_FLAG_DEBUG_JVM" |
|
357 |
CXX_O_FLAG_HIGHEST="$CXX_O_FLAG_DEBUG" |
|
358 |
CXX_O_FLAG_HI="$CXX_O_FLAG_DEBUG" |
|
359 |
CXX_O_FLAG_NORM="$CXX_O_FLAG_DEBUG" |
|
360 |
CXX_O_FLAG_SIZE="$CXX_O_FLAG_DEBUG" |
|
361 |
;; |
|
362 |
esac |
|
363 |
||
364 |
AC_SUBST(C_O_FLAG_HIGHEST_JVM) |
|
365 |
AC_SUBST(C_O_FLAG_HIGHEST) |
|
366 |
AC_SUBST(C_O_FLAG_HI) |
|
367 |
AC_SUBST(C_O_FLAG_NORM) |
|
368 |
AC_SUBST(C_O_FLAG_NONE) |
|
369 |
AC_SUBST(C_O_FLAG_SIZE) |
|
370 |
AC_SUBST(CXX_O_FLAG_HIGHEST_JVM) |
|
371 |
AC_SUBST(CXX_O_FLAG_HIGHEST) |
|
372 |
AC_SUBST(CXX_O_FLAG_HI) |
|
373 |
AC_SUBST(CXX_O_FLAG_NORM) |
|
374 |
AC_SUBST(CXX_O_FLAG_NONE) |
|
375 |
AC_SUBST(CXX_O_FLAG_SIZE) |
|
376 |
]) |
|
377 |
||
378 |
AC_DEFUN([FLAGS_SETUP_CFLAGS], |
|
379 |
[ |
|
380 |
### CFLAGS |
|
381 |
||
382 |
FLAGS_SETUP_CFLAGS_HELPER |
|
383 |
||
384 |
FLAGS_OS=$OPENJDK_TARGET_OS |
|
385 |
FLAGS_OS_TYPE=$OPENJDK_TARGET_OS_TYPE |
|
386 |
FLAGS_CPU=$OPENJDK_TARGET_CPU |
|
387 |
FLAGS_CPU_ARCH=$OPENJDK_TARGET_CPU_ARCH |
|
388 |
FLAGS_CPU_BITS=$OPENJDK_TARGET_CPU_BITS |
|
389 |
FLAGS_CPU_ENDIAN=$OPENJDK_TARGET_CPU_ENDIAN |
|
390 |
FLAGS_CPU_LEGACY=$OPENJDK_TARGET_CPU_LEGACY |
|
391 |
FLAGS_CPU_LEGACY_LIB=$OPENJDK_TARGET_CPU_LEGACY_LIB |
|
392 |
||
393 |
FLAGS_SETUP_CFLAGS_CPU_DEP([TARGET]) |
|
394 |
||
395 |
FLAGS_OS=$OPENJDK_BUILD_OS |
|
396 |
FLAGS_OS_TYPE=$OPENJDK_BUILD_OS_TYPE |
|
397 |
FLAGS_CPU=$OPENJDK_BUILD_CPU |
|
398 |
FLAGS_CPU_ARCH=$OPENJDK_BUILD_CPU_ARCH |
|
399 |
FLAGS_CPU_BITS=$OPENJDK_BUILD_CPU_BITS |
|
400 |
FLAGS_CPU_ENDIAN=$OPENJDK_BUILD_CPU_ENDIAN |
|
401 |
FLAGS_CPU_LEGACY=$OPENJDK_BUILD_CPU_LEGACY |
|
402 |
FLAGS_CPU_LEGACY_LIB=$OPENJDK_BUILD_CPU_LEGACY_LIB |
|
403 |
||
404 |
FLAGS_SETUP_CFLAGS_CPU_DEP([BUILD], [OPENJDK_BUILD_]) |
|
405 |
||
406 |
# Tests are only ever compiled for TARGET |
|
407 |
CFLAGS_TESTLIB="$CFLAGS_JDKLIB" |
|
408 |
CXXFLAGS_TESTLIB="$CXXFLAGS_JDKLIB" |
|
409 |
CFLAGS_TESTEXE="$CFLAGS_JDKEXE" |
|
410 |
CXXFLAGS_TESTEXE="$CXXFLAGS_JDKEXE" |
|
411 |
||
412 |
AC_SUBST(CFLAGS_TESTLIB) |
|
413 |
AC_SUBST(CFLAGS_TESTEXE) |
|
414 |
AC_SUBST(CXXFLAGS_TESTLIB) |
|
415 |
AC_SUBST(CXXFLAGS_TESTEXE) |
|
416 |
]) |
|
417 |
||
418 |
################################################################################ |
|
419 |
# platform independent |
|
420 |
AC_DEFUN([FLAGS_SETUP_CFLAGS_HELPER], |
|
421 |
[ |
|
422 |
#### OS DEFINES, these should be independent on toolchain |
|
423 |
if test "x$OPENJDK_TARGET_OS" = xlinux; then |
|
424 |
CFLAGS_OS_DEF_JVM="-DLINUX" |
|
425 |
CFLAGS_OS_DEF_JDK="-D_GNU_SOURCE -D_REENTRANT -D_LARGEFILE64_SOURCE" |
|
426 |
elif test "x$OPENJDK_TARGET_OS" = xsolaris; then |
|
427 |
CFLAGS_OS_DEF_JVM="-DSOLARIS" |
|
428 |
CFLAGS_OS_DEF_JDK="-D__solaris__" |
|
429 |
elif test "x$OPENJDK_TARGET_OS" = xmacosx; then |
|
430 |
CFLAGS_OS_DEF_JVM="-D_ALLBSD_SOURCE -D_DARWIN_C_SOURCE -D_XOPEN_SOURCE" |
|
431 |
CFLAGS_OS_DEF_JDK="-D_ALLBSD_SOURCE -D_DARWIN_UNLIMITED_SELECT" |
|
432 |
elif test "x$OPENJDK_TARGET_OS" = xaix; then |
|
433 |
CFLAGS_OS_DEF_JVM="-DAIX" |
|
434 |
elif test "x$OPENJDK_TARGET_OS" = xbsd; then |
|
435 |
CFLAGS_OS_DEF_JDK="-D_ALLBSD_SOURCE" |
|
436 |
elif test "x$OPENJDK_TARGET_OS" = xwindows; then |
|
437 |
CFLAGS_OS_DEF_JVM="-D_WINDOWS -DWIN32 -D_JNI_IMPLEMENTATION_" |
|
438 |
fi |
|
439 |
||
440 |
CFLAGS_OS_DEF_JDK="$CFLAGS_OS_DEF_JDK -D$OPENJDK_TARGET_OS_UPPERCASE" |
|
441 |
||
442 |
#### GLOBAL DEFINES |
|
443 |
# Set some common defines. These works for all compilers, but assume |
|
444 |
# -D is universally accepted. |
|
445 |
||
446 |
# Always enable optional macros for VM. |
|
447 |
ALWAYS_CFLAGS_JVM="-D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS" |
|
448 |
||
449 |
# Setup some hard coded includes |
|
450 |
ALWAYS_CFLAGS_JDK=" \ |
|
451 |
-I\$(SUPPORT_OUTPUTDIR)/modules_include/java.base \ |
|
452 |
-I\$(SUPPORT_OUTPUTDIR)/modules_include/java.base/\$(OPENJDK_TARGET_OS_INCLUDE_SUBDIR) \ |
|
453 |
-I${TOPDIR}/src/java.base/share/native/libjava \ |
|
454 |
-I${TOPDIR}/src/java.base/$OPENJDK_TARGET_OS_TYPE/native/libjava \ |
|
455 |
-I${TOPDIR}/src/hotspot/share/include \ |
|
456 |
-I${TOPDIR}/src/hotspot/os/${HOTSPOT_TARGET_OS_TYPE}/include" |
|
457 |
||
458 |
############################################################################### |
|
459 |
||
460 |
# Adjust flags according to debug level. |
|
461 |
# Setup debug/release defines |
|
462 |
if test "x$DEBUG_LEVEL" = xrelease; then |
|
463 |
DEBUG_CFLAGS_JDK="-DNDEBUG" |
|
464 |
if test "x$OPENJDK_TARGET_OS" = xsolaris; then |
|
465 |
DEBUG_CFLAGS_JDK="$DEBUG_CFLAGS_JDK -DTRIMMED" |
|
466 |
fi |
|
467 |
else |
|
468 |
DEBUG_CFLAGS_JDK="-DDEBUG" |
|
469 |
||
470 |
if test "x$TOOLCHAIN_TYPE" = xxlc; then |
|
471 |
# We need '-qminimaltoc' or '-qpic=large -bbigtoc' if the TOC overflows. |
|
472 |
# Hotspot now overflows its 64K TOC (currently only for debug), |
|
473 |
# so for debug we build with '-qpic=large -bbigtoc'. |
|
474 |
DEBUG_CFLAGS_JVM="-qpic=large" |
|
475 |
fi |
|
476 |
fi |
|
477 |
||
478 |
if test "x$DEBUG_LEVEL" != xrelease; then |
|
479 |
DEBUG_OPTIONS_FLAGS_JDK="$CFLAGS_DEBUG_OPTIONS" |
|
480 |
DEBUG_SYMBOLS_CFLAGS_JDK="$CFLAGS_DEBUG_SYMBOLS" |
|
481 |
fi |
|
482 |
||
483 |
#### TOOLCHAIN DEFINES |
|
484 |
||
485 |
if test "x$TOOLCHAIN_TYPE" = xgcc; then |
|
486 |
ALWAYS_DEFINES_JVM="-D_GNU_SOURCE -D_REENTRANT" |
|
487 |
elif test "x$TOOLCHAIN_TYPE" = xclang; then |
|
488 |
ALWAYS_DEFINES_JVM="-D_GNU_SOURCE" |
|
489 |
elif test "x$TOOLCHAIN_TYPE" = xsolstudio; then |
|
490 |
ALWAYS_DEFINES_JVM="-DSPARC_WORKS -D_Crun_inline_placement" |
|
491 |
ALWAYS_DEFINES_JDK="-DTRACING -DMACRO_MEMSYS_OPS -DBREAKPTS" |
|
492 |
ALWAYS_DEFINES_JDK_CXXONLY="-DCC_NOEX" |
|
493 |
elif test "x$TOOLCHAIN_TYPE" = xxlc; then |
|
494 |
ALWAYS_DEFINES_JVM="-D_REENTRANT" |
|
495 |
ALWAYS_DEFINES_JDK="-D_GNU_SOURCE -D_REENTRANT -D_LARGEFILE64_SOURCE -DSTDC" |
|
496 |
elif test "x$TOOLCHAIN_TYPE" = xmicrosoft; then |
|
497 |
ALWAYS_DEFINES_JDK="-DWIN32_LEAN_AND_MEAN -D_CRT_SECURE_NO_DEPRECATE \ |
|
498 |
-D_CRT_NONSTDC_NO_DEPRECATE -DWIN32 -DIAL" |
|
49726
4ae63fcabe2e
8199736: Define WIN32_LEAN_AND_MEAN before including windows.h
rwestberg
parents:
49679
diff
changeset
|
499 |
ALWAYS_DEFINES_JVM="-DNOMINMAX -DWIN32_LEAN_AND_MEAN" |
49120 | 500 |
fi |
501 |
||
502 |
############################################################################### |
|
503 |
# |
|
504 |
# |
|
505 |
# CFLAGS BASIC |
|
506 |
if test "x$TOOLCHAIN_TYPE" = xgcc || test "x$TOOLCHAIN_TYPE" = xclang; then |
|
507 |
# COMMON to gcc and clang |
|
508 |
TOOLCHAIN_CFLAGS_JVM="-pipe -fno-rtti -fno-exceptions \ |
|
509 |
-fvisibility=hidden -fno-strict-aliasing -fno-omit-frame-pointer" |
|
510 |
fi |
|
511 |
||
512 |
if test "x$TOOLCHAIN_TYPE" = xgcc; then |
|
513 |
TOOLCHAIN_CFLAGS_JVM="$TOOLCHAIN_CFLAGS_JVM -fcheck-new" |
|
514 |
TOOLCHAIN_CFLAGS_JDK="-pipe" |
|
515 |
TOOLCHAIN_CFLAGS_JDK_CONLY="-fno-strict-aliasing" # technically NOT for CXX (but since this gives *worse* performance, use no-strict-aliasing everywhere!) |
|
516 |
||
517 |
CXXSTD_CXXFLAG="-std=gnu++98" |
|
518 |
FLAGS_CXX_COMPILER_CHECK_ARGUMENTS(ARGUMENT: [$CXXSTD_CXXFLAG -Werror], |
|
519 |
IF_FALSE: [CXXSTD_CXXFLAG=""]) |
|
520 |
TOOLCHAIN_CFLAGS_JDK_CXXONLY="$CXXSTD_CXXFLAG" |
|
521 |
TOOLCHAIN_CFLAGS_JVM="$TOOLCHAIN_CFLAGS_JVM $CXXSTD_CXXFLAG" |
|
522 |
ADLC_CXXFLAG="$CXXSTD_CXXFLAG" |
|
523 |
||
524 |
||
525 |
elif test "x$TOOLCHAIN_TYPE" = xclang; then |
|
526 |
# Restrict the debug information created by Clang to avoid |
|
527 |
# too big object files and speed the build up a little bit |
|
528 |
# (see http://llvm.org/bugs/show_bug.cgi?id=7554) |
|
529 |
TOOLCHAIN_CFLAGS_JVM="$TOOLCHAIN_CFLAGS_JVM -flimit-debug-info" |
|
530 |
||
531 |
if test "x$OPENJDK_TARGET_OS" = xlinux; then |
|
532 |
TOOLCHAIN_CFLAGS_JDK="-pipe" |
|
533 |
TOOLCHAIN_CFLAGS_JDK_CONLY="-fno-strict-aliasing" # technically NOT for CXX |
|
534 |
fi |
|
535 |
elif test "x$TOOLCHAIN_TYPE" = xsolstudio; then |
|
56219 | 536 |
TOOLCHAIN_FLAGS="-errtags -errfmt" |
537 |
TOOLCHAIN_CFLAGS="-errshort=tags" |
|
538 |
||
56222 | 539 |
TOOLCHAIN_CFLAGS_JDK="-mt $TOOLCHAIN_FLAGS" |
540 |
TOOLCHAIN_CFLAGS_JDK_CONLY="-xc99=%none -xCC -Xa -W0,-noglobal $TOOLCHAIN_CFLAGS" # C only |
|
49120 | 541 |
TOOLCHAIN_CFLAGS_JDK_CXXONLY="-features=no%except -norunpath -xnolib" # CXX only |
542 |
TOOLCHAIN_CFLAGS_JVM="-template=no%extdef -features=no%split_init \ |
|
56222 | 543 |
-library=stlport4 -mt -features=no%except $TOOLCHAIN_FLAGS" |
49155
7cd937277d5e
8199338: Use -g0 on solstudio also for compiling C programs
ihse
parents:
49120
diff
changeset
|
544 |
if test "x$DEBUG_LEVEL" = xslowdebug; then |
7cd937277d5e
8199338: Use -g0 on solstudio also for compiling C programs
ihse
parents:
49120
diff
changeset
|
545 |
# Previously -g was used instead of -g0 for slowdebug; this is equivalent |
7cd937277d5e
8199338: Use -g0 on solstudio also for compiling C programs
ihse
parents:
49120
diff
changeset
|
546 |
# to setting +d. |
7cd937277d5e
8199338: Use -g0 on solstudio also for compiling C programs
ihse
parents:
49120
diff
changeset
|
547 |
TOOLCHAIN_CFLAGS_JVM="$TOOLCHAIN_CFLAGS_JVM +d" |
7cd937277d5e
8199338: Use -g0 on solstudio also for compiling C programs
ihse
parents:
49120
diff
changeset
|
548 |
fi |
7cd937277d5e
8199338: Use -g0 on solstudio also for compiling C programs
ihse
parents:
49120
diff
changeset
|
549 |
|
49120 | 550 |
elif test "x$TOOLCHAIN_TYPE" = xxlc; then |
551 |
TOOLCHAIN_CFLAGS_JDK="-qchars=signed -qfullpath -qsaveopt" # add on both CFLAGS |
|
552 |
TOOLCHAIN_CFLAGS_JVM="-qtune=balanced \ |
|
553 |
-qalias=noansi -qstrict -qtls=default -qlanglvl=c99vla \ |
|
554 |
-qlanglvl=noredefmac -qnortti -qnoeh -qignerrno" |
|
555 |
elif test "x$TOOLCHAIN_TYPE" = xmicrosoft; then |
|
556 |
TOOLCHAIN_CFLAGS_JVM="-nologo -MD -MP" |
|
557 |
TOOLCHAIN_CFLAGS_JDK="-nologo -MD -Zc:wchar_t-" |
|
558 |
fi |
|
559 |
||
560 |
# CFLAGS WARNINGS STUFF |
|
561 |
# Set JVM_CFLAGS warning handling |
|
56221 | 562 |
if test "x$TOOLCHAIN_TYPE" = xgcc; then |
56238 | 563 |
# JDK_DISABLED="-Wno-pointer-arith -Wno-undef -Wno-unused-function -Wno-unused-value -Wno-unused-but-set-variable -Wno-unused-parameter -Wno-unused-variable -Wno-unused-label" |
564 |
# JVM_DISABLED="-Wno-unknown-pragmas -Wno-comment -Wno-delete-non-virtual-dtor -Wno-ignored-qualifiers -Wno-parentheses -Wno-reorder -Wno-unused-local-typedefs -Wno-unused-parameter -Wno-unused-variable -Wno-address -Wno-missing-field-initializers -Wno-unused-but-set-variable -Wno-char-subscripts -Wno-array-bounds -Wno-narrowing -Wno-empty-body -Wno-unused-but-set-parameter" |
|
49120 | 565 |
|
56221 | 566 |
WARNING_CFLAGS_JDK="$WARNINGS_ENABLE_ALL $JDK_DISABLED" |
56238 | 567 |
WARNING_CFLAGS_JDK_CONLY="$WARNINGS_ENABLE_ALL_CFLAGS" |
56221 | 568 |
WARNING_CFLAGS_JDK_CXXONLY="$WARNINGS_ENABLE_ALL_CXXFLAGS" |
569 |
WARNING_CFLAGS_JVM="$WARNINGS_ENABLE_ALL $WARNINGS_ENABLE_ALL_CXXFLAGS $JVM_DISABLED" |
|
49120 | 570 |
|
571 |
elif test "x$TOOLCHAIN_TYPE" = xclang; then |
|
56221 | 572 |
WARNING_CFLAGS_JVM="-Wpointer-arith -Wsign-compare -Wunused-function -Wno-deprecated" |
49120 | 573 |
if test "x$OPENJDK_TARGET_OS" = xlinux; then |
574 |
WARNING_CFLAGS_JVM="$WARNING_CFLAGS_JVM -Wno-sometimes-uninitialized" |
|
575 |
WARNING_CFLAGS_JDK="-Wall -Wextra -Wno-unused -Wno-unused-parameter -Wformat=2" |
|
576 |
fi |
|
577 |
elif test "x$TOOLCHAIN_TYPE" = xsolstudio; then |
|
56221 | 578 |
WARNING_CFLAGS_JDK_CONLY="$WARNINGS_ENABLE_ALL_CFLAGS" |
579 |
WARNING_CFLAGS_JDK_CXXONLY="$WARNINGS_ENABLE_ALL_CXXFLAGS" |
|
580 |
WARNING_CFLAGS_JVM="$WARNINGS_ENABLE_ALL_CXXFLAGS" |
|
49120 | 581 |
elif test "x$TOOLCHAIN_TYPE" = xmicrosoft; then |
56242
e60ee82dc0ce
Initial conversion for windows with -Wall and disables.
ihse
parents:
56240
diff
changeset
|
582 |
WARNING_CFLAGS="$WARNINGS_ENABLE_ALL" |
e60ee82dc0ce
Initial conversion for windows with -Wall and disables.
ihse
parents:
56240
diff
changeset
|
583 |
#WARNING_CFLAGS="-W3" |
e60ee82dc0ce
Initial conversion for windows with -Wall and disables.
ihse
parents:
56240
diff
changeset
|
584 |
#WARNING_CFLAGS_JDK="-wd4800" |
49120 | 585 |
fi |
586 |
||
587 |
# Set some additional per-OS defines. |
|
588 |
||
589 |
# Additional macosx handling |
|
590 |
if test "x$OPENJDK_TARGET_OS" = xmacosx; then |
|
591 |
OS_CFLAGS="-DMAC_OS_X_VERSION_MIN_REQUIRED=$MACOSX_VERSION_MIN_NODOTS \ |
|
592 |
-mmacosx-version-min=$MACOSX_VERSION_MIN" |
|
593 |
||
594 |
if test -n "$MACOSX_VERSION_MAX"; then |
|
595 |
OS_CFLAGS="$OS_CFLAGS \ |
|
596 |
-DMAC_OS_X_VERSION_MAX_ALLOWED=$MACOSX_VERSION_MAX_NODOTS" |
|
597 |
fi |
|
598 |
fi |
|
599 |
||
600 |
# Where does this really belong?? |
|
601 |
if test "x$TOOLCHAIN_TYPE" = xgcc || test "x$TOOLCHAIN_TYPE" = xclang; then |
|
602 |
PICFLAG="-fPIC" |
|
603 |
elif test "x$TOOLCHAIN_TYPE" = xsolstudio; then |
|
604 |
PICFLAG="-KPIC" |
|
605 |
elif test "x$TOOLCHAIN_TYPE" = xxlc; then |
|
606 |
# '-qpic' defaults to 'qpic=small'. This means that the compiler generates only |
|
607 |
# one instruction for accessing the TOC. If the TOC grows larger than 64K, the linker |
|
608 |
# will have to patch this single instruction with a call to some out-of-order code which |
|
609 |
# does the load from the TOC. This is of course slow. But in that case we also would have |
|
610 |
# to use '-bbigtoc' for linking anyway so we could also change the PICFLAG to 'qpic=large'. |
|
611 |
# With 'qpic=large' the compiler will by default generate a two-instruction sequence which |
|
612 |
# can be patched directly by the linker and does not require a jump to out-of-order code. |
|
613 |
# Another alternative instead of using 'qpic=large -bbigtoc' may be to use '-qminimaltoc' |
|
614 |
# instead. This creates a distinct TOC for every compilation unit (and thus requires two |
|
615 |
# loads for accessing a global variable). But there are rumors that this may be seen as a |
|
616 |
# 'performance feature' because of improved code locality of the symbols used in a |
|
617 |
# compilation unit. |
|
618 |
PICFLAG="-qpic" |
|
619 |
elif test "x$TOOLCHAIN_TYPE" = xmicrosoft; then |
|
620 |
PICFLAG="" |
|
621 |
fi |
|
622 |
||
623 |
JVM_PICFLAG="$PICFLAG" |
|
624 |
JDK_PICFLAG="$PICFLAG" |
|
625 |
||
626 |
if test "x$OPENJDK_TARGET_OS" = xmacosx; then |
|
627 |
# Linking is different on MacOSX |
|
628 |
JDK_PICFLAG='' |
|
629 |
if test "x$STATIC_BUILD" = xtrue; then |
|
630 |
JVM_PICFLAG="" |
|
631 |
fi |
|
632 |
fi |
|
633 |
||
634 |
if test "x$OPENJDK_TARGET_OS" = xmacosx; then |
|
635 |
OS_CFLAGS_JVM="$OS_CFLAGS_JVM -mno-omit-leaf-frame-pointer -mstack-alignment=16" |
|
636 |
fi |
|
637 |
||
638 |
# Optional POSIX functionality needed by the JVM |
|
639 |
# |
|
640 |
# Check if clock_gettime is available and in which library. This indicates |
|
641 |
# availability of CLOCK_MONOTONIC for hotspot. But we don't need to link, so |
|
642 |
# don't let it update LIBS. |
|
643 |
save_LIBS="$LIBS" |
|
644 |
AC_SEARCH_LIBS(clock_gettime, rt, [HAS_CLOCK_GETTIME=true], []) |
|
645 |
if test "x$LIBS" = "x-lrt "; then |
|
646 |
CLOCK_GETTIME_IN_LIBRT=true |
|
647 |
fi |
|
648 |
LIBS="$save_LIBS" |
|
649 |
||
650 |
if test "x$HAS_CLOCK_GETTIME" = "xtrue"; then |
|
651 |
OS_CFLAGS_JVM="$OS_CFLAGS_JVM -DSUPPORTS_CLOCK_MONOTONIC" |
|
652 |
if test "x$CLOCK_GETTIME_IN_LIBRT" = "xtrue"; then |
|
653 |
OS_CFLAGS_JVM="$OS_CFLAGS_JVM -DNEEDS_LIBRT" |
|
654 |
fi |
|
655 |
fi |
|
656 |
||
657 |
# EXPORT |
|
658 |
AC_SUBST(ADLC_CXXFLAG) |
|
659 |
]) |
|
660 |
||
661 |
################################################################################ |
|
662 |
# $1 - Either BUILD or TARGET to pick the correct OS/CPU variables to check |
|
663 |
# conditionals against. |
|
664 |
# $2 - Optional prefix for each variable defined. |
|
665 |
AC_DEFUN([FLAGS_SETUP_CFLAGS_CPU_DEP], |
|
666 |
[ |
|
667 |
#### CPU DEFINES, these should (in theory) be independent on toolchain |
|
668 |
||
669 |
# Setup target CPU |
|
670 |
# Setup endianness |
|
671 |
if test "x$FLAGS_CPU_ENDIAN" = xlittle; then |
|
672 |
$1_DEFINES_CPU_JVM="-DVM_LITTLE_ENDIAN" |
|
673 |
fi |
|
674 |
if test "x$TOOLCHAIN_TYPE" = xsolstudio; then |
|
675 |
# The macro _LITTLE_ENDIAN needs to be defined the same to avoid the |
|
676 |
# Sun C compiler warning message: warning: macro redefined: _LITTLE_ENDIAN |
|
677 |
if test "x$FLAGS_CPU_ENDIAN" = xlittle; then |
|
678 |
$1_DEFINES_CPU_JDK="-D_LITTLE_ENDIAN=" |
|
679 |
else |
|
680 |
$1_DEFINES_CPU_JDK="-D_BIG_ENDIAN=" |
|
681 |
fi |
|
682 |
else |
|
683 |
if test "x$FLAGS_CPU_ENDIAN" = xlittle; then |
|
684 |
$1_DEFINES_CPU_JDK="-D_LITTLE_ENDIAN" |
|
685 |
else |
|
686 |
$1_DEFINES_CPU_JDK="-D_BIG_ENDIAN" |
|
687 |
fi |
|
688 |
fi |
|
689 |
||
690 |
# setup CPU bit size |
|
691 |
$1_DEFINES_CPU_JDK="${$1_DEFINES_CPU_JDK} -DARCH='\"$FLAGS_CPU_LEGACY\"' \ |
|
692 |
-D$FLAGS_CPU_LEGACY" |
|
693 |
||
694 |
if test "x$FLAGS_CPU_BITS" = x64; then |
|
695 |
# -D_LP64=1 is only set on linux and mac. Setting on windows causes diff in |
|
696 |
# unpack200.exe. |
|
697 |
if test "x$FLAGS_OS" = xlinux || test "x$FLAGS_OS" = xmacosx; then |
|
698 |
$1_DEFINES_CPU_JDK="${$1_DEFINES_CPU_JDK} -D_LP64=1" |
|
699 |
fi |
|
700 |
if test "x$FLAGS_OS" != xsolaris && test "x$FLAGS_OS" != xaix; then |
|
701 |
# Solaris does not have _LP64=1 in the old build. |
|
702 |
# xlc on AIX defines _LP64=1 by default and issues a warning if we redefine it. |
|
703 |
$1_DEFINES_CPU_JVM="${$1_DEFINES_CPU_JVM} -D_LP64=1" |
|
704 |
fi |
|
705 |
fi |
|
706 |
||
707 |
# toolchain dependend, per-cpu |
|
708 |
if test "x$TOOLCHAIN_TYPE" = xsolstudio; then |
|
709 |
if test "x$FLAGS_CPU_ARCH" = xx86; then |
|
710 |
$1_DEFINES_CPU_JDK="${$1_DEFINES_CPU_JDK} -DcpuIntel -Di586 -D$FLAGS_CPU_LEGACY_LIB" |
|
711 |
fi |
|
712 |
elif test "x$TOOLCHAIN_TYPE" = xmicrosoft; then |
|
713 |
if test "x$FLAGS_CPU" = xx86_64; then |
|
714 |
$1_DEFINES_CPU_JDK="${$1_DEFINES_CPU_JDK} -D_AMD64_ -Damd64" |
|
715 |
else |
|
716 |
$1_DEFINES_CPU_JDK="${$1_DEFINES_CPU_JDK} -D_X86_ -Dx86" |
|
717 |
fi |
|
718 |
fi |
|
719 |
||
720 |
# CFLAGS PER CPU |
|
721 |
if test "x$TOOLCHAIN_TYPE" = xgcc || test "x$TOOLCHAIN_TYPE" = xclang; then |
|
722 |
# COMMON to gcc and clang |
|
723 |
if test "x$FLAGS_CPU" = xx86; then |
|
724 |
# Force compatibility with i586 on 32 bit intel platforms. |
|
725 |
$1_CFLAGS_CPU="-march=i586" |
|
726 |
fi |
|
727 |
fi |
|
728 |
||
729 |
if test "x$TOOLCHAIN_TYPE" = xgcc; then |
|
730 |
if test "x$FLAGS_CPU" = xarm; then |
|
731 |
# -Wno-psabi to get rid of annoying "note: the mangling of 'va_list' has changed in GCC 4.4" |
|
732 |
$1_CFLAGS_CPU="-fsigned-char -Wno-psabi $ARM_ARCH_TYPE_FLAGS $ARM_FLOAT_TYPE_FLAGS -DJDK_ARCH_ABI_PROP_NAME='\"\$(JDK_ARCH_ABI_PROP_NAME)\"'" |
|
733 |
$1_CFLAGS_CPU_JVM="-DARM" |
|
734 |
elif test "x$FLAGS_CPU" = xaarch64; then |
|
735 |
if test "x$HOTSPOT_TARGET_CPU_PORT" = xarm64; then |
|
736 |
$1_CFLAGS_CPU_JVM="-fsigned-char -DARM" |
|
737 |
fi |
|
738 |
elif test "x$FLAGS_CPU_ARCH" = xppc; then |
|
739 |
$1_CFLAGS_CPU_JVM="-minsert-sched-nops=regroup_exact -mno-multiple -mno-string" |
|
740 |
if test "x$FLAGS_CPU" = xppc64; then |
|
741 |
# -mminimal-toc fixes `relocation truncated to fit' error for gcc 4.1. |
|
742 |
# Use ppc64 instructions, but schedule for power5 |
|
743 |
$1_CFLAGS_CPU_JVM="${$1_CFLAGS_CPU_JVM} -mminimal-toc -mcpu=powerpc64 -mtune=power5" |
|
744 |
elif test "x$FLAGS_CPU" = xppc64le; then |
|
745 |
# Little endian machine uses ELFv2 ABI. |
|
746 |
# Use Power8, this is the first CPU to support PPC64 LE with ELFv2 ABI. |
|
747 |
$1_CFLAGS_CPU_JVM="${$1_CFLAGS_CPU_JVM} -DABI_ELFv2 -mcpu=power8 -mtune=power8" |
|
748 |
fi |
|
749 |
elif test "x$FLAGS_CPU" = xs390x; then |
|
750 |
$1_CFLAGS_CPU="-mbackchain -march=z10" |
|
751 |
fi |
|
752 |
||
753 |
if test "x$FLAGS_CPU_ARCH" != xarm && test "x$FLAGS_CPU_ARCH" != xppc; then |
|
754 |
# for all archs except arm and ppc, prevent gcc to omit frame pointer |
|
755 |
$1_CFLAGS_CPU_JDK="${$1_CFLAGS_CPU_JDK} -fno-omit-frame-pointer" |
|
756 |
fi |
|
757 |
||
758 |
elif test "x$TOOLCHAIN_TYPE" = xclang; then |
|
759 |
if test "x$FLAGS_OS" = xlinux; then |
|
760 |
# ppc test not really needed for clang |
|
761 |
if test "x$FLAGS_CPU_ARCH" != xarm && test "x$FLAGS_CPU_ARCH" != xppc; then |
|
762 |
# for all archs except arm and ppc, prevent gcc to omit frame pointer |
|
763 |
$1_CFLAGS_CPU_JDK="${$1_CFLAGS_CPU_JDK} -fno-omit-frame-pointer" |
|
764 |
fi |
|
765 |
fi |
|
766 |
||
767 |
elif test "x$TOOLCHAIN_TYPE" = xsolstudio; then |
|
768 |
if test "x$FLAGS_CPU" = xx86_64; then |
|
769 |
# NOTE: -xregs=no%frameptr is supposed to be default on x64 |
|
770 |
$1_CFLAGS_CPU_JDK="-xregs=no%frameptr" |
|
771 |
elif test "x$FLAGS_CPU" = xsparcv9; then |
|
772 |
$1_CFLAGS_CPU_JVM="-xarch=sparc" |
|
773 |
$1_CFLAGS_CPU_JDK_LIBONLY="-xregs=no%appl" |
|
774 |
fi |
|
775 |
||
776 |
elif test "x$TOOLCHAIN_TYPE" = xxlc; then |
|
777 |
if test "x$FLAGS_CPU" = xppc64; then |
|
778 |
$1_CFLAGS_CPU_JVM="-qarch=ppc64" |
|
779 |
fi |
|
780 |
||
781 |
elif test "x$TOOLCHAIN_TYPE" = xmicrosoft; then |
|
782 |
if test "x$FLAGS_CPU" = xx86; then |
|
783 |
$1_CFLAGS_CPU_JVM="-arch:IA32" |
|
784 |
elif test "x$OPENJDK_TARGET_CPU" = xx86_64; then |
|
785 |
if test "x$DEBUG_LEVEL" != xrelease; then |
|
786 |
# NOTE: This is probably redundant; -homeparams is default on |
|
787 |
# non-release builds. |
|
788 |
$1_CFLAGS_CPU_JVM="-homeparams" |
|
789 |
fi |
|
790 |
fi |
|
791 |
fi |
|
792 |
||
793 |
if test "x$TOOLCHAIN_TYPE" = xgcc; then |
|
794 |
TOOLCHAIN_CHECK_COMPILER_VERSION(VERSION: 6, PREFIX: $2, IF_AT_LEAST: FLAGS_SETUP_GCC6_COMPILER_FLAGS($1)) |
|
795 |
$1_TOOLCHAIN_CFLAGS="${$1_GCC6_CFLAGS}" |
|
796 |
||
49200 | 797 |
$1_WARNING_CFLAGS_JVM="-Wno-format-zero-length -Wtype-limits -Wuninitialized" |
49120 | 798 |
fi |
799 |
||
800 |
# EXPORT to API |
|
801 |
CFLAGS_JVM_COMMON="$ALWAYS_CFLAGS_JVM $ALWAYS_DEFINES_JVM $TOOLCHAIN_CFLAGS_JVM \ |
|
802 |
$OS_CFLAGS $OS_CFLAGS_JVM $CFLAGS_OS_DEF_JVM $DEBUG_CFLAGS_JVM \ |
|
803 |
$WARNING_CFLAGS $WARNING_CFLAGS_JVM $JVM_PICFLAG" |
|
804 |
||
805 |
CFLAGS_JDK_COMMON="$ALWAYS_CFLAGS_JDK $ALWAYS_DEFINES_JDK $TOOLCHAIN_CFLAGS_JDK \ |
|
806 |
$OS_CFLAGS $CFLAGS_OS_DEF_JDK $DEBUG_CFLAGS_JDK $DEBUG_OPTIONS_FLAGS_JDK \ |
|
49155
7cd937277d5e
8199338: Use -g0 on solstudio also for compiling C programs
ihse
parents:
49120
diff
changeset
|
807 |
$WARNING_CFLAGS $WARNING_CFLAGS_JDK $DEBUG_SYMBOLS_CFLAGS_JDK" |
49120 | 808 |
|
809 |
# Use ${$2EXTRA_CFLAGS} to block EXTRA_CFLAGS to be added to build flags. |
|
810 |
# (Currently we don't have any OPENJDK_BUILD_EXTRA_CFLAGS, but that might |
|
811 |
# change in the future.) |
|
812 |
||
49155
7cd937277d5e
8199338: Use -g0 on solstudio also for compiling C programs
ihse
parents:
49120
diff
changeset
|
813 |
CFLAGS_JDK_COMMON_CONLY="$TOOLCHAIN_CFLAGS_JDK_CONLY \ |
49120 | 814 |
$WARNING_CFLAGS_JDK_CONLY ${$2EXTRA_CFLAGS}" |
815 |
CFLAGS_JDK_COMMON_CXXONLY="$ALWAYS_DEFINES_JDK_CXXONLY $TOOLCHAIN_CFLAGS_JDK_CXXONLY \ |
|
49155
7cd937277d5e
8199338: Use -g0 on solstudio also for compiling C programs
ihse
parents:
49120
diff
changeset
|
816 |
$WARNING_CFLAGS_JDK_CXXONLY ${$2EXTRA_CXXFLAGS}" |
49120 | 817 |
|
818 |
$1_CFLAGS_JVM="${$1_DEFINES_CPU_JVM} ${$1_CFLAGS_CPU} ${$1_CFLAGS_CPU_JVM} ${$1_TOOLCHAIN_CFLAGS} ${$1_WARNING_CFLAGS_JVM}" |
|
819 |
$1_CFLAGS_JDK="${$1_DEFINES_CPU_JDK} ${$1_CFLAGS_CPU} ${$1_CFLAGS_CPU_JDK} ${$1_TOOLCHAIN_CFLAGS}" |
|
820 |
||
821 |
$2JVM_CFLAGS="$CFLAGS_JVM_COMMON ${$1_CFLAGS_JVM} ${$2EXTRA_CXXFLAGS}" |
|
822 |
||
823 |
$2CFLAGS_JDKEXE="$CFLAGS_JDK_COMMON $CFLAGS_JDK_COMMON_CONLY ${$1_CFLAGS_JDK}" |
|
824 |
$2CXXFLAGS_JDKEXE="$CFLAGS_JDK_COMMON $CFLAGS_JDK_COMMON_CXXONLY ${$1_CFLAGS_JDK}" |
|
825 |
$2CFLAGS_JDKLIB="${$2CFLAGS_JDKEXE} $JDK_PICFLAG ${$1_CFLAGS_CPU_JDK_LIBONLY}" |
|
826 |
$2CXXFLAGS_JDKLIB="${$2CXXFLAGS_JDKEXE} $JDK_PICFLAG ${$1_CFLAGS_CPU_JDK_LIBONLY}" |
|
827 |
||
828 |
AC_SUBST($2JVM_CFLAGS) |
|
829 |
AC_SUBST($2CFLAGS_JDKLIB) |
|
830 |
AC_SUBST($2CFLAGS_JDKEXE) |
|
831 |
AC_SUBST($2CXXFLAGS_JDKLIB) |
|
832 |
AC_SUBST($2CXXFLAGS_JDKEXE) |
|
833 |
]) |
|
834 |
||
835 |
# FLAGS_SETUP_GCC6_COMPILER_FLAGS([PREFIX]) |
|
836 |
# Arguments: |
|
837 |
# $1 - Prefix for each variable defined. |
|
838 |
AC_DEFUN([FLAGS_SETUP_GCC6_COMPILER_FLAGS], |
|
839 |
[ |
|
840 |
# These flags are required for GCC 6 builds as undefined behaviour in OpenJDK code |
|
841 |
# runs afoul of the more aggressive versions of these optimisations. |
|
842 |
# Notably, value range propagation now assumes that the this pointer of C++ |
|
843 |
# member functions is non-null. |
|
844 |
NO_DELETE_NULL_POINTER_CHECKS_CFLAG="-fno-delete-null-pointer-checks" |
|
845 |
dnl Argument check is disabled until FLAGS_COMPILER_CHECK_ARGUMENTS handles cross-compilation |
|
846 |
dnl FLAGS_COMPILER_CHECK_ARGUMENTS(ARGUMENT: [$NO_DELETE_NULL_POINTER_CHECKS_CFLAG -Werror], |
|
847 |
dnl IF_FALSE: [NO_DELETE_NULL_POINTER_CHECKS_CFLAG=""]) |
|
848 |
NO_LIFETIME_DSE_CFLAG="-fno-lifetime-dse" |
|
849 |
dnl Argument check is disabled until FLAGS_COMPILER_CHECK_ARGUMENTS handles cross-compilation |
|
850 |
dnl FLAGS_COMPILER_CHECK_ARGUMENTS(ARGUMENT: [$NO_LIFETIME_DSE_CFLAG -Werror], |
|
851 |
dnl IF_FALSE: [NO_LIFETIME_DSE_CFLAG=""]) |
|
852 |
AC_MSG_NOTICE([GCC >= 6 detected; adding ${NO_DELETE_NULL_POINTER_CHECKS_CFLAG} and ${NO_LIFETIME_DSE_CFLAG}]) |
|
853 |
$1_GCC6_CFLAGS="${NO_DELETE_NULL_POINTER_CHECKS_CFLAG} ${NO_LIFETIME_DSE_CFLAG}" |
|
854 |
]) |
|
855 |
||
856 |
# Documentation on common flags used for solstudio in HIGHEST. |
|
857 |
# |
|
858 |
# WARNING: Use of OPTIMIZATION_LEVEL=HIGHEST in your Makefile needs to be |
|
859 |
# done with care, there are some assumptions below that need to |
|
860 |
# be understood about the use of pointers, and IEEE behavior. |
|
861 |
# |
|
862 |
# -fns: Use non-standard floating point mode (not IEEE 754) |
|
863 |
# -fsimple: Do some simplification of floating point arithmetic (not IEEE 754) |
|
864 |
# -fsingle: Use single precision floating point with 'float' |
|
865 |
# -xalias_level=basic: Assume memory references via basic pointer types do not alias |
|
866 |
# (Source with excessing pointer casting and data access with mixed |
|
867 |
# pointer types are not recommended) |
|
868 |
# -xbuiltin=%all: Use intrinsic or inline versions for math/std functions |
|
869 |
# (If you expect perfect errno behavior, do not use this) |
|
870 |
# -xdepend: Loop data dependency optimizations (need -xO3 or higher) |
|
871 |
# -xrestrict: Pointer parameters to functions do not overlap |
|
872 |
# (Similar to -xalias_level=basic usage, but less obvious sometimes. |
|
873 |
# If you pass in multiple pointers to the same data, do not use this) |
|
874 |
# -xlibmil: Inline some library routines |
|
875 |
# (If you expect perfect errno behavior, do not use this) |
|
876 |
# -xlibmopt: Use optimized math routines (CURRENTLY DISABLED) |
|
877 |
# (If you expect perfect errno behavior, do not use this) |
|
878 |
# Can cause undefined external on Solaris 8 X86 on __sincos, removing for now |