2
# Copyright (c) 2011, 2020, Oracle and/or its affiliates. All rights reserved.
3
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
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.
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).
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.
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
26
################################################################################
27
# Setup the standard C/C++ runtime libraries.
29
# Most importantly, determine if stdc++ should be linked statically or
31
################################################################################
32
AC_DEFUN_ONCE([LIB_SETUP_STD_LIBS],
34
# statically link libstdc++ before C++ ABI is stabilized 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])],
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!])
44
[with_stdc__lib=default]
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"
53
LIBS="$STATIC_STDCXX_FLAGS"
54
AC_LINK_IFELSE([AC_LANG_PROGRAM([], [return 0;])],
55
[has_static_libstdcxx=yes],
56
[has_static_libstdcxx=no])
59
AC_MSG_RESULT([$has_static_libstdcxx])
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!])
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 ; then
69
AC_MSG_RESULT([dynamic])
71
LIBCXX="$LIBCXX $STATIC_STDCXX_FLAGS"
72
JVM_LDFLAGS="$JVM_LDFLAGS $STATIC_STDCXX_FLAGS"
73
ADLC_LDFLAGS="$ADLC_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])
83
# Setup Windows runtime dlls
84
if test "x$OPENJDK_TARGET_OS" = "xwindows"; then
85
TOOLCHAIN_SETUP_VS_RUNTIME_DLLS