diff options
| author | Lei YU <mine260309@gmail.com> | 2018-09-18 14:46:36 +0800 |
|---|---|---|
| committer | Lei YU <mine260309@gmail.com> | 2018-09-19 10:01:45 +0800 |
| commit | 19b37ee2205ff4e772d344fe8a5fcfee2aa0d8ec (patch) | |
| tree | 3ea065555f9e97d63b161c4fa25ebf2aba5eb812 | |
| parent | 1cd4248d4afa664b94411dd57e7e686f944dfafc (diff) | |
| download | phosphor-time-manager-19b37ee2205ff4e772d344fe8a5fcfee2aa0d8ec.tar.gz phosphor-time-manager-19b37ee2205ff4e772d344fe8a5fcfee2aa0d8ec.zip | |
Enable link time optimization
To enable link time optimization, several configures needs to be
changed:
1. Add -flto in Makefiles
2. Use C++17 to get inline constexpr
3. Use gcc-ar and gcc-ranlib to generate static library, otherwise it
gets link errors.
Tested: Build OK and unit tests passes.
Change-Id: Ic58cbfb631c97f43c82d5669cbf6ac1ebc5e0ab9
Signed-off-by: Lei YU <mine260309@gmail.com>
| -rw-r--r-- | Makefile.am | 2 | ||||
| -rw-r--r-- | configure.ac | 6 | ||||
| -rw-r--r-- | test/Makefile.am | 2 |
3 files changed, 7 insertions, 3 deletions
diff --git a/Makefile.am b/Makefile.am index fce04e0..0aadf6c 100644 --- a/Makefile.am +++ b/Makefile.am @@ -19,7 +19,7 @@ phosphor_timemanager_SOURCES = \ phosphor_timemanager_LDADD = libtimemanager.la generic_cxx_flags = $(PHOSPHOR_DBUS_INTERFACES_CFLAGS) \ - $(SDBUSPLUS_CFLAGS) + $(SDBUSPLUS_CFLAGS) -flto generic_ld_flags = $(PHOSPHOR_DBUS_INTERFACES_LIBS) \ $(SDBUSPLUS_LIBS) diff --git a/configure.ac b/configure.ac index 2680788..7e7d28c 100644 --- a/configure.ac +++ b/configure.ac @@ -6,6 +6,10 @@ AC_CONFIG_HEADERS([config.h]) AM_INIT_AUTOMAKE([subdir-objects -Wall -Werror foreign dist-xz]) AM_SILENT_RULES([yes]) +# Use gcc-ar and gcc-ranlib for static libraries built with -flto +AC_SUBST([AR], [${ac_tool_prefix}gcc-ar]) +AC_SUBST([RANLIB], [${ac_tool_prefix}gcc-ranlib]) + # Checks for programs AC_PROG_CXX AM_PROG_AR @@ -53,7 +57,7 @@ AC_PATH_PROG([SDBUSPLUSPLUS], [sdbus++]) AS_IF([test "x$SDBUSPLUSPLUS" == "x"], AC_MSG_ERROR([Cannot find sdbus++])) # Checks for typedefs, structures, and compiler characteristics. -AX_CXX_COMPILE_STDCXX_14([noext]) +AX_CXX_COMPILE_STDCXX_17([noext]) AX_APPEND_COMPILE_FLAGS([-fpic -Wall -Werror], [CXXFLAGS]) # DBUS interface diff --git a/test/Makefile.am b/test/Makefile.am index 0c14421..a8cd3b7 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -21,7 +21,7 @@ test_CPPFLAGS = $(GTEST_CPPFLAGS) \ test_CXXFLAGS = $(PTHREAD_CFLAGS) \ $(PHOSPHOR_DBUS_INTERFACES_CFLAGS) \ - $(SDBUSPLUS_CFLAGS) + $(SDBUSPLUS_CFLAGS) -flto test_LDFLAGS = $(GMOCK_LIBS) \ $(GTEST_MAIN_LIBS) \ |

