Subject: Re: circular dependencies in elisp files and make

From: Max Nikulin <[email-masked]>
Date: Sat, 13 May 2023 10:08:25 +0700

On 12/05/2023 23:01, Eli Zaretskii wrote:
>> Date: Fri, 12 May 2023 22:26:47 +0700 From: Max Nikulin
>>
>> I expect that
>>
>> emacs -Q --batch -l bytecomp --eval \
>>     "(mapc (lambda (x) (princ (car x) (terpri))) load-history)"
>>
>> gives reasonable approximation to "files necessary to load bytecomp".
>> What should be added to prerequisites besides bytecomp dependencies?
> 
> Anything that bytecomp loads via autoloads while compiling.  Also
> byte-opt and its autoloads, I think.

You are right concerning autoloads, while byte-opt is just one extra 
file in the dependency list. However the same expression evaluated when 
`batch-byte-compile' call finished gives list of dependencies for the 
just created .elc files. Basic statistics based on dependency files may 
provide better approximation which files should be compiled at first to 
achieve faster build. I do not think that complications you described 
are blockers for accurate dependency tracking.

My initial idea was to compile files necessary for byte compilation at 
first and for compilation of "regular" files load components required 
for byte compilation and after that suppress loading of .elc files. What 
can be better is removing all stale .elc file before compiling of 
updates sources. A script iterates over dependency files and deletes 
.elc if any its prerequisite has been updated. Following compilation 
pass can safely use .elc files that are either survived from previous 
build as up to date or just refreshed.