From 71c648e7a9d1c677381a66a9eafc8fb461942b32 Mon Sep 17 00:00:00 2001 From: Alex Murray Date: Mon, 25 Nov 2024 17:42:36 +1030 Subject: [PATCH 1/5] Update to new pretest 30.0.92 release Signed-off-by: Alex Murray --- snapcraft.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/snapcraft.yaml b/snapcraft.yaml index 40ff97c..fc34e90 100644 --- a/snapcraft.yaml +++ b/snapcraft.yaml @@ -1,6 +1,6 @@ name: emacs title: GNU Emacs -version: "29.4" +version: "30.0.92" summary: GNU Emacs is the extensible self-documenting text editor description: | Emacs is the extensible, customizable, self-documenting real-time @@ -55,8 +55,8 @@ parts: plugin: nil build-attributes: - enable-patchelf - source: https://mirrors.ocf.berkeley.edu/gnu/emacs/emacs-29.4.tar.xz - source-checksum: sha256/ba897946f94c36600a7e7bb3501d27aa4112d791bfe1445c61ed28550daca235 + source: https://alpha.gnu.org/gnu/emacs/pretest/emacs-30.0.92.tar.xz + source-checksum: sha256/d89287bd5a8381bb60e14aab95202377261d43a60d15dc0a61d0d662bc5626be organize: snap/emacs/current/usr: usr build-packages: From 68ac681ffa91cbb73f4e65750fdc3aa5995f4f83 Mon Sep 17 00:00:00 2001 From: Alex Murray Date: Mon, 25 Nov 2024 21:02:29 +1030 Subject: [PATCH 2/5] Remove erroneous version setting from git We are using a tarball so it won't work to try and set it via git anyway plus its a fixed version anyway. Signed-off-by: Alex Murray --- snapcraft.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/snapcraft.yaml b/snapcraft.yaml index f583549..7a275b0 100644 --- a/snapcraft.yaml +++ b/snapcraft.yaml @@ -277,7 +277,6 @@ parts: - LD_LIBRARY_PATH: "$SNAPCRAFT_STAGE/usr/lib" override-pull: | craftctl default - craftctl set version=$(grep AC_INIT configure.ac | grep -o '[0-9.]\+' | head -n1)-$(git branch --show-current | sed 's|/|-|')-$(git log -n 1 --format=%h) # ensure we hard-code our copy of gcc-14 and g++14 for tree-sitter # otherwise it will use the system installed ones which will have a # different libc version and we will fail to load them From 62d97980a688cdcdab0b6162302a7c392fe87139 Mon Sep 17 00:00:00 2001 From: Alex Murray Date: Tue, 26 Nov 2024 10:35:36 +1030 Subject: [PATCH 3/5] Fix build to find correct location of compiled comp files Signed-off-by: Alex Murray --- snapcraft.yaml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/snapcraft.yaml b/snapcraft.yaml index 7a275b0..0c62d80 100644 --- a/snapcraft.yaml +++ b/snapcraft.yaml @@ -354,8 +354,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 From 84496c4ba54ea2627a3e5006a07b3deb068e96db Mon Sep 17 00:00:00 2001 From: Alex Murray Date: Thu, 28 Nov 2024 10:17:43 +1030 Subject: [PATCH 4/5] Fix tree sitter to use local sysroot Signed-off-by: Alex Murray --- native-comp.patch | 2 +- site-lisp/site-start.el | 4 +++- treesit.patch | 8 ++++---- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/native-comp.patch b/native-comp.patch index 14af595..86a7545 100644 --- a/native-comp.patch +++ b/native-comp.patch @@ -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. diff --git a/site-lisp/site-start.el b/site-lisp/site-start.el index 31145f6..fd659bd 100644 --- a/site-lisp/site-start.el +++ b/site-lisp/site-start.el @@ -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/"))) diff --git a/treesit.patch b/treesit.patch index d630931..fd99e8a 100644 --- a/treesit.patch +++ b/treesit.patch @@ -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 @@ -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)) From e5da79309e84b73ff9af78fc5410979ba8f47262 Mon Sep 17 00:00:00 2001 From: Alex Murray Date: Thu, 28 Nov 2024 10:20:46 +1030 Subject: [PATCH 5/5] Keep snapshot separate after merging in pretest branch changes Signed-off-by: Alex Murray --- snapcraft.yaml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/snapcraft.yaml b/snapcraft.yaml index 0c62d80..b4b8167 100644 --- a/snapcraft.yaml +++ b/snapcraft.yaml @@ -1,6 +1,6 @@ name: emacs title: GNU Emacs -version: "30.0.92" +adopt-info: emacs summary: GNU Emacs is the extensible self-documenting text editor description: | Emacs is the extensible, customizable, self-documenting real-time @@ -55,8 +55,8 @@ parts: plugin: nil build-attributes: - enable-patchelf - source: https://alpha.gnu.org/gnu/emacs/pretest/emacs-30.0.92.tar.xz - source-checksum: sha256/d89287bd5a8381bb60e14aab95202377261d43a60d15dc0a61d0d662bc5626be + source: git://git.savannah.gnu.org/emacs.git + source-depth: 1 organize: snap/emacs/current/usr: usr build-packages: @@ -277,6 +277,7 @@ parts: - LD_LIBRARY_PATH: "$SNAPCRAFT_STAGE/usr/lib" override-pull: | craftctl default + craftctl set version=$(grep AC_INIT configure.ac | grep -o '[0-9.]\+' | head -n1)-$(git branch --show-current | sed 's|/|-|')-$(git log -n 1 --format=%h) # ensure we hard-code our copy of gcc-14 and g++14 for tree-sitter # otherwise it will use the system installed ones which will have a # different libc version and we will fail to load them