From: Maria Matejka Date: Mon, 2 Sep 2024 13:38:01 +0000 (+0200) Subject: Enabled LTO for LLVM and making use of jobserver for LTO in GCC X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=08acdc93641d840a8114d53ecba19a0d833a3b96;p=thirdparty%2Fbird.git Enabled LTO for LLVM and making use of jobserver for LTO in GCC --- diff --git a/Makefile.in b/Makefile.in index 839efe243..6f01dd164 100644 --- a/Makefile.in +++ b/Makefile.in @@ -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) diff --git a/aclocal.m4 b/aclocal.m4 index 9884811da..dd5cca359 100644 --- a/aclocal.m4 +++ b/aclocal.m4 @@ -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__; ], []) ], @@ -258,8 +258,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], diff --git a/configure.ac b/configure.ac index ae7b9467d..a5f06c510 100644 --- a/configure.ac +++ b/configure.ac @@ -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