From 39433d908eaf6467d8a1b0c4f32a43a99f0a7ae0 Mon Sep 17 00:00:00 2001 From: Phil Brown Date: Sun, 30 Jan 2022 14:27:44 -0800 Subject: [PATCH] Fix txt file paths during native-compile-async When building systemd.el with async native compile, we can't rely on `load-file-name`, so fall back to the native relative path lookup performed in `insert-file-contents`. native-compile-async runs compilation in a subprocess launched by loading an elisp program from a temporary file: (native-compile-async "/home/phil/.emacs.d/systemd/systemd.el") => invokes emacs --batch -l /tmp/emacs-async-comp-systemd-BZ3kNs.el Inside the subprocess, `load-file-name` is /tmp/emacs-async-comp-systemd-BZ3kNs.el instead of .../systemd/systemd.el and the local txt resource files (unit-directives.txt etc) aren't resolvable from /tmp. --- systemd.el | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/systemd.el b/systemd.el index 0505868..8aed374 100644 --- a/systemd.el +++ b/systemd.el @@ -88,7 +88,9 @@ (with-temp-buffer (insert-file-contents (let ((f "unit-directives.txt")) - (if (null load-file-name) f + (if (or (null load-file-name) + (bound-and-true-p comp-async-compilation)) + f (expand-file-name f (file-name-directory load-file-name))))) (split-string (buffer-string)))) "Configuration directives for systemd.") @@ -107,7 +109,9 @@ (with-temp-buffer (insert-file-contents (let ((f "network-directives.txt")) - (if (null load-file-name) f + (if (or (null load-file-name) + (bound-and-true-p comp-async-compilation)) + f (expand-file-name f (file-name-directory load-file-name))))) (split-string (buffer-string)))) "Network configuration directives for systemd.") @@ -121,7 +125,9 @@ (with-temp-buffer (insert-file-contents (let ((f "nspawn-directives.txt")) - (if (null load-file-name) f + (if (or (null load-file-name) + (bound-and-true-p comp-async-compilation)) + f (expand-file-name f (file-name-directory load-file-name))))) (split-string (buffer-string)))) "Namespace container configuration directives for systemd.")