* Fixing parallel byte-compilation
@ 2010-09-10 23:51 Glenn Morris
2010-09-10 23:56 ` Chad Brown
` (2 more replies)
0 siblings, 3 replies; 9+ messages in thread
From: Glenn Morris @ 2010-09-10 23:51 UTC (permalink / raw)
To: emacs-devel
Parallel bootstrap sometimes fails if one Emacs process tries to read
an .elc file that another is in the middle of writing. See eg
http://debbugs.gnu.org/cgi/bugreport.cgi?bug=4196
http://debbugs.gnu.org/cgi/bugreport.cgi?bug=6858
and recent mails on this list.
One suggested solution was to compile to a temp-file, then move it in
place. That seems simple to do...?
*** lisp/emacs-lisp/bytecomp.el 2010-09-08 16:02:38 +0000
--- lisp/emacs-lisp/bytecomp.el 2010-09-10 23:42:25 +0000
***************
*** 1698,1714 ****
(insert "\n") ; aaah, unix.
(if (file-writable-p target-file)
;; We must disable any code conversion here.
! (let ((coding-system-for-write 'no-conversion))
(if (memq system-type '(ms-dos 'windows-nt))
(setq buffer-file-type t))
! (when (file-exists-p target-file)
! ;; Remove the target before writing it, so that any
! ;; hard-links continue to point to the old file (this makes
! ;; it possible for installed files to share disk space with
! ;; the build tree, without causing problems when emacs-lisp
! ;; files in the build tree are recompiled).
! (delete-file target-file))
! (write-region (point-min) (point-max) target-file))
;; This is just to give a better error message than write-region
(signal 'file-error
(list "Opening output file"
--- 1698,1720 ----
(insert "\n") ; aaah, unix.
(if (file-writable-p target-file)
;; We must disable any code conversion here.
! (let ((coding-system-for-write 'no-conversion)
! ;; Write to a tempfile so that if another Emacs
! ;; process is trying to load target-file (eg in a
! ;; parallel bootstrap), it does not risk getting a
! ;; half-finished file. (Bug#4196)
! (tempfile (make-temp-name target-file)))
(if (memq system-type '(ms-dos 'windows-nt))
(setq buffer-file-type t))
! ;; The old code used to: delete target-file before
! ;; writing it, so that any hard-links continue to
! ;; point to the old file (this makes it possible
! ;; for installed files to share disk space with
! ;; the build tree, without causing problems when
! ;; emacs-lisp files in the build tree are
! ;; recompiled). Renaming works the same way.
! (write-region (point-min) (point-max) tempfile)
! (rename-file tempfile target-file t))
;; This is just to give a better error message than write-region
(signal 'file-error
(list "Opening output file"
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Fixing parallel byte-compilation
2010-09-10 23:51 Fixing parallel byte-compilation Glenn Morris
@ 2010-09-10 23:56 ` Chad Brown
2010-09-11 0:52 ` Glenn Morris
2010-09-11 10:58 ` Stefan Monnier
2010-09-13 16:33 ` Davis Herring
2 siblings, 1 reply; 9+ messages in thread
From: Chad Brown @ 2010-09-10 23:56 UTC (permalink / raw)
To: Glenn Morris; +Cc: emacs-devel
I'll hazard a guess that this solves the `exact-same-time' problem,
but still leaves dueling emacs builds with potentially incompatible
.elc files if there's a multi-file change, and so it wasn't deemed
worth the trouble. Of course, applying a patch someone already
wrote is less effort, so... :-)
*Chad
On Sep 10, 2010, at 4:51 PM, Glenn Morris wrote:
>
> Parallel bootstrap sometimes fails if one Emacs process tries to read
> an .elc file that another is in the middle of writing. See eg
>
> http://debbugs.gnu.org/cgi/bugreport.cgi?bug=4196
> http://debbugs.gnu.org/cgi/bugreport.cgi?bug=6858
>
> and recent mails on this list.
>
> One suggested solution was to compile to a temp-file, then move it in
> place. That seems simple to do...?
>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Fixing parallel byte-compilation
2010-09-10 23:51 Fixing parallel byte-compilation Glenn Morris
2010-09-10 23:56 ` Chad Brown
@ 2010-09-11 10:58 ` Stefan Monnier
2010-09-11 19:04 ` Glenn Morris
2010-09-13 16:33 ` Davis Herring
2 siblings, 1 reply; 9+ messages in thread
From: Stefan Monnier @ 2010-09-11 10:58 UTC (permalink / raw)
To: Glenn Morris; +Cc: emacs-devel
> One suggested solution was to compile to a temp-file, then move it in
> place. That seems simple to do...?
Thanks, feel free to install it,
Stefan
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Fixing parallel byte-compilation
2010-09-10 23:51 Fixing parallel byte-compilation Glenn Morris
2010-09-10 23:56 ` Chad Brown
2010-09-11 10:58 ` Stefan Monnier
@ 2010-09-13 16:33 ` Davis Herring
2010-09-13 17:10 ` Eli Zaretskii
2 siblings, 1 reply; 9+ messages in thread
From: Davis Herring @ 2010-09-13 16:33 UTC (permalink / raw)
To: Glenn Morris; +Cc: emacs-devel
> ! ;; The old code used to: delete target-file before
> ! ;; writing it, so that any hard-links continue to
> ! ;; point to the old file (this makes it possible
> ! ;; for installed files to share disk space with
> ! ;; the build tree, without causing problems when
> ! ;; emacs-lisp files in the build tree are
> ! ;; recompiled). Renaming works the same way.
> ! (write-region (point-min) (point-max) tempfile)
> ! (rename-file tempfile target-file t))
Does `rename-file' work outside of POSIX (that is, on Windows) if the
target file exists?
Davis
--
This product is sold by volume, not by mass. If it appears too dense or
too sparse, it is because mass-energy conversion has occurred during
shipping.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Fixing parallel byte-compilation
2010-09-13 16:33 ` Davis Herring
@ 2010-09-13 17:10 ` Eli Zaretskii
2010-09-13 18:32 ` Glenn Morris
0 siblings, 1 reply; 9+ messages in thread
From: Eli Zaretskii @ 2010-09-13 17:10 UTC (permalink / raw)
To: herring; +Cc: emacs-devel
> Date: Mon, 13 Sep 2010 09:33:21 -0700 (PDT)
> From: "Davis Herring" <herring@lanl.gov>
> Cc: emacs-devel@gnu.org
>
> > ! ;; The old code used to: delete target-file before
> > ! ;; writing it, so that any hard-links continue to
> > ! ;; point to the old file (this makes it possible
> > ! ;; for installed files to share disk space with
> > ! ;; the build tree, without causing problems when
> > ! ;; emacs-lisp files in the build tree are
> > ! ;; recompiled). Renaming works the same way.
> > ! (write-region (point-min) (point-max) tempfile)
> > ! (rename-file tempfile target-file t))
>
> Does `rename-file' work outside of POSIX (that is, on Windows) if the
> target file exists?
Not for free, but it does. Windows has sys_rename, which see in
w32.c, while the DOS build uses a standard C library whose `rename'
does that under the hood.
Of course, this could still fail if the target is open by some other
program, but the old code uses delete-file which would fail in that
case as well. So we didn't make the situation worse than it was
already.
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2010-09-13 18:32 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-09-10 23:51 Fixing parallel byte-compilation Glenn Morris
2010-09-10 23:56 ` Chad Brown
2010-09-11 0:52 ` Glenn Morris
2010-09-11 10:58 ` Stefan Monnier
2010-09-11 19:04 ` Glenn Morris
2010-09-12 9:50 ` Stefan Monnier
2010-09-13 16:33 ` Davis Herring
2010-09-13 17:10 ` Eli Zaretskii
2010-09-13 18:32 ` Glenn Morris
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).