steeve / python-lz4

LZ4 bindings for python
http://github.com/steeve/python-lz4
105 stars 31 forks source link

O4 flag causes build failure #8

Closed pdh closed 10 years ago

pdh commented 11 years ago

With the O4 flag and clang version 4.0 on os x 10.8.3 I get the following error when trying to build:

clang: error: cannot use 'lto-bc' output with multiple -arch options

The full compile command: clang -fno-strict-aliasing -fno-common -dynamic -g -Os -pipe -fno-common -fno-strict-aliasing -fwrapv -mno-fused-madd -DENABLE_DTRACE -DMACOSX -DNDEBUG -Wall -Wstrict-prototypes -Wshorten-64-to-32 -DNDEBUG -g -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -arch i386 -arch x86_64 -pipe -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c src/lz4.c -o build/temp.macosx-10.8-intel-2.7/src/lz4.o -O4

Setting the arg to O3 works fine, but I imagine does not yield the same performance gains.

steeve commented 11 years ago

It seems the issue stems from the fact that it's trying to build a universal binary. From what I could gather online, try adding -flto to your CFLAGS. One thing you can do also is force arch x86_64 via arch -arch x86_64, so running like so:

$ arch -arch x86_64 pip install lz4

But I can't reproduce the problem on my machine:

$ CFLAGS=-O4 pip install -e .                                                                                                              ⏎ ◼
Obtaining file:///Users/steeve/projects/python-lz4
  Running setup.py egg_info for package from file:///Users/steeve/projects/python-lz4

Installing collected packages: lz4
  Running setup.py develop for lz4

    building 'lz4' extension
    /usr/bin/clang -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -O4 -arch x86_64 -I/usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c src/lz4.c -o build/temp.macosx-10.8-x86_64-2.7/src/lz4.o -O4
    /usr/bin/clang -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -O4 -arch x86_64 -I/usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c src/lz4hc.c -o build/temp.macosx-10.8-x86_64-2.7/src/lz4hc.o -O4
    /usr/bin/clang -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -O4 -arch x86_64 -I/usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c src/python-lz4.c -o build/temp.macosx-10.8-x86_64-2.7/src/python-lz4.o -O4
    /usr/bin/clang -bundle -undefined dynamic_lookup -L/usr/local/Cellar/readline/6.2.4/lib -L/usr/local/Cellar/gettext/0.18.1.1/lib -L/usr/local/lib -L/opt/X11/lib -O4 -arch x86_64 build/temp.macosx-10.8-x86_64-2.7/src/lz4.o build/temp.macosx-10.8-x86_64-2.7/src/lz4hc.o build/temp.macosx-10.8-x86_64-2.7/src/python-lz4.o -o build/lib.macosx-10.8-x86_64-2.7/lz4.so
    Creating /Users/steeve/projects/veezio/instance/lib/python2.7/site-packages/lz4.egg-link (link to src)
    Adding lz4 0.6.0 to easy-install.pth file

    Installed /Users/steeve/projects/python-lz4/src
Successfully installed lz4
Cleaning up...
$
pdh commented 11 years ago

Thank you for the suggestions. The following worked for me:

CFLAGS=-arch=x86-64 pip install -e .
steeve commented 11 years ago

I'm leaving it open because I think you shouldn't have to fiddle with that. I'll investigate :)

AJRenold commented 11 years ago

I had the same installation issues (in a virtualenv) and solved the problem by navigating into the lz4 directory created by pip in my virtualenv directory and ran:

CFLAGS=-arch=x86-64 pip install -e .

This on OS X 10.8.5 intel x86