Setting default compilation flags

(François Beaune) #1

We’re building a large C++ application on OS X Yosemite 10.10. This application relies on a number of third-party libraries which we install using Homebrew prior to building our application. Our release script picks up all the dependencies and include them in the final package.

We love Homebrew as it makes our live so much simpler! We’d like to keep using it.

Unfortunately several of our users reported that our application didn’t work on their Mac. For instance a user running macOS 10.12.6 on a late 2012 27-inch iMac is getting llegal instruction: 4 (all details here).

It looks like the crash occurs in one of the third-party dependency we bundle, OpenImageIO, which was installed on the build machine with the following commands:

brew tap homebrew/science
brew install openimageio

brew info openimageio reports that it was indeed built from source:

/usr/local/Cellar/openimageio/1.7.17_1 (66 files, 16.0MB) *
  Built from source on 2017-11-27 at 19:15:19

I suspect that Homebrew enables advanced x86 instruction sets when compiling on the build machine.

Here is the Homebrew formula for OpenImageIO:


  1. Is there a way to find out which flags or which command lines Homebrew is using?
  2. Are HOMEBREW_CC and HOMEBREW_CXX still honored?
  3. Alternatively, is there a way to globally set clang’s default flags on macOS?

(Mike McQuaid) #2

Homebrew formulae are not build for redistribution. If you wish to do so you should build them from source yourself.

(François Beaune) #3

Hi Mike, thanks for the quick answer.

I understand that, and will switch to fully built-from-source if I have no other options. However, if Homebrew happens to support custom build flags (HOMEBREW_CC or HOMEBREW_CXX? Are these still supported) then we could probably continue using Homebrew for most third-party libs and save a ton of time.

(Mike McQuaid) #4

We do not support custom build flags, sorry.

(Franklin Yu) #5

I think Homebrew is wrong tool for such task. Even Docker or something similar would be better.

(François Beaune) #6

How would Docker help?

The problem is the staggering amount of work required to build third party libraries manually. The fact that Homebrew knows how to build most of them automatically is a great help, and all I’m looking for is a way to leverage that.

If I could just hack Homebrew or convince it to not emit SSE4.2 instructions on my OS X Yosemite build VM, it’d be just fine and I could move on to more interesting tasks :slight_smile:

I perfectly understand that this is not the primary purpose of Homebrew, but it happens to almost completely fulfill my needs. That’s why I feel it’s worth exploring if a simple hack or environment variable could fill the 0.1% gap. If not I’ll just go ahead and spend the best part of a week-end rebuilding everything manually :slight_smile: