emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] /srv/bzr/emacs/trunk r101412: Close bug#4196.


From: Glenn Morris
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r101412: Close bug#4196.
Date: Sat, 11 Sep 2010 11:52:04 -0700
User-agent: Bazaar (2.0.3)

------------------------------------------------------------
revno: 101412
committer: Glenn Morris <address@hidden>
branch nick: trunk
timestamp: Sat 2010-09-11 11:52:04 -0700
message:
  Close bug#4196.
  * lisp/emacs-lisp/bytecomp.el (byte-compile-file): Create .elc files
  atomically, to avoid parallel build errors.
modified:
  lisp/ChangeLog
  lisp/emacs-lisp/bytecomp.el
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2010-09-11 03:17:02 +0000
+++ b/lisp/ChangeLog    2010-09-11 18:52:04 +0000
@@ -1,3 +1,8 @@
+2010-09-11  Glenn Morris  <address@hidden>
+
+       * emacs-lisp/bytecomp.el (byte-compile-file): Create .elc files
+       atomically, to avoid parallel build errors.  (Bug#4196)
+
 2010-09-11  Michael R. Mauger  <address@hidden>
 
        * progmodes/sql.el: Version 2.6

=== modified file 'lisp/emacs-lisp/bytecomp.el'
--- a/lisp/emacs-lisp/bytecomp.el       2010-09-08 16:02:38 +0000
+++ b/lisp/emacs-lisp/bytecomp.el       2010-09-11 18:52:04 +0000
@@ -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"


reply via email to

[Prev in Thread] Current Thread [Next in Thread]