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
extend/ENV/shared: effective_arch as public API #16477
Conversation
Thanks for the PR @cho-m!
Can you elaborate on some formulae that might use that, preferably in homebrew-core? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like a good idea to me.
Probably every existing call to |
Ah, I thought it might be this. Note that we intentionally removed/changed this in the past so that from-source builds would more closely align with bottles because:
It would probably be good to write this policy down somewhere, assuming we're agreed on sticking with it. |
I think # Fix illegal instruction errors when using bottles on older CPUs.
# https://github.com/Homebrew/homebrew-core/issues/92282
cpu = case Hardware.oldest_cpu
when :arm_vortex_tempest then "apple_m1" # See `zig targets`.
else Hardware.oldest_cpu
end
# Set MARCH and JULIA_CPU_TARGET to ensure Julia works on machines we distribute to.
# Values adapted from https://github.com/JuliaCI/julia-buildbot/blob/master/master/inventory.py
args << "MARCH=#{Hardware.oldest_cpu}" if Hardware::CPU.intel? Not sure on cpu = Hardware::CPU.arm? ? "aarch64" : Hardware.oldest_cpu
if OS.mac?
args << "--build=#{cpu}-apple-darwin#{OS.kernel_version.major}"
else
args << "--build=#{cpu}-linux-gnu"
ENV["TARGET"] = case Hardware.oldest_cpu
when :arm_vortex_tempest
"VORTEX"
else
Hardware.oldest_cpu.upcase.to_s
end As note, changes shouldn't impact Homebrew's bottling, but is mainly for users who want to prepare their own bottles perhaps optimized for different CPU. I think best for Linux users (given we only optimize for old Core2) or macOS Intel users (given we do not provide AVX due to Rosetta limitation). |
Yeh, this seems like a good idea.
I don't think this is a path we should be working at supporting better as we don't support it and bottle usage outside the Homebrew org is fairly minimal. |
Sorry, I should have also clarified the native CPU logic is Linux-specific: brew/Library/Homebrew/extend/os/linux/extend/ENV/shared.rb Lines 6 to 14 in 594ed2a
This behaviour already applies to the shims today even without this pull request. On macOS there's basically no difference between
|
Hah, yes, I forgot about this compromise 😅
Does this API handle |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense, thanks @cho-m!
Yes. |
brew style
with your changes locally?brew typecheck
with your changes locally?brew tests
with your changes locally?Opening this to discuss possibility of exposing
effective_arch
information.Main reason is that we currently use
Hardware.oldest_cpu
in formulae but this may not be accurate if user wants to target different arch.Would need some input if anything else needs to change to get this information available to be used by formulae that are not capable of relying on existing shim arch selection.