Skip to content

qemu: fix segfault on macOS 15.0-15.3 #221539

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions Formula/q/qemu.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,12 @@ class Qemu < Formula
end

def install
# Fix segfault on macOS 15.0-15.3
# https://github.com/Homebrew/homebrew-core/issues/221154
if OS.mac? && MacOS.version == :sequoia && build.bottle?
inreplace "meson.build", "config_host_data.set('HAVE_STRCHRNUL', cc.has_function('strchrnul'))\n", ""
end
Copy link
Member

Choose a reason for hiding this comment

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

Can this be raised upstream?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am not sure if upstream can fix this issue. This is a Homebrew-specific issue that occurs because we build bottles for the latest macOS version. If we had separate runners for 15.0, 15.1, and other macOS versions this wouldn't happen.

The only way how QEMU maintainers could "fix" the issue is to explicitly remove strchrnul support on macOS Sequoia but it feels more like a workaround (and why would they do it if there's already cc.has_function('strchrnul') function that works well?)

Copy link
Member

Choose a reason for hiding this comment

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

See https://mesonbuild.com/Compiler-properties.html#does-a-function-exist

Note that, on macOS programs can be compiled targeting older macOS versions than the one that the program is compiled on. It can't be assumed that the OS version that is compiled on matches the OS version that the binary will run on.

Therefore when detecting function availability with compiler.has_function(), it is important to specify the correct header in the prefix argument.

Copy link
Member

Choose a reason for hiding this comment

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

I have written an issue and suggested a fix to qemu: https://gitlab.com/qemu-project/qemu/-/issues/2935


ENV["LIBTOOL"] = "glibtool"

# Remove wheels unless explicitly permitted. Currently this:
Expand Down
Loading