]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
Enabled LTO for LLVM and making use of jobserver for LTO in GCC
authorMaria Matejka <mq@ucw.cz>
Mon, 2 Sep 2024 13:38:01 +0000 (15:38 +0200)
committerMaria Matejka <mq@ucw.cz>
Fri, 14 Mar 2025 19:43:10 +0000 (20:43 +0100)
Makefile.in
aclocal.m4
configure.ac

index 839efe2438fb21fbd89d230a64bc10ec7e53c264..6f01dd164a1358848bd8b04629a453bc3ca89ca8 100644 (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)
index 9884811da86b412128d974299964ac5c1a0c08c8..dd5cca359662338f3025d2d0d617aa33f334aa79 100644 (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__; ], [])
     ],
@@ -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],
index f34275ac569f900065d39cb6140bcabf286d5db3..228936f51233d40bc551bb9d9f2722c62fd105a9 100644 (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.])
@@ -150,12 +152,18 @@ if test "$bird_cflags_default" = yes ; then
   BIRD_CHECK_GCC_OPTION([bird_cv_c_option_werror_implicit_function_declaration], [-Werror=implicit-function-declaration], [-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