Skip to content

Draft: Fix building FFI gem on M1

Ryan Egesdahl requested to merge fix-ffi-build into main

What does this merge request do and why?

Fix building ffi gem on M1

In a previous commit [1], we switched to using the built-in FFI provided with the ffi Ruby gem to avoid problems with upgrades to the system FFI breaking the gem. However, this doesn't always work because the built-in FFI implementation doesn't always build correctly, dependent on the system compiler. For example, many M1 Macs with a recent XCode installation are seeing odd failures since 2022 [2].

In this commit, the switch to use --disable-system-ffi is reveted; however, we still won't be using the system FFI. Instead, we will take advantage of the fact that we use a Brewfile and have Homebrew install a stable libffi version for us.

[1] !3061 (merged) [2] https://github.com/ffi/ffi/issues/937

How to set up and validate locally

Numbered steps to set up and validate the change are strongly suggested.

With an existing GDK setup, the following will simulate the changes:

  1. Run gem uninstall ffi
  2. Run bundle config unset build.ffi (to remove the previous config)
  3. Run brew bundle (to install libffi)
  4. Run bundle config build.ffi "--with-ld-flags=-L$(brew --prefix libffi)/lib --with-cppflags=-I$(brew --prefix libffi)/include"

With a new GDK setup:

  1. Clone the repository as usual
  2. Check out this merge request's branch
  3. Run the remainder of the bootstrap/install process as usual

Impacted categories

The following categories relate to this merge request:

Merge request checklist

  • This change is backward compatible. If not, please include steps to communicate to our users.
  • Tests added for new functionality. If not, please raise an issue to follow-up.
  • Documentation added/updated, if needed.
  • Announcement added, if change is notable.
  • gdk doctor test added, if needed.
  • Add the ~highlight label if this MR should be included in the CHANGELOG.md.

Merge request reports