]> git.eshelyaron.com Git - emacs.git/commitdiff
Close bug#4196.
authorGlenn Morris <rgm@gnu.org>
Sat, 11 Sep 2010 18:52:04 +0000 (11:52 -0700)
committerGlenn Morris <rgm@gnu.org>
Sat, 11 Sep 2010 18:52:04 +0000 (11:52 -0700)
* lisp/emacs-lisp/bytecomp.el (byte-compile-file): Create .elc files
atomically, to avoid parallel build errors.

lisp/ChangeLog
lisp/emacs-lisp/bytecomp.el

index c47a458f2f7948b55ff076b4f5e0ac61aa88f891..1088bf432c444708ee1b6123cac6a53822e2de45 100644 (file)
@@ -1,3 +1,8 @@
+2010-09-11  Glenn Morris  <rgm@gnu.org>
+
+       * emacs-lisp/bytecomp.el (byte-compile-file): Create .elc files
+       atomically, to avoid parallel build errors.  (Bug#4196)
+
 2010-09-11  Michael R. Mauger  <mmaug@yahoo.com>
 
        * progmodes/sql.el: Version 2.6
index cb1deb9a762fc86e1dd6f47bbc4133529ee4e39e..04bc254b319f688bf7e0cbc562519d8a93f85433 100644 (file)
@@ -1698,17 +1698,24 @@ The value is non-nil if there were no errors, nil if errors."
          (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"