mirror of
https://github.com/jimeh/build-emacs-for-macos.git
synced 2026-02-19 13:06:38 +00:00
Replace the launcher script with a emacs-lisp patch to `comp.el` which sets the `LIBRARY_PATH` environment variable to point at the embedded GCC/libgccjit. This fixes issues related to the launcher script on macOS 10.15 and later. Fixes #14 BREAKING CHANGE: `--[no-]launcher` option is deprecated, as launcher script is no longer used.
42 lines
1.7 KiB
Diff
42 lines
1.7 KiB
Diff
diff --git a/lisp/emacs-lisp/comp.el b/lisp/emacs-lisp/comp.el
|
|
index 25e2de9..14ee6dc 100644
|
|
--- a/lisp/emacs-lisp/comp.el
|
|
+++ b/lisp/emacs-lisp/comp.el
|
|
@@ -2801,6 +2801,36 @@ queued with LOAD %"
|
|
(comp-run-async-workers)
|
|
(message "Compilation started."))))
|
|
|
|
+;;;###autoload
|
|
+(defun native-compile-setup-environment-variables (&rest _args)
|
|
+ "Ensure LIBRARY_PATH is set correctly when libgccjit is bundled."
|
|
+ (when (and (eq system-type 'darwin)
|
|
+ (string-match-p "\.app\/Contents\/MacOS\/?$"
|
|
+ invocation-directory))
|
|
+ (let* ((library-path-env (getenv "LIBRARY_PATH"))
|
|
+ (gcc-dir (car (file-expand-wildcards
|
|
+ (concat invocation-directory "lib-*/gcc/*"))))
|
|
+ (gcc-darwin-dir (car (file-expand-wildcards
|
|
+ (concat gcc-dir "/gcc/*apple-darwin*/*"))))
|
|
+ (lib-paths (append
|
|
+ (list gcc-dir gcc-darwin-dir)
|
|
+ (if library-path-env (list library-path-env) (list)))))
|
|
+
|
|
+ (when (and gcc-dir gcc-darwin-dir)
|
|
+ (setenv "LIBRARY_PATH" (mapconcat 'identity lib-paths ":")))))
|
|
+
|
|
+ ;; Remove advice, as it only needs to run once.
|
|
+ (advice-remove 'native-compile
|
|
+ 'native-compile-setup-environment-variables)
|
|
+ (advice-remove 'native-compile-async
|
|
+ 'native-compile-setup-environment-variables))
|
|
+
|
|
+;; Ensure environment setup runs before any native compilation.
|
|
+(advice-add 'native-compile :before
|
|
+ 'native-compile-setup-environment-variables)
|
|
+(advice-add 'native-compile-async :before
|
|
+ 'native-compile-setup-environment-variables)
|
|
+
|
|
(provide 'comp)
|
|
|
|
;;; comp.el ends here
|