Skip to content

Commit

Permalink
Set a proxy environment variable EMACS_SNAP_DIR for SNAP_ARCH
Browse files Browse the repository at this point in the history
We unset $SNAP in site-start.el so that any other snaps that get run as child
processes by emacs don't get confused so make sure we can preserve and still
refer to this via the name EMACS_SNAP_DIR

Signed-off-by: Alex Murray <[email protected]>
  • Loading branch information
alexmurray committed Apr 30, 2023
1 parent 22d77ab commit 56c91ca
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
10 changes: 6 additions & 4 deletions site-lisp/site-start.el
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,15 @@
"FONTCONFIG_FILE"))
(setenv env))

;; ensure the correct native-comp-driver-options are set - use
;; /snap/emacs/current if $SNAP is not set for some reason - we also patch
;; keep a proxy to the SNAP env so that our patched comp.el and treesit.el can
;; use it - use /snap/emacs/current if $SNAP is not set for some reason
(setenv "EMACS_SNAP_DIR" (or (getenv "SNAP") "/snap/emacs/current"))

;; ensure the correct native-comp-driver-options are set -- we also patch
;; comp.el in when building the emacs snap but do it here too to try and
;; ensure this is always set no matter what
(when (require 'comp nil t)
(let ((sysroot (file-name-as-directory (or (getenv "SNAP")
"/snap/emacs/current"))))
(let ((sysroot (file-name-as-directory (getenv "EMACS_SNAP_DIR"))))
(dolist (opt (list (concat "--sysroot=" sysroot)
(concat "-B" sysroot "usr/lib/gcc/")))
(add-to-list 'native-comp-driver-options opt t))))
Expand Down
4 changes: 2 additions & 2 deletions treesit.patch
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ index e718ea1a23a..3a313c613ee 100644
(workdir (expand-file-name "repo"))
(source-dir (expand-file-name (or source-dir "src") workdir))
- (cc (or cc (seq-find #'executable-find '("cc" "gcc" "c99"))
+ (cc (or cc (concat (file-name-as-directory (getenv "SNAP")) "usr/bin/gcc-10")
+ (cc (or cc (concat (file-name-as-directory (getenv "EMACS_SNAP_DIR")) "usr/bin/gcc-10")
;; If no C compiler found, just use cc and let
;; `call-process' signal the error.
"cc"))
- (c++ (or c++ (seq-find #'executable-find '("c++" "g++"))
+ (c++ (or c++ (concat (file-name-as-directory (getenv "SNAP")) "usr/bin/g++-10")
+ (c++ (or c++ (concat (file-name-as-directory (getenv "EMACS_SNAP_DIR")) "usr/bin/g++-10")
"c++"))
(soext (or (car dynamic-library-suffixes)
(signal 'treesit-error '("Emacs cannot figure out the file extension for dynamic libraries for this system, because `dynamic-library-suffixes' is nil"))))

0 comments on commit 56c91ca

Please sign in to comment.