Skip to content

Commit

Permalink
Merge branch 'snapshot' into pgtk
Browse files Browse the repository at this point in the history
  • Loading branch information
alexmurray committed Nov 27, 2024
2 parents f113611 + e5da793 commit a1777df
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 8 deletions.
2 changes: 1 addition & 1 deletion native-comp.patch
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ index e97832455b9..b04cfa00c33 100644
(cond ((eq system-type 'darwin) '("-Wl,-w"))
- ((eq system-type 'cygwin) '("-Wl,-dynamicbase")))
+ ((eq system-type 'cygwin) '("-Wl,-dynamicbase"))
+ ((getenv "SNAP_USER_COMMON") (list (concat "--sysroot=" (file-name-as-directory (getenv "SNAP_USER_COMMON")) "sysroot/") (concat "-B" (file-name-as-directory (getenv "SNAP_USER_COMMON")) "sysroot/usr/lib/gcc/"))))
+ ((getenv "EMACS_SNAP_USER_COMMON") (list (concat "--sysroot=" (file-name-as-directory (getenv "EMACS_SNAP_USER_COMMON")) "sysroot/") (concat "-B" (file-name-as-directory (getenv "EMACS_SNAP_USER_COMMON")) "sysroot/usr/lib/gcc/"))))
"Options passed verbatim to the native compiler's back-end driver.
Note that not all options are meaningful; typically only the options
affecting the assembler and linker are likely to be useful.
4 changes: 3 additions & 1 deletion site-lisp/site-start.el
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,13 @@
;; use it - use /snap/emacs/current if $SNAP is not set for some reason
(setenv "EMACS_SNAP_DIR" (or (getenv "SNAP") "/snap/emacs/current"))

(setenv "EMACS_SNAP_USER_COMMON" (or (getenv "SNAP_USER_COMMON") (expand-file-name "~/snap/emacs/common")))

;; 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 (concat (file-name-as-directory (getenv "SNAP_USER_COMMON"))
(let ((sysroot (concat (file-name-as-directory (getenv "EMACS_SNAP_USER_COMMON"))
"sysroot/")))
(dolist (opt (list (concat "--sysroot=" sysroot)
(concat "-B" sysroot "usr/lib/gcc/")))
Expand Down
7 changes: 5 additions & 2 deletions snapcraft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ parts:
emacs:
after: [tree-sitter]
plugin: nil
build-attributes:
- enable-patchelf
source: git://git.savannah.gnu.org/emacs.git
source-depth: 1
organize:
Expand Down Expand Up @@ -353,8 +355,9 @@ parts:
grep -q SNAP "usr/share/emacs/${VERSION}/lisp/emacs-lisp/comp.el" || sed "s/@@VERSION@@/${VERSION}/g" $SNAPCRAFT_PROJECT_DIR/native-comp.patch | sed "s/@@MULTIARCH@@/$CRAFT_ARCH_TRIPLET_BUILD_FOR/g" | patch -p1
../parts/emacs/build/src/emacs -batch -f batch-byte+native-compile "usr/share/emacs/${VERSION}/lisp/emacs-lisp/comp.el"
# compiled eln files get put back in the build directory - copy them over
# manually
VERSION_HASH=$(basename ../parts/emacs/build/native-lisp/*)
# manually - there may be more than one directory here but only one will
# contain the comp related eln files
VERSION_HASH=$(basename $(dirname ../parts/emacs/build/native-lisp/*/comp-common*.eln))
cp "../parts/emacs/build/native-lisp/${VERSION_HASH}"/comp-*.eln "usr/lib/emacs/${VERSION}/native-lisp/${VERSION_HASH}/"
gzip usr/share/emacs/*/lisp/emacs-lisp/comp.el
Expand Down
8 changes: 4 additions & 4 deletions treesit.patch
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,21 @@ index a9761dbb38d..274b3979bd7 100644
(treesit--call-process-signal
- cc nil t nil "-fPIC" "-c" "-I." "parser.c")
+ cc nil t nil "-fPIC" "-c" "-I."
+ "--sysroot" (file-name-as-directory (getenv "EMACS_SNAP_DIR"))
+ "--sysroot" (concat (file-name-as-directory (getenv "EMACS_SNAP_USER_COMMON")) "sysroot/")
+ "parser.c")
;; cc -fPIC -c -I. scanner.c
(when (file-exists-p "scanner.c")
(treesit--call-process-signal
- cc nil t nil "-fPIC" "-c" "-I." "scanner.c"))
+ cc nil t nil "-fPIC" "-c" "-I."
+ "--sysroot" (file-name-as-directory (getenv "EMACS_SNAP_DIR"))
+ "--sysroot" (concat (file-name-as-directory (getenv "EMACS_SNAP_USER_COMMON")) "sysroot/")
+ "scanner.c"))
;; c++ -fPIC -I. -c scanner.cc
(when (file-exists-p "scanner.cc")
(treesit--call-process-signal
- c++ nil t nil "-fPIC" "-c" "-I." "scanner.cc"))
+ c++ nil t nil "-fPIC" "-c" "-I."
+ "--sysroot" (file-name-as-directory (getenv "EMACS_SNAP_DIR"))
+ "--sysroot" (concat (file-name-as-directory (getenv "EMACS_SNAP_USER_COMMON")) "sysroot/")
+ "scanner.cc"))
;; cc/c++ -fPIC -shared *.o -o "libtree-sitter-${lang}.${soext}"
(apply #'treesit--call-process-signal
Expand All @@ -45,7 +45,7 @@ index a9761dbb38d..274b3979bd7 100644
(rx bos (+ anychar) ".o" eos))
"-o" ,lib-name)
`("-fPIC" "-shared"
+ "--sysroot" ,(file-name-as-directory (getenv "EMACS_SNAP_DIR"))
+ "--sysroot" ,(concat (file-name-as-directory (getenv "EMACS_SNAP_USER_COMMON")) "sysroot/")
,@(directory-files
default-directory nil
(rx bos (+ anychar) ".o" eos))

0 comments on commit a1777df

Please sign in to comment.