From: Michael Ow Date: Thu, 21 Jul 2011 23:38:15 +0000 (+0000) Subject: ICU-8453 On certain platforms, use static library optimization option when building... X-Git-Tag: milestone-59-0-1~4632 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=11e0c9a5bfe62b0260889f7d1b89694c1b18ca13;p=icu ICU-8453 On certain platforms, use static library optimization option when building static ICU libraries in release mode X-SVN-Rev: 30406 --- diff --git a/icu4c/source/configure b/icu4c/source/configure index 79692966443..9fedf989fd3 100755 --- a/icu4c/source/configure +++ b/icu4c/source/configure @@ -5296,6 +5296,56 @@ fi $as_echo "$enabled" >&6; } +# When building release static library, there might be some optimization flags we can use +if test "$ENABLE_STATIC" = "YES"; then + if test "$ENABLE_SHARED" != "YES"; then + if test "$ENABLE_RELEASE" = 1; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we can use static library optimization option" >&5 +$as_echo_n "checking whether we can use static library optimization option... " >&6; } + CHECK_STATIC_OPT_FLAG=no + + OLD_CPPFLAGS="${CPPFLAGS}" + OLD_LDFLAGS="${LDFLAGS}" + + case "${host}" in + *-linux*|i*86-*-*bsd*|i*86-pc-gnu) + if test "$ac_cv_c_compiler_gnu" = yes; then + CPPFLAGS="${CPPFLAGS} -ffunction-sections -fdata-sections" + LDFLAGS="${LDFLAGS} -Wl,--gc-sections" + fi + ;; + *) + ;; + esac + + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + CHECK_STATIC_OPT_FLAG=yes +else + CHECK_STATIC_OPT_FLAG=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CHECK_STATIC_OPT_FLAG" >&5 +$as_echo "$CHECK_STATIC_OPT_FLAG" >&6; } + if test "$CHECK_STATIC_OPT_FLAG" = no; then + CPPFLAGS="${OLD_CPPFLAGS}" + LDFLAGS="${OLD_LDFLAGS}" + fi + fi + fi +fi + # Check whether to enable auto cleanup of libraries { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to enable auto cleanup of libraries" >&5 $as_echo_n "checking whether to enable auto cleanup of libraries... " >&6; } diff --git a/icu4c/source/configure.in b/icu4c/source/configure.in index e95182831c6..62728a3bd4c 100644 --- a/icu4c/source/configure.in +++ b/icu4c/source/configure.in @@ -261,6 +261,37 @@ AC_ARG_ENABLE(static, AC_MSG_RESULT($enabled) AC_SUBST(ENABLE_STATIC) +# When building release static library, there might be some optimization flags we can use +if test "$ENABLE_STATIC" = "YES"; then + if test "$ENABLE_SHARED" != "YES"; then + if test "$ENABLE_RELEASE" = 1; then + AC_MSG_CHECKING([whether we can use static library optimization option]) + CHECK_STATIC_OPT_FLAG=no + + OLD_CPPFLAGS="${CPPFLAGS}" + OLD_LDFLAGS="${LDFLAGS}" + + case "${host}" in + *-linux*|i*86-*-*bsd*|i*86-pc-gnu) + if test "$ac_cv_c_compiler_gnu" = yes; then + CPPFLAGS="${CPPFLAGS} -ffunction-sections -fdata-sections" + LDFLAGS="${LDFLAGS} -Wl,--gc-sections" + fi + ;; + *) + ;; + esac + + AC_LINK_IFELSE(AC_LANG_PROGRAM, CHECK_STATIC_OPT_FLAG=yes, CHECK_STATIC_OPT_FLAG=no, ) + AC_MSG_RESULT($CHECK_STATIC_OPT_FLAG) + if test "$CHECK_STATIC_OPT_FLAG" = no; then + CPPFLAGS="${OLD_CPPFLAGS}" + LDFLAGS="${OLD_LDFLAGS}" + fi + fi + fi +fi + # Check whether to enable auto cleanup of libraries AC_MSG_CHECKING([whether to enable auto cleanup of libraries]) enabled=no