author | jvernee |
Thu, 14 Nov 2019 10:55:46 +0100 | |
changeset 59075 | 355f4f42dda5 |
parent 54790 | b77bf7f216f4 |
child 58665 | 30a5049a36bb |
child 59286 | a2441ac23eeb |
permissions | -rw-r--r-- |
49120 | 1 |
# |
54790
b77bf7f216f4
8223307: enable the Stack Execution Disable flag for JDK binaries on AIX
mbaesken
parents:
52351
diff
changeset
|
2 |
# Copyright (c) 2011, 2019, Oracle and/or its affiliates. All rights reserved. |
49120 | 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 |
||
29 |
AC_DEFUN([FLAGS_SETUP_LDFLAGS], |
|
30 |
[ |
|
31 |
FLAGS_SETUP_LDFLAGS_HELPER |
|
32 |
||
33 |
# Setup the target toolchain |
|
34 |
||
35 |
# On some platforms (mac) the linker warns about non existing -L dirs. |
|
36 |
# For any of the variants server, client or minimal, the dir matches the |
|
37 |
# variant name. The "main" variant should be used for linking. For the |
|
38 |
# rest, the dir is just server. |
|
39 |
if HOTSPOT_CHECK_JVM_VARIANT(server) || HOTSPOT_CHECK_JVM_VARIANT(client) \ |
|
40 |
|| HOTSPOT_CHECK_JVM_VARIANT(minimal); then |
|
41 |
TARGET_JVM_VARIANT_PATH=$JVM_VARIANT_MAIN |
|
42 |
else |
|
43 |
TARGET_JVM_VARIANT_PATH=server |
|
44 |
fi |
|
45 |
FLAGS_SETUP_LDFLAGS_CPU_DEP([TARGET]) |
|
46 |
||
47 |
# Setup the build toolchain |
|
48 |
||
49 |
# When building a buildjdk, it's always only the server variant |
|
50 |
BUILD_JVM_VARIANT_PATH=server |
|
51 |
||
52 |
FLAGS_SETUP_LDFLAGS_CPU_DEP([BUILD], [OPENJDK_BUILD_]) |
|
53 |
||
51814 | 54 |
LDFLAGS_TESTEXE="${TARGET_LDFLAGS_JDK_LIBPATH}" |
49120 | 55 |
AC_SUBST(LDFLAGS_TESTEXE) |
56 |
]) |
|
57 |
||
58 |
################################################################################ |
|
59 |
||
60 |
# CPU independent LDFLAGS setup, used for both target and build toolchain. |
|
61 |
AC_DEFUN([FLAGS_SETUP_LDFLAGS_HELPER], |
|
62 |
[ |
|
63 |
# Setup basic LDFLAGS |
|
64 |
if test "x$TOOLCHAIN_TYPE" = xgcc; then |
|
65 |
# If this is a --hash-style=gnu system, use --hash-style=both, why? |
|
66 |
# We have previously set HAS_GNU_HASH if this is the case |
|
67 |
if test -n "$HAS_GNU_HASH"; then |
|
68 |
BASIC_LDFLAGS="-Wl,--hash-style=both" |
|
69 |
LIBJSIG_HASHSTYLE_LDFLAGS="-Wl,--hash-style=both" |
|
70 |
fi |
|
71 |
||
49199 | 72 |
# Add -z defs, to forbid undefined symbols in object files. |
49120 | 73 |
BASIC_LDFLAGS="$BASIC_LDFLAGS -Wl,-z,defs" |
74 |
||
51805
eb2adb0a9b09
8209817: stack is executable when building with Clang on Linux
martin
parents:
50733
diff
changeset
|
75 |
BASIC_LDFLAGS_JVM_ONLY="-Wl,-O1 -Wl,-z,relro" |
49120 | 76 |
|
77 |
||
78 |
elif test "x$TOOLCHAIN_TYPE" = xclang; then |
|
79 |
BASIC_LDFLAGS_JVM_ONLY="-mno-omit-leaf-frame-pointer -mstack-alignment=16 \ |
|
50733 | 80 |
-fPIC" |
49120 | 81 |
|
82 |
elif test "x$TOOLCHAIN_TYPE" = xsolstudio; then |
|
83 |
BASIC_LDFLAGS="-Wl,-z,defs" |
|
84 |
BASIC_LDFLAGS_ONLYCXX="-norunpath" |
|
85 |
BASIC_LDFLAGS_ONLYCXX_JDK_ONLY="-xnolib" |
|
86 |
||
87 |
BASIC_LDFLAGS_JDK_ONLY="-ztext" |
|
88 |
BASIC_LDFLAGS_JVM_ONLY="-library=%none -mt -z noversion" |
|
89 |
||
90 |
elif test "x$TOOLCHAIN_TYPE" = xxlc; then |
|
54790
b77bf7f216f4
8223307: enable the Stack Execution Disable flag for JDK binaries on AIX
mbaesken
parents:
52351
diff
changeset
|
91 |
BASIC_LDFLAGS="-b64 -brtl -bnorwexec -bnolibpath -bexpall -bernotok -btextpsize:64K \ |
49120 | 92 |
-bdatapsize:64K -bstackpsize:64K" |
50550
41ff671ed8cf
8204935: [aix] TOC overflow in libjvm.so (release build)
stuefe
parents:
49523
diff
changeset
|
93 |
# libjvm.so has gotten too large for normal TOC size; compile with qpic=large and link with bigtoc |
41ff671ed8cf
8204935: [aix] TOC overflow in libjvm.so (release build)
stuefe
parents:
49523
diff
changeset
|
94 |
BASIC_LDFLAGS_JVM_ONLY="-Wl,-lC_r -bbigtoc" |
49120 | 95 |
|
96 |
elif test "x$TOOLCHAIN_TYPE" = xmicrosoft; then |
|
97 |
BASIC_LDFLAGS="-nologo -opt:ref" |
|
98 |
BASIC_LDFLAGS_JDK_ONLY="-incremental:no" |
|
49425
e9cb414f94eb
8198652: Stop linking with -base:0x8000000 on Windows
erikj
parents:
49199
diff
changeset
|
99 |
BASIC_LDFLAGS_JVM_ONLY="-opt:icf,8 -subsystem:windows" |
49120 | 100 |
fi |
101 |
||
51805
eb2adb0a9b09
8209817: stack is executable when building with Clang on Linux
martin
parents:
50733
diff
changeset
|
102 |
if test "x$TOOLCHAIN_TYPE" = xgcc || test "x$TOOLCHAIN_TYPE" = xclang; then |
eb2adb0a9b09
8209817: stack is executable when building with Clang on Linux
martin
parents:
50733
diff
changeset
|
103 |
if test -n "$HAS_NOEXECSTACK"; then |
eb2adb0a9b09
8209817: stack is executable when building with Clang on Linux
martin
parents:
50733
diff
changeset
|
104 |
BASIC_LDFLAGS="$BASIC_LDFLAGS -Wl,-z,noexecstack" |
eb2adb0a9b09
8209817: stack is executable when building with Clang on Linux
martin
parents:
50733
diff
changeset
|
105 |
fi |
eb2adb0a9b09
8209817: stack is executable when building with Clang on Linux
martin
parents:
50733
diff
changeset
|
106 |
fi |
eb2adb0a9b09
8209817: stack is executable when building with Clang on Linux
martin
parents:
50733
diff
changeset
|
107 |
|
49120 | 108 |
# Setup OS-dependent LDFLAGS |
109 |
if test "x$TOOLCHAIN_TYPE" = xclang || test "x$TOOLCHAIN_TYPE" = xgcc; then |
|
110 |
if test "x$OPENJDK_TARGET_OS" = xmacosx; then |
|
111 |
# Assume clang or gcc. |
|
112 |
# FIXME: We should really generalize SET_SHARED_LIBRARY_ORIGIN instead. |
|
113 |
OS_LDFLAGS_JVM_ONLY="-Wl,-rpath,@loader_path/. -Wl,-rpath,@loader_path/.." |
|
114 |
OS_LDFLAGS_JDK_ONLY="-mmacosx-version-min=$MACOSX_VERSION_MIN" |
|
115 |
fi |
|
116 |
fi |
|
117 |
||
118 |
# Setup debug level-dependent LDFLAGS |
|
119 |
if test "x$TOOLCHAIN_TYPE" = xgcc; then |
|
120 |
if test "x$OPENJDK_TARGET_OS" = xlinux; then |
|
49199 | 121 |
if test x$DEBUG_LEVEL = xrelease; then |
122 |
DEBUGLEVEL_LDFLAGS_JDK_ONLY="$DEBUGLEVEL_LDFLAGS_JDK_ONLY -Wl,-O1" |
|
123 |
else |
|
124 |
# mark relocations read only on (fast/slow) debug builds |
|
125 |
DEBUGLEVEL_LDFLAGS_JDK_ONLY="-Wl,-z,relro" |
|
126 |
fi |
|
127 |
if test x$DEBUG_LEVEL = xslowdebug; then |
|
128 |
# do relocations at load |
|
129 |
DEBUGLEVEL_LDFLAGS="-Wl,-z,now" |
|
130 |
fi |
|
49120 | 131 |
fi |
132 |
||
133 |
elif test "x$TOOLCHAIN_TYPE" = xxlc; then |
|
134 |
# We need '-qminimaltoc' or '-qpic=large -bbigtoc' if the TOC overflows. |
|
135 |
# Hotspot now overflows its 64K TOC (currently only for debug), |
|
136 |
# so we build with '-qpic=large -bbigtoc'. |
|
137 |
if test "x$DEBUG_LEVEL" != xrelease; then |
|
138 |
DEBUGLEVEL_LDFLAGS_JVM_ONLY="$DEBUGLEVEL_LDFLAGS_JVM_ONLY -bbigtoc" |
|
139 |
fi |
|
140 |
fi |
|
141 |
||
51839
ab54a4d61d7f
8210988: Improved handling of compiler warnings in the build
ihse
parents:
51814
diff
changeset
|
142 |
# Setup warning flags |
ab54a4d61d7f
8210988: Improved handling of compiler warnings in the build
ihse
parents:
51814
diff
changeset
|
143 |
if test "x$TOOLCHAIN_TYPE" = xsolstudio; then |
ab54a4d61d7f
8210988: Improved handling of compiler warnings in the build
ihse
parents:
51814
diff
changeset
|
144 |
LDFLAGS_WARNINGS_ARE_ERRORS="-Wl,-z,fatal-warnings" |
ab54a4d61d7f
8210988: Improved handling of compiler warnings in the build
ihse
parents:
51814
diff
changeset
|
145 |
else |
ab54a4d61d7f
8210988: Improved handling of compiler warnings in the build
ihse
parents:
51814
diff
changeset
|
146 |
LDFLAGS_WARNINGS_ARE_ERRORS="" |
ab54a4d61d7f
8210988: Improved handling of compiler warnings in the build
ihse
parents:
51814
diff
changeset
|
147 |
fi |
ab54a4d61d7f
8210988: Improved handling of compiler warnings in the build
ihse
parents:
51814
diff
changeset
|
148 |
AC_SUBST(LDFLAGS_WARNINGS_ARE_ERRORS) |
ab54a4d61d7f
8210988: Improved handling of compiler warnings in the build
ihse
parents:
51814
diff
changeset
|
149 |
|
49120 | 150 |
# Setup LDFLAGS for linking executables |
151 |
if test "x$TOOLCHAIN_TYPE" = xgcc; then |
|
152 |
EXECUTABLE_LDFLAGS="$EXECUTABLE_LDFLAGS -Wl,--allow-shlib-undefined" |
|
153 |
fi |
|
154 |
||
155 |
# Export some intermediate variables for compatibility |
|
156 |
LDFLAGS_CXX_JDK="$BASIC_LDFLAGS_ONLYCXX $BASIC_LDFLAGS_ONLYCXX_JDK_ONLY $DEBUGLEVEL_LDFLAGS_JDK_ONLY" |
|
157 |
AC_SUBST(LDFLAGS_CXX_JDK) |
|
158 |
AC_SUBST(LIBJSIG_HASHSTYLE_LDFLAGS) |
|
159 |
AC_SUBST(LIBJSIG_NOEXECSTACK_LDFLAGS) |
|
160 |
]) |
|
161 |
||
162 |
################################################################################ |
|
163 |
# $1 - Either BUILD or TARGET to pick the correct OS/CPU variables to check |
|
164 |
# conditionals against. |
|
165 |
# $2 - Optional prefix for each variable defined. |
|
166 |
AC_DEFUN([FLAGS_SETUP_LDFLAGS_CPU_DEP], |
|
167 |
[ |
|
168 |
# Setup CPU-dependent basic LDFLAGS. These can differ between the target and |
|
169 |
# build toolchain. |
|
170 |
if test "x$TOOLCHAIN_TYPE" = xgcc; then |
|
171 |
if test "x${OPENJDK_$1_CPU}" = xx86; then |
|
172 |
$1_CPU_LDFLAGS_JVM_ONLY="-march=i586" |
|
173 |
elif test "x$OPENJDK_$1_CPU" = xarm; then |
|
174 |
$1_CPU_LDFLAGS_JVM_ONLY="${$1_CPU_LDFLAGS_JVM_ONLY} -fsigned-char" |
|
175 |
$1_CPU_LDFLAGS="$ARM_ARCH_TYPE_FLAGS $ARM_FLOAT_TYPE_FLAGS" |
|
176 |
fi |
|
177 |
||
178 |
elif test "x$TOOLCHAIN_TYPE" = xsolstudio; then |
|
179 |
if test "x${OPENJDK_$1_CPU}" = "xsparcv9"; then |
|
180 |
$1_CPU_LDFLAGS_JVM_ONLY="-xarch=sparc" |
|
181 |
fi |
|
182 |
||
183 |
elif test "x$TOOLCHAIN_TYPE" = xmicrosoft; then |
|
184 |
if test "x${OPENJDK_$1_CPU}" = "xx86"; then |
|
185 |
$1_CPU_LDFLAGS="-safeseh" |
|
186 |
# NOTE: Old build added -machine. Probably not needed. |
|
187 |
$1_CPU_LDFLAGS_JVM_ONLY="-machine:I386" |
|
188 |
$1_CPU_EXECUTABLE_LDFLAGS="-stack:327680" |
|
189 |
else |
|
190 |
$1_CPU_LDFLAGS_JVM_ONLY="-machine:AMD64" |
|
191 |
$1_CPU_EXECUTABLE_LDFLAGS="-stack:1048576" |
|
192 |
fi |
|
193 |
fi |
|
194 |
||
195 |
# JVM_VARIANT_PATH depends on if this is build or target... |
|
196 |
if test "x$TOOLCHAIN_TYPE" = xmicrosoft; then |
|
197 |
$1_LDFLAGS_JDK_LIBPATH="-libpath:${OUTPUTDIR}/support/modules_libs/java.base" |
|
198 |
else |
|
199 |
$1_LDFLAGS_JDK_LIBPATH="-L\$(SUPPORT_OUTPUTDIR)/modules_libs/java.base \ |
|
200 |
-L\$(SUPPORT_OUTPUTDIR)/modules_libs/java.base/${$1_JVM_VARIANT_PATH}" |
|
201 |
fi |
|
202 |
||
203 |
# Export variables according to old definitions, prefix with $2 if present. |
|
204 |
LDFLAGS_JDK_COMMON="$BASIC_LDFLAGS $BASIC_LDFLAGS_JDK_ONLY \ |
|
205 |
$OS_LDFLAGS_JDK_ONLY $DEBUGLEVEL_LDFLAGS_JDK_ONLY ${$2EXTRA_LDFLAGS}" |
|
206 |
$2LDFLAGS_JDKLIB="$LDFLAGS_JDK_COMMON $BASIC_LDFLAGS_JDK_LIB_ONLY \ |
|
207 |
${$1_LDFLAGS_JDK_LIBPATH} $SHARED_LIBRARY_FLAGS" |
|
208 |
$2LDFLAGS_JDKEXE="$LDFLAGS_JDK_COMMON $EXECUTABLE_LDFLAGS \ |
|
209 |
${$1_CPU_EXECUTABLE_LDFLAGS}" |
|
210 |
||
211 |
$2JVM_LDFLAGS="$BASIC_LDFLAGS $BASIC_LDFLAGS_JVM_ONLY $OS_LDFLAGS_JVM_ONLY \ |
|
212 |
$DEBUGLEVEL_LDFLAGS $DEBUGLEVEL_LDFLAGS_JVM_ONLY $BASIC_LDFLAGS_ONLYCXX \ |
|
213 |
${$1_CPU_LDFLAGS} ${$1_CPU_LDFLAGS_JVM_ONLY} ${$2EXTRA_LDFLAGS}" |
|
214 |
||
215 |
AC_SUBST($2LDFLAGS_JDKLIB) |
|
216 |
AC_SUBST($2LDFLAGS_JDKEXE) |
|
217 |
||
218 |
AC_SUBST($2JVM_LDFLAGS) |
|
219 |
]) |