Run Homebrew Natively on Apple Silicon Arm M1
github.com
github.com
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.
https://ziglang.org/download/0.7.0/release-notes.html
But yeah, I think musl is the main target, and it ships with the source for it
I don't think it uses glibc to compile Linux binaries on macOS or macOS libc to compile macOS binaries on Linux.
https://andrewkelley.me/post/zig-cc-powerful-drop-in-replace...
macOS handles libc a little differently from Linux; whereas the Linux kernel publishes its syscall API, and allows programs to make syscalls however they want (e.g. with glibc or musl, or with go, which does syscalls itself), macOS's syscall API is subject to change at any time, and the only (supported) way to make syscalls is to dynamically link to the system libc.
Getting an .o out from a cross compiler is easy, in my experience - the big problem is getting libraries, includes and linkage right. And in my (admittedly small) experience, Nim makes that part much simpler as soon as you have a compiler set up (which in my case was an apt-get away)
Not so nice on Windows or macOS.
While Go supports it all out of the box.
Not so with Nim.
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.
It also uses cgo internally for that task. https://github.com/golang/go/blob/2a029b3f26169be7c89cb2cdcc...
Yes. I never cared for cgo, and I'd say most don't.
>and for Go libraries that don't call into OS APIs.
Or that have those APIs wrapped for different conventions. So? This still leaves billions of possible apps, and thousands of existing ones...
Mingw can do it provided the desired APIs are known to the toolchain.
FreePascal always knows the same Windows APIs, no matter on what it is compiling
I installed it with the x86_64 architecture.
EDIT: Was more explicit in architecture nomenclature.
Do the 32-bit binaries really run on M1? I thought only x86_64 would run there, emulated.
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,
It would be unreasonable to the point of impossibility to expect it to implement every instruction that an x86_64 CPU could possibly have. So as far as it pretends to be an x86_64 CPU, rather than every x86_64 CPU, it works on all [program] binaries.
I've seen some poorly behaved Mac software which used AVX instructions without testing for availability. It crashes if run on some older Macs, and it won't work at all on Apple Silicon.
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.
When they are doing a bad job, they might anger maintainers ("I didn't add this bug - this was added by macports - complain to them!"), or they might introduce additional security issues not present in the upstream package (see the Debian openssl bug from 2008)
It might also mean that you're not getting the latest versions of upstream packages because adding those patches and rebasing them on top of upstream changes takes time.
Being close to upstream was a selling-point of homebrew back in the days when it was just a collection of scripts to make it easier to build original source distributions of common Unix software.
If you want to regain my trust, remove the analytics function, swear off such things forever, and expel Mike McQuaid from the project. But I doubt that will happen, so MacPorts it is. And I'll encourage everyone I know to use it rather than Homebrew.
One thing I still want to point out though: whatever we do, we do it in good faith and with the best of intentions for both our users and ourselves.
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).
Oh nice! That was a big annoyance on older systems; glad to see they've fixed it.
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.
Apple had their own stuff to develop, including a new architecture, a new OS version for 2 architectures, ports of all their apps, and several other stuff besides, including the UNIX userland they ship.
The idea that a company should be responsible for all third party FOSS stuff on its platform, used by a small minority of users, is a little strange...
That said, a MacPorts guy below says that "Apple engineers had patches for basic support ready fairly quickly".
Not to mention:
https://twitter.com/wongmjane/status/1275177255681982464?s=2...
That would be me, who is not really a MacPorts guy…
> https://twitter.com/wongmjane/status/1275177255681982464
…and this is the link I replied to ;)
I'm not claiming they should have done anything. I was actually pleasantly surprised when they said they would. I'm just saying that they didn't show up with all the fixes as some may have believed from what Apple said during WWDC.
Lol, missed that. Rarely pay attention to who I'm responding to, just what they wrote :-)
I never bothered with these alternative eco-systems.
This isn't really about alternative ecosystems, it's about complementary ecosystems. There are a lot of people that use MacOS desktops alongside Linux or other Unix machines. For these people having a common set of tools that work the same, so you can use the same command lines and scripts across multiple platforms, is incredibly useful.
Other's don't.
But, to paraphrase Big Lebowski, "that's like, his preference, man".
As if some self-imposed UNIX/POSIX austerity, making do with the basic (and old) UNIX userland that comes with macOS (or other platforms), is something to be lauded?
(As opposed to just an example of someone making do with the little they need, where others' mileage may vary?)
Or is needing some of the tons of programs that don't come with "Apple platforms and their UNIX" (e.g. some random stuff I use: gnuplot, ripgrep, redis, postgres, jq, graphviz, and tons of different things others might want) somehow problematic?
Not even sure where Apple platforms and UNIX come into play as something to be contrasted to "replacements for GNU/Linux".
One of the benefits of macOS is precisely that as a UNIX it can run all kinds of UNIX tools, not just the basic POSIX utils, but close to everything available in a Linux/FreeBSD/etc package manager...
OK, I get what you mean.
But "what it is" includes being a very usable Unix core that can run all kinds of stuff one might want.
So, like you, I don't expect macOS to be a GNU/Linux, or cater to tinkering and Linux/FOSS preferences. And I do my Linux-based development in Docker, remote VPS and servers, and so on.
But, on the other hand, I wouldn't carry two laptops, a "Linux" one for running postgres and redis and gnuplot, and a Mac one for running XCode and Instruments and Photoshop, out of some principle that Mac is Mac and Linux is Linux and "never the twain (use cases) shall meet".
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.
Cite: https://github.com/NixOS/nix/issues/3853#issuecomment-678249...
Though, I'm pretty sure he's mistaken on its status.