0
0
mirror of https://gitlab.nic.cz/labs/bird.git synced 2024-12-22 09:41:54 +00:00

Enabled LTO for LLVM and making use of jobserver for LTO in GCC

This commit is contained in:
Maria Matejka 2024-09-02 15:38:01 +02:00
parent f534543733
commit 6f67e47ad5
3 changed files with 16 additions and 8 deletions

View File

@ -158,7 +158,7 @@ $(objdir)/.dir-stamp: Makefile
$(client) $(daemon):
$(E)echo LD $(LDFLAGS) -o $@ $^ $(LIBS)
$(Q)$(CC) $(LDFLAGS) -o $@ $^ $(LIBS)
+$(Q)$(CC) $(LDFLAGS) -o $@ $^ $(LIBS)
$(objdir)/sysdep/paths.h: Makefile
$(E)echo GEN $@
@ -173,7 +173,7 @@ tests_targets_ok = $(addsuffix .ok,$(tests_targets))
$(tests_targets): %: %.o $(tests_objs) | prepare
$(E)echo LD $(LDFLAGS) -o $@ $< "..." $(LIBS)
$(Q)$(CC) $(LDFLAGS) -o $@ $^ $(LIBS)
+$(Q)$(CC) $(LDFLAGS) -o $@ $^ $(LIBS)
# Hack to avoid problems with tests linking everything
$(tests_targets): LIBS += $(DAEMON_LIBS)

6
aclocal.m4 vendored
View File

@ -11,7 +11,7 @@ AC_DEFUN([BIRD_COMPILER_VENDOR],
AC_COMPILE_IFELSE([
AC_LANG_PROGRAM([ int x = __clang__; ], [])
],
[bird_cv_compiler_vendor=clang],
[bird_cv_compiler_vendor=llvm],
AC_COMPILE_IFELSE([
AC_LANG_PROGRAM([ int x = __GNUC__; ], [])
],
@ -234,8 +234,8 @@ AC_DEFUN([BIRD_CHECK_LTO],
[
bird_tmp_cflags="$CFLAGS"
bird_tmp_ldflags="$LDFLAGS"
CFLAGS="-flto"
LDFLAGS="-flto=4"
CFLAGS="$1"
LDFLAGS="$2"
AC_CACHE_CHECK(
[whether link time optimizer is available],

View File

@ -124,6 +124,8 @@ if test -z "$GCC" ; then
AC_MSG_ERROR([This program requires the GNU C Compiler.])
fi
BIRD_COMPILER_VENDOR
BIRD_CHECK_THREAD_LOCAL
if test "$bird_cv_thread_local" = no ; then
AC_MSG_ERROR([This program requires thread local storage.])
@ -149,12 +151,18 @@ if test "$bird_cflags_default" = yes ; then
BIRD_CHECK_GCC_OPTION([bird_cv_c_option_watomic_implicit_seq_cst], [-Watomic-implicit-seq-cst], [-Wall -Wextra])
if test "$enable_debug" = no; then
BIRD_CHECK_LTO
LTO_CFLAGS=-flto
AS_CASE(${bird_cv_compiler_vendor},
gnu,LTO_LDFLAGS="-flto=jobserver",
llvm,LTO_LDFLAGS="-flto",
unknown,LTO_LDFLAGS="-flto",
AC_MSG_ERROR([Compiler vendor check failed for LTO: got ${bird_cv_compiler_vendor}]))
BIRD_CHECK_LTO(${LTO_CFLAGS}, ${LTO_LDFLAGS})
fi
if test "$bird_cv_c_lto" = yes; then
CFLAGS="$CFLAGS -flto"
LDFLAGS="$LDFLAGS -flto=4 -g"
CFLAGS="$CFLAGS $LTO_CFLAGS"
LDFLAGS="$LDFLAGS $LTO_LDFLAGS -g"
else
LDFLAGS="$LDFLAGS -g"
fi