Support compiling native MacOS arm64 (Apple Silicon) builds #4772
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Following along with the original request in #3125 and the followup plus community troubleshooting in #3302, I was able to successfully build a working native arm64 build of trilium for MacOS on my M1 mac as well using my Windows 11 wsl environment.
Using the native package rather than relying on the Rosetta translation layer leads to a much better startup time (a couple seconds at most vs 10-20 seconds before) and a much snappier experience. (as originally reported in #3302)
A user in #3302 voiced concerns about an arm64 native build being bigger than the x86-64 build, but their observations seem to come from using a different packaging system than trilium uses for its other builds. I replicated the current build flow for arm64 and the resulting binaries are comparable to the released build sizes. (See below)
I built both the latest and second latest versions of trilium to test. The top row of applications was compiled by me (both intel and arm builds) and the bottom are from the trilium releases.
Concerning future maintainability, better-sqlite3 does not have prebuilt binaries for version 8.4.0 with electron 25 so I compiled that combination myself for macos arm64 and added it to the precompiled binaries used for trilium releases. If in future releases of trilium the version of electron and/or better-sqlite3 is changed, precompiled binaries will most likely be available through better-sqlite3 releases, removing the need for an Apple Silicon computer to keep arm64 builds up to date.