From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Alan Mackenzie Newsgroups: gmane.emacs.devel Subject: Re: Speeding up the bootstrap build - a quick hack. Date: Thu, 20 Jan 2022 11:35:17 +0000 Message-ID: References: <83pmopunzl.fsf@gnu.org> <83y23cu9bl.fsf@gnu.org> <835yqgt0bf.fsf@gnu.org> <835yqfsln1.fsf@gnu.org> <87fspilpx5.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="33526"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Eli Zaretskii , monnier@iro.umontreal.ca, emacs-devel@gnu.org To: Robert Pluim Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Thu Jan 20 16:23:58 2022 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nAZI5-0008Rb-RH for ged-emacs-devel@m.gmane-mx.org; Thu, 20 Jan 2022 16:23:57 +0100 Original-Received: from localhost ([::1]:60388 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nAZI4-0006HC-M2 for ged-emacs-devel@m.gmane-mx.org; Thu, 20 Jan 2022 10:23:56 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:55578) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nAVjN-00077K-7i for emacs-devel@gnu.org; Thu, 20 Jan 2022 06:35:54 -0500 Original-Received: from colin.muc.de ([193.149.48.1]:40533 helo=mail.muc.de) by eggs.gnu.org with smtp (Exim 4.90_1) (envelope-from ) id 1nAViz-00005B-Ta for emacs-devel@gnu.org; Thu, 20 Jan 2022 06:35:40 -0500 Original-Received: (qmail 63316 invoked by uid 3782); 20 Jan 2022 11:35:18 -0000 Original-Received: from acm.muc.de (p4fe15859.dip0.t-ipconnect.de [79.225.88.89]) (using STARTTLS) by colin.muc.de (tmda-ofmipd) with ESMTP; Thu, 20 Jan 2022 12:35:17 +0100 Original-Received: (qmail 20520 invoked by uid 1000); 20 Jan 2022 11:35:17 -0000 Content-Disposition: inline In-Reply-To: <87fspilpx5.fsf@gmail.com> X-Submission-Agent: TMDA/1.3.x (Ph3nix) X-Primary-Address: acm@muc.de Received-SPF: pass client-ip=193.149.48.1; envelope-from=acm@muc.de; helo=mail.muc.de X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:285042 Archived-At: Hello, Robert. On Thu, Jan 20, 2022 at 10:25:26 +0100, Robert Pluim wrote: > >>>>> On Wed, 19 Jan 2022 21:32:30 +0000, Alan Mackenzie said: > Alan> This was surprisingly difficult to solve. There appears to be no way in > Alan> make to set a variable depending on what the target is. The make manual > Alan> doesn't say this explicitly, it just depends on vagueness. After an hour > Alan> of searching for such a feature, it gradually dawns on you that there is > Alan> no such feature, even though one might be expected. I'm glad the Emacs > Alan> manuals aren't like that. > "Target-specific Variable Values" in the Gnu Make info manual. eg > Makefile: > FOO=bar > default: > @echo FOO=$(FOO) > foo: FOO=foo > foo: > @echo FOO=$(FOO) > results: > > make > FOO=bar > > make foo > FOO=foo Thank you indeed. That's exactly what I needed. I've amended my patch to use this. So, if there are no objections, I'll be committing the following to master within the next day or so: In early bootstrap, use byte-compiled compiler to native compile first files This speeds up a make bootstrap by around 15%. * lisp/Makefile.in (BYTE_COMPILE_FLAGS): set a value specific to compile-first which doesn't contain the setting of Emacs variable load-prefer-newer. Add a new make hunk which byte-compiles (rather then native compiles) when the environment variable ANCIENT is "yes". Set the date of the .elc files built to 1970-01-01 to cause a second compilation of them later. * src/Makefile.in: Add an extra invocation of directory lisp's MAKE with target compile-first and the flag environment variable ANCIENT set to yes. * src/verbose.mk.in: When ANCIENT is yes, output ELC, not ELC+ELN for AM_V_ELC. diff --git a/lisp/Makefile.in b/lisp/Makefile.in index 3a72034463..3d03b16331 100644 --- a/lisp/Makefile.in +++ b/lisp/Makefile.in @@ -77,6 +77,8 @@ AUTOGENEL = # Set load-prefer-newer for the benefit of the non-bootstrappers. BYTE_COMPILE_FLAGS = \ --eval '(setq load-prefer-newer t)' $(BYTE_COMPILE_EXTRA_FLAGS) +# ... but we must prefer .elc files for those in the early bootstrap. +compile-first: BYTE_COMPILE_FLAGS = $(BYTE_COMPILE_EXTRA_FLAGS) # Files to compile before others during a bootstrap. This is done to # speed up the bootstrap process. They're ordered by size, so we use @@ -303,9 +305,22 @@ .SUFFIXES: # An old-fashioned suffix rule, which, according to the GNU Make manual, # cannot have prerequisites. ifeq ($(HAVE_NATIVE_COMP),yes) +ifeq ($(ANCIENT),yes) +# The first compilation of compile-first, using an interpreted compiler: +# The resulting .elc files get given a date of 1970-01-01 so that their +# date stamp is earlier than the source files, causing these to be compiled +# into native code at the second recursive invocation of this $(MAKE), +# using these .elc's. This is faster than just compiling the native code +# directly using the interpreted compile-first files. +.el.elc: + $(AM_V_ELC)$(emacs) $(BYTE_COMPILE_FLAGS) \ + -l comp -f batch-byte-compile $< + touch -t 197001010000 $@ +else .el.elc: $(AM_V_ELC)$(emacs) $(BYTE_COMPILE_FLAGS) \ -l comp -f batch-byte+native-compile $< +endif else .el.elc: $(AM_V_ELC)$(emacs) $(BYTE_COMPILE_FLAGS) -f batch-byte-compile $< diff --git a/src/Makefile.in b/src/Makefile.in index 04fabd5f42..13392bfad6 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -914,6 +914,9 @@ $(bootstrap_pdmp): $(RUN_TEMACS) --batch $(BUILD_DETAILS) -l loadup --temacs=pbootstrap \ --bin-dest $(BIN_DESTDIR) --eln-dest $(ELN_DESTDIR) @: Compile some files earlier to speed up further compilation. + @: First, byte compile these files, .... + ANCIENT=yes $(MAKE) -C ../lisp compile-first EMACS="$(bootstrap_exe)" + @: .... then use their .elcs in native compiling these and other files. $(MAKE) -C ../lisp compile-first EMACS="$(bootstrap_exe)" endif diff --git a/src/verbose.mk.in b/src/verbose.mk.in index e3f5678303..01076df946 100644 --- a/src/verbose.mk.in +++ b/src/verbose.mk.in @@ -40,12 +40,17 @@ AM_V_CXX = @$(info $ CXX $@) AM_V_CCLD = @$(info $ CCLD $@) AM_V_CXXLD = @$(info $ CXXLD $@) ifeq ($(HAVE_NATIVE_COMP),yes) -ifeq ($(NATIVE_DISABLED),1) +ifneq ($(NATIVE_DISABLED),1) +ifneq ($(ANCIENT),yes) +AM_V_ELC = @$(info $ ELC+ELN $@) +AM_V_ELN = @$(info $ ELN $@) +else AM_V_ELC = @$(info $ ELC $@) AM_V_ELN = +endif else -AM_V_ELC = @$(info $ ELC+ELN $@) -AM_V_ELN = @$(info $ ELN $@) +AM_V_ELC = @$(info $ ELC $@) +AM_V_ELN = endif else AM_V_ELC = @$(info $ ELC $@) > Robert > -- -- Alan Mackenzie (Nuremberg, Germany).