unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: Ken Brown <kbrown@cornell.edu>
Cc: Stromeko@nexgo.de, 50666@debbugs.gnu.org, akrl@sdf.org
Subject: bug#50666: 28.0.50; Fix native compilation on Cygwin
Date: Thu, 23 Sep 2021 19:37:31 +0300	[thread overview]
Message-ID: <83bl4juu2c.fsf@gnu.org> (raw)
In-Reply-To: <8e8e74ce-0deb-bcdc-d298-be2e9d4636d7@cornell.edu> (message from Ken Brown on Thu, 23 Sep 2021 10:20:19 -0400)

> Cc: Stromeko@nexgo.de, 50666@debbugs.gnu.org
> From: Ken Brown <kbrown@cornell.edu>
> Date: Thu, 23 Sep 2021 10:20:19 -0400
> 
> > Is it really necessary to rebase the *.eln files before each startup?
> > Isn't it enough to rebase each of the .eln files just once, when it is
> > produced?  If indeed this is needed every time, can you explain why?
> 
> We have to distinguish between system libraries and user libraries.  Libraries 
> installed by Cygwin packages are system libraries.  The *.eln files in 
> ~/.emacs.d/eln-cache are user libraries.  Cygwin maintains a database of all 
> system libraries and their base addresses.  Whenever a Cygwin package is 
> installed or updated, Cygwin rebases all system libraries and updates the database.
> 
> Each time Emacs starts, it has no way of knowing whether the system libraries 
> have been rebased since the last time Emacs was run.  So the user's *.eln files 
> could now have base address conflicts with system libraries.  Rebasing the *.eln 
> files fixes this problem.

What do you mean by "system libraries" here?  Does it, for example,
include the DLLs distributed in the Cygwin port of libpng or libjpeg?
Or does that include only the basic libraries: the Cygwin DLL, the C
runtime, etc.?

> > The non-preloaded *.eln files are all loaded by native-elisp-load, so
> > I guess the rebase should be launched from there?  The preloaded *.eln
> > files are loaded in pdumper.c:dump_do_dump_relocation, but do we need
> > to support non-rebased preloaded *.eln files?
> 
> The preloaded *.eln files will be installed by Cygwin's package manager when 
> emacs is installed.  They are therefore system libraries and are automatically 
> rebased as needed.

If the only problem is with non-preloaded *.eln files, why not rebase
them on the fly, when they are loaded.  That is, run the 'rebase'
command from the native-elisp-load function, before it actually loads
the file.  User libraries are never loaded during startup, only when
some Lisp requires them.

> > When an updated .eln file is produced for .eln that is loaded into
> > some running Emacs, Emacs on Windows renames the original .eln to
> > avoid a similar problem.  
> 
> I hadn't thought of this issue.  We may have to use a similar technique...
> 
> > Can't you use the same technique, to avoid
> > the need of rebasing on each start?
> 
> ...but it wouldn't eliminate the need for rebasing at each start for the reasons 
> explained above.

Perhaps that need could be eliminated after all, see above.

> >  Please note that users could
> > place *.eln files in unusual locations (and customize
> > native-comp-eln-load-path to reflect that), so finding _all_ of the
> > relevant *.eln files from a shell script might not be easy.  In fact,
> > even without customizing the load-path, I don't think I understand how
> > will that script you propose know where to find all the *.eln files.
> 
> The current proposal that Achim and I are looking at would require each user to 
> maintain a file ~/.config/rebase/dynpath.d/emacs containing a list of 
> directories where the .eln files can be found.  By default, this file would 
> contain one line, which is the path to the standard eln-cache directory.  Users 
> who customize native-comp-eln-load-path would have to modify that file accordingly.

That's tough on users, because Emacs by default automatically compiles
every .el file it loads into .eln, if there's no up-to-date .eln file
already, and the compilation runs in the background (by forking
additional Emacs sub-processes that run in batch mode).  In addition,
the native-compilation process sometimes decides that it needs to
create a special "trampoline" .eln file (if you want to know why, I'm
sure Andrea can explain) that correspond to parts of the *.el files.
The upshot is that users may not even be aware that new *.eln files
have been created as part of their session, and may not know their
names.  Unless the automatic rebase process, which runs from
native-elisp-load, will also update the file in dynpath.d, I don't see
how users could maintain such a database by hand in practice.

There's one more aspect that you should be aware of.  A single file
FOO.el could give birth to several different .eln files, for example
if they are compiled by different Emacs binaries and/or from different
source directories and/or from somewhat different versions of FOO.el.
For example, I now have 3 different versions of .eln files
corresponding to window.el, in the same directory:

   window-0d1b8b93-3370bedb.eln
   window-0d1b8b93-7d08b7b4.eln
   window-0d1b8b93-f8fc9683.eln

This makes the job of maintaining the database by hand even harder and
more error-prone.

> Finally, as a side note, I don't think it would be a tragedy if this just turns 
> out to be too complicated and we have to disable native compilation on 32-bit 
> Cygwin.  The Cygwin home page at https://cygwin.com/ already contains the following:
> 
>    Address space is a very limiting factor for Cygwin. These days, a full
>    32 bit Cygwin distro is not feasible anymore, and will in all likelihood
>    fail in random places due to an issue with the fork(2) system call.
> 
>    Therefore we recommend using 32 bit Cygwin only in limited scenarios, with
>    only a minimum of necessary packages installed, and only if there's no way
>    to run 64 bit Cygwin instead.

My point is that maybe we should make that decision already, before
burning too much time and energy on it.  Maybe you should ask on the
Cygwin list whether somebody will object to making 32-bit Cygwin Emacs
a second-class citizen.

Thanks.





  reply	other threads:[~2021-09-23 16:37 UTC|newest]

Thread overview: 51+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-18 20:46 bug#50666: 28.0.50; Fix native compilation on Cygwin Ken Brown
2021-09-18 20:58 ` Ken Brown
2021-09-19  5:37   ` Eli Zaretskii
2021-09-19  7:00     ` ASSI
2021-09-19  7:08       ` Eli Zaretskii
2021-09-19 11:31         ` ASSI
2021-09-19 12:06           ` Eli Zaretskii
2021-09-19 12:37             ` Ken Brown
2021-09-19 13:41               ` Eli Zaretskii
2021-09-19 14:27                 ` Ken Brown
2021-09-19 15:28                   ` Eli Zaretskii
2021-09-19 16:17                     ` Ken Brown
2021-09-19 17:12                       ` Eli Zaretskii
2021-09-22 21:35                         ` Ken Brown
2021-09-23  7:42                           ` Eli Zaretskii
2021-09-23 14:20                             ` Ken Brown
2021-09-23 16:37                               ` Eli Zaretskii [this message]
2021-09-23 17:13                                 ` Ken Brown
2021-09-23 17:29                                   ` Eli Zaretskii
2021-09-23 17:49                                     ` Achim Gratz
2021-09-23 18:01                                       ` Eli Zaretskii
2021-09-23 18:25                                         ` Achim Gratz
2021-09-23 18:46                                           ` Eli Zaretskii
2021-10-28 22:22                                   ` Ken Brown
2021-10-29  5:54                                     ` Eli Zaretskii
2021-10-29 17:03                                       ` Ken Brown
2021-10-29 18:01                                         ` Eli Zaretskii
2021-10-29 18:12                                           ` Ken Brown
2021-10-31 20:22                                             ` Achim Gratz
2021-10-31 23:52                                               ` Ken Brown
2021-09-23 17:27                                 ` Achim Gratz
2021-09-23 17:48                                   ` Eli Zaretskii
2021-09-23 18:29                                     ` Achim Gratz
2021-09-23 18:57                                       ` Eli Zaretskii
2021-09-23 19:37                                       ` Andrea Corallo via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-09-24  6:11                                         ` ASSI
2021-09-24  7:13                                           ` Eli Zaretskii
2021-09-24  7:32                                           ` Andrea Corallo via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-09-24  9:05                                             ` ASSI
2021-09-24 10:48                                             ` Eli Zaretskii
2021-09-25 15:10                                               ` Eli Zaretskii
2021-09-23 19:11                             ` Andrea Corallo via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-09-23 19:21                               ` Eli Zaretskii
2021-09-24  6:04                               ` ASSI
2021-09-24  7:10                                 ` Eli Zaretskii
2021-09-24  7:26                                   ` Andrea Corallo via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-09-24 11:10                                     ` Eli Zaretskii
2021-09-24 12:49                                       ` Andrea Corallo via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-09-24  9:15                                   ` ASSI
2021-09-24 11:03                                     ` Eli Zaretskii
2021-09-19  5:32 ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=83bl4juu2c.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=50666@debbugs.gnu.org \
    --cc=Stromeko@nexgo.de \
    --cc=akrl@sdf.org \
    --cc=kbrown@cornell.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).