From a306d0397427870afea584233942e40cd78d16f7 Mon Sep 17 00:00:00 2001
From: Paul Eggert <eggert@cs.ucla.edu>
Date: Sat, 20 Jan 2018 19:12:05 -0800
Subject: [PATCH] Fix tempfile creation when byte compiling

This improves on the recent fix for master failing to build
on FreeBSD.  Suggested by Stefan Monnier in:
https://lists.gnu.org/r/emacs-devel/2018-01/msg00600.html
* lisp/emacs-lisp/bytecomp.el (byte-compile-file):
Put tempfile next to the target file, as was the original intent.

(cherry picked from commit 64c846738617d1d037eac0cefb6586c04317b0a1)
---
 lisp/emacs-lisp/bytecomp.el | 12 +-----------
 1 file changed, 1 insertion(+), 11 deletions(-)

diff --git a/lisp/emacs-lisp/bytecomp.el b/lisp/emacs-lisp/bytecomp.el
index 68e2fd1d104..bc65f2cfaf0 100644
--- a/lisp/emacs-lisp/bytecomp.el
+++ b/lisp/emacs-lisp/bytecomp.el
@@ -1938,17 +1938,7 @@ The value is non-nil if there were no errors, nil if errors."
 		       ;; parallel bootstrap), it does not risk getting a
 		       ;; half-finished file.  (Bug#4196)
 		       (tempfile
-                        (if (file-name-absolute-p target-file)
-                            (make-temp-file target-file)
-                          ;; If target-file is relative and includes
-                          ;; leading directories, make-temp-file will
-                          ;; assume those leading directories exist
-                          ;; under temporary-file-directory, which might
-                          ;; not be true.  So strip leading directories
-                          ;; from relative file names before calling
-                          ;; make-temp-file.
-                          (make-temp-file
-                           (file-name-nondirectory target-file))))
+			(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))
-- 
2.39.5