Skip to content

Commit

Permalink
Merge branch 'emacs-29'
Browse files Browse the repository at this point in the history
Update to new emacs-29.1 release
  • Loading branch information
alexmurray committed Jul 30, 2023
2 parents 08cc469 + 2d069d9 commit 6872c35
Show file tree
Hide file tree
Showing 5 changed files with 116 additions and 12 deletions.
12 changes: 12 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: build-snap

on:
pull_request:
push:

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: snapcore/action-build@v1
14 changes: 14 additions & 0 deletions native-comp.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
diff --git a/usr/share/emacs/@@VERSION@@/lisp/emacs-lisp/comp.el b/usr/share/emacs/@@VERSION@@/lisp/emacs-lisp/comp.el
index e97832455b9..b04cfa00c33 100644
--- a/usr/share/emacs/@@VERSION@@/lisp/emacs-lisp/comp.el
+++ b/usr/share/emacs/@@VERSION@@/lisp/emacs-lisp/comp.el
@@ -186,8 +186,7 @@ and above."
:type '(repeat string)
:version "28.1")

-(defcustom native-comp-driver-options (when (eq system-type 'darwin)
- '("-Wl,-w"))
+(defcustom native-comp-driver-options (when (getenv "SNAP") (list (concat "--sysroot=" (file-name-as-directory (getenv "SNAP"))) (concat "-B" (file-name-as-directory (getenv "SNAP")) "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.
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
43 changes: 35 additions & 8 deletions snapcraft.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: emacs
title: GNU Emacs
version: "28.2"
version: "29.1"
summary: GNU Emacs is the extensible self-documenting text editor
description: |
Emacs is the extensible, customizable, self-documenting real-time
Expand Down Expand Up @@ -42,10 +42,17 @@ apps:
command: usr/bin/etags

parts:
tree-sitter:
plugin: make
source: https://github.com/tree-sitter/tree-sitter.git
source-tag: v0.20.8
build-environment:
- PREFIX: "/usr"
emacs:
after: [tree-sitter]
plugin: autotools
source: https://mirrors.ocf.berkeley.edu/gnu/emacs/emacs-28.2.tar.xz
source-checksum: sha512/a7cec7e3e82367815a1442f69af54102dbfc434069810a9dec5938a6660cb8b076e6f1fb0bfff9695b15603dbbe05eb9c7dfd92e90cf40fc4d1e5746bce83bd8
source: https://mirrors.ocf.berkeley.edu/gnu/emacs/emacs-29.1.tar.xz
source-checksum: sha256/d2f881a5cc231e2f5a03e86f4584b0438f83edd7598a09d24a21bd8d003e2e01
autotools-configure-parameters:
[
"--prefix=/snap/emacs/current/usr",
Expand All @@ -54,6 +61,9 @@ parts:
"--with-modules",
"--with-cairo",
"--with-native-compilation",
"--with-xinput2",
"--with-tree-sitter",
"--with-json"
]
organize:
snap/emacs/current/usr: usr
Expand All @@ -66,6 +76,7 @@ parts:
- dpkg-dev
- gawk
- gcc-10
- g++-10
- libacl1-dev
- libasound2-dev
- libdbus-1-dev
Expand All @@ -85,8 +96,10 @@ parts:
- libpng-dev
- librsvg2-dev
- libselinux1-dev
- libsqlite3-dev
- libsystemd-dev
- libtiff-dev
- libxi-dev
- libxml2-dev
- libxpm-dev
- libxt-dev
Expand All @@ -96,6 +109,8 @@ parts:
- texinfo
- zlib1g-dev
stage-packages:
- gcc-10 # for tree-sitter
- g++-10 # for tree-sitter
- gvfs
- ibus-gtk3
- libasound2
Expand Down Expand Up @@ -124,6 +139,7 @@ parts:
- libfreetype6
- libgbm1
- libgccjit0
- libgccjit-10-dev
- libgcc-s1
- libgdk-pixbuf2.0-0
- libgif7
Expand Down Expand Up @@ -172,6 +188,7 @@ parts:
- libsm6
- libsndfile1
- libsoup2.4-1
- libsqlite3-0
- libssl1.1
- libstdc++6
- libtdb1
Expand Down Expand Up @@ -212,8 +229,16 @@ parts:
- -usr/share/emacs/site-lisp
build-environment:
- CC: "gcc-10"
- CXX: "g++-10"
- CFLAGS: "$CFLAGS -O2"
- NATIVE_FULL_AOT: "1"
- LD_LIBRARY_PATH: "$SNAPCRAFT_STAGE/usr/lib"
override-build: |
# ensure we hard-code our copy of gcc-10 and g++10 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
patch -p1 < $SNAPCRAFT_PROJECT_DIR/treesit.patch
snapcraftctl build
override-prime: |
set -eu
snapcraftctl prime
Expand All @@ -227,11 +252,13 @@ parts:
# this before we compile otherwise these options get used for doing
# the AOT compile as well - so set them afterwards just inside the
# snap
rm -f usr/share/emacs/$SNAPCRAFT_PROJECT_VERSION/lisp/emacs-lisp/comp.elc
gunzip -f usr/share/emacs/$SNAPCRAFT_PROJECT_VERSION/lisp/emacs-lisp/comp.el.gz
sed -i -e 's|defcustom native-comp-driver-options nil|defcustom native-comp-driver-options (when (getenv "SNAP") (list (concat "--sysroot=" (file-name-as-directory (getenv "SNAP"))) (concat "-B" (file-name-as-directory (getenv "SNAP")) "usr/lib/gcc/")))|' usr/share/emacs/$SNAPCRAFT_PROJECT_VERSION/lisp/emacs-lisp/comp.el
../parts/emacs/build/src/emacs -batch -f batch-byte-compile usr/share/emacs/$SNAPCRAFT_PROJECT_VERSION/lisp/emacs-lisp/comp.el
gzip usr/share/emacs/$SNAPCRAFT_PROJECT_VERSION/lisp/emacs-lisp/comp.el
rm -f usr/share/emacs/*/lisp/emacs-lisp/comp.elc
gunzip -f usr/share/emacs/*/lisp/emacs-lisp/comp.el.gz
# ensure we use the right path in the patch file
VERSION=$(echo usr/share/emacs/*/lisp/emacs-lisp/comp.el | cut -d / -f 4)
sed s/@@VERSION@@/$VERSION/g $SNAPCRAFT_PROJECT_DIR/native-comp.patch | patch -p1
../parts/emacs/build/src/emacs -batch -f batch-byte-compile usr/share/emacs/*/lisp/emacs-lisp/comp.el
gzip usr/share/emacs/*/lisp/emacs-lisp/comp.el
site-lisp:
source: site-lisp
plugin: dump
Expand Down
49 changes: 49 additions & 0 deletions treesit.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
diff --git a/lisp/treesit.el b/lisp/treesit.el
index d7502560fea..dbdbdb193c0 100644
--- a/lisp/treesit.el
+++ b/lisp/treesit.el
@@ -2952,11 +2952,11 @@ function signals an error."
(default-directory (make-temp-file "treesit-workdir" t))
(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 "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 "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"))))
@@ -2981,20 +2981,27 @@ function signals an error."
(message "Compiling library")
;; cc -fPIC -c -I. parser.c
(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"))
+ "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"))
+ "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"))
+ "scanner.cc"))
;; cc/c++ -fPIC -shared *.o -o "libtree-sitter-${lang}.${soext}"
(apply #'treesit--call-process-signal
(if (file-exists-p "scanner.cc") c++ cc)
nil t nil
`("-fPIC" "-shared"
+ "--sysroot" ,(file-name-as-directory (getenv "EMACS_SNAP_DIR"))
,@(directory-files
default-directory nil
(rx bos (+ anychar) ".o" eos))

0 comments on commit 6872c35

Please sign in to comment.