From: Andrea Corallo Date: Sun, 20 Dec 2020 21:07:48 +0000 (+0100) Subject: Merge remote-tracking branch 'savannah/master' into HEAD X-Git-Tag: emacs-28.0.90~2727^2~258 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=f244c2190259875d095be8508a959a61339263b8;p=emacs.git Merge remote-tracking branch 'savannah/master' into HEAD --- f244c2190259875d095be8508a959a61339263b8 diff --cc lisp/emacs-lisp/bytecomp.el index 02605f3d9f6,7e1a3304cc8..620f15c619d --- a/lisp/emacs-lisp/bytecomp.el +++ b/lisp/emacs-lisp/bytecomp.el @@@ -2013,46 -1965,54 +2018,63 @@@ See also `emacs-lisp-byte-compile-and-l (with-current-buffer output-buffer (goto-char (point-max)) (insert "\n") ; aaah, unix. - (if (or (file-writable-p target-file) - byte-native-compiling) - ;; We must disable any code conversion here. - (progn - (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-file (when (file-writable-p target-file) - (expand-file-name target-file)))) - (default-modes (default-file-modes)) - (temp-modes (logand default-modes #o600)) - (desired-modes (logand default-modes #o666)) - (kill-emacs-hook - (cons (lambda () (ignore-errors - (delete-file tempfile))) - kill-emacs-hook))) - (unless (= temp-modes desired-modes) - (set-file-modes tempfile desired-modes 'nofollow)) - (write-region (point-min) (point-max) tempfile nil 1) - ;; 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. - (if byte-native-compiling - (if byte-native-for-bootstrap - ;; Defer elc final renaming. - (setf byte-to-native-output-file - (cons tempfile target-file)) - (delete-file tempfile)) - (rename-file tempfile target-file t))) - (or noninteractive - byte-native-compiling - (message "Wrote %s" target-file))) + (cond + ((null target-file) nil) ;We only wanted the warnings! - ((and (file-writable-p target-file) ++ ((and (or (file-writable-p target-file) ++ byte-native-compiling) + ;; We attempt to create a temporary file in the + ;; target directory, so the target directory must be + ;; writable. + (file-writable-p + (file-name-directory + ;; Need to expand in case TARGET-FILE doesn't + ;; include a directory (Bug#45287). + (expand-file-name 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-file (expand-file-name target-file))) + (default-modes (default-file-modes)) + (temp-modes (logand default-modes #o600)) + (desired-modes (logand default-modes #o666)) + (kill-emacs-hook + (cons (lambda () (ignore-errors + (delete-file tempfile))) + kill-emacs-hook))) + (unless (= temp-modes desired-modes) + (set-file-modes tempfile desired-modes 'nofollow)) + (write-region (point-min) (point-max) tempfile nil 1) + ;; 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)) - (or noninteractive (message "Wrote %s" target-file))) ++ (if byte-native-compiling ++ (if byte-native-for-bootstrap ++ ;; Defer elc final renaming. ++ (setf byte-to-native-output-file ++ (cons tempfile target-file)) ++ (delete-file tempfile)) ++ (rename-file tempfile target-file t))) ++ (or noninteractive ++ byte-native-compiling ++ (message "Wrote %s" target-file))) + ((file-writable-p target-file) + ;; In case the target directory isn't writable (see e.g. Bug#44631), + ;; try writing to the output file directly. We must disable any + ;; code conversion here. + (let ((coding-system-for-write 'no-conversion)) + (with-file-modes (logand (default-file-modes) #o666) + (write-region (point-min) (point-max) target-file nil 1))) + (or noninteractive (message "Wrote %s" target-file))) + (t ;; This is just to give a better error message than write-region (let ((exists (file-exists-p target-file))) (signal (if exists 'file-error 'file-missing)