# HG changeset patch # User Glenn Morris # Date 1284231124 25200 # Node ID 6388b1d1793a43578ea0aa8c2f5f85659ebe95c6 # Parent 9b5623e06689888a0b5cab3d47b7ebf73a365352 Close bug#4196. * lisp/emacs-lisp/bytecomp.el (byte-compile-file): Create .elc files atomically, to avoid parallel build errors. diff -r 9b5623e06689 -r 6388b1d1793a lisp/ChangeLog --- a/lisp/ChangeLog Sat Sep 11 15:58:57 2010 +0200 +++ b/lisp/ChangeLog Sat Sep 11 11:52:04 2010 -0700 @@ -1,3 +1,8 @@ +2010-09-11 Glenn Morris + + * emacs-lisp/bytecomp.el (byte-compile-file): Create .elc files + atomically, to avoid parallel build errors. (Bug#4196) + 2010-09-11 Michael R. Mauger * progmodes/sql.el: Version 2.6 diff -r 9b5623e06689 -r 6388b1d1793a lisp/emacs-lisp/bytecomp.el --- a/lisp/emacs-lisp/bytecomp.el Sat Sep 11 15:58:57 2010 +0200 +++ b/lisp/emacs-lisp/bytecomp.el Sat Sep 11 11:52:04 2010 -0700 @@ -1698,17 +1698,24 @@ (insert "\n") ; aaah, unix. (if (file-writable-p target-file) ;; We must disable any code conversion here. - (let ((coding-system-for-write 'no-conversion)) + (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)) - (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)) + (write-region (point-min) (point-max) tempfile) + ;; This has the intentional side effect that any + ;; hard-links to target-file 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). Previously this was accomplished by + ;; deleting target-file before writing it. + (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"