Skip to content
Permalink
Browse files

Add `--enable-lto` option.

  • Loading branch information...
wilx committed Jun 18, 2018
1 parent 66ae142 commit 66d3d36495e0670f20d88b1bf2ba9245093ef2de
Showing with 108 additions and 7 deletions.
  1. +2 −2 Makefile.am
  2. +2 −2 Makefile.am.tpl
  3. +5 −2 Makefile.in
  4. +77 −0 configure
  5. +19 −1 configure.ac
  6. +2 −0 include/Makefile.in
  7. +1 −0 src/Makefile.am
@@ -6,8 +6,8 @@ AM_CPPFLAGS = -I$(top_srcdir)/include \
-I$(top_srcdir)/catch/single_include \
-DCATCH_CONFIG_PREFIX_ALL=1 \
@LOG4CPLUS_NDEBUG@
AM_CXXFLAGS=@LOG4CPLUS_PROFILING_CXXFLAGS@
AM_LDFLAGS=@LOG4CPLUS_PROFILING_LDFLAGS@
AM_CXXFLAGS=@LOG4CPLUS_PROFILING_CXXFLAGS@ @LOG4CPLUS_LTO_CXXFLAGS@
AM_LDFLAGS=@LOG4CPLUS_PROFILING_LDFLAGS@ @LOG4CPLUS_LTO_LDFLAGS@

ACLOCAL_AMFLAGS = -I m4
EXTRA_DIST = ChangeLog log4cplus.pc.in
@@ -10,8 +10,8 @@ AM_CPPFLAGS = -I$(top_srcdir)/include \
-I$(top_srcdir)/catch/single_include \
-DCATCH_CONFIG_PREFIX_ALL=1 \
@LOG4CPLUS_NDEBUG@
AM_CXXFLAGS=@LOG4CPLUS_PROFILING_CXXFLAGS@
AM_LDFLAGS=@LOG4CPLUS_PROFILING_LDFLAGS@
AM_CXXFLAGS=@LOG4CPLUS_PROFILING_CXXFLAGS@ @LOG4CPLUS_LTO_CXXFLAGS@
AM_LDFLAGS=@LOG4CPLUS_PROFILING_LDFLAGS@ @LOG4CPLUS_LTO_LDFLAGS@

ACLOCAL_AMFLAGS = -I m4
EXTRA_DIST = ChangeLog log4cplus.pc.in
@@ -1076,6 +1076,8 @@ LIBTOOL = @LIBTOOL@
LIPO = @LIPO@
LN_S = @LN_S@
LOG4CPLUS_AIX_XLC_LDFLAGS = @LOG4CPLUS_AIX_XLC_LDFLAGS@
LOG4CPLUS_LTO_CXXFLAGS = @LOG4CPLUS_LTO_CXXFLAGS@
LOG4CPLUS_LTO_LDFLAGS = @LOG4CPLUS_LTO_LDFLAGS@
LOG4CPLUS_NDEBUG = @LOG4CPLUS_NDEBUG@
LOG4CPLUS_PROFILING_CXXFLAGS = @LOG4CPLUS_PROFILING_CXXFLAGS@
LOG4CPLUS_PROFILING_LDFLAGS = @LOG4CPLUS_PROFILING_LDFLAGS@
@@ -1198,8 +1200,8 @@ AM_CPPFLAGS = -I$(top_srcdir)/include \
-DCATCH_CONFIG_PREFIX_ALL=1 \
@LOG4CPLUS_NDEBUG@

AM_CXXFLAGS = @LOG4CPLUS_PROFILING_CXXFLAGS@
AM_LDFLAGS = @LOG4CPLUS_PROFILING_LDFLAGS@
AM_CXXFLAGS = @LOG4CPLUS_PROFILING_CXXFLAGS@ @LOG4CPLUS_LTO_CXXFLAGS@
AM_LDFLAGS = @LOG4CPLUS_PROFILING_LDFLAGS@ @LOG4CPLUS_LTO_LDFLAGS@
ACLOCAL_AMFLAGS = -I m4
EXTRA_DIST = ChangeLog log4cplus.pc.in tests/testsuite.at $(TESTSUITE) \
tests/atlocal.in
@@ -1282,6 +1284,7 @@ liblog4cplus_la_SOURCES = $(common_liblog4cplus_la_sources)
common_liblog4cplus_la_ldflags = -no-undefined \
$(LOG4CPLUS_VERSION_LT_FLAGS) \
$(LOG4CPLUS_PROFILING_LDFLAGS) \
$(LOG4CPLUS_LTO_LDFLAGS) \
$(LOG4CPLUS_AIX_XLC_LDFLAGS) \
$(LOG4CPLUS_EXPORT_SYMBOLS_REGEX)

