Subject: bug#16107: changing load-path during dumping

From: Glenn Morris <[email-masked]>
Date: Tue, 10 Dec 2013 19:57:46 -0500

Package: emacs
Version: 24.3

Quoth the elisp manual:

    Dumping Emacs uses a special value of `load-path'. If the value of
    `load-path' at the end of dumping is unchanged (that is, still the
    same special value), the dumped Emacs switches to the ordinary
    `load-path' value when it starts up, as described above. But if
    `load-path' has any other value at the end of dumping, that value is
    used for execution of the dumped Emacs also.

I think this behaviour does not make sense, and that it would be better
to remove it. Motivation:

AFAICS, the only way load-path can change during dumping is if you
change it in a site-load/site-init file. The only thing that you might
sensibly want to do is add an element at the front. Firstly, there is a
better way to do this: use configure's --enable-locallisppath argument.

Secondly, it will break your Emacs. Dumping occurs before Emacs is
installed, so dump_path contains elements that refers to the *source*
directory (ie, PATH_DUMPLOADSEARCH). Your addition gets added to these
elements. After `make install', Emacs normally switches to a load-path
based on the *installation* directory (ie, PATH_LOADSEARCH). If it
notices that the load-path has changed from dump_path, it won't do this.
So if you run `make install' and delete the source directory, your Emacs
won't start, because it will still be looking for source/lisp.

(IIRC, the uninstalled Emacs used to have a load-path that also
contained the installation directories if they existed. This was wrong
and has been removed, but it does mean that changing load-path during
dumping probably did not use to break your Emacs. But
--enable-locallisppath is better anyway.)

So I suggest:
1) In src/lread.c, removing "dump_path" and associated code.

2) In loadup.el, if load-path changes during the loading of
site-load/site-init, print a warning that the changes will be ignored in
the dumped Emacs, and recommending use of --enable-locallisppath if the
changes were intended to be permanent.

Any objections?