author | xuelei |
Tue, 15 May 2018 13:01:37 -0700 | |
branch | JDK-8145252-TLS13-branch |
changeset 56559 | a423173d0578 |
parent 49523 | 69c6eb97297f |
child 50550 | 41ff671ed8cf |
child 56726 | 3a9b7a1f9197 |
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 |
||
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 |
||
54 |
LDFLAGS_TESTLIB="$LDFLAGS_JDKLIB" |
|
55 |
LDFLAGS_TESTEXE="$LDFLAGS_JDKEXE ${TARGET_LDFLAGS_JDK_LIBPATH}" |
|
56 |
AC_SUBST(LDFLAGS_TESTLIB) |
|
57 |
AC_SUBST(LDFLAGS_TESTEXE) |
|
58 |
]) |
|
59 |
||
60 |
################################################################################ |
|
61 |
||
62 |
# CPU independent LDFLAGS setup, used for both target and build toolchain. |
|
63 |
AC_DEFUN([FLAGS_SETUP_LDFLAGS_HELPER], |
|
64 |
[ |
|
65 |
# Setup basic LDFLAGS |
|
66 |
if test "x$TOOLCHAIN_TYPE" = xgcc; then |
|
67 |
# If this is a --hash-style=gnu system, use --hash-style=both, why? |
|
68 |
# We have previously set HAS_GNU_HASH if this is the case |
|
69 |
if test -n "$HAS_GNU_HASH"; then |
|
70 |
BASIC_LDFLAGS="-Wl,--hash-style=both" |
|
71 |
LIBJSIG_HASHSTYLE_LDFLAGS="-Wl,--hash-style=both" |
|
72 |
fi |
|
73 |
||
49199 | 74 |
# Add -z defs, to forbid undefined symbols in object files. |
49120 | 75 |
BASIC_LDFLAGS="$BASIC_LDFLAGS -Wl,-z,defs" |
76 |
||
49199 | 77 |
BASIC_LDFLAGS_JVM_ONLY="-Wl,-z,noexecstack -Wl,-O1 -Wl,-z,relro" |
49120 | 78 |
|
79 |
BASIC_LDFLAGS_JDK_LIB_ONLY="-Wl,-z,noexecstack" |
|
80 |
LIBJSIG_NOEXECSTACK_LDFLAGS="-Wl,-z,noexecstack" |
|
81 |
||
82 |
elif test "x$TOOLCHAIN_TYPE" = xclang; then |
|
83 |
BASIC_LDFLAGS_JVM_ONLY="-mno-omit-leaf-frame-pointer -mstack-alignment=16 \ |
|
49523 | 84 |
-stdlib=libc++ -fPIC" |
49120 | 85 |
|
86 |
elif test "x$TOOLCHAIN_TYPE" = xsolstudio; then |
|
87 |
BASIC_LDFLAGS="-Wl,-z,defs" |
|
88 |
BASIC_LDFLAGS_ONLYCXX="-norunpath" |
|
89 |
BASIC_LDFLAGS_ONLYCXX_JDK_ONLY="-xnolib" |
|
90 |
||
91 |
BASIC_LDFLAGS_JDK_ONLY="-ztext" |
|
92 |
BASIC_LDFLAGS_JVM_ONLY="-library=%none -mt -z noversion" |
|
93 |
||
94 |
elif test "x$TOOLCHAIN_TYPE" = xxlc; then |
|
95 |
BASIC_LDFLAGS="-b64 -brtl -bnolibpath -bexpall -bernotok -btextpsize:64K \ |
|
96 |
-bdatapsize:64K -bstackpsize:64K" |
|
97 |
BASIC_LDFLAGS_JVM_ONLY="-Wl,-lC_r" |
|
98 |
||
99 |
elif test "x$TOOLCHAIN_TYPE" = xmicrosoft; then |
|
100 |
BASIC_LDFLAGS="-nologo -opt:ref" |
|
101 |
BASIC_LDFLAGS_JDK_ONLY="-incremental:no" |
|
49425
e9cb414f94eb
8198652: Stop linking with -base:0x8000000 on Windows
erikj
parents:
49199
diff
changeset
|
102 |
BASIC_LDFLAGS_JVM_ONLY="-opt:icf,8 -subsystem:windows" |
49120 | 103 |
fi |
104 |
||
105 |
# Setup OS-dependent LDFLAGS |
|
106 |
if test "x$TOOLCHAIN_TYPE" = xclang || test "x$TOOLCHAIN_TYPE" = xgcc; then |
|
107 |
if test "x$OPENJDK_TARGET_OS" = xmacosx; then |
|
108 |
# Assume clang or gcc. |
|
109 |
# FIXME: We should really generalize SET_SHARED_LIBRARY_ORIGIN instead. |
|
110 |
OS_LDFLAGS_JVM_ONLY="-Wl,-rpath,@loader_path/. -Wl,-rpath,@loader_path/.." |
|
111 |
OS_LDFLAGS_JDK_ONLY="-mmacosx-version-min=$MACOSX_VERSION_MIN" |
|
112 |
fi |
|
113 |
fi |
|
114 |
||
115 |
# Setup debug level-dependent LDFLAGS |
|
116 |
if test "x$TOOLCHAIN_TYPE" = xgcc; then |
|
117 |
if test "x$OPENJDK_TARGET_OS" = xlinux; then |
|
49199 | 118 |
if test x$DEBUG_LEVEL = xrelease; then |
119 |
DEBUGLEVEL_LDFLAGS_JDK_ONLY="$DEBUGLEVEL_LDFLAGS_JDK_ONLY -Wl,-O1" |
|
120 |
else |
|
121 |
# mark relocations read only on (fast/slow) debug builds |
|
122 |
DEBUGLEVEL_LDFLAGS_JDK_ONLY="-Wl,-z,relro" |
|
123 |
fi |
|
124 |
if test x$DEBUG_LEVEL = xslowdebug; then |
|
125 |
# do relocations at load |
|
126 |
DEBUGLEVEL_LDFLAGS="-Wl,-z,now" |
|
127 |
fi |
|
49120 | 128 |
fi |
129 |
||
130 |
elif test "x$TOOLCHAIN_TYPE" = xxlc; then |
|
131 |
# We need '-qminimaltoc' or '-qpic=large -bbigtoc' if the TOC overflows. |
|
132 |
# Hotspot now overflows its 64K TOC (currently only for debug), |
|
133 |
# so we build with '-qpic=large -bbigtoc'. |
|
134 |
if test "x$DEBUG_LEVEL" != xrelease; then |
|
135 |
DEBUGLEVEL_LDFLAGS_JVM_ONLY="$DEBUGLEVEL_LDFLAGS_JVM_ONLY -bbigtoc" |
|
136 |
fi |
|
137 |
fi |
|
138 |
||
139 |
# Setup LDFLAGS for linking executables |
|
140 |
if test "x$TOOLCHAIN_TYPE" = xgcc; then |
|
141 |
EXECUTABLE_LDFLAGS="$EXECUTABLE_LDFLAGS -Wl,--allow-shlib-undefined" |
|
142 |
fi |
|
143 |
||
144 |
# Export some intermediate variables for compatibility |
|
145 |
LDFLAGS_CXX_JDK="$BASIC_LDFLAGS_ONLYCXX $BASIC_LDFLAGS_ONLYCXX_JDK_ONLY $DEBUGLEVEL_LDFLAGS_JDK_ONLY" |
|
146 |
AC_SUBST(LDFLAGS_CXX_JDK) |
|
147 |
AC_SUBST(LIBJSIG_HASHSTYLE_LDFLAGS) |
|
148 |
AC_SUBST(LIBJSIG_NOEXECSTACK_LDFLAGS) |
|
149 |
]) |
|
150 |
||
151 |
################################################################################ |
|
152 |
# $1 - Either BUILD or TARGET to pick the correct OS/CPU variables to check |
|
153 |
# conditionals against. |
|
154 |
# $2 - Optional prefix for each variable defined. |
|
155 |
AC_DEFUN([FLAGS_SETUP_LDFLAGS_CPU_DEP], |
|
156 |
[ |
|
157 |
# Setup CPU-dependent basic LDFLAGS. These can differ between the target and |
|
158 |
# build toolchain. |
|
159 |
if test "x$TOOLCHAIN_TYPE" = xgcc; then |
|
160 |
if test "x${OPENJDK_$1_CPU}" = xx86; then |
|
161 |
$1_CPU_LDFLAGS_JVM_ONLY="-march=i586" |
|
162 |
elif test "x$OPENJDK_$1_CPU" = xarm; then |
|
163 |
$1_CPU_LDFLAGS_JVM_ONLY="${$1_CPU_LDFLAGS_JVM_ONLY} -fsigned-char" |
|
164 |
$1_CPU_LDFLAGS="$ARM_ARCH_TYPE_FLAGS $ARM_FLOAT_TYPE_FLAGS" |
|
165 |
elif test "x$FLAGS_CPU" = xaarch64; then |
|
166 |
if test "x$HOTSPOT_TARGET_CPU_PORT" = xarm64; then |
|
167 |
$1_CPU_LDFLAGS_JVM_ONLY="${$1_CPU_LDFLAGS_JVM_ONLY} -fsigned-char" |
|
168 |
fi |
|
169 |
fi |
|
170 |
||
171 |
elif test "x$TOOLCHAIN_TYPE" = xsolstudio; then |
|
172 |
if test "x${OPENJDK_$1_CPU}" = "xsparcv9"; then |
|
173 |
$1_CPU_LDFLAGS_JVM_ONLY="-xarch=sparc" |
|
174 |
fi |
|
175 |
||
176 |
elif test "x$TOOLCHAIN_TYPE" = xmicrosoft; then |
|
177 |
if test "x${OPENJDK_$1_CPU}" = "xx86"; then |
|
178 |
$1_CPU_LDFLAGS="-safeseh" |
|
179 |
# NOTE: Old build added -machine. Probably not needed. |
|
180 |
$1_CPU_LDFLAGS_JVM_ONLY="-machine:I386" |
|
181 |
$1_CPU_EXECUTABLE_LDFLAGS="-stack:327680" |
|
182 |
else |
|
183 |
$1_CPU_LDFLAGS_JVM_ONLY="-machine:AMD64" |
|
184 |
$1_CPU_EXECUTABLE_LDFLAGS="-stack:1048576" |
|
185 |
fi |
|
186 |
fi |
|
187 |
||
188 |
# JVM_VARIANT_PATH depends on if this is build or target... |
|
189 |
if test "x$TOOLCHAIN_TYPE" = xmicrosoft; then |
|
190 |
$1_LDFLAGS_JDK_LIBPATH="-libpath:${OUTPUTDIR}/support/modules_libs/java.base" |
|
191 |
else |
|
192 |
$1_LDFLAGS_JDK_LIBPATH="-L\$(SUPPORT_OUTPUTDIR)/modules_libs/java.base \ |
|
193 |
-L\$(SUPPORT_OUTPUTDIR)/modules_libs/java.base/${$1_JVM_VARIANT_PATH}" |
|
194 |
fi |
|
195 |
||
196 |
# Export variables according to old definitions, prefix with $2 if present. |
|
197 |
LDFLAGS_JDK_COMMON="$BASIC_LDFLAGS $BASIC_LDFLAGS_JDK_ONLY \ |
|
198 |
$OS_LDFLAGS_JDK_ONLY $DEBUGLEVEL_LDFLAGS_JDK_ONLY ${$2EXTRA_LDFLAGS}" |
|
199 |
$2LDFLAGS_JDKLIB="$LDFLAGS_JDK_COMMON $BASIC_LDFLAGS_JDK_LIB_ONLY \ |
|
200 |
${$1_LDFLAGS_JDK_LIBPATH} $SHARED_LIBRARY_FLAGS" |
|
201 |
$2LDFLAGS_JDKEXE="$LDFLAGS_JDK_COMMON $EXECUTABLE_LDFLAGS \ |
|
202 |
${$1_CPU_EXECUTABLE_LDFLAGS}" |
|
203 |
||
204 |
$2JVM_LDFLAGS="$BASIC_LDFLAGS $BASIC_LDFLAGS_JVM_ONLY $OS_LDFLAGS_JVM_ONLY \ |
|
205 |
$DEBUGLEVEL_LDFLAGS $DEBUGLEVEL_LDFLAGS_JVM_ONLY $BASIC_LDFLAGS_ONLYCXX \ |
|
206 |
${$1_CPU_LDFLAGS} ${$1_CPU_LDFLAGS_JVM_ONLY} ${$2EXTRA_LDFLAGS}" |
|
207 |
||
208 |
AC_SUBST($2LDFLAGS_JDKLIB) |
|
209 |
AC_SUBST($2LDFLAGS_JDKEXE) |
|
210 |
||
211 |
AC_SUBST($2JVM_LDFLAGS) |
|
212 |
]) |