@@ -633,6 +633,8 @@ ac_subst_vars='am__EXEEXT_FALSE
am__EXEEXT_TRUE
LTLIBOBJS
LIBOBJS
LOG4CPLUS_LTO_CXXFLAGS
LOG4CPLUS_LTO_LDFLAGS
LOG4CPLUS_PROFILING_CXXFLAGS
LOG4CPLUS_PROFILING_LDFLAGS
AUTOM4TE
@@ -833,6 +835,7 @@ enable_release_version
enable_symbols_visibility_options
with_wchar_t_support
enable_unit_tests
enable_lto
enable_profiling
enable_threads
with_qt
@@ -1510,6 +1513,7 @@ Optional Features:
visibility options, where they are available.
[default=yes]
--enable-unit-tests Enable unit tests [default=no]
--enable-lto Enable LTO build [default=no]
--enable-profiling Compile with profiling compiler options.
[default=no]
--enable-threads Use this option to create a singled-threaded version
@@ -4680,6 +4684,18 @@ fi
fi


# Check whether --enable-lto was given.
if test "${enable_lto+set}" = set; then :
enableval=$enable_lto;
log4cplus_check_yesno_func "${enableval}" "--enable-lto"
else
enable_lto=no
fi

LOG4CPLUS_LTO_LDFLAGS=
LOG4CPLUS_LTO_CXXFLAGS=


ac_ext=cpp
ac_cpp='$CXXCPP $CPPFLAGS'
ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
@@ -7543,6 +7559,64 @@ case ".$var" in
;;
esac

fi


if test "x$enable_lto" = "xyes"; then :
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking CXXFLAGS for gcc -flto" >&5
$as_echo_n "checking CXXFLAGS for gcc -flto... " >&6; }
if ${ax_cv_cxxflags_gcc_option__flto+:} false; then :
$as_echo_n "(cached) " >&6
else
ax_cv_cxxflags_gcc_option__flto="no, unknown"
ac_ext=cpp
ac_cpp='$CXXCPP $CPPFLAGS'
ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
ac_compiler_gnu=$ac_cv_cxx_compiler_gnu

ac_save_CXXFLAGS="$CXXFLAGS"
for ac_arg in "-pedantic -Werror % -flto" "-pedantic % -flto %% no, obsolete" #
do CXXFLAGS="$ac_save_CXXFLAGS "`echo $ac_arg | sed -e 's,%%.*,,' -e 's,%,,'`
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
int zero;
int
main ()
{
zero = 0; return zero;
;
return 0;
}
_ACEOF
if ac_fn_cxx_try_link "$LINENO"; then :
ax_cv_cxxflags_gcc_option__flto=`echo $ac_arg | sed -e 's,.*% *,,'`; break
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
done
CXXFLAGS="$ac_save_CXXFLAGS"
ac_ext=cpp
ac_cpp='$CXXCPP $CPPFLAGS'
ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
ac_compiler_gnu=$ac_cv_cxx_compiler_gnu


fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_cxxflags_gcc_option__flto" >&5
$as_echo "$ax_cv_cxxflags_gcc_option__flto" >&6; }
var=$ax_cv_cxxflags_gcc_option__flto
case ".$var" in
.ok|.ok,*) LOG4CPLUS_LTO_LDFLAGS="-flto"
LOG4CPLUS_LTO_CXXFLAGS="-flto"
;;
.|.no|.no,*) ;;
*) LOG4CPLUS_LTO_LDFLAGS="-flto"
LOG4CPLUS_LTO_CXXFLAGS="-flto"
;;
esac

fi

case "$target_os" in #(






cat >confcache <<\_ACEOF
# This file is a shell script that caches the results of configure
# tests run on this system so they can be shared between configure
@@ -136,6 +136,14 @@ LOG4CPLUS_DEFINE_MACRO_IF([LOG4CPLUS_WITH_UNIT_TESTS],
[Defined to enable unit tests.],
[test "x$enable_unit_tests" = "xyes"], [1])

dnl Enable LTO build.

LOG4CPLUS_ARG_ENABLE([lto],
[Enable LTO build [default=no]],
[enable_lto=no])
LOG4CPLUS_LTO_LDFLAGS=
LOG4CPLUS_LTO_CXXFLAGS=

dnl Check for c/c++ compilers.

AC_PROG_CXX
@@ -267,6 +275,13 @@ AS_CASE([$ax_cv_cxx_compiler_vendor],
LOG4CPLUS_PROFILING_CXXFLAGS="-pg"])
AX_CXXFLAGS_GCC_OPTION([-g3])])

dnl LTO options.

AS_IF([test "x$enable_lto" = "xyes"],
[AX_CXXFLAGS_GCC_OPTION([-flto],[],
[LOG4CPLUS_LTO_LDFLAGS="-flto"
LOG4CPLUS_LTO_CXXFLAGS="-flto"])])

dnl The --enable-auto-import and --enable-runtime-pseudo-reloc
dnl options are required for log4cplus to work when compiled with
dnl Cygwin's GCC 4.3.x.
@@ -349,7 +364,7 @@ LOG4CPLUS_DEFINE_MACRO_IF([LOG4CPLUS_HAVE_FUNCTION_MACRO],

AX___PRETTY_FUNCTION___MACRO
LOG4CPLUS_DEFINE_MACRO_IF([LOG4CPLUS_HAVE_PRETTY_FUNCTION_MACRO],
[DEfine if compiler supports __PRETTY_FUNCTION__ macro.],
[Define if compiler supports __PRETTY_FUNCTION__ macro.],
[test "x$ac_cv_have___pretty_function___macro" = "xyes"], [1])

AX___FUNC___SYMBOL
@@ -660,4 +675,7 @@ AM_MISSING_PROG([AUTOM4TE], [autom4te])
AC_SUBST([LOG4CPLUS_PROFILING_LDFLAGS])
AC_SUBST([LOG4CPLUS_PROFILING_CXXFLAGS])

AC_SUBST([LOG4CPLUS_LTO_LDFLAGS])
AC_SUBST([LOG4CPLUS_LTO_CXXFLAGS])

AC_OUTPUT
@@ -238,6 +238,8 @@ LIBTOOL = @LIBTOOL@
LIPO = @LIPO@
LN_S = @LN_S@
LOG4CPLUS_AIX_XLC_LDFLAGS = @LOG4CPLUS_AIX_XLC_LDFLAGS@
LOG4CPLUS_LTO_CXXFLAGS = @LOG4CPLUS_LTO_CXXFLAGS@
LOG4CPLUS_LTO_LDFLAGS = @LOG4CPLUS_LTO_LDFLAGS@
LOG4CPLUS_NDEBUG = @LOG4CPLUS_NDEBUG@
LOG4CPLUS_PROFILING_CXXFLAGS = @LOG4CPLUS_PROFILING_CXXFLAGS@
LOG4CPLUS_PROFILING_LDFLAGS = @LOG4CPLUS_PROFILING_LDFLAGS@
@@ -73,6 +73,7 @@ endif
common_liblog4cplus_la_ldflags = -no-undefined \
$(LOG4CPLUS_VERSION_LT_FLAGS) \
$(LOG4CPLUS_PROFILING_LDFLAGS) \
$(LOG4CPLUS_LTO_LDFLAGS) \
$(LOG4CPLUS_AIX_XLC_LDFLAGS) \
$(LOG4CPLUS_EXPORT_SYMBOLS_REGEX)
liblog4cplus_la_LDFLAGS = $(common_liblog4cplus_la_ldflags)

0 comments on commit 66d3d36

Please sign in to comment.
You can’t perform that action at this time.