Subject: Re: bug#48079: Temporary files while building after native-comp merge

From: Stefan Kangas <[email-masked]>
Date: Sun, 2 May 2021 05:12:24 -0500

tags 48079 - patch
thanks

Lars Ingebrigtsen <[email-masked]> writes:

> Stefan Kangas <[email-masked]> writes:
>
>> But perhaps the fix is as simple as:
>>
>> diff --git a/.gitignore b/.gitignore
>> index fcbc9cd7f4..e27ebe36d0 100644
>> --- a/.gitignore
>> +++ b/.gitignore
>> @@ -135,6 +135,7 @@ src/gl-stamp
>>  *.dll
>>  *.core
>>  *.elc
>> +*.elc[0-9A-Za-z][0-9A-Za-z][0-9A-Za-z][0-9A-Za-z][0-9A-Za-z][0-9A-Za-z]
>>  *.eln
>>  *.o
>>  *.res
>
> Sounds like a good idea to me.  (But add a comment about what these
> files are.)

Thanks.

But now I am seeing that some of these files have not been deleted in my
tree:

    lisp/emacs-lisp/comp.elcivrXZS
    lisp/window.elc9aaVMg

This might be because I interrupted the build process at some point; I
don't know.

These files don't get removed when I run extraclean or bootstrap.  So if
we just ignore them there is a risk that these files will slowly build
up over time.

Perhaps we should also make sure they get cleaned up when building, as
in the attached.

Another alternative, arguably more correct, would be to figure out
exactly under which circumstances these files gets left over and delete
them there.  (There is a let-bound `kill-emacs-hook' in
`byte-compile-file', which might be a good place to start looking.)
What makes this a bit tricky is that this is somewhat hard to reproduce.
From 54a57a777968dc5ae12256a661ad2d548cc9bfd0 Mon Sep 17 00:00:00 2001
From: Stefan Kangas <[email-masked]>
Date: Thu, 29 Apr 2021 13:16:13 +0200
Subject: [PATCH] Delete temporary *.elcXXXXXX files created when compiling

* lisp/Makefile.in (compile-clean):
* test/Makefile.in (clean): Delete left-over *.elcXXXXXX files created
when compiling.

* .gitignore: Ignore temporary *.elcXXXXXX files created when
compiling.  (Bug#48079)
---
 .gitignore       | 3 +++
 lisp/Makefile.in | 2 ++
 test/Makefile.in | 2 +-
 3 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/.gitignore b/.gitignore
index fcbc9cd7f4..14882b5353 100644
--- a/.gitignore
+++ b/.gitignore
@@ -148,6 +148,9 @@ oo-spd/
 src/*.map
 vgcore.*[0-9]
 
+# Temporary files when byte-compiling.
+*.elc[0-9A-Za-z][0-9A-Za-z][0-9A-Za-z][0-9A-Za-z][0-9A-Za-z][0-9A-Za-z]
+
 # Tests.
 test/manual/biditest.txt
 test/manual/etags/srclist
diff --git a/lisp/Makefile.in b/lisp/Makefile.in
index b970451dd2..de2c8fcad1 100644
--- a/lisp/Makefile.in
+++ b/lisp/Makefile.in
@@ -345,6 +345,7 @@ compile-main:
 
 .PHONY: compile-clean
 # Erase left-over .elc files that do not have a corresponding .el file.
+# Also erase any left-over temporary files such as "*.elcivrXZS".
 compile-clean:
 	@cd $(lisp) && \
 	elcs=`echo "${SUBDIRS_REL} " | sed -e 's|/\./|/|g' -e 's|/\. | |g' -e 's| |/*.elc |g'`; \
@@ -354,6 +355,7 @@ compile-clean:
 	    rm "$${el}c"; \
 	  fi; \
 	done
+	find $(lisp) -name '*.elc[0-9A-Za-z][0-9A-Za-z][0-9A-Za-z][0-9A-Za-z][0-9A-Za-z][0-9A-Za-z]' $(FIND_DELETE)
 
 .PHONY: gen-lisp leim semantic
 
diff --git a/test/Makefile.in b/test/Makefile.in
index 84ab4e70ae..d04376be56 100644
--- a/test/Makefile.in
+++ b/test/Makefile.in
@@ -339,7 +339,7 @@ mostlyclean:
 	rm -f ./*.tmp
 
 clean:
-	find . '(' -name '*.log' -o -name '*.log~' ')' $(FIND_DELETE)
+	find . '(' -name '*.log' -o -name '*.log~' -o -name '*.elc[0-9A-Za-z][0-9A-Za-z][0-9A-Za-z][0-9A-Za-z][0-9A-Za-z][0-9A-Za-z]' ')' $(FIND_DELETE)
 	rm -f $(test_module_dir)/*.o $(test_module_dir)/*.so \
 	  $(test_module_dir)/*.dll
 
-- 
2.30.2