MacOS – HomeBrew offloading package compilation

binaryhomebrewinstallmacos

My poor old 2008 aluminium MacBook isn't the only old piece of kit I have running homebrew packages, I really appreciate the ability to have a package manager in Mac OS, at least while I make my way to linux. However, even my 2014 iMac is feeling some weight from Homebrew package management. It's slow although very automated, I would like to speed things up a little on my older computers.

Is there any way, that the source code for packages like youtube-dl, aircrack-ng, or most non-bottled packages could be pre-compiled and installed as a binary file for Mac OS / OS X? Or at the very least, something similar to a .deb file (like a bottle), where the source code has been compiled and it's left to the system to appropriately decompress and copy files and libraries to their appropriate locations? Thanks!

Best Answer

By default, packages are installed in the way you describe... "Bottles" are precompiled binaries downloaded as compressed tape archives, the contents of which are then "poured" into the appropriate paths.

If you specify options, or use custom compile flags, then naturally brew will build from source. But if you for example, brew install nmap htop bmon, it will download the bottle for your system version and pour it along with any missing dependencies.

That being said, there are definitely situations where brew compiles from source, so to try to answer your question, how often is it that you find this a problem?

There's no way to set it up so that brew compiles on a different machine "automagically" (that is, unless you implement this as a feature and implement it into your installation of brew). You can imagine how this could be difficult; architecture differences aside, conflicts/dependencies needing to be resolved, the differences in environment, etc. would make this a nightmare.

If this is more of an occasional annoyance than a regular problem, what you might want to try is install whatever formula you want on the faster machine with --build-bottle. Then you can "bottle" the package yourself by running brew bottle to install on the slower machine.

I can't recommend this with any level of confidence though, since I don't know how well it would work for all formulae. You would need to be on the same OS/architecture, and the binaries will be compiled for the lowest common denominator CPU (unless you specify which one) so the build might perform worse, depending on which features it was designed to use.

If the difference in compilation time is so large that this seems like a viable route, the two machines might not even be compatible (I don't remember what the 2008 MacBook was, core 2?), and cross-compiling within brew would be a whole separate headache all on its own, you might be better off just not using a package manager at all and compiling/configuring the software yourself.