提交 f9f6b1c9 编写于 作者: T tbell

8001875: build-infra: We must be able to force static linking of stdc++

Summary: Ensure that we build with static linking when requested, or do not build at all
Reviewed-by: ohair, tbell
Contributed-by: erik.joelsson@oracle.com
上级 b0aec948
...@@ -1035,7 +1035,7 @@ with_alsa ...@@ -1035,7 +1035,7 @@ with_alsa
with_alsa_include with_alsa_include
with_alsa_lib with_alsa_lib
with_zlib with_zlib
enable_static_link_stdc++ with_stdc++lib
with_num_cores with_num_cores
with_memory_size with_memory_size
with_sjavac_server_java with_sjavac_server_java
...@@ -1712,9 +1712,6 @@ Optional Features: ...@@ -1712,9 +1712,6 @@ Optional Features:
--disable-macosx-runtime-support --disable-macosx-runtime-support
disable the use of MacOSX Java runtime support disable the use of MacOSX Java runtime support
framework [enabled] framework [enabled]
--disable-static-link-stdc++
disable static linking of the C++ runtime on Linux
[enabled]
--enable-sjavac use sjavac to do fast incremental compiles --enable-sjavac use sjavac to do fast incremental compiles
[disabled] [disabled]
--disable-precompiled-headers --disable-precompiled-headers
...@@ -1796,6 +1793,10 @@ Optional Packages: ...@@ -1796,6 +1793,10 @@ Optional Packages:
--with-alsa-lib specify directory for the alsa library --with-alsa-lib specify directory for the alsa library
--with-zlib use zlib from build system or OpenJDK source --with-zlib use zlib from build system or OpenJDK source
(system, bundled) [bundled] (system, bundled) [bundled]
--with-stdc++lib=<static>,<dynamic>,<default>
force linking of the C++ runtime on Linux to either
static or dynamic, default is static with dynamic as
fallback
--with-num-cores number of cores in the build system, e.g. --with-num-cores number of cores in the build system, e.g.
--with-num-cores=8 [probed] --with-num-cores=8 [probed]
--with-memory-size memory (in MB) available in the build system, e.g. --with-memory-size memory (in MB) available in the build system, e.g.
...@@ -3067,7 +3068,7 @@ fi ...@@ -3067,7 +3068,7 @@ fi
#CUSTOM_AUTOCONF_INCLUDE #CUSTOM_AUTOCONF_INCLUDE
# Do not change or remove the following line, it is needed for consistency checks: # Do not change or remove the following line, it is needed for consistency checks:
DATE_WHEN_GENERATED=1352751880 DATE_WHEN_GENERATED=1352916731
############################################################################### ###############################################################################
# #
...@@ -33006,12 +33007,19 @@ LIBS="$save_LIBS" ...@@ -33006,12 +33007,19 @@ LIBS="$save_LIBS"
# statically link libstdc++ before C++ ABI is stablized on Linux unless # statically link libstdc++ before C++ ABI is stablized on Linux unless
# dynamic build is configured on command line. # dynamic build is configured on command line.
# #
# Check whether --enable-static-link-stdc++ was given.
if test "${enable_static_link_stdc+++set}" = set; then
enableval=$enable_static_link_stdc++;
else
enable_static_link_stdc__=yes # Check whether --with-stdc++lib was given.
if test "${with_stdc++lib+set}" = set; then
withval=$with_stdc++lib;
if test "x$with_stdc__lib" != xdynamic && test "x$with_stdc__lib" != xstatic \
&& test "x$with_stdc__lib" != xdefault; then
{ { $as_echo "$as_me:$LINENO: error: Bad parameter value --with-stdc++lib=$with_stdc__lib!" >&5
$as_echo "$as_me: error: Bad parameter value --with-stdc++lib=$with_stdc__lib!" >&2;}
{ (exit 1); exit 1; }; }
fi
else
with_stdc__lib=default
fi fi
...@@ -33157,38 +33165,40 @@ ac_compiler_gnu=$ac_cv_cxx_compiler_gnu ...@@ -33157,38 +33165,40 @@ ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
{ $as_echo "$as_me:$LINENO: result: $has_static_libstdcxx" >&5 { $as_echo "$as_me:$LINENO: result: $has_static_libstdcxx" >&5
$as_echo "$has_static_libstdcxx" >&6; } $as_echo "$has_static_libstdcxx" >&6; }
if test "x$has_static_libcxx" = xno && test "x$has_dynamic_libcxx" = xno; then if test "x$has_static_libstdcxx" = xno && test "x$has_dynamic_libstdcxx" = xno; then
{ { $as_echo "$as_me:$LINENO: error: I cannot link to stdc++! Neither dynamically nor statically." >&5 { { $as_echo "$as_me:$LINENO: error: Cannot link to stdc++, neither dynamically nor statically!" >&5
$as_echo "$as_me: error: I cannot link to stdc++! Neither dynamically nor statically." >&2;} $as_echo "$as_me: error: Cannot link to stdc++, neither dynamically nor statically!" >&2;}
{ (exit 1); exit 1; }; } { (exit 1); exit 1; }; }
fi fi
if test "x$enable_static_link_stdc__" = xyes && test "x$has_static_libstdcxx" = xno; then if test "x$with_stdc__lib" = xstatic && test "x$has_static_libstdcxx" = xno; then
{ $as_echo "$as_me:$LINENO: Static linking of libstdc++ was not possible reverting to dynamic linking." >&5 { { $as_echo "$as_me:$LINENO: error: Static linking of libstdc++ was not possible!" >&5
$as_echo "$as_me: Static linking of libstdc++ was not possible reverting to dynamic linking." >&6;} $as_echo "$as_me: error: Static linking of libstdc++ was not possible!" >&2;}
enable_static_link_stdc__=no { (exit 1); exit 1; }; }
fi fi
if test "x$enable_static_link_stdc__" = xno && test "x$has_dynamic_libstdcxx" = xno; then if test "x$with_stdc__lib" = xdynamic && test "x$has_dynamic_libstdcxx" = xno; then
{ $as_echo "$as_me:$LINENO: Dynamic linking of libstdc++ was not possible reverting to static linking." >&5 { { $as_echo "$as_me:$LINENO: error: Dynamic linking of libstdc++ was not possible!" >&5
$as_echo "$as_me: Dynamic linking of libstdc++ was not possible reverting to static linking." >&6;} $as_echo "$as_me: error: Dynamic linking of libstdc++ was not possible!" >&2;}
enable_static_link_stdc__=yes { (exit 1); exit 1; }; }
fi fi
{ $as_echo "$as_me:$LINENO: checking how to link with libstdc++" >&5 { $as_echo "$as_me:$LINENO: checking how to link with libstdc++" >&5
$as_echo_n "checking how to link with libstdc++... " >&6; } $as_echo_n "checking how to link with libstdc++... " >&6; }
if test "x$enable_static_link_stdc__" = xyes; then # If dynamic was requested, it's available since it would fail above otherwise.
LIBCXX="$LIBCXX $STATIC_STDCXX_FLAGS" # If dynamic wasn't requested, go with static unless it isn't available.
LDCXX="$CC" if test "x$with_stdc__lib" = xdynamic || test "x$has_static_libstdcxx" = xno; then
STATIC_CXX_SETTING="STATIC_CXX=true"
{ $as_echo "$as_me:$LINENO: result: static" >&5
$as_echo "static" >&6; }
else
LIBCXX="$LIBCXX -lstdc++" LIBCXX="$LIBCXX -lstdc++"
LDCXX="$CXX" LDCXX="$CXX"
STATIC_CXX_SETTING="STATIC_CXX=false" STATIC_CXX_SETTING="STATIC_CXX=false"
{ $as_echo "$as_me:$LINENO: result: dynamic" >&5 { $as_echo "$as_me:$LINENO: result: dynamic" >&5
$as_echo "dynamic" >&6; } $as_echo "dynamic" >&6; }
else
LIBCXX="$LIBCXX $STATIC_STDCXX_FLAGS"
LDCXX="$CC"
STATIC_CXX_SETTING="STATIC_CXX=true"
{ $as_echo "$as_me:$LINENO: result: static" >&5
$as_echo "static" >&6; }
fi fi
fi fi
...@@ -601,11 +601,16 @@ AC_DEFUN_ONCE([LIB_SETUP_STATIC_LINK_LIBSTDCPP], ...@@ -601,11 +601,16 @@ AC_DEFUN_ONCE([LIB_SETUP_STATIC_LINK_LIBSTDCPP],
# statically link libstdc++ before C++ ABI is stablized on Linux unless # statically link libstdc++ before C++ ABI is stablized on Linux unless
# dynamic build is configured on command line. # dynamic build is configured on command line.
# #
AC_ARG_ENABLE([static-link-stdc++], [AS_HELP_STRING([--disable-static-link-stdc++], AC_ARG_WITH([stdc++lib], [AS_HELP_STRING([--with-stdc++lib=<static>,<dynamic>,<default>],
[disable static linking of the C++ runtime on Linux @<:@enabled@:>@])],, [force linking of the C++ runtime on Linux to either static or dynamic, default is static with dynamic as fallback])],
[ [
enable_static_link_stdc__=yes if test "x$with_stdc__lib" != xdynamic && test "x$with_stdc__lib" != xstatic \
]) && test "x$with_stdc__lib" != xdefault; then
AC_MSG_ERROR([Bad parameter value --with-stdc++lib=$with_stdc__lib!])
fi
],
[with_stdc__lib=default]
)
if test "x$OPENJDK_TARGET_OS" = xlinux; then if test "x$OPENJDK_TARGET_OS" = xlinux; then
# Test if -lstdc++ works. # Test if -lstdc++ works.
...@@ -636,31 +641,31 @@ if test "x$OPENJDK_TARGET_OS" = xlinux; then ...@@ -636,31 +641,31 @@ if test "x$OPENJDK_TARGET_OS" = xlinux; then
AC_LANG_POP(C++) AC_LANG_POP(C++)
AC_MSG_RESULT([$has_static_libstdcxx]) AC_MSG_RESULT([$has_static_libstdcxx])
if test "x$has_static_libcxx" = xno && test "x$has_dynamic_libcxx" = xno; then if test "x$has_static_libstdcxx" = xno && test "x$has_dynamic_libstdcxx" = xno; then
AC_MSG_ERROR([I cannot link to stdc++! Neither dynamically nor statically.]) AC_MSG_ERROR([Cannot link to stdc++, neither dynamically nor statically!])
fi fi
if test "x$enable_static_link_stdc__" = xyes && test "x$has_static_libstdcxx" = xno; then if test "x$with_stdc__lib" = xstatic && test "x$has_static_libstdcxx" = xno; then
AC_MSG_NOTICE([Static linking of libstdc++ was not possible reverting to dynamic linking.]) AC_MSG_ERROR([Static linking of libstdc++ was not possible!])
enable_static_link_stdc__=no
fi fi
if test "x$enable_static_link_stdc__" = xno && test "x$has_dynamic_libstdcxx" = xno; then if test "x$with_stdc__lib" = xdynamic && test "x$has_dynamic_libstdcxx" = xno; then
AC_MSG_NOTICE([Dynamic linking of libstdc++ was not possible reverting to static linking.]) AC_MSG_ERROR([Dynamic linking of libstdc++ was not possible!])
enable_static_link_stdc__=yes
fi fi
AC_MSG_CHECKING([how to link with libstdc++]) AC_MSG_CHECKING([how to link with libstdc++])
if test "x$enable_static_link_stdc__" = xyes; then # If dynamic was requested, it's available since it would fail above otherwise.
LIBCXX="$LIBCXX $STATIC_STDCXX_FLAGS" # If dynamic wasn't requested, go with static unless it isn't available.
LDCXX="$CC" if test "x$with_stdc__lib" = xdynamic || test "x$has_static_libstdcxx" = xno; then
STATIC_CXX_SETTING="STATIC_CXX=true"
AC_MSG_RESULT([static])
else
LIBCXX="$LIBCXX -lstdc++" LIBCXX="$LIBCXX -lstdc++"
LDCXX="$CXX" LDCXX="$CXX"
STATIC_CXX_SETTING="STATIC_CXX=false" STATIC_CXX_SETTING="STATIC_CXX=false"
AC_MSG_RESULT([dynamic]) AC_MSG_RESULT([dynamic])
else
LIBCXX="$LIBCXX $STATIC_STDCXX_FLAGS"
LDCXX="$CC"
STATIC_CXX_SETTING="STATIC_CXX=true"
AC_MSG_RESULT([static])
fi fi
fi fi
AC_SUBST(STATIC_CXX_SETTING) AC_SUBST(STATIC_CXX_SETTING)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册