Skip to content
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

brew: re-exec under native arch if requested #9418

Merged
merged 1 commit into from
Dec 5, 2020

Conversation

fxcoudert
Copy link
Member

We are in the process of setting up a CI runner for macOS Big Sur on ARM. However, github's action-runner is not available for macOS ARM, so at least in the short term we will run the action-runner under Rosetta 2. In that use case, we need brew to still run natively, even when it is launched from a Rosetta process.

This PR allows this, and will let brew re-exec itself natively (under ARM architecture) if:

  • requested by setting an environment variable, HOMEBREW_CHANGE_ARCH_TO_ARM=1
  • we're on darwin, with ARM hardware (hw.optional.arm64)
  • we were invoked under Rosetta (sysctl -n sysctl.proc_translated)

The idea and code is borrowed from @mistydemeo's pull request to do things the other away around #9287


With this patch, we have:

  • native brew:
brew@28105 bin % brew config
HOMEBREW_VERSION: 2.6.0-82-gde1afcb-dirty
ORIGIN: https://github.com/Homebrew/brew
HEAD: de1afcbfc58fb3cd5779bd8fbb6b9995700dda4c
Last commit: 4 hours ago
Core tap ORIGIN: https://github.com/Homebrew/homebrew-core
Core tap HEAD: 597d19eb9dd526fb1dd27e7105b2926b381a8c5e
Core tap last commit: 2 hours ago
Core tap branch: master
HOMEBREW_PREFIX: /opt/homebrew
HOMEBREW_REPOSITORY: /opt/homebrew
HOMEBREW_CASK_OPTS: []
HOMEBREW_MAKE_JOBS: 8
Homebrew Ruby: 2.6.3 => /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/ruby
CPU: octa-core 64-bit arm_vortex_tempest
Clang: 12.0 build 1200
Git: 2.24.3 => /Applications/Xcode.app/Contents/Developer/usr/bin/git
Curl: 7.64.1 => /usr/bin/curl
macOS: 11.0.1-arm64
CLT: 12.2.0.0.1.1604076827
Xcode: 12.2
Rosetta 2: false
  • once we are under Rosetta 2:
brew@28105 bin % arch -x86_64 zsh
brew@28105 bin % brew config
HOMEBREW_VERSION: 2.6.0-82-gde1afcb-dirty
ORIGIN: https://github.com/Homebrew/brew
HEAD: de1afcbfc58fb3cd5779bd8fbb6b9995700dda4c
Last commit: 4 hours ago
Core tap ORIGIN: https://github.com/Homebrew/homebrew-core
Core tap HEAD: 597d19eb9dd526fb1dd27e7105b2926b381a8c5e
Core tap last commit: 2 hours ago
Core tap branch: master
HOMEBREW_PREFIX: /opt/homebrew
HOMEBREW_REPOSITORY: /opt/homebrew
HOMEBREW_CELLAR: /opt/homebrew/Cellar
HOMEBREW_CASK_OPTS: []
HOMEBREW_MAKE_JOBS: 4
Homebrew Ruby: 2.6.3 => /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/ruby
CPU: quad-core 64-bit arrandale
Clang: 12.0 build 1200
Git: 2.24.3 => /Applications/Xcode.app/Contents/Developer/usr/bin/git
Curl: 7.64.1 => /usr/bin/curl
macOS: 11.0.1-x86_64
CLT: 12.2.0.0.1.1604076827
Xcode: 12.2
Rosetta 2: true
brew@28105 bin % HOMEBREW_CHANGE_ARCH_TO_ARM=1 brew config
HOMEBREW_VERSION: 2.6.0-82-gde1afcb-dirty
ORIGIN: https://github.com/Homebrew/brew
HEAD: de1afcbfc58fb3cd5779bd8fbb6b9995700dda4c
Last commit: 4 hours ago
Core tap ORIGIN: https://github.com/Homebrew/homebrew-core
Core tap HEAD: 597d19eb9dd526fb1dd27e7105b2926b381a8c5e
Core tap last commit: 2 hours ago
Core tap branch: master
HOMEBREW_PREFIX: /opt/homebrew
HOMEBREW_REPOSITORY: /opt/homebrew
HOMEBREW_CASK_OPTS: []
HOMEBREW_MAKE_JOBS: 8
Homebrew Ruby: 2.6.3 => /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/ruby
CPU: octa-core 64-bit arm_vortex_tempest
Clang: 12.0 build 1200
Git: 2.24.3 => /Applications/Xcode.app/Contents/Developer/usr/bin/git
Curl: 7.64.1 => /usr/bin/curl
macOS: 11.0.1-arm64
CLT: 12.2.0.0.1.1604076827
Xcode: 12.2
Rosetta 2: false

@fxcoudert fxcoudert requested a review from MikeMcQuaid December 4, 2020 17:06
@fxcoudert fxcoudert force-pushed the rosetta2 branch 2 times, most recently from 4a7b140 to 961f4cc Compare December 4, 2020 17:11
@BrewTestBot
Copy link
Member

Review period will end on 2020-12-07 at 17:06:19 UTC.

@BrewTestBot BrewTestBot added the waiting for feedback Merging is blocked until sufficient time has passed for review label Dec 4, 2020
@fxcoudert
Copy link
Member Author

@MikeMcQuaid if you approve, and if you think this is safely contained (and I believe it is, being protected behind HOMEBREW_CHANGE_ARCH_TO_ARM), I would like to merge before the 24-hour period, in order to be able to set up new CI runners over the week-end, while I have some time

@fxcoudert fxcoudert added the critical Critical change which should be shipped as soon as possible. label Dec 5, 2020
@BrewTestBot BrewTestBot removed the waiting for feedback Merging is blocked until sufficient time has passed for review label Dec 5, 2020
@BrewTestBot
Copy link
Member

BrewTestBot commented Dec 5, 2020

Review period ended.

@fxcoudert
Copy link
Member Author

I'm in a bit of a bind here… we recently decided to wait 1 week day to leave time for review, but I need this to merge in order to test it fully on ARM. And because I have a day job during the week, I really have time to work on this during the week-end.

So, I'm going to go on a limb here, and merge for now. @MikeMcQuaid approved the basic principle on a previous version: #9417

If there is the slightest hint of trouble, I'll revert immediately. And @MikeMcQuaid if on Monday or whenever you can review, you think it was not suitable, I'll revert and apologise.

@fxcoudert
Copy link
Member Author

Completed testing by building a native ARM bottle through github actions here: Homebrew/homebrew-core#66288

@MikeMcQuaid
Copy link
Member

I'm in a bit of a bind here… we recently decided to wait 1 week day to leave time for review, but I need this to merge in order to test it fully on ARM. And because I have a day job during the week, I really have time to work on this during the week-end.

So, I'm going to go on a limb here, and merge for now. @MikeMcQuaid approved the basic principle on a previous version: #9417

If there is the slightest hint of trouble, I'll revert immediately. And @MikeMcQuaid if on Monday or whenever you can review, you think it was not suitable, I'll revert and apologise.

@fxcoudert this was the right decision, thanks for unblocking yourself 🙇🏻

@BrewTestBot BrewTestBot added the outdated PR was locked due to age label Jan 6, 2021
@Homebrew Homebrew locked as resolved and limited conversation to collaborators Jan 6, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
critical Critical change which should be shipped as soon as possible. outdated PR was locked due to age
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants