[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] Add the --jobserver option for GCC -flto=jobserver
From: |
H.J. Lu |
Subject: |
[PATCH] Add the --jobserver option for GCC -flto=jobserver |
Date: |
Tue, 27 Oct 2020 16:34:13 -0700 |
From
https://lists.gnu.org/archive/html/automake/2020-02/msg00012.html
GCC introduced some time ago option -flto=jobserver in order to use the
GNU Make jobserver when parallelising LTO builds. It is actually a
similar "recursive make". When doing a recursive make, you need to
place a '+' character at the beginning of the recipe line in order to
let GNU Make pass the jobserver file descriptors to the child processes.
Add the --jobserver option to add a '+' character to the recipe line in
program.am and ltlibrary.am.
---
NEWS | 2 ++
bin/automake.in | 6 ++++++
doc/automake.texi | 5 +++++
lib/am/ltlibrary.am | 2 +-
lib/am/program.am | 2 +-
t/jobserver.sh | 40 ++++++++++++++++++++++++++++++++++++++++
t/list-of-tests.mk | 1 +
7 files changed, 56 insertions(+), 2 deletions(-)
create mode 100644 t/jobserver.sh
diff --git a/NEWS b/NEWS
index fa35bf120..f2ec656ea 100644
--- a/NEWS
+++ b/NEWS
@@ -66,6 +66,8 @@ New in ?.?.?:
* New features added
+ - Add the --jobserver option to support GCC -flto=jobserver.
+
- In the testsuite summary, the "for $(PACKAGE_STRING)" suffix
can be overridden with the AM_TESTSUITE_SUMMARY_HEADER variable.
diff --git a/bin/automake.in b/bin/automake.in
index a88b835a5..a7aa57999 100644
--- a/bin/automake.in
+++ b/bin/automake.in
@@ -268,6 +268,9 @@ use constant QUEUE_STRING => "string";
# TRUE if we should always generate Makefile.in.
my $force_generation = 1;
+# TRUE if we should enable GNU make jobserver in Makefile.in.
+my $enable_jobserver = "";
+
# From the Perl manual.
my $symlink_exists = (eval 'symlink ("", "");', $@ eq '');
@@ -6814,6 +6817,7 @@ sub preprocess_file
'LIBTOOL' => !! var ('LIBTOOL'),
'NONLIBTOOL' => 1,
+ 'JOBSERVER' => $enable_jobserver,
%transform);
if (! defined ($_ = $am_file_cache{$file}))
@@ -8100,6 +8104,7 @@ Operation modes:
--version print version number, then exit
-v, --verbose verbosely list files processed
--no-force only update Makefile.in's that are out of date
+ --jobserver enable GNU make jobserver
-W, --warnings=CATEGORY report the warnings falling in CATEGORY
Dependency tracking:
@@ -8176,6 +8181,7 @@ sub parse_arguments ()
'include-deps' => sub { $ignore_deps = 0; },
'i|ignore-deps' => sub { $ignore_deps = 1; },
'no-force' => sub { $force_generation = 0; },
+ 'jobserver' => sub { $enable_jobserver = '+ '; },
'f|force-missing' => \$force_missing,
'a|add-missing' => \$add_missing,
'c|copy' => \$copy_missing,
diff --git a/doc/automake.texi b/doc/automake.texi
index ed7e2e242..84423e6f1 100644
--- a/doc/automake.texi
+++ b/doc/automake.texi
@@ -2719,6 +2719,11 @@ This enables the dependency tracking feature. This
feature is enabled
by default. This option is provided for historical reasons only and
probably should not be used.
+@item --jobserver
+@opindex --jobserver
+This enables the GNU make jobserver feature support for GCC
+-flto=jobserver option.
+
@item --no-force
@opindex --no-force
Ordinarily @command{automake} creates all @file{Makefile.in}s mentioned in
diff --git a/lib/am/ltlibrary.am b/lib/am/ltlibrary.am
index 5e5f6ca5b..d8cf2665b 100644
--- a/lib/am/ltlibrary.am
+++ b/lib/am/ltlibrary.am
@@ -15,4 +15,4 @@
## along with this program. If not, see <https://www.gnu.org/licenses/>.
%LTLIBRARY%: $(%XLTLIBRARY%_OBJECTS) $(%XLTLIBRARY%_DEPENDENCIES)
$(EXTRA_%XLTLIBRARY%_DEPENDENCIES) %DIRSTAMP%
- %VERBOSE%$(%XLINK%) %RPATH% $(%XLTLIBRARY%_OBJECTS)
$(%XLTLIBRARY%_LIBADD) $(LIBS)
+ %JOBSERVER%%VERBOSE%$(%XLINK%) %RPATH% $(%XLTLIBRARY%_OBJECTS)
$(%XLTLIBRARY%_LIBADD) $(LIBS)
diff --git a/lib/am/program.am b/lib/am/program.am
index 9a243b399..4df9cbeee 100644
--- a/lib/am/program.am
+++ b/lib/am/program.am
@@ -21,4 +21,4 @@
## Or maybe not... sadly, incremental linkers are rarer than losing
## systems.
@rm -f %PROGRAM%%EXEEXT%
- %VERBOSE%$(%XLINK%) $(%XPROGRAM%_OBJECTS) $(%XPROGRAM%_LDADD) $(LIBS)
+ %JOBSERVER%%VERBOSE%$(%XLINK%) $(%XPROGRAM%_OBJECTS)
$(%XPROGRAM%_LDADD) $(LIBS)
diff --git a/t/jobserver.sh b/t/jobserver.sh
new file mode 100644
index 000000000..cd4cfc44c
--- /dev/null
+++ b/t/jobserver.sh
@@ -0,0 +1,40 @@
+#! /bin/sh
+# Copyright (C) 2020 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <https://www.gnu.org/licenses/>.
+
+# Test GNU make jobserver support.
+
+required='GNUmake gcc'
+. test-init.sh
+
+cat >> configure.ac <<'END'
+AC_PROG_CC
+AC_OUTPUT
+END
+
+echo bin_PROGRAMS = foo > Makefile.am
+echo 'int main (void) { return 0; }' > foo.c
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE --add-missing --jobserver
+./configure
+
+$MAKE foo
+
+# Check for the '+' prefix on the recipe line.
+grep "^ + \$(AM_V_CCLD)" Makefile || exit 1
+
+:
diff --git a/t/list-of-tests.mk b/t/list-of-tests.mk
index f44eed0e5..52424412e 100644
--- a/t/list-of-tests.mk
+++ b/t/list-of-tests.mk
@@ -579,6 +579,7 @@ t/java-noinst.sh \
t/java-rebuild.sh \
t/java-sources.sh \
t/java-uninstall.sh \
+t/jobserver.sh \
t/ldadd.sh \
t/ldflags.sh \
t/lex.sh \
--
2.28.0
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [PATCH] Add the --jobserver option for GCC -flto=jobserver,
H.J. Lu <=