-
Notifications
You must be signed in to change notification settings - Fork 74
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Provide arm64
build of tsc-dyn.dylib
for Apple Silicon (M1) Macs
#88
Comments
This will likely need system toolchain for arm64 as well, in addition to Rust toolchain. Have you been able to cross-compile it? Or do you have a link to a working guide for targeting |
Tested on x86_64 macOS 11.1. Use emacs = { path = "../../emacs-module-rs" }
tree-sitter = { git = "https://github.com/tree-sitter/tree-sitter.git" } and run this command:
|
Did you install XCode Beta? My MacOS SDK doesn't support https://stackoverflow.com/questions/64313634/xcode-12-compiling-for-macos-arm64-arch |
Nope, I'm using the latest stable Xcode 12.3 (12C33) on macOS Big Sur 11.1. |
Ah ok, I misread as 10.11. Yeah, Big Sur's SDK supports I'll check this again when I have access to an SDK supporting |
Does it work if you delete |
Deleting |
I'm struggling with how to build this on my M1 mac. I seem to be stuck on resolving dependencies, the earliest error being:
With some help from someone more knowledgeable in rust I can try to build this |
@theothornhill Seems like you need to install |
Yeah, you're right. |
I think I managed to compile it to M1 now. running
However, now I'm stuck at compiling the
after it has run the |
I'm seeing something similar. I built
|
Emacs collapses the error message. You can click on the dots
This is a different error. It means that your |
Compiling the |
I don't really know the ins and outs of tree-sitter intimately, or elisp as I'm still new to both of these but I played around with this all for an hour or two and got as far as manually compiling a parser for arm64 (using gcc not clang) but emacs segfaults when that's done. I've looked at the source for
So I've hit a dead end. |
The error was just that Now I got it to work using this recipe: Steps to reproduce:
|
What remains from here for M1 support in MELPA? It is possible to generate bindings just fine, it seems :) |
Awesome!
That's weird. IIRC, this is what
We'd need to update CI jobs to build M1 binaries, and update the code ( However, since GitHub Actions and Azure Pipelines don't support M1 at the moment, what we can do now is just updating the docs with M1 installation instructions. |
edit: 2021-08-05 - I had to update my build process to handle the fact that
I just went through getting emacs-tree-sitter set up on an M1 laptop, and the tl;dr: for any other M1 users treading this path: I had to (use-package tsc
:straight `(:pre-build ,(when (and (memq window-system '(mac ns))
(string-match-p (rx string-start "arm-")
system-configuration))
;; required for tree-sitter
(unless (and (executable-find "cargo")
;; required for building bindings
(executable-find "cask")
(executable-find "git")
;; required for tree-sitter to generate
(executable-find "npm")
;; required for bindings
(executable-find "llvm-gcc"))
(warn "tree-sitter build will fail"))
(setf lyn--self-compiled-tsc t)
;; get tree-sitter v0.19.5 - last to put files in a reasonable place
'(("sh" "-c" "test -d rust-tree-sitter || git clone https://github.com/tree-sitter/tree-sitter rust-tree-sitter; cd rust-tree-sitter && git fetch && git checkout v0.19.5")
("sh" "-c" "cd rust-tree-sitter/cli && cargo install --path .")
;; needed or it will download x86_64 dylibs over the arm64 ones we just built
("sh" "-c" "file core/tsc-dyn.dylib | grep -q arm64 || rm -f core/tsc-dyn.dylib")
("sh" "-c" "grep -q LOCAL core/DYN-VERSION || printf LOCAL >core/DYN-VERSION")
("sh" "-c" "grep -q DYN-VERSION bin/build && sed -e '/DYN-VERSION/d' bin/build >bin/build.tmp && mv bin/build.tmp bin/build && chmod +x bin/build || :")
;; rebuild bindings
("sh" "-c" "EMACS=emacs ./bin/setup && EMACS=emacs ./bin/build")
;; ensure all language definitions
("find" "langs/repos" "-type" "f" "-name" "grammar.js" "-not" "-path" "*/node_modules/*" "-not" "-path" "*/ocaml/interface/*" "-exec" "sh" "-c" "targets=''; for grammar_file in \"$@\"; do grammar_dir=\"${grammar_file%/*}\"; targets=\"$targets ensure/${grammar_dir##*/}\"; done; EMACS=emacs make -j7 $targets" "sh" "{}" "+")))
:files ("core/DYN-VERSION" "core/tsc-dyn.*" "core/*.el")))
(use-package tree-sitter
:commands (tree-sitter-hl-mode))
(use-package tree-sitter-langs
;; Don't clone the separate tree-sitter-langs repo, use the dylibs we
;; already built
:straight (:host github :repo "ubolonton/emacs-tree-sitter"
:files ("langs/*.el" ("bin" "langs/bin/*.dylib") ("queries" "langs/queries/*")))
:after tree-sitter
;; If this isn't set then it'll download x86_64 dylibs over the arm64
;; dylibs we built
:init (setf tree-sitter-langs--testing lyn--self-compiled-tsc)) |
Still can't get it to work on my M1. @lynlevenick Could you please write a short walkthrough on how to do it manually? |
Does anyone have instructions on how to compile it manually? |
Any update? |
The binaries are available starting from release 0.16.1. Notes:
|
Pre-compiled grammars for Apple Silicon are available starting from tree-sitter-langs 0.10.13. Notes:
|
Just reporting that I tried these now (hadn't been using Emacs on my M1 in a bit) and it seems to work fine so far. |
@timlod what version of emacs are you using? I'm using emacs-mac with use pacakge and am getting the error
i tried using straight-use-package with the same result. |
See the last two messages by ubolonton - you need to manually download the files still and extract them into the tree-sitter directories. |
Thank you @timlod |
Currently,
tsc-dyn.dylib
has onlyx86_64
binary.tsc-dyn.dylib
can be cross-compiled using the latest Rust toolchain.The text was updated successfully, but these errors were encountered: