Skip to content

Commit c669536

Browse files
committed
Adds a --enable-lto option (Link Time Optimization)
1 parent b3f30ef commit c669536

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

configure.ac

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,17 @@ AC_ARG_ENABLE([tsan],
233233
)
234234
AC_MSG_RESULT([$enable_tsan])
235235

236+
#
237+
# Enable Link Time Optimization. This may need different settings per compiler?
238+
#
239+
AC_MSG_CHECKING([whether to enable LTO])
240+
AC_ARG_ENABLE([lto],
241+
[AS_HELP_STRING([--enable-lto],[turn on Link Time Optomization])],
242+
[],
243+
[enable_lto=no]
244+
)
245+
AC_MSG_RESULT([$enable_lto])
246+
236247
#
237248
# Fast SDK APIs, this disables the parameter checks (assert)
238249
# on all APIs.
@@ -938,6 +949,13 @@ AS_IF([test x"$enable_werror" = "xyes"], [
938949
TS_ADDTO(debug_opt, -Werror)
939950
])
940951

952+
# Add the necessary flags for LTO, but only for release builds
953+
AS_IF([test x"$enable_lto" = "xyes"], [
954+
TS_ADDTO(AM_CXXFLAGS, "-flto")
955+
TS_ADDTO(AM_CFLAGS, "-flto")
956+
TS_ADDTO(AM_LDFLAGS, "-flto")
957+
])
958+
941959
cc_oflag_opt=$release_opt
942960
cc_oflag_dbg=$debug_opt
943961
cxx_oflag_opt="$release_opt $cxx_opt $cxx_rel"

0 commit comments

Comments
 (0)