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
|
|
111 |
if test "x$OPENJDK_TARGET_CPU_BITS" = "x64" && test "x$DEBUG_LEVEL" = "xfastdebug"; then
|
|
112 |
CFLAGS_DEBUG_SYMBOLS="-g1"
|
|
113 |
else
|
|
114 |
CFLAGS_DEBUG_SYMBOLS="-g"
|
|
115 |
fi
|
|
116 |
elif test "x$TOOLCHAIN_TYPE" = xclang; then
|
|
117 |
CFLAGS_DEBUG_SYMBOLS="-g"
|
|
118 |
elif test "x$TOOLCHAIN_TYPE" = xsolstudio; then
|
|
119 |
CFLAGS_DEBUG_SYMBOLS="-g -xs"
|
|
120 |
# -g0 enables debug symbols without disabling inlining.
|
|
121 |
CXXFLAGS_DEBUG_SYMBOLS="-g0 -xs"
|
|
122 |
elif test "x$TOOLCHAIN_TYPE" = xxlc; then
|
|
123 |
CFLAGS_DEBUG_SYMBOLS="-g"
|
|
124 |
elif test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
|
|
125 |
CFLAGS_DEBUG_SYMBOLS="-Zi"
|
|
126 |
fi
|
|
127 |
|
|
128 |
if test "x$CXXFLAGS_DEBUG_SYMBOLS" = x; then
|
|
129 |
# If we did not specify special flags for C++, use C version
|
|
130 |
CXXFLAGS_DEBUG_SYMBOLS="$CFLAGS_DEBUG_SYMBOLS"
|
|
131 |
fi
|
|
132 |
AC_SUBST(CFLAGS_DEBUG_SYMBOLS)
|
|
133 |
AC_SUBST(CXXFLAGS_DEBUG_SYMBOLS)
|
|
134 |
|
|
135 |
# FIXME: This was never used in the old build. What to do with it?
|
|
136 |
if test "x$TOOLCHAIN_TYPE" = xgcc; then
|
|
137 |
# "-Og" suppported for GCC 4.8 and later
|
|
138 |
CFLAG_OPTIMIZE_DEBUG_FLAG="-Og"
|
|
139 |
FLAGS_COMPILER_CHECK_ARGUMENTS(ARGUMENT: [$CFLAG_OPTIMIZE_DEBUG_FLAG],
|
|
140 |
IF_TRUE: [HAS_CFLAG_OPTIMIZE_DEBUG=true],
|
|
141 |
IF_FALSE: [HAS_CFLAG_OPTIMIZE_DEBUG=false])
|
|
142 |
fi
|
|
143 |
|
|
144 |
# Debug symbols for JVM_CFLAGS
|
|
145 |
if test "x$TOOLCHAIN_TYPE" = xsolstudio; then
|
|
146 |
JVM_CFLAGS_SYMBOLS="$JVM_CFLAGS_SYMBOLS -xs"
|
|
147 |
if test "x$DEBUG_LEVEL" = xslowdebug; then
|
|
148 |
JVM_CFLAGS_SYMBOLS="$JVM_CFLAGS_SYMBOLS -g"
|
|
149 |
else
|
|
150 |
# -g0 does not disable inlining, which -g does.
|
|
151 |
JVM_CFLAGS_SYMBOLS="$JVM_CFLAGS_SYMBOLS -g0"
|
|
152 |
fi
|
|
153 |
elif test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
|
|
154 |
JVM_CFLAGS_SYMBOLS="$JVM_CFLAGS_SYMBOLS -Z7 -d2Zi+"
|
|
155 |
else
|
|
156 |
JVM_CFLAGS_SYMBOLS="$JVM_CFLAGS_SYMBOLS -g"
|
|
157 |
fi
|
|
158 |
AC_SUBST(JVM_CFLAGS_SYMBOLS)
|
|
159 |
])
|
|
160 |
|
|
161 |
AC_DEFUN([FLAGS_SETUP_WARNINGS],
|
|
162 |
[
|
|
163 |
AC_ARG_ENABLE([warnings-as-errors], [AS_HELP_STRING([--disable-warnings-as-errors],
|
|
164 |
[do not consider native warnings to be an error @<:@enabled@:>@])])
|
|
165 |
|
|
166 |
AC_MSG_CHECKING([if native warnings are errors])
|
|
167 |
if test "x$enable_warnings_as_errors" = "xyes"; then
|
|
168 |
AC_MSG_RESULT([yes (explicitly set)])
|
|
169 |
WARNINGS_AS_ERRORS=true
|
|
170 |
elif test "x$enable_warnings_as_errors" = "xno"; then
|
|
171 |
AC_MSG_RESULT([no])
|
|
172 |
WARNINGS_AS_ERRORS=false
|
|
173 |
elif test "x$enable_warnings_as_errors" = "x"; then
|
|
174 |
AC_MSG_RESULT([yes (default)])
|
|
175 |
WARNINGS_AS_ERRORS=true
|
|
176 |
else
|
|
177 |
AC_MSG_ERROR([--enable-warnings-as-errors accepts no argument])
|
|
178 |
fi
|
|
179 |
|
|
180 |
AC_SUBST(WARNINGS_AS_ERRORS)
|
|
181 |
|
|
182 |
case "${TOOLCHAIN_TYPE}" in
|
|
183 |
microsoft)
|
|
184 |
DISABLE_WARNING_PREFIX="-wd"
|
|
185 |
CFLAGS_WARNINGS_ARE_ERRORS="-WX"
|
|
186 |
;;
|
|
187 |
solstudio)
|
|
188 |
DISABLE_WARNING_PREFIX="-erroff="
|
|
189 |
CFLAGS_WARNINGS_ARE_ERRORS="-errtags -errwarn=%all"
|
|
190 |
;;
|
|
191 |
gcc)
|
|
192 |
# Prior to gcc 4.4, a -Wno-X where X is unknown for that version of gcc will cause an error
|
|
193 |
FLAGS_COMPILER_CHECK_ARGUMENTS(ARGUMENT: [-Wno-this-is-a-warning-that-do-not-exist],
|
|
194 |
IF_TRUE: [GCC_CAN_DISABLE_WARNINGS=true],
|
|
195 |
IF_FALSE: [GCC_CAN_DISABLE_WARNINGS=false]
|
|
196 |
)
|
|
197 |
if test "x$GCC_CAN_DISABLE_WARNINGS" = "xtrue"; then
|
|
198 |
DISABLE_WARNING_PREFIX="-Wno-"
|
|
199 |
else
|
|
200 |
DISABLE_WARNING_PREFIX=
|
|
201 |
fi
|
|
202 |
CFLAGS_WARNINGS_ARE_ERRORS="-Werror"
|
|
203 |
# Repeate the check for the BUILD_CC and BUILD_CXX. Need to also reset
|
|
204 |
# CFLAGS since any target specific flags will likely not work with the
|
|
205 |
# build compiler
|
|
206 |
CC_OLD="$CC"
|
|
207 |
CXX_OLD="$CXX"
|
|
208 |
CC="$BUILD_CC"
|
|
209 |
CXX="$BUILD_CXX"
|
|
210 |
CFLAGS_OLD="$CFLAGS"
|
|
211 |
CFLAGS=""
|
|
212 |
FLAGS_COMPILER_CHECK_ARGUMENTS(ARGUMENT: [-Wno-this-is-a-warning-that-do-not-exist],
|
|
213 |
IF_TRUE: [BUILD_CC_CAN_DISABLE_WARNINGS=true],
|
|
214 |
IF_FALSE: [BUILD_CC_CAN_DISABLE_WARNINGS=false]
|
|
215 |
)
|
|
216 |
if test "x$BUILD_CC_CAN_DISABLE_WARNINGS" = "xtrue"; then
|
|
217 |
BUILD_CC_DISABLE_WARNING_PREFIX="-Wno-"
|
|
218 |
else
|
|
219 |
BUILD_CC_DISABLE_WARNING_PREFIX=
|
|
220 |
fi
|
|
221 |
CC="$CC_OLD"
|
|
222 |
CXX="$CXX_OLD"
|
|
223 |
CFLAGS="$CFLAGS_OLD"
|
|
224 |
;;
|
|
225 |
clang)
|
|
226 |
DISABLE_WARNING_PREFIX="-Wno-"
|
|
227 |
CFLAGS_WARNINGS_ARE_ERRORS="-Werror"
|
|
228 |
;;
|
|
229 |
xlc)
|
|
230 |
DISABLE_WARNING_PREFIX="-qsuppress="
|
|
231 |
CFLAGS_WARNINGS_ARE_ERRORS="-qhalt=w"
|
|
232 |
;;
|
|
233 |
esac
|
|
234 |
AC_SUBST(DISABLE_WARNING_PREFIX)
|
|
235 |
AC_SUBST(BUILD_CC_DISABLE_WARNING_PREFIX)
|
|
236 |
AC_SUBST(CFLAGS_WARNINGS_ARE_ERRORS)
|
|
237 |
])
|
|
238 |
|
|
239 |
AC_DEFUN([FLAGS_SETUP_QUALITY_CHECKS],
|
|
240 |
[
|
|
241 |
# bounds, memory and behavior checking options
|
|
242 |
if test "x$TOOLCHAIN_TYPE" = xgcc; then
|
|
243 |
case $DEBUG_LEVEL in
|
|
244 |
release )
|
|
245 |
# no adjustment
|
|
246 |
;;
|
|
247 |
fastdebug )
|
|
248 |
# no adjustment
|
|
249 |
;;
|
|
250 |
slowdebug )
|
|
251 |
# FIXME: By adding this to C(XX)FLAGS_DEBUG_OPTIONS/JVM_CFLAGS_SYMBOLS it
|
|
252 |
# get's added conditionally on whether we produce debug symbols or not.
|
|
253 |
# This is most likely not really correct.
|
|
254 |
|
|
255 |
# Add runtime stack smashing and undefined behavior checks.
|
|
256 |
# Not all versions of gcc support -fstack-protector
|
|
257 |
STACK_PROTECTOR_CFLAG="-fstack-protector-all"
|
|
258 |
FLAGS_COMPILER_CHECK_ARGUMENTS(ARGUMENT: [$STACK_PROTECTOR_CFLAG -Werror],
|
|
259 |
IF_FALSE: [STACK_PROTECTOR_CFLAG=""])
|
|
260 |
|
|
261 |
CFLAGS_DEBUG_OPTIONS="$STACK_PROTECTOR_CFLAG --param ssp-buffer-size=1"
|
|
262 |
CXXFLAGS_DEBUG_OPTIONS="$STACK_PROTECTOR_CFLAG --param ssp-buffer-size=1"
|
|
263 |
|
|
264 |
if test "x$STACK_PROTECTOR_CFLAG" != x; then
|
|
265 |
JVM_CFLAGS_SYMBOLS="$JVM_CFLAGS_SYMBOLS $STACK_PROTECTOR_CFLAG --param ssp-buffer-size=1"
|
|
266 |
fi
|
|
267 |
;;
|
|
268 |
esac
|
|
269 |
fi
|
|
270 |
])
|
|
271 |
|
|
272 |
AC_DEFUN([FLAGS_SETUP_OPTIMIZATION],
|
|
273 |
[
|
|
274 |
if test "x$TOOLCHAIN_TYPE" = xsolstudio; then
|
|
275 |
CC_HIGHEST="-fns -fsimple -fsingle -xbuiltin=%all -xdepend -xrestrict -xlibmil"
|
|
276 |
|
|
277 |
C_O_FLAG_HIGHEST_JVM="-xO4"
|
|
278 |
C_O_FLAG_DEBUG_JVM=""
|
|
279 |
C_O_FLAG_SIZE=""
|
|
280 |
C_O_FLAG_DEBUG=""
|
|
281 |
C_O_FLAG_NONE=""
|
|
282 |
if test "x$OPENJDK_TARGET_CPU_ARCH" = "xx86"; then
|
|
283 |
C_O_FLAG_HIGHEST="-xO4 -Wu,-O4~yz $CC_HIGHEST"
|
|
284 |
C_O_FLAG_HI="-xO4 -Wu,-O4~yz"
|
|
285 |
C_O_FLAG_NORM="-xO2 -Wu,-O2~yz"
|
|
286 |
elif test "x$OPENJDK_TARGET_CPU_ARCH" = "xsparc"; then
|
|
287 |
C_O_FLAG_HIGHEST="-xO4 -Wc,-Qrm-s -Wc,-Qiselect-T0 \
|
|
288 |
-xprefetch=auto,explicit -xchip=ultra $CC_HIGHEST"
|
|
289 |
C_O_FLAG_HI="-xO4 -Wc,-Qrm-s -Wc,-Qiselect-T0"
|
|
290 |
C_O_FLAG_NORM="-xO2 -Wc,-Qrm-s -Wc,-Qiselect-T0"
|
|
291 |
fi
|
|
292 |
elif test "x$TOOLCHAIN_TYPE" = xgcc; then
|
|
293 |
C_O_FLAG_HIGHEST_JVM="-O3"
|
|
294 |
C_O_FLAG_HIGHEST="-O3"
|
|
295 |
C_O_FLAG_HI="-O3"
|
|
296 |
C_O_FLAG_NORM="-O2"
|
|
297 |
C_O_FLAG_SIZE="-Os"
|
|
298 |
C_O_FLAG_DEBUG="-O0"
|
|
299 |
C_O_FLAG_DEBUG_JVM="-O0"
|
|
300 |
C_O_FLAG_NONE="-O0"
|
|
301 |
elif test "x$TOOLCHAIN_TYPE" = xclang; then
|
|
302 |
if test "x$OPENJDK_TARGET_OS" = xmacosx; then
|
|
303 |
# On MacOSX we optimize for size, something
|
|
304 |
# we should do for all platforms?
|
|
305 |
C_O_FLAG_HIGHEST_JVM="-Os"
|
|
306 |
C_O_FLAG_HIGHEST="-Os"
|
|
307 |
C_O_FLAG_HI="-Os"
|
|
308 |
C_O_FLAG_NORM="-Os"
|
|
309 |
C_O_FLAG_DEBUG_JVM=""
|
|
310 |
else
|
|
311 |
C_O_FLAG_HIGHEST_JVM="-O3"
|
|
312 |
C_O_FLAG_HIGHEST="-O3"
|
|
313 |
C_O_FLAG_HI="-O3"
|
|
314 |
C_O_FLAG_NORM="-O2"
|
|
315 |
C_O_FLAG_DEBUG_JVM="-O0"
|
|
316 |
fi
|
|
317 |
C_O_FLAG_SIZE="-Os"
|
|
318 |
C_O_FLAG_DEBUG="-O0"
|
|
319 |
C_O_FLAG_NONE="-O0"
|
|
320 |
elif test "x$TOOLCHAIN_TYPE" = xxlc; then
|
|
321 |
C_O_FLAG_HIGHEST_JVM="-O3 -qhot=level=1 -qinline -qinlglue"
|
|
322 |
C_O_FLAG_HIGHEST="-O3 -qhot=level=1 -qinline -qinlglue"
|
|
323 |
C_O_FLAG_HI="-O3 -qinline -qinlglue"
|
|
324 |
C_O_FLAG_NORM="-O2"
|
|
325 |
C_O_FLAG_DEBUG="-qnoopt"
|
|
326 |
# FIXME: Value below not verified.
|
|
327 |
C_O_FLAG_DEBUG_JVM=""
|
|
328 |
C_O_FLAG_NONE="-qnoopt"
|
|
329 |
elif test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
|
|
330 |
C_O_FLAG_HIGHEST_JVM="-O2 -Oy-"
|
|
331 |
C_O_FLAG_HIGHEST="-O2"
|
|
332 |
C_O_FLAG_HI="-O1"
|
|
333 |
C_O_FLAG_NORM="-O1"
|
|
334 |
C_O_FLAG_DEBUG="-Od"
|
|
335 |
C_O_FLAG_DEBUG_JVM=""
|
|
336 |
C_O_FLAG_NONE="-Od"
|
|
337 |
C_O_FLAG_SIZE="-Os"
|
|
338 |
fi
|
|
339 |
|
|
340 |
# Now copy to C++ flags
|
|
341 |
CXX_O_FLAG_HIGHEST_JVM="$C_O_FLAG_HIGHEST_JVM"
|
|
342 |
CXX_O_FLAG_HIGHEST="$C_O_FLAG_HIGHEST"
|
|
343 |
CXX_O_FLAG_HI="$C_O_FLAG_HI"
|
|
344 |
CXX_O_FLAG_NORM="$C_O_FLAG_NORM"
|
|
345 |
CXX_O_FLAG_DEBUG="$C_O_FLAG_DEBUG"
|
|
346 |
CXX_O_FLAG_DEBUG_JVM="$C_O_FLAG_DEBUG_JVM"
|
|
347 |
CXX_O_FLAG_NONE="$C_O_FLAG_NONE"
|
|
348 |
CXX_O_FLAG_SIZE="$C_O_FLAG_SIZE"
|
|
349 |
|
|
350 |
if test "x$TOOLCHAIN_TYPE" = xsolstudio; then
|
|
351 |
# In solstudio, also add this to C (but not C++) flags...
|
|
352 |
C_O_FLAG_HIGHEST="$C_O_FLAG_HIGHEST -xalias_level=basic"
|
|
353 |
fi
|
|
354 |
|
|
355 |
# Adjust optimization flags according to debug level.
|
|
356 |
case $DEBUG_LEVEL in
|
|
357 |
release )
|
|
358 |
# no adjustment
|
|
359 |
;;
|
|
360 |
fastdebug )
|
|
361 |
# Not quite so much optimization
|
|
362 |
C_O_FLAG_HI="$C_O_FLAG_NORM"
|
|
363 |
CXX_O_FLAG_HI="$CXX_O_FLAG_NORM"
|
|
364 |
;;
|
|
365 |
slowdebug )
|
|
366 |
# Disable optimization
|
|
367 |
C_O_FLAG_HIGHEST_JVM="$C_O_FLAG_DEBUG_JVM"
|
|
368 |
C_O_FLAG_HIGHEST="$C_O_FLAG_DEBUG"
|
|
369 |
C_O_FLAG_HI="$C_O_FLAG_DEBUG"
|
|
370 |
C_O_FLAG_NORM="$C_O_FLAG_DEBUG"
|
|
371 |
C_O_FLAG_SIZE="$C_O_FLAG_DEBUG"
|
|
372 |
CXX_O_FLAG_HIGHEST_JVM="$CXX_O_FLAG_DEBUG_JVM"
|
|
373 |
CXX_O_FLAG_HIGHEST="$CXX_O_FLAG_DEBUG"
|
|
374 |
CXX_O_FLAG_HI="$CXX_O_FLAG_DEBUG"
|
|
375 |
CXX_O_FLAG_NORM="$CXX_O_FLAG_DEBUG"
|
|
376 |
CXX_O_FLAG_SIZE="$CXX_O_FLAG_DEBUG"
|
|
377 |
;;
|
|
378 |
esac
|
|
379 |
|
|
380 |
AC_SUBST(C_O_FLAG_HIGHEST_JVM)
|
|
381 |
AC_SUBST(C_O_FLAG_HIGHEST)
|
|
382 |
AC_SUBST(C_O_FLAG_HI)
|
|
383 |
AC_SUBST(C_O_FLAG_NORM)
|
|
384 |
AC_SUBST(C_O_FLAG_NONE)
|
|
385 |
AC_SUBST(C_O_FLAG_SIZE)
|
|
386 |
AC_SUBST(CXX_O_FLAG_HIGHEST_JVM)
|
|
387 |
AC_SUBST(CXX_O_FLAG_HIGHEST)
|
|
388 |
AC_SUBST(CXX_O_FLAG_HI)
|
|
389 |
AC_SUBST(CXX_O_FLAG_NORM)
|
|
390 |
AC_SUBST(CXX_O_FLAG_NONE)
|
|
391 |
AC_SUBST(CXX_O_FLAG_SIZE)
|
|
392 |
])
|
|
393 |
|
|
394 |
AC_DEFUN([FLAGS_SETUP_CFLAGS],
|
|
395 |
[
|
|
396 |
### CFLAGS
|
|
397 |
|
|
398 |
FLAGS_SETUP_CFLAGS_HELPER
|
|
399 |
|
|
400 |
FLAGS_OS=$OPENJDK_TARGET_OS
|
|
401 |
FLAGS_OS_TYPE=$OPENJDK_TARGET_OS_TYPE
|
|
402 |
FLAGS_CPU=$OPENJDK_TARGET_CPU
|
|
403 |
FLAGS_CPU_ARCH=$OPENJDK_TARGET_CPU_ARCH
|
|
404 |
FLAGS_CPU_BITS=$OPENJDK_TARGET_CPU_BITS
|
|
405 |
FLAGS_CPU_ENDIAN=$OPENJDK_TARGET_CPU_ENDIAN
|
|
406 |
FLAGS_CPU_LEGACY=$OPENJDK_TARGET_CPU_LEGACY
|
|
407 |
FLAGS_CPU_LEGACY_LIB=$OPENJDK_TARGET_CPU_LEGACY_LIB
|
|
408 |
|
|
409 |
FLAGS_SETUP_CFLAGS_CPU_DEP([TARGET])
|
|
410 |
|
|
411 |
FLAGS_OS=$OPENJDK_BUILD_OS
|
|
412 |
FLAGS_OS_TYPE=$OPENJDK_BUILD_OS_TYPE
|
|
413 |
FLAGS_CPU=$OPENJDK_BUILD_CPU
|
|
414 |
FLAGS_CPU_ARCH=$OPENJDK_BUILD_CPU_ARCH
|
|
415 |
FLAGS_CPU_BITS=$OPENJDK_BUILD_CPU_BITS
|
|
416 |
FLAGS_CPU_ENDIAN=$OPENJDK_BUILD_CPU_ENDIAN
|
|
417 |
FLAGS_CPU_LEGACY=$OPENJDK_BUILD_CPU_LEGACY
|
|
418 |
FLAGS_CPU_LEGACY_LIB=$OPENJDK_BUILD_CPU_LEGACY_LIB
|
|
419 |
|
|
420 |
FLAGS_SETUP_CFLAGS_CPU_DEP([BUILD], [OPENJDK_BUILD_])
|
|
421 |
|
|
422 |
# Tests are only ever compiled for TARGET
|
|
423 |
CFLAGS_TESTLIB="$CFLAGS_JDKLIB"
|
|
424 |
CXXFLAGS_TESTLIB="$CXXFLAGS_JDKLIB"
|
|
425 |
CFLAGS_TESTEXE="$CFLAGS_JDKEXE"
|
|
426 |
CXXFLAGS_TESTEXE="$CXXFLAGS_JDKEXE"
|
|
427 |
|
|
428 |
AC_SUBST(CFLAGS_TESTLIB)
|
|
429 |
AC_SUBST(CFLAGS_TESTEXE)
|
|
430 |
AC_SUBST(CXXFLAGS_TESTLIB)
|
|
431 |
AC_SUBST(CXXFLAGS_TESTEXE)
|
|
432 |
])
|
|
433 |
|
|
434 |
################################################################################
|
|
435 |
# platform independent
|
|
436 |
AC_DEFUN([FLAGS_SETUP_CFLAGS_HELPER],
|
|
437 |
[
|
|
438 |
#### OS DEFINES, these should be independent on toolchain
|
|
439 |
if test "x$OPENJDK_TARGET_OS" = xlinux; then
|
|
440 |
CFLAGS_OS_DEF_JVM="-DLINUX"
|
|
441 |
CFLAGS_OS_DEF_JDK="-D_GNU_SOURCE -D_REENTRANT -D_LARGEFILE64_SOURCE"
|
|
442 |
elif test "x$OPENJDK_TARGET_OS" = xsolaris; then
|
|
443 |
CFLAGS_OS_DEF_JVM="-DSOLARIS"
|
|
444 |
CFLAGS_OS_DEF_JDK="-D__solaris__"
|
|
445 |
elif test "x$OPENJDK_TARGET_OS" = xmacosx; then
|
|
446 |
CFLAGS_OS_DEF_JVM="-D_ALLBSD_SOURCE -D_DARWIN_C_SOURCE -D_XOPEN_SOURCE"
|
|
447 |
CFLAGS_OS_DEF_JDK="-D_ALLBSD_SOURCE -D_DARWIN_UNLIMITED_SELECT"
|
|
448 |
elif test "x$OPENJDK_TARGET_OS" = xaix; then
|
|
449 |
CFLAGS_OS_DEF_JVM="-DAIX"
|
|
450 |
elif test "x$OPENJDK_TARGET_OS" = xbsd; then
|
|
451 |
CFLAGS_OS_DEF_JDK="-D_ALLBSD_SOURCE"
|
|
452 |
elif test "x$OPENJDK_TARGET_OS" = xwindows; then
|
|
453 |
CFLAGS_OS_DEF_JVM="-D_WINDOWS -DWIN32 -D_JNI_IMPLEMENTATION_"
|
|
454 |
fi
|
|
455 |
|
|
456 |
# Setup target OS define. Use OS target name but in upper case.
|
|
457 |
OPENJDK_TARGET_OS_UPPERCASE=`$ECHO $OPENJDK_TARGET_OS | $TR 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
|
|
458 |
CFLAGS_OS_DEF_JDK="$CFLAGS_OS_DEF_JDK -D$OPENJDK_TARGET_OS_UPPERCASE"
|
|
459 |
|
|
460 |
#### GLOBAL DEFINES
|
|
461 |
# Set some common defines. These works for all compilers, but assume
|
|
462 |
# -D is universally accepted.
|
|
463 |
|
|
464 |
# Always enable optional macros for VM.
|
|
465 |
ALWAYS_CFLAGS_JVM="-D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS"
|
|
466 |
|
|
467 |
# Setup some hard coded includes
|
|
468 |
ALWAYS_CFLAGS_JDK=" \
|
|
469 |
-I\$(SUPPORT_OUTPUTDIR)/modules_include/java.base \
|
|
470 |
-I\$(SUPPORT_OUTPUTDIR)/modules_include/java.base/\$(OPENJDK_TARGET_OS_INCLUDE_SUBDIR) \
|
|
471 |
-I${TOPDIR}/src/java.base/share/native/libjava \
|
|
472 |
-I${TOPDIR}/src/java.base/$OPENJDK_TARGET_OS_TYPE/native/libjava \
|
|
473 |
-I${TOPDIR}/src/hotspot/share/include \
|
|
474 |
-I${TOPDIR}/src/hotspot/os/${HOTSPOT_TARGET_OS_TYPE}/include"
|
|
475 |
|
|
476 |
###############################################################################
|
|
477 |
|
|
478 |
# Adjust flags according to debug level.
|
|
479 |
# Setup debug/release defines
|
|
480 |
if test "x$DEBUG_LEVEL" = xrelease; then
|
|
481 |
DEBUG_CFLAGS_JDK="-DNDEBUG"
|
|
482 |
if test "x$OPENJDK_TARGET_OS" = xsolaris; then
|
|
483 |
DEBUG_CFLAGS_JDK="$DEBUG_CFLAGS_JDK -DTRIMMED"
|
|
484 |
fi
|
|
485 |
else
|
|
486 |
DEBUG_CFLAGS_JDK="-DDEBUG"
|
|
487 |
|
|
488 |
if test "x$TOOLCHAIN_TYPE" = xxlc; then
|
|
489 |
# We need '-qminimaltoc' or '-qpic=large -bbigtoc' if the TOC overflows.
|
|
490 |
# Hotspot now overflows its 64K TOC (currently only for debug),
|
|
491 |
# so for debug we build with '-qpic=large -bbigtoc'.
|
|
492 |
DEBUG_CFLAGS_JVM="-qpic=large"
|
|
493 |
fi
|
|
494 |
fi
|
|
495 |
|
|
496 |
if test "x$DEBUG_LEVEL" != xrelease; then
|
|
497 |
DEBUG_OPTIONS_FLAGS_JDK="$CFLAGS_DEBUG_OPTIONS"
|
|
498 |
DEBUG_SYMBOLS_CFLAGS_JDK="$CFLAGS_DEBUG_SYMBOLS"
|
|
499 |
DEBUG_SYMBOLS_CXXFLAGS_JDK="$CXXFLAGS_DEBUG_SYMBOLS"
|
|
500 |
fi
|
|
501 |
|
|
502 |
#### TOOLCHAIN DEFINES
|
|
503 |
|
|
504 |
if test "x$TOOLCHAIN_TYPE" = xgcc; then
|
|
505 |
ALWAYS_DEFINES_JVM="-D_GNU_SOURCE -D_REENTRANT"
|
|
506 |
elif test "x$TOOLCHAIN_TYPE" = xclang; then
|
|
507 |
ALWAYS_DEFINES_JVM="-D_GNU_SOURCE"
|
|
508 |
elif test "x$TOOLCHAIN_TYPE" = xsolstudio; then
|
|
509 |
ALWAYS_DEFINES_JVM="-DSPARC_WORKS -D_Crun_inline_placement"
|
|
510 |
ALWAYS_DEFINES_JDK="-DTRACING -DMACRO_MEMSYS_OPS -DBREAKPTS"
|
|
511 |
ALWAYS_DEFINES_JDK_CXXONLY="-DCC_NOEX"
|
|
512 |
elif test "x$TOOLCHAIN_TYPE" = xxlc; then
|
|
513 |
ALWAYS_DEFINES_JVM="-D_REENTRANT"
|
|
514 |
ALWAYS_DEFINES_JDK="-D_GNU_SOURCE -D_REENTRANT -D_LARGEFILE64_SOURCE -DSTDC"
|
|
515 |
elif test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
|
|
516 |
ALWAYS_DEFINES_JDK="-DWIN32_LEAN_AND_MEAN -D_CRT_SECURE_NO_DEPRECATE \
|
|
517 |
-D_CRT_NONSTDC_NO_DEPRECATE -DWIN32 -DIAL"
|
|
518 |
fi
|
|
519 |
|
|
520 |
###############################################################################
|
|
521 |
#
|
|
522 |
#
|
|
523 |
# CFLAGS BASIC
|
|
524 |
if test "x$TOOLCHAIN_TYPE" = xgcc || test "x$TOOLCHAIN_TYPE" = xclang; then
|
|
525 |
# COMMON to gcc and clang
|
|
526 |
TOOLCHAIN_CFLAGS_JVM="-pipe -fno-rtti -fno-exceptions \
|
|
527 |
-fvisibility=hidden -fno-strict-aliasing -fno-omit-frame-pointer"
|
|
528 |
fi
|
|
529 |
|
|
530 |
if test "x$TOOLCHAIN_TYPE" = xgcc; then
|
|
531 |
TOOLCHAIN_CFLAGS_JVM="$TOOLCHAIN_CFLAGS_JVM -fcheck-new"
|
|
532 |
TOOLCHAIN_CFLAGS_JDK="-pipe"
|
|
533 |
TOOLCHAIN_CFLAGS_JDK_CONLY="-fno-strict-aliasing" # technically NOT for CXX (but since this gives *worse* performance, use no-strict-aliasing everywhere!)
|
|
534 |
|
|
535 |
CXXSTD_CXXFLAG="-std=gnu++98"
|
|
536 |
FLAGS_CXX_COMPILER_CHECK_ARGUMENTS(ARGUMENT: [$CXXSTD_CXXFLAG -Werror],
|
|
537 |
IF_FALSE: [CXXSTD_CXXFLAG=""])
|
|
538 |
TOOLCHAIN_CFLAGS_JDK_CXXONLY="$CXXSTD_CXXFLAG"
|
|
539 |
TOOLCHAIN_CFLAGS_JVM="$TOOLCHAIN_CFLAGS_JVM $CXXSTD_CXXFLAG"
|
|
540 |
ADLC_CXXFLAG="$CXXSTD_CXXFLAG"
|
|
541 |
|
|
542 |
|
|
543 |
elif test "x$TOOLCHAIN_TYPE" = xclang; then
|
|
544 |
# Restrict the debug information created by Clang to avoid
|
|
545 |
# too big object files and speed the build up a little bit
|
|
546 |
# (see http://llvm.org/bugs/show_bug.cgi?id=7554)
|
|
547 |
TOOLCHAIN_CFLAGS_JVM="$TOOLCHAIN_CFLAGS_JVM -flimit-debug-info"
|
|
548 |
|
|
549 |
if test "x$OPENJDK_TARGET_OS" = xlinux; then
|
|
550 |
TOOLCHAIN_CFLAGS_JDK="-pipe"
|
|
551 |
TOOLCHAIN_CFLAGS_JDK_CONLY="-fno-strict-aliasing" # technically NOT for CXX
|
|
552 |
fi
|
|
553 |
elif test "x$TOOLCHAIN_TYPE" = xsolstudio; then
|
|
554 |
TOOLCHAIN_CFLAGS_JDK="-mt"
|
|
555 |
TOOLCHAIN_CFLAGS_JDK_CONLY="-xc99=%none -xCC -Xa -v -W0,-noglobal" # C only
|
|
556 |
TOOLCHAIN_CFLAGS_JDK_CXXONLY="-features=no%except -norunpath -xnolib" # CXX only
|
|
557 |
TOOLCHAIN_CFLAGS_JVM="-template=no%extdef -features=no%split_init \
|
|
558 |
-library=stlport4 -mt -features=no%except"
|
|
559 |
elif test "x$TOOLCHAIN_TYPE" = xxlc; then
|
|
560 |
TOOLCHAIN_CFLAGS_JDK="-qchars=signed -qfullpath -qsaveopt" # add on both CFLAGS
|
|
561 |
TOOLCHAIN_CFLAGS_JVM="-qtune=balanced \
|
|
562 |
-qalias=noansi -qstrict -qtls=default -qlanglvl=c99vla \
|
|
563 |
-qlanglvl=noredefmac -qnortti -qnoeh -qignerrno"
|
|
564 |
elif test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
|
|
565 |
TOOLCHAIN_CFLAGS_JVM="-nologo -MD -MP"
|
|
566 |
TOOLCHAIN_CFLAGS_JDK="-nologo -MD -Zc:wchar_t-"
|
|
567 |
fi
|
|
568 |
|
|
569 |
# CFLAGS WARNINGS STUFF
|
|
570 |
# Set JVM_CFLAGS warning handling
|
|
571 |
if test "x$TOOLCHAIN_TYPE" = xgcc || test "x$TOOLCHAIN_TYPE" = xclang; then
|
|
572 |
# COMMON to gcc and clang
|
|
573 |
WARNING_CFLAGS_JVM="-Wpointer-arith -Wsign-compare -Wunused-function"
|
|
574 |
if ! HOTSPOT_CHECK_JVM_VARIANT(zero); then
|
|
575 |
# Non-zero builds have stricter warnings
|
|
576 |
WARNING_CFLAGS_JVM="$WARNING_CFLAGS_JVM -Wundef -Wformat=2"
|
|
577 |
fi
|
|
578 |
|
|
579 |
fi
|
|
580 |
if test "x$TOOLCHAIN_TYPE" = xgcc; then
|
|
581 |
WARNING_CFLAGS_JDK="-Wall -Wextra -Wno-unused -Wno-unused-parameter -Wformat=2"
|
|
582 |
WARNING_CFLAGS_JVM="$WARNING_CFLAGS_JVM -Wunused-value -Woverloaded-virtual"
|
|
583 |
|
|
584 |
if ! HOTSPOT_CHECK_JVM_VARIANT(zero); then
|
|
585 |
# Non-zero builds have stricter warnings
|
|
586 |
WARNING_CFLAGS_JVM="$WARNING_CFLAGS_JVM -Wreturn-type"
|
|
587 |
fi
|
|
588 |
elif test "x$TOOLCHAIN_TYPE" = xclang; then
|
|
589 |
WARNING_CFLAGS_JVM="$WARNING_CFLAGS_JVM -Wno-deprecated"
|
|
590 |
if test "x$OPENJDK_TARGET_OS" = xlinux; then
|
|
591 |
WARNING_CFLAGS_JVM="$WARNING_CFLAGS_JVM -Wno-sometimes-uninitialized"
|
|
592 |
WARNING_CFLAGS_JDK="-Wall -Wextra -Wno-unused -Wno-unused-parameter -Wformat=2"
|
|
593 |
fi
|
|
594 |
elif test "x$TOOLCHAIN_TYPE" = xsolstudio; then
|
|
595 |
WARNING_CFLAGS_JDK_CONLY="-errshort=tags"
|
|
596 |
WARNING_CFLAGS_JDK_CXXONLY="+w"
|
|
597 |
WARNING_CFLAGS_JDK="-errtags=yes -errfmt"
|
|
598 |
elif test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
|
|
599 |
WARNING_CFLAGS="-W3"
|
|
600 |
WARNING_CFLAGS_JDK="-wd4800"
|
|
601 |
fi
|
|
602 |
|
|
603 |
# Set some additional per-OS defines.
|
|
604 |
|
|
605 |
# Additional macosx handling
|
|
606 |
if test "x$OPENJDK_TARGET_OS" = xmacosx; then
|
|
607 |
OS_CFLAGS="-DMAC_OS_X_VERSION_MIN_REQUIRED=$MACOSX_VERSION_MIN_NODOTS \
|
|
608 |
-mmacosx-version-min=$MACOSX_VERSION_MIN"
|
|
609 |
|
|
610 |
if test -n "$MACOSX_VERSION_MAX"; then
|
|
611 |
OS_CFLAGS="$OS_CFLAGS \
|
|
612 |
-DMAC_OS_X_VERSION_MAX_ALLOWED=$MACOSX_VERSION_MAX_NODOTS"
|
|
613 |
fi
|
|
614 |
fi
|
|
615 |
|
|
616 |
# Where does this really belong??
|
|
617 |
if test "x$TOOLCHAIN_TYPE" = xgcc || test "x$TOOLCHAIN_TYPE" = xclang; then
|
|
618 |
PICFLAG="-fPIC"
|
|
619 |
elif test "x$TOOLCHAIN_TYPE" = xsolstudio; then
|
|
620 |
PICFLAG="-KPIC"
|
|
621 |
elif test "x$TOOLCHAIN_TYPE" = xxlc; then
|
|
622 |
# '-qpic' defaults to 'qpic=small'. This means that the compiler generates only
|
|
623 |
# one instruction for accessing the TOC. If the TOC grows larger than 64K, the linker
|
|
624 |
# will have to patch this single instruction with a call to some out-of-order code which
|
|
625 |
# does the load from the TOC. This is of course slow. But in that case we also would have
|
|
626 |
# to use '-bbigtoc' for linking anyway so we could also change the PICFLAG to 'qpic=large'.
|
|
627 |
# With 'qpic=large' the compiler will by default generate a two-instruction sequence which
|
|
628 |
# can be patched directly by the linker and does not require a jump to out-of-order code.
|
|
629 |
# Another alternative instead of using 'qpic=large -bbigtoc' may be to use '-qminimaltoc'
|
|
630 |
# instead. This creates a distinct TOC for every compilation unit (and thus requires two
|
|
631 |
# loads for accessing a global variable). But there are rumors that this may be seen as a
|
|
632 |
# 'performance feature' because of improved code locality of the symbols used in a
|
|
633 |
# compilation unit.
|
|
634 |
PICFLAG="-qpic"
|
|
635 |
elif test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
|
|
636 |
PICFLAG=""
|
|
637 |
fi
|
|
638 |
|
|
639 |
JVM_PICFLAG="$PICFLAG"
|
|
640 |
JDK_PICFLAG="$PICFLAG"
|
|
641 |
|
|
642 |
if test "x$OPENJDK_TARGET_OS" = xmacosx; then
|
|
643 |
# Linking is different on MacOSX
|
|
644 |
JDK_PICFLAG=''
|
|
645 |
if test "x$STATIC_BUILD" = xtrue; then
|
|
646 |
JVM_PICFLAG=""
|
|
647 |
fi
|
|
648 |
fi
|
|
649 |
|
|
650 |
if test "x$OPENJDK_TARGET_OS" = xmacosx; then
|
|
651 |
OS_CFLAGS_JVM="$OS_CFLAGS_JVM -mno-omit-leaf-frame-pointer -mstack-alignment=16"
|
|
652 |
fi
|
|
653 |
|
|
654 |
# Optional POSIX functionality needed by the JVM
|
|
655 |
#
|
|
656 |
# Check if clock_gettime is available and in which library. This indicates
|
|
657 |
# availability of CLOCK_MONOTONIC for hotspot. But we don't need to link, so
|
|
658 |
# don't let it update LIBS.
|
|
659 |
save_LIBS="$LIBS"
|
|
660 |
AC_SEARCH_LIBS(clock_gettime, rt, [HAS_CLOCK_GETTIME=true], [])
|
|
661 |
if test "x$LIBS" = "x-lrt "; then
|
|
662 |
CLOCK_GETTIME_IN_LIBRT=true
|
|
663 |
fi
|
|
664 |
LIBS="$save_LIBS"
|
|
665 |
|
|
666 |
if test "x$HAS_CLOCK_GETTIME" = "xtrue"; then
|
|
667 |
OS_CFLAGS_JVM="$OS_CFLAGS_JVM -DSUPPORTS_CLOCK_MONOTONIC"
|
|
668 |
if test "x$CLOCK_GETTIME_IN_LIBRT" = "xtrue"; then
|
|
669 |
OS_CFLAGS_JVM="$OS_CFLAGS_JVM -DNEEDS_LIBRT"
|
|
670 |
fi
|
|
671 |
fi
|
|
672 |
|
|
673 |
# EXPORT
|
|
674 |
AC_SUBST(ADLC_CXXFLAG)
|
|
675 |
])
|
|
676 |
|
|
677 |
################################################################################
|
|
678 |
# $1 - Either BUILD or TARGET to pick the correct OS/CPU variables to check
|
|
679 |
# conditionals against.
|
|
680 |
# $2 - Optional prefix for each variable defined.
|
|
681 |
AC_DEFUN([FLAGS_SETUP_CFLAGS_CPU_DEP],
|
|
682 |
[
|
|
683 |
#### CPU DEFINES, these should (in theory) be independent on toolchain
|
|
684 |
|
|
685 |
# Setup target CPU
|
|
686 |
# Setup endianness
|
|
687 |
if test "x$FLAGS_CPU_ENDIAN" = xlittle; then
|
|
688 |
$1_DEFINES_CPU_JVM="-DVM_LITTLE_ENDIAN"
|
|
689 |
fi
|
|
690 |
if test "x$TOOLCHAIN_TYPE" = xsolstudio; then
|
|
691 |
# The macro _LITTLE_ENDIAN needs to be defined the same to avoid the
|
|
692 |
# Sun C compiler warning message: warning: macro redefined: _LITTLE_ENDIAN
|
|
693 |
if test "x$FLAGS_CPU_ENDIAN" = xlittle; then
|
|
694 |
$1_DEFINES_CPU_JDK="-D_LITTLE_ENDIAN="
|
|
695 |
else
|
|
696 |
$1_DEFINES_CPU_JDK="-D_BIG_ENDIAN="
|
|
697 |
fi
|
|
698 |
else
|
|
699 |
if test "x$FLAGS_CPU_ENDIAN" = xlittle; then
|
|
700 |
$1_DEFINES_CPU_JDK="-D_LITTLE_ENDIAN"
|
|
701 |
else
|
|
702 |
$1_DEFINES_CPU_JDK="-D_BIG_ENDIAN"
|
|
703 |
fi
|
|
704 |
fi
|
|
705 |
|
|
706 |
# setup CPU bit size
|
|
707 |
$1_DEFINES_CPU_JDK="${$1_DEFINES_CPU_JDK} -DARCH='\"$FLAGS_CPU_LEGACY\"' \
|
|
708 |
-D$FLAGS_CPU_LEGACY"
|
|
709 |
|
|
710 |
if test "x$FLAGS_CPU_BITS" = x64; then
|
|
711 |
# -D_LP64=1 is only set on linux and mac. Setting on windows causes diff in
|
|
712 |
# unpack200.exe.
|
|
713 |
if test "x$FLAGS_OS" = xlinux || test "x$FLAGS_OS" = xmacosx; then
|
|
714 |
$1_DEFINES_CPU_JDK="${$1_DEFINES_CPU_JDK} -D_LP64=1"
|
|
715 |
fi
|
|
716 |
if test "x$FLAGS_OS" != xsolaris && test "x$FLAGS_OS" != xaix; then
|
|
717 |
# Solaris does not have _LP64=1 in the old build.
|
|
718 |
# xlc on AIX defines _LP64=1 by default and issues a warning if we redefine it.
|
|
719 |
$1_DEFINES_CPU_JVM="${$1_DEFINES_CPU_JVM} -D_LP64=1"
|
|
720 |
fi
|
|
721 |
fi
|
|
722 |
|
|
723 |
# toolchain dependend, per-cpu
|
|
724 |
if test "x$TOOLCHAIN_TYPE" = xsolstudio; then
|
|
725 |
if test "x$FLAGS_CPU_ARCH" = xx86; then
|
|
726 |
$1_DEFINES_CPU_JDK="${$1_DEFINES_CPU_JDK} -DcpuIntel -Di586 -D$FLAGS_CPU_LEGACY_LIB"
|
|
727 |
fi
|
|
728 |
elif test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
|
|
729 |
if test "x$FLAGS_CPU" = xx86_64; then
|
|
730 |
$1_DEFINES_CPU_JDK="${$1_DEFINES_CPU_JDK} -D_AMD64_ -Damd64"
|
|
731 |
else
|
|
732 |
$1_DEFINES_CPU_JDK="${$1_DEFINES_CPU_JDK} -D_X86_ -Dx86"
|
|
733 |
fi
|
|
734 |
fi
|
|
735 |
|
|
736 |
# CFLAGS PER CPU
|
|
737 |
if test "x$TOOLCHAIN_TYPE" = xgcc || test "x$TOOLCHAIN_TYPE" = xclang; then
|
|
738 |
# COMMON to gcc and clang
|
|
739 |
if test "x$FLAGS_CPU" = xx86; then
|
|
740 |
# Force compatibility with i586 on 32 bit intel platforms.
|
|
741 |
$1_CFLAGS_CPU="-march=i586"
|
|
742 |
fi
|
|
743 |
fi
|
|
744 |
|
|
745 |
if test "x$TOOLCHAIN_TYPE" = xgcc; then
|
|
746 |
if test "x$FLAGS_CPU" = xarm; then
|
|
747 |
# -Wno-psabi to get rid of annoying "note: the mangling of 'va_list' has changed in GCC 4.4"
|
|
748 |
$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)\"'"
|
|
749 |
$1_CFLAGS_CPU_JVM="-DARM"
|
|
750 |
elif test "x$FLAGS_CPU" = xaarch64; then
|
|
751 |
if test "x$HOTSPOT_TARGET_CPU_PORT" = xarm64; then
|
|
752 |
$1_CFLAGS_CPU_JVM="-fsigned-char -DARM"
|
|
753 |
fi
|
|
754 |
elif test "x$FLAGS_CPU_ARCH" = xppc; then
|
|
755 |
$1_CFLAGS_CPU_JVM="-minsert-sched-nops=regroup_exact -mno-multiple -mno-string"
|
|
756 |
if test "x$FLAGS_CPU" = xppc64; then
|
|
757 |
# -mminimal-toc fixes `relocation truncated to fit' error for gcc 4.1.
|
|
758 |
# Use ppc64 instructions, but schedule for power5
|
|
759 |
$1_CFLAGS_CPU_JVM="${$1_CFLAGS_CPU_JVM} -mminimal-toc -mcpu=powerpc64 -mtune=power5"
|
|
760 |
elif test "x$FLAGS_CPU" = xppc64le; then
|
|
761 |
# Little endian machine uses ELFv2 ABI.
|
|
762 |
# Use Power8, this is the first CPU to support PPC64 LE with ELFv2 ABI.
|
|
763 |
$1_CFLAGS_CPU_JVM="${$1_CFLAGS_CPU_JVM} -DABI_ELFv2 -mcpu=power8 -mtune=power8"
|
|
764 |
fi
|
|
765 |
elif test "x$FLAGS_CPU" = xs390x; then
|
|
766 |
$1_CFLAGS_CPU="-mbackchain -march=z10"
|
|
767 |
fi
|
|
768 |
|
|
769 |
if test "x$FLAGS_CPU_ARCH" != xarm && test "x$FLAGS_CPU_ARCH" != xppc; then
|
|
770 |
# for all archs except arm and ppc, prevent gcc to omit frame pointer
|
|
771 |
$1_CFLAGS_CPU_JDK="${$1_CFLAGS_CPU_JDK} -fno-omit-frame-pointer"
|
|
772 |
fi
|
|
773 |
|
|
774 |
elif test "x$TOOLCHAIN_TYPE" = xclang; then
|
|
775 |
if test "x$FLAGS_OS" = xlinux; then
|
|
776 |
# ppc test not really needed for clang
|
|
777 |
if test "x$FLAGS_CPU_ARCH" != xarm && test "x$FLAGS_CPU_ARCH" != xppc; then
|
|
778 |
# for all archs except arm and ppc, prevent gcc to omit frame pointer
|
|
779 |
$1_CFLAGS_CPU_JDK="${$1_CFLAGS_CPU_JDK} -fno-omit-frame-pointer"
|
|
780 |
fi
|
|
781 |
fi
|
|
782 |
|
|
783 |
elif test "x$TOOLCHAIN_TYPE" = xsolstudio; then
|
|
784 |
if test "x$FLAGS_CPU" = xx86_64; then
|
|
785 |
# NOTE: -xregs=no%frameptr is supposed to be default on x64
|
|
786 |
$1_CFLAGS_CPU_JDK="-xregs=no%frameptr"
|
|
787 |
elif test "x$FLAGS_CPU" = xsparcv9; then
|
|
788 |
$1_CFLAGS_CPU_JVM="-xarch=sparc"
|
|
789 |
$1_CFLAGS_CPU_JDK_LIBONLY="-xregs=no%appl"
|
|
790 |
fi
|
|
791 |
|
|
792 |
elif test "x$TOOLCHAIN_TYPE" = xxlc; then
|
|
793 |
if test "x$FLAGS_CPU" = xppc64; then
|
|
794 |
$1_CFLAGS_CPU_JVM="-qarch=ppc64"
|
|
795 |
fi
|
|
796 |
|
|
797 |
elif test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
|
|
798 |
if test "x$FLAGS_CPU" = xx86; then
|
|
799 |
$1_CFLAGS_CPU_JVM="-arch:IA32"
|
|
800 |
elif test "x$OPENJDK_TARGET_CPU" = xx86_64; then
|
|
801 |
if test "x$DEBUG_LEVEL" != xrelease; then
|
|
802 |
# NOTE: This is probably redundant; -homeparams is default on
|
|
803 |
# non-release builds.
|
|
804 |
$1_CFLAGS_CPU_JVM="-homeparams"
|
|
805 |
fi
|
|
806 |
fi
|
|
807 |
fi
|
|
808 |
|
|
809 |
if test "x$TOOLCHAIN_TYPE" = xgcc; then
|
|
810 |
TOOLCHAIN_CHECK_COMPILER_VERSION(VERSION: 6, PREFIX: $2, IF_AT_LEAST: FLAGS_SETUP_GCC6_COMPILER_FLAGS($1))
|
|
811 |
$1_TOOLCHAIN_CFLAGS="${$1_GCC6_CFLAGS}"
|
|
812 |
|
|
813 |
TOOLCHAIN_CHECK_COMPILER_VERSION(VERSION: [4.8], PREFIX: $2,
|
|
814 |
IF_AT_LEAST: [
|
|
815 |
# These flags either do not work or give spurious warnings prior to gcc 4.8.
|
|
816 |
$1_WARNING_CFLAGS_JVM="-Wno-format-zero-length -Wtype-limits -Wuninitialized"
|
|
817 |
]
|
|
818 |
)
|
|
819 |
fi
|
|
820 |
|
|
821 |
# EXPORT to API
|
|
822 |
CFLAGS_JVM_COMMON="$ALWAYS_CFLAGS_JVM $ALWAYS_DEFINES_JVM $TOOLCHAIN_CFLAGS_JVM \
|
|
823 |
$OS_CFLAGS $OS_CFLAGS_JVM $CFLAGS_OS_DEF_JVM $DEBUG_CFLAGS_JVM \
|
|
824 |
$WARNING_CFLAGS $WARNING_CFLAGS_JVM $JVM_PICFLAG"
|
|
825 |
|
|
826 |
CFLAGS_JDK_COMMON="$ALWAYS_CFLAGS_JDK $ALWAYS_DEFINES_JDK $TOOLCHAIN_CFLAGS_JDK \
|
|
827 |
$OS_CFLAGS $CFLAGS_OS_DEF_JDK $DEBUG_CFLAGS_JDK $DEBUG_OPTIONS_FLAGS_JDK \
|
|
828 |
$WARNING_CFLAGS $WARNING_CFLAGS_JDK"
|
|
829 |
|
|
830 |
# Use ${$2EXTRA_CFLAGS} to block EXTRA_CFLAGS to be added to build flags.
|
|
831 |
# (Currently we don't have any OPENJDK_BUILD_EXTRA_CFLAGS, but that might
|
|
832 |
# change in the future.)
|
|
833 |
|
|
834 |
CFLAGS_JDK_COMMON_CONLY="$TOOLCHAIN_CFLAGS_JDK_CONLY $DEBUG_SYMBOLS_CFLAGS_JDK \
|
|
835 |
$WARNING_CFLAGS_JDK_CONLY ${$2EXTRA_CFLAGS}"
|
|
836 |
CFLAGS_JDK_COMMON_CXXONLY="$ALWAYS_DEFINES_JDK_CXXONLY $TOOLCHAIN_CFLAGS_JDK_CXXONLY \
|
|
837 |
$DEBUG_SYMBOLS_CXXFLAGS_JDK $WARNING_CFLAGS_JDK_CXXONLY ${$2EXTRA_CXXFLAGS}"
|
|
838 |
|
|
839 |
$1_CFLAGS_JVM="${$1_DEFINES_CPU_JVM} ${$1_CFLAGS_CPU} ${$1_CFLAGS_CPU_JVM} ${$1_TOOLCHAIN_CFLAGS} ${$1_WARNING_CFLAGS_JVM}"
|
|
840 |
$1_CFLAGS_JDK="${$1_DEFINES_CPU_JDK} ${$1_CFLAGS_CPU} ${$1_CFLAGS_CPU_JDK} ${$1_TOOLCHAIN_CFLAGS}"
|
|
841 |
|
|
842 |
$2JVM_CFLAGS="$CFLAGS_JVM_COMMON ${$1_CFLAGS_JVM} ${$2EXTRA_CXXFLAGS}"
|
|
843 |
|
|
844 |
$2CFLAGS_JDKEXE="$CFLAGS_JDK_COMMON $CFLAGS_JDK_COMMON_CONLY ${$1_CFLAGS_JDK}"
|
|
845 |
$2CXXFLAGS_JDKEXE="$CFLAGS_JDK_COMMON $CFLAGS_JDK_COMMON_CXXONLY ${$1_CFLAGS_JDK}"
|
|
846 |
$2CFLAGS_JDKLIB="${$2CFLAGS_JDKEXE} $JDK_PICFLAG ${$1_CFLAGS_CPU_JDK_LIBONLY}"
|
|
847 |
$2CXXFLAGS_JDKLIB="${$2CXXFLAGS_JDKEXE} $JDK_PICFLAG ${$1_CFLAGS_CPU_JDK_LIBONLY}"
|
|
848 |
|
|
849 |
AC_SUBST($2JVM_CFLAGS)
|
|
850 |
AC_SUBST($2CFLAGS_JDKLIB)
|
|
851 |
AC_SUBST($2CFLAGS_JDKEXE)
|
|
852 |
AC_SUBST($2CXXFLAGS_JDKLIB)
|
|
853 |
AC_SUBST($2CXXFLAGS_JDKEXE)
|
|
854 |
])
|
|
855 |
|
|
856 |
# FLAGS_SETUP_GCC6_COMPILER_FLAGS([PREFIX])
|
|
857 |
# Arguments:
|
|
858 |
# $1 - Prefix for each variable defined.
|
|
859 |
AC_DEFUN([FLAGS_SETUP_GCC6_COMPILER_FLAGS],
|
|
860 |
[
|
|
861 |
# These flags are required for GCC 6 builds as undefined behaviour in OpenJDK code
|
|
862 |
# runs afoul of the more aggressive versions of these optimisations.
|
|
863 |
# Notably, value range propagation now assumes that the this pointer of C++
|
|
864 |
# member functions is non-null.
|
|
865 |
NO_DELETE_NULL_POINTER_CHECKS_CFLAG="-fno-delete-null-pointer-checks"
|
|
866 |
dnl Argument check is disabled until FLAGS_COMPILER_CHECK_ARGUMENTS handles cross-compilation
|
|
867 |
dnl FLAGS_COMPILER_CHECK_ARGUMENTS(ARGUMENT: [$NO_DELETE_NULL_POINTER_CHECKS_CFLAG -Werror],
|
|
868 |
dnl IF_FALSE: [NO_DELETE_NULL_POINTER_CHECKS_CFLAG=""])
|
|
869 |
NO_LIFETIME_DSE_CFLAG="-fno-lifetime-dse"
|
|
870 |
dnl Argument check is disabled until FLAGS_COMPILER_CHECK_ARGUMENTS handles cross-compilation
|
|
871 |
dnl FLAGS_COMPILER_CHECK_ARGUMENTS(ARGUMENT: [$NO_LIFETIME_DSE_CFLAG -Werror],
|
|
872 |
dnl IF_FALSE: [NO_LIFETIME_DSE_CFLAG=""])
|
|
873 |
AC_MSG_NOTICE([GCC >= 6 detected; adding ${NO_DELETE_NULL_POINTER_CHECKS_CFLAG} and ${NO_LIFETIME_DSE_CFLAG}])
|
|
874 |
$1_GCC6_CFLAGS="${NO_DELETE_NULL_POINTER_CHECKS_CFLAG} ${NO_LIFETIME_DSE_CFLAG}"
|
|
875 |
])
|
|
876 |
|
|
877 |
# Documentation on common flags used for solstudio in HIGHEST.
|
|
878 |
#
|
|
879 |
# WARNING: Use of OPTIMIZATION_LEVEL=HIGHEST in your Makefile needs to be
|
|
880 |
# done with care, there are some assumptions below that need to
|
|
881 |
# be understood about the use of pointers, and IEEE behavior.
|
|
882 |
#
|
|
883 |
# -fns: Use non-standard floating point mode (not IEEE 754)
|
|
884 |
# -fsimple: Do some simplification of floating point arithmetic (not IEEE 754)
|
|
885 |
# -fsingle: Use single precision floating point with 'float'
|
|
886 |
# -xalias_level=basic: Assume memory references via basic pointer types do not alias
|
|
887 |
# (Source with excessing pointer casting and data access with mixed
|
|
888 |
# pointer types are not recommended)
|
|
889 |
# -xbuiltin=%all: Use intrinsic or inline versions for math/std functions
|
|
890 |
# (If you expect perfect errno behavior, do not use this)
|
|
891 |
# -xdepend: Loop data dependency optimizations (need -xO3 or higher)
|
|
892 |
# -xrestrict: Pointer parameters to functions do not overlap
|
|
893 |
# (Similar to -xalias_level=basic usage, but less obvious sometimes.
|
|
894 |
# If you pass in multiple pointers to the same data, do not use this)
|
|
895 |
# -xlibmil: Inline some library routines
|
|
896 |
# (If you expect perfect errno behavior, do not use this)
|
|
897 |
# -xlibmopt: Use optimized math routines (CURRENTLY DISABLED)
|
|
898 |
# (If you expect perfect errno behavior, do not use this)
|
|
899 |
# Can cause undefined external on Solaris 8 X86 on __sincos, removing for now
|