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 Dec 2, 2024
2 parents 39c6840 + ce08c26 commit 76b1d1d
Showing 1 changed file with 19 additions and 6 deletions.
25 changes: 19 additions & 6 deletions treesit.patch
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
diff --git a/lisp/treesit.el b/lisp/treesit.el
index a9761dbb38d..274b3979bd7 100644
index 2518204ce93..7e6aef76bd1 100644
--- a/lisp/treesit.el
+++ b/lisp/treesit.el
@@ -3146,11 +3146,11 @@ function signals an error."
(default-directory (make-temp-file "treesit-workdir" t))
(workdir (expand-file-name "repo"))
@@ -3790,17 +3790,19 @@ function signals an error."
maybe-repo-dir
(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-14")
Expand All @@ -16,36 +16,49 @@ index a9761dbb38d..274b3979bd7 100644
"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"))))
@@ -3175,15 +3175,21 @@ function signals an error."
(out-dir (or (and out-dir (expand-file-name out-dir))
(locate-user-emacs-file "tree-sitter")))
- (lib-name (concat "libtree-sitter-" lang soext)))
+ (lib-name (concat "libtree-sitter-" lang soext))
+ (process-environment (copy-sequence process-environment)))
+ (setenv "COMPILER_PATH" (concat (file-name-as-directory (getenv "EMACS_SNAP_DIR")) "usr/bin"))
(unwind-protect
(with-temp-buffer
(if url-is-dir
@@ -3814,15 +3816,24 @@ 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" (concat (file-name-as-directory (getenv "EMACS_SNAP_USER_COMMON")) "sysroot/")
+ "-B" (concat (file-name-as-directory (getenv "EMACS_SNAP_USER_COMMON")) "sysroot/usr/lib/gcc")
+ "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" (concat (file-name-as-directory (getenv "EMACS_SNAP_USER_COMMON")) "sysroot/")
+ "-B" (concat (file-name-as-directory (getenv "EMACS_SNAP_USER_COMMON")) "sysroot/usr/lib/gcc")
+ "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" (concat (file-name-as-directory (getenv "EMACS_SNAP_USER_COMMON")) "sysroot/")
+ "-B" (concat (file-name-as-directory (getenv "EMACS_SNAP_USER_COMMON")) "sysroot/usr/lib/gcc")
+ "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)
@@ -3195,6 +3201,7 @@ function signals an error."
@@ -3834,6 +3845,8 @@ function signals an error."
(rx bos (+ anychar) ".o" eos))
"-o" ,lib-name)
`("-fPIC" "-shared"
+ "--sysroot" ,(concat (file-name-as-directory (getenv "EMACS_SNAP_USER_COMMON")) "sysroot/")
+ "-B" ,(concat (file-name-as-directory (getenv "EMACS_SNAP_USER_COMMON")) "sysroot/usr/lib/gcc")
,@(directory-files
default-directory nil
(rx bos (+ anychar) ".o" eos))

0 comments on commit 76b1d1d

Please sign in to comment.