macvim icon indicating copy to clipboard operation
macvim copied to clipboard

Epic: Build universal app to support Apple Silicon

Open ychin opened this issue 4 years ago • 6 comments

We need to get an universal app built for MacVim that will work both on Apple Silicon / M1 Macs. Currently MacVim is buildable under Apple Silicon, but the binary release is only x86 and will work in Apple Silicon under Rosetta. This is usually not a big deal but it's less efficient, and it makes it impossible to interface with native Python / Ruby / etc in plugins.

Tracking some tasks that we need to do or dependencies:

  • [x] #1263
  • [x] Homebrew support for Apple Silicon. We mostly need it to work for external packages like gettext and other scripting languages.
    • They already support Apple Silicon in unofficial manner, with /opt/homebrew/ currently the tentative folder for arm64 packages (since Homebrew is planning to only support thin binaries for now, they have to put these packages at a difference place).
  • [x] #1150
    • Modify CI build scripts to generate universal app. MacVim itself is easy via a single Xcode setting, but to build Vim itself we need to either get the compiler to generate universal binary or use lipo to stitch it together. Also, it's unclear if each CI instance builds their own non-universal app and we combine them in a later CI step, or each CI builds an universal app separately (which is annoying because then we need to cross-compile with all the dependencies available).
  • [x] Update Homebrew-core's formula, so brew install macvim also gets Apple Silicon version.
    • See https://github.com/Homebrew/homebrew-core/pull/66828
  • [x] ~~Documentation for users for how to use this, turn on/off, configure scripting languages.~~
    • Thinking more about this, I don't know what this actually means. MacVim works right now and there really isn't much you need to know about as a user. Just crossing this off.

ychin avatar Dec 10 '20 08:12 ychin

For building Vim as universal:

  • set CC=xcrun --sdk macosx11.0 clang (on 10.15. on 11.0 is ok to default)
  • append -arch arm64e -arch x86_64 to CFLAGS and LDFLAGS

ref: https://github.com/ichizok/macvim/tree/build-universal https://travis-ci.com/github/ichizok/macvim/jobs/445399373

ichizok avatar Dec 10 '20 09:12 ichizok

@ichizok Yes it will work, but as I mentioned, we still need to get both ARM and x86 versions of dependencies (gettext, python, etc) on the same build machine since Vim needs to be built against them. Right now we use Homebrew to do it, but I don't think it quite has full support for doing that yet. We also need to make sure the Apple Silicon version of MacVim knows where to grab pythonthreedll from correctly.

ychin avatar Dec 10 '20 19:12 ychin

Actually I'm not sure if we are supposed to use arm64e. I remember when I looked into it a few months ago, it's not really an officially supported target yet, and Apple's docs just calls for arm64.

Also, we don't need to add to CFLAGS I think. configure script already supports a --with-macarchs flag to do that for us.

ychin avatar Dec 12 '20 00:12 ychin

I didn't know --with-macarchs... thank you. As to arm64e, since Apple native apps and executables are built for arm64e (and x86_64) so I just thought of using it and not particular about it. And I overlooked Sparkle is built for arm64 but not arm64e thus MacVim cannot be for arm64e now. (Speaking of this point, using CFLAGS is applied to MacVim.app/Contents/MacOS/Vim and not to MacVim so then Vim is built for arm64e/x86_64 and MacVim is for arm64/x86_64)

ichizok avatar Dec 14 '20 06:12 ichizok

We are currently building for Apple Silicon in CI! It will build the app, but no testing support though since we don't have M1 Macs in CI yet. Testing will have to be done manually.

ychin avatar Dec 23 '20 20:12 ychin

Ok this is bad. Merging upstream Vim changes can cause GitHub issue closure markers to trigger, which closed this issue from a completely unrelated Vim issue.

Edit: See https://github.com/orgs/community/discussions/17308

ychin avatar Mar 23 '23 22:03 ychin