|
1 # |
|
2 # Copyright (c) 2011, 2016, 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 # Setup the standard C/C++ runtime libraries. |
|
28 # |
|
29 # Most importantly, determine if stdc++ should be linked statically or |
|
30 # dynamically. |
|
31 ################################################################################ |
|
32 AC_DEFUN_ONCE([LIB_SETUP_STD_LIBS], |
|
33 [ |
|
34 # statically link libstdc++ before C++ ABI is stablized on Linux unless |
|
35 # dynamic build is configured on command line. |
|
36 AC_ARG_WITH([stdc++lib], [AS_HELP_STRING([--with-stdc++lib=<static>,<dynamic>,<default>], |
|
37 [force linking of the C++ runtime on Linux to either static or dynamic, default is static with dynamic as fallback])], |
|
38 [ |
|
39 if test "x$with_stdc__lib" != xdynamic && test "x$with_stdc__lib" != xstatic \ |
|
40 && test "x$with_stdc__lib" != xdefault; then |
|
41 AC_MSG_ERROR([Bad parameter value --with-stdc++lib=$with_stdc__lib!]) |
|
42 fi |
|
43 ], |
|
44 [with_stdc__lib=default] |
|
45 ) |
|
46 |
|
47 if test "x$OPENJDK_TARGET_OS" = xlinux; then |
|
48 # Test if stdc++ can be linked statically. |
|
49 AC_MSG_CHECKING([if static link of stdc++ is possible]) |
|
50 STATIC_STDCXX_FLAGS="-static-libstdc++ -static-libgcc" |
|
51 AC_LANG_PUSH(C++) |
|
52 OLD_LIBS="$LIBS" |
|
53 LIBS="$STATIC_STDCXX_FLAGS" |
|
54 AC_LINK_IFELSE([AC_LANG_PROGRAM([], [return 0;])], |
|
55 [has_static_libstdcxx=yes], |
|
56 [has_static_libstdcxx=no]) |
|
57 LIBS="$OLD_LIBS" |
|
58 AC_LANG_POP(C++) |
|
59 AC_MSG_RESULT([$has_static_libstdcxx]) |
|
60 |
|
61 if test "x$with_stdc__lib" = xstatic && test "x$has_static_libstdcxx" = xno; then |
|
62 AC_MSG_ERROR([Static linking of libstdc++ was not possible!]) |
|
63 fi |
|
64 |
|
65 # If dynamic was requested, it's available since it would fail above otherwise. |
|
66 # If dynamic wasn't requested, go with static unless it isn't available. |
|
67 AC_MSG_CHECKING([how to link with libstdc++]) |
|
68 if test "x$with_stdc__lib" = xdynamic || test "x$has_static_libstdcxx" = xno \ |
|
69 || HOTSPOT_CHECK_JVM_VARIANT(zeroshark); then |
|
70 AC_MSG_RESULT([dynamic]) |
|
71 else |
|
72 LIBCXX="$LIBCXX $STATIC_STDCXX_FLAGS" |
|
73 JVM_LDFLAGS="$JVM_LDFLAGS $STATIC_STDCXX_FLAGS" |
|
74 # Ideally, we should test stdc++ for the BUILD toolchain separately. For now |
|
75 # just use the same setting as for the TARGET toolchain. |
|
76 OPENJDK_BUILD_JVM_LDFLAGS="$OPENJDK_BUILD_JVM_LDFLAGS $STATIC_STDCXX_FLAGS" |
|
77 AC_MSG_RESULT([static]) |
|
78 fi |
|
79 fi |
|
80 |
|
81 # libCrun is the c++ runtime-library with SunStudio (roughly the equivalent of gcc's libstdc++.so) |
|
82 if test "x$TOOLCHAIN_TYPE" = xsolstudio && test "x$LIBCXX" = x; then |
|
83 LIBCXX="${SYSROOT}/usr/lib${OPENJDK_TARGET_CPU_ISADIR}/libCrun.so.1" |
|
84 fi |
|
85 |
|
86 AC_SUBST(LIBCXX) |
|
87 |
|
88 # Setup Windows runtime dlls |
|
89 if test "x$OPENJDK_TARGET_OS" = "xwindows"; then |
|
90 TOOLCHAIN_SETUP_VS_RUNTIME_DLLS |
|
91 fi |
|
92 ]) |