311 points · by soheil · 6y ago · 151 comments
export ARCHFLAGS='-arch arm64'
brew install -s --HEAD pkg_name_here
Nothing else needed. Honestly, the `--HEAD` part may not even be needed anymore.
Realize the problem with homebrew isn't brew itself right now on the M1. I have absolutely zero doubt (go read the issues) the maintainers want to support it properly and be done with this kind of noise. The reason they can't or don't is because a lot of shit is broken still. They can't safely let you go all willis-nillis installing ARM packages because they're broken.
Installing stuff from source, yourself, isn't hard if it's going to actually work... 99% of it boils down to:
1. git clone whatever_it_is 2. ./configure --prefix=/usr/local/bin 3. make 4. make install
https://github.com/Homebrew/homebrew-core/tree/master/Formul...
For the most part, no real complaints. It'll depend heavily on what you install, and obviously you have to be OK with compiling things, but yeah no real complaints so far here either.
Other than the Python scientific ecosystem, Rust is really the main thing in my end-user stack I'm waiting on since fzy, bat, exa, etc. still don't compile, but other than that I'm fairly OK.
Can you expand further?
% cargo install bat
Finished release [optimized] target(s) in 2m 21s
Installing ~/.cargo/bin/bat
Installed package `bat v0.16.0` (executable `bat`)
% file $(which bat)
~/.cargo/bin/bat: Mach-O 64-bit executable arm64
% cargo install exa
Finished release [optimized] target(s) in 1m 21s
Installing ~/.cargo/bin/exa
Installed package `exa v0.9.0` (executable `exa`)
% file $(which exa)
~/.cargo/bin/exa: Mach-O 64-bit executable arm64
I don't know what you mean by [fzy], as it appears to be a C program, not Rust.See also:
• The tracking issue for tier 1 support [tracking]
• My intermediate README with instructions [readme]
[fzy]: https://github.com/jhawthorn/fzy
[tracking]: https://github.com/rust-lang/rust/issues/73908
[readme]: https://github.com/shepmaster/rust/blob/silicon/silicon/READ...
Installs of rust itself aren't succeeding yet for me via Homebrew, with what look like likely simple errors but not ones I investigated yet (though yeah I saw the Rust tracking ticket you linked).
But e.g. retrying `brew install rust` this morning produces 404 errors trying to download https://static.rust-lang.org/dist/2020-08-27/rust-std-1.46.0...
It looks like https://github.com/Homebrew/homebrew-core/pull/65286 may fix things. Haven't spent a ton of time investigating though. Obviously if you have recommendations would love them.
Will have a look at your README, thanks for writing it.
Ah, yes. Homebrew builds Rust itself and building Rust uses a previous beta release to build the current development code.
Until my recent [pr] bumping the beta bootstrap version, building Rust on aarch64-apple-darwin required specifying a nightly version of Rust because we only had nightly artifacts. I've mentioned that to a homebrew developer, so it should flow through soon. I'd expect that you'd only be able to install the nightly release at first.
> if you have recommendations
I'm a Rust fanboy, so I'd recommend installing Rust via rustup ;-)
So I can see why it's a problem if it works with cargo but not with brew.
Sure and that's fine, but the original comment wasn't clear that they were waiting for homebrew to ship an arm64 version of Rust. The phrasing made it sound like Rust itself was the aspect blocking those tools from working. That's the point I was addressing.
> not system-wide installs
rustup installs Rust into your home directory by default, and then `cargo install` follows suit, so it's not system-wide.
I guess we are closer and closer to The Year of Linux on Desktop after all!
Zig extends that excellent support to its embedded LLVM C compiler - it’s probably the easiest way to cross compile C across operating system boundaries these days.
Nim doesn't seem to have excellent cross compiling support out of the box. It simply relies on cross platform toolchains that you have to set up.
Good luck setting up cross platform GCC.
Zig uses musl AFAIK? That can often be problematic.
To compile to linux it needs to have a linker installed. For windows it has an internal linker, so probably does not even need that
(Not to mention the golang folks' need to reinvent the wheel has caused a few high-profile bugs that have needlessly wasted people's time.)
Regardless, this quickly falls apart whenever you have an app that does any kind of FFI to system libraries, or even third-party libraries that the author didn't want to reimplement in golang.
Windows makes cross compiling work by shipping the libs for each of the architectures in the SDK. I think that's quite reasonable for macOS since Apple controls the SDK, but it's always seemed to be a mess on Linux.
Disclaimer: I work at Microsoft on Windows but I have tried cross compiling code on both Windows and Linux in the past and I've always found it painful on Linux.
For non-trivial projects you want CI anyway so it's a better ROI of your time to just to add an additional VM, Docker or native runner.
And let's not forget you'll also want to run your automated tests in the native environment.
Cross compilation only works for toy examples, or when one has 100% of the target libraries available.
I installed it with the x86_64 architecture.
EDIT: Was more explicit in architecture nomenclature.
Just a guess though.
“What Can't Be Translated?
Rosetta can translate most Intel-based apps, including apps that contain just-in-time (JIT) compilers. However, Rosetta doesn’t translate the following executables:
- Kernel extensions
- Virtual Machine apps that virtualize x86_64 computer platforms
Rosetta translates all x86_64 instructions, but it doesn’t support the execution of some newer instruction sets and processor features, such as AVX, AVX2, and AVX512 vector instructions. If you include these newer instructions in your code, execute them only after verifying that they are available. For example, to determine if AVX512 vector instructions are available, use the sysctlbyname function to check the hw.optional.avx512f attribute.“
So, if you compiled specifically for some CPU,
That said—while I don't know whether ARM actually works yet, MacPorts still supports PowerPC wherever possible, so they have a long history of managing multiple architectures. I expect they'll have a somewhat easier time with ARM as a result.
Edit: MacPorts does indeed support ARM as of the latest release! https://lists.macports.org/pipermail/macports-announce/2020-...
And I can also envision that certain packages might not get updated, necessitating a fork to patch them for M1.
I’m interested in how homebrew and others will handle that (so official package x chooses not to patch/accept a patch for whatever reason, leading to a fork of package x with a patch applied), presumably to avoid namespace collisions/not giving the user what they want, there could be an error message that states that an ARM64 version doesn’t officially exist but links it to the fork and gives the option to install that instead. And then there could be a flag to always allow linked-replacements if an official patch doesn’t exist.
Given that policy I would assume that such a package might die until somebody forks it and takes on responsibility for maintenance.
Homebrew is about building and installing upstream packages, not about installing and maintaining custom forks of packages.
here are some examples:
aom: https://github.com/Homebrew/homebrew-core/pull/57976
boost: https://github.com/Homebrew/homebrew-core/pull/59257
...
if you notice the code changes for the items above, they make changes to detect if the compile target is ARM and make the necessary changes so it would compile.
Anything run from the Xcode UI (or Terminal if you use "spctl developer-mode enable-terminal" to show the Developer Tools group under Security > Privacy in System Preferences) and enable Terminal is exempt from GateKeeper notarization checks. You can also put other terminal clients in the same list and they get the same benefit (child processes exempt from GateKeeper).
In a similar note "DevToolsSecurity -enable" allows any admin or member of the _developer group to use the debugger or performance tools without authing first. (Normally you must auth the first time and the authorization can expire if you don't unlock your system after a certain amount of time).
That’s why one user above suggests `-s`: it forces a compilation from source.
They have an overview issue here:
Isn't the benefit of Homebrew that it all goes into /usr/local and it can just blow everything away if necessary? You could run `brew leaves` to see what packages you have, uninstall everything, and reinstall. Easier than keeping track of what you've manually installed where.
Wouldn't this just make things even messier? Some packages from Homebrew and some compiled from source that you have to remember to update manually?
But these replies are making me think that a large part of my decision to do this is motivated by me just not understanding Homebrew well enough (e.g. how easy it is to nuke everything). Oh well, we'll see how it goes.
Absolutely stunning computer though - first time back to Apple for over 8 years for me.
I bought the base model Pro to try, but 512GB looks like a must for me going forward.
I've been fighting disk space issues with my Mac for the past five years because I was short-sighted and only got the 128GB disk. This time I went with 1TB, not making that mistake again.
I downvoted your comment. I think this article is spot on for HN, and I think you showed a lack of critical self-awareness questioning its relevance.
I never bothered with these alternative eco-systems.
Other's don't.
But the truth is that XCode built software is far more important to Mac users and that’s where Apples focus was. Homebrew users are less than 1% of their installed base.
The other truth is the M1 hadn’t been important to Homebrew maintainers. At least not yet.
Though, I'm pretty sure he's mistaken on its status.