Skip to content

Support for building universal x86 / Apple Silicon (arm64) app #1150

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

Merged
merged 1 commit into from
Dec 23, 2020

Conversation

ychin
Copy link
Member

@ychin ychin commented Dec 22, 2020

This adds support for building MacVim as a fat binary (aka universal app) for x86_64 / arm64 in CI.

The main challenge mostly lies in configuring the scripting language default search paths for the libraries, and linking against gettext. There are two possible approaches:

  1. configure/build each arch completely separately, and then use lipo to stitch them back together. This is pretty annoying to set up, and kind of manual to do, and requires building the same thing twice, which is not great.
  2. Build once with --with-macarchs="x86_64 arm64 flag, which is what we do here.

gettext: Homebrew doesn't support fat binaries, and we also need to build a custom x86 version of gettext to support down to macOS 10.9 anyway, so we manually download the bottle for arm64 gettext bottle, and then stitch it with the x86 version to create a unified binary under /usr/local/lib. This way we can just link against it in one go.

Scripting languages: Add new ifdef's to load different libs under different architecture. Modify configure to support that (instead of hacking a patch in during CI like Ruby). This means while on x86_64 it will look under /usr/local/lib for Python 3, on arm64 it will look under /opt/homebrew instead (this is the recommended path for Homebrew installs for native arm64 packages). This new path is very specific to Homebrew which is not ideal, but we could change this later and maybe make the default search path logic for scripting languages smarter.

Note that since there is no arm64 in CI right now, this just builds the app, but there will be no automatic testing to make sure it actually works.

This is part of #1136.

This adds support for building MacVim as a fat binary (aka universal
app) for x86_64 / arm64 in CI.

The main challenge mostly lies in configuring the scripting language
default search paths for the libraries, and linking against gettext.
There are two possible approaches:
1. configure/build each arch completely separately, and then use `lipo`
   to stitch them back together. This is pretty annoying to set up, and
   kind of manual to do, and requires building the same thing twice,
   which is not great.
2. Build once with `--with-macarchs="x86_64 arm64` flag, which is what
   we do here.

gettext: Homebrew doesn't support fat binaries, and we also need to
build a custom x86 version of gettext to support down to macOS 10.9
anyway, so we manually download the bottle for arm64 gettext bottle, and
then stitch it with the x86 version to create a unified binary under
/usr/local/lib. This way we can just link against it in one go.

Scripting languages: Add new ifdef's to load different libs under
different architecture. Modify configure to support that (instead of
hacking a patch in during CI like Ruby). This means while on x86_64 it
will look under /usr/local/lib for Python 3, on arm64 it will look under
/opt/homebrew instead (this is the recommended path for Homebrew
installs for native arm64 packages). This new path is very specific to
Homebrew which is not ideal, but we could change this later and maybe
make the default search path logic for scripting languages smarter.

Note that since there is no arm64 in CI right now, this just builds the
app, but there will be no automatic testing to make sure it actually
works.

This is part of macvim-dev#1136.
@ychin ychin force-pushed the apple-silicon-support branch from eea62dd to 9817aba Compare December 22, 2020 12:12
@ychin ychin added the Infrastructure Non-app infrastructure issues, e.g. CI label Dec 22, 2020
@ychin ychin added this to the snapshot-170 milestone Dec 22, 2020
- os: macos-11.0
publish: true

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

current macos is 11.1 -- is that version available in ci?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No: https://docs.github.com/en/free-pro-team@latest/actions/reference/specifications-for-github-hosted-runners#supported-runners-and-hardware-resources

Why does it matter though? I am not aware of any breaking issues in 11.0 that would prevent CI from running. Most of the work is done by Xcode anyway

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess it doesn't matter 👍

@ychin ychin merged commit 5ba08b4 into macvim-dev:master Dec 23, 2020
@ychin ychin deleted the apple-silicon-support branch December 23, 2020 05:39
ychin added a commit that referenced this pull request Mar 8, 2021
Updated to Vim 8.2.2576.

Features
====================

Apple Silicon Support
--------------------

MacVim's binary release now fully supports Apple Silicon! If you have an
M1 Mac you should notice MacVim being more snappy and smoother. #1150

If you would like to (e.g. if you only installed Python 3 in Rosetta and
use plugins that use Python), you could run MacVim under Rosetta. You
could use `:version` while in MacVim to tell whether you are running in
Rosetta / Intel or Apple Silicon by seeing whether it says x86_64 or
arm64. (Vim 8.2.2174)

If you rely on Python/Ruby/Lua integration, note that previously MacVim
by default searches the `/usr/local/` path for installed language
runtimes. With this release, MacVim will still search those folders
under Intel / x86-64 builds, but under Apple Silicon / M1, MacVim will
search under `/opt/homebrew/` instead, which is the default folder for
Homebrew under Apple Silicon. If you don't use Homebrew, or installed
language runtimes under other folders, you would need to set
`python3dll`/`luadll`/`rubydll` in your vimrc.

Full Screen Fixes and Improvements
--------------------

Removed the fade-to-black animation when transition to full screen, as
they were distracting and looked jarring. For non-native full screen,
you could set `MMFullScreenFadeTime` to a non-zero value to still get
the animation back. #1171

Non-native full screen

- Non-native full screen now has an option to show menu bar when it's
  active (under Appearance preference pane). #1170

- Fixed non-native full screen to properly hide the menu / dock when
  used on a secondary screen. Also, fixed misc issues with non-native
  full screen not drawing at the right offset. #7 #1155 #1170

- Fixed non-native full screen's `fuopt` setting. It now works again.
  This feature allows you to limit only expand horizontally or
  vertically when using non-native full screen to help focus on the
  content, see `:help fuopt`. #509

Fixed small bug in Touch Bar's full screen button sometimes not being
updated correctly. #1171

Known Issues
====================

Text invisible after plugging in monitor or waking from sleep
--------------------

There is currently a known issue in rendering where after
plugging/unplugging an external monitor, or waking from sleep when
connected to a monitor, there is a small change MacVim will stop drawing
text. If you see that, please report that to #1164. This release
contains some additional logging to help dignose the issue and we are
still looking to root cause it.

General
====================

- Added an option to ignore font's line height. r168 introduced a new
  renderer which changed the behavior for how font's line height works
  -- instead of ignoring it, the new renderer respects the line height
  of the font. This new setting allows MacVim to behave in the old way,
  since some fonts have large line height that the user may not want to
  use. #1152

Fixes
====================

- Fixed balloon APIs (`balloon_show()` / `balloon_gettext()`) so plugins
  relying on them should now work. #902 #1064

Misc
====================

- Scripting languages versions:
    - Ruby is now built against 3.0, up from 2.7.

Compatibility
====================

Requires macOS 10.9 or above.

Script interfaces have compatibility with these versions:

- Lua 5.4
- Perl 5.18
- Python2 2.7
- Python3 3.9
- Ruby 3.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Infrastructure Non-app infrastructure issues, e.g. CI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants