unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* 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

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).