Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to force pip to use GCC on OSX?

A bit of an irritating problem with pip on OSX. A python program I am trying to install requires GCC.

The suggested invocation is:

env CC=/usr/local/bin/gcc-6 pip install angr 

However this results in an error suggested OSX decided to run CLANG instead:

clang: error: unknown argument: '-malign-double'

This makes sense since:

$ env CC
clang: error: no input files

Despite the fact that:

$env 
...
cc=/usr/local/bin/gcc-6
CC=/usr/local/bin/gcc-6

Of course I tried:

$CC-/usr/local/bin/gcc-6 
env $CC pip install angr 

but of course:

$ env $CC pip install angr
gcc-6: error: pip: No such file or directory
gcc-6: error: install: No such file or directory
gcc-6: error: angr: No such file or directory
gcc-6: fatal error: no input files

and despite what env tells me just running

$ pip install angr 

results in more

clang: error: unknown argument: '-malign-double'

So what am I missing here? Does OSX hate GCC that bad or is there some basic shell fu I am missing out on here?

like image 838
MrSynAckSter Avatar asked Sep 13 '25 03:09

MrSynAckSter


1 Answers

Your test command env $CC pip install angr fails because the dollar sign evaluates the variable and it effectively ran gcc rather than pip!

Inian's suggested command env CC="/usr/local/bin/gcc-6 pip install angr" has the closing quote in the wrong place, making it a no-op.

The syntax for env CC=/usr/local/bin/gcc-6 pip install angr is correct, but the gcc error could be in angr or any of the 26 packages it depends on such as ana, bintrees, cachetools, capstone, cooldict, z3-solver...

So let's get back to clang. Looking at angr issues on github, it appears that a clang-incompatibility for z3-solver was fixed on May 10th, a month after this question was posted. See: https://github.com/Z3Prover/z3/issues/1016

So this now works fine for me with the latest pip (pip install --upgrade pip) on macOS 10.13 High Sierra + Xcode 9.0.1:

pip install --user angr

Well, the above command actually defaults to using binary packages so of course it works. With 10 minutes, you can verify that the compiled path works with clang by uninstalling all pips then:

pip install --user --no-cache-dir --no-binary :all: angr
like image 51
jdonald Avatar answered Sep 14 '25 17:09

jdonald