mirror of
https://github.com/jimeh/build-emacs-for-macos.git
synced 2026-02-19 10:46:39 +00:00
Apple's codesign CLI toolthrows a "bundle format unrecognized" error if there are any folders within the application that contain two dots in their name. Hence we need to get rid of the one instance of that we end up with from GCC, and update the native-comp patch accordingly. As of writing, this means renaming: Emacs.app/Contents/MacOS/lib/gcc/11/gcc/x86_64-apple-darwin20/11.1.0 To: Emacs.app/Contents/MacOS/lib/gcc/11/gcc/x86_64-apple-darwin20/11
58 lines
2.4 KiB
Plaintext
58 lines
2.4 KiB
Plaintext
diff --git a/lisp/emacs-lisp/comp.el b/lisp/emacs-lisp/comp.el
|
|
index 8c638312b0..87af889ef4 100644
|
|
--- a/lisp/emacs-lisp/comp.el
|
|
+++ b/lisp/emacs-lisp/comp.el
|
|
@@ -4215,6 +4215,52 @@ native-compile-async
|
|
(let ((load (not (not load))))
|
|
(native--compile-async files recursively load selector)))
|
|
|
|
+;;;###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"))
|
|
+ (devtools-dir
|
|
+ "/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib")
|
|
+ (gcc-dir (expand-file-name
|
|
+ "<%= relative_lib_dir %>"
|
|
+ invocation-directory))
|
|
+ (darwin-dir (expand-file-name
|
|
+ "<%= sanitized_relative_darwin_lib_dir %>"
|
|
+ invocation-directory))
|
|
+ (lib-paths (list)))
|
|
+
|
|
+ (if library-path-env
|
|
+ (push library-path-env lib-paths))
|
|
+ (if (file-directory-p devtools-dir)
|
|
+ (push devtools-dir lib-paths))
|
|
+ (push darwin-dir lib-paths)
|
|
+ (push gcc-dir lib-paths)
|
|
+
|
|
+ (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 'comp--native-compile
|
|
+ 'native-compile-setup-environment-variables)
|
|
+ (advice-remove 'native-compile-async
|
|
+ '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 'comp--native-compile :before
|
|
+ 'native-compile-setup-environment-variables)
|
|
+(advice-add 'native-compile-async :before
|
|
+ 'native-compile-setup-environment-variables)
|
|
+(advice-add 'native--compile-async :before
|
|
+ 'native-compile-setup-environment-variables)
|
|
+
|
|
(provide 'comp)
|
|
|
|
;; LocalWords: limplified limplified limplification limplify Limple LIMPLE libgccjit elc eln
|