Re: Compile mahouts with clang

267 views
Skip to first unread message

Luis Pedro Coelho

unread,
Aug 30, 2012, 12:55:23 PM8/30/12
to python...@googlegroups.com
This is one of those Mac OS weirdnesses that I think can be fixed by shuffling
the order of the #include<>s around (yes, really).

I only have access to a Mac OS 10.6 system, where mahotas compiles cleanly.

Can you try changing the order of the includes in _convex.cpp?

Other than that, it's hard for me to help you.

Sorry
Luis

On Thursday, August 30, 2012 03:38:24 PM Davide Cittaro wrote:
> Hi there, I'm trying to install mahotas on OS X 10.8 and I get this long
> error, which I guess is due to the different c++ compiler (clang in place
> of gcc):
>
> customize UnixCCompiler
> #### ['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'] ####### Missing compiler_cxx fix for UnixCCompiler
> customize UnixCCompiler using build_ext
> building 'mahotas._convex' extension
> compiling C++ sources
> C compiler: clang++ -fno-strict-aliasing -fno-common -dynamic -g -Os -pipe
> -fno-common -fno-strict-aliasing -fwrapv -mno-fused-madd -DENABLE_DTRACE
> -DMACOSX -DNDEBUG -Wall -Wshorten-64-to-32 -DNDEBUG -g -Os -Wall
> -Wstrict-prototypes -DENABLE_DTRACE -arch i386 -arch x86_64 -pipe
>
> compile options:
> '-I/Library/Python/2.7/site-packages/numpy-1.8.0.dev_5c944b9_20120828-py2.7
> -macosx-10.8-x86_64.egg/numpy/core/include
> -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.
> 7 -c' clang++: mahotas/_convex.cpp
> clang: warning: argument unused during compilation: '-mno-fused-madd'
> In file included from mahotas/_convex.cpp:7:
> In file included from mahotas/utils.hpp:6:
> In file included from
> /Library/Python/2.7/site-packages/numpy-1.8.0.dev_5c944b9_20120828-py2.7-ma
> cosx-10.8-x86_64.egg/numpy/core/include/numpy/ndarrayobject.h:17: In file
> included from
> /Library/Python/2.7/site-packages/numpy-1.8.0.dev_5c944b9_20120828-py2.7-ma
> cosx-10.8-x86_64.egg/numpy/core/include/numpy/ndarraytypes.h:1722:
> /Library/Python/2.7/site-packages/numpy-1.8.0.dev_5c944b9_20120828-py2.7-ma
> cosx-10.8-x86_64.egg/numpy/core/include/numpy/npy_deprecated_api.h:11:2:
> warning: "Using deprecated NumPy API, disable it by #defining
> NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION" [-W#warnings] #warning "Using
> deprecated NumPy API, disable it by #defining NPY_NO_DEPRECATED_API
> NPY_1_7_API_VERSION" ^
> In file included from mahotas/_convex.cpp:8:
> In file included from mahotas/numpypp/array.hpp:9:
> In file included from /usr/include/c++/4.2.1/iterator:69:
> In file included from /usr/include/c++/4.2.1/ostream:44:
> In file included from /usr/include/c++/4.2.1/ios:46:
> /usr/include/c++/4.2.1/bits/localefwd.h:57:21: error: too many arguments
> provided to function-like macro invocation isspace(_CharT, const locale&);
> ^
> /usr/include/c++/4.2.1/bits/localefwd.h:56:5: error: 'inline' can only
> appear on functions inline bool
> ^
> /usr/include/c++/4.2.1/bits/localefwd.h:57:5: error: variable 'isspace'
> declared as a template isspace(_CharT, const locale&);
> ^
> /usr/include/c++/4.2.1/bits/localefwd.h:69:21: error: too many arguments
> provided to function-like macro invocation isupper(_CharT, const locale&);
> ^
> /usr/include/c++/4.2.1/bits/localefwd.h:68:5: error: 'inline' can only
> appear on functions inline bool
> ^
> /usr/include/c++/4.2.1/bits/localefwd.h:69:5: error: variable 'isupper'
> declared as a template isupper(_CharT, const locale&);
> ^
> /usr/include/c++/4.2.1/bits/localefwd.h:73:21: error: too many arguments
> provided to function-like macro invocation islower(_CharT, const locale&);
> ^
> /usr/include/c++/4.2.1/bits/localefwd.h:72:5: error: 'inline' can only
> appear on functions inline bool
> ^
> /usr/include/c++/4.2.1/bits/localefwd.h:73:5: error: variable 'islower'
> declared as a template islower(_CharT, const locale&);
> ^
> /usr/include/c++/4.2.1/bits/localefwd.h:77:21: error: too many arguments
> provided to function-like macro invocation isalpha(_CharT, const locale&);
> ^
> /usr/include/c++/4.2.1/bits/localefwd.h:76:5: error: 'inline' can only
> appear on functions inline bool
> ^
> /usr/include/c++/4.2.1/bits/localefwd.h:77:5: error: variable 'isalpha'
> declared as a template isalpha(_CharT, const locale&);
> ^
> /usr/include/c++/4.2.1/bits/localefwd.h:93:21: error: too many arguments
> provided to function-like macro invocation isalnum(_CharT, const locale&);
> ^
> /usr/include/c++/4.2.1/bits/localefwd.h:92:5: error: 'inline' can only
> appear on functions inline bool
> ^
> /usr/include/c++/4.2.1/bits/localefwd.h:93:5: error: variable 'isalnum'
> declared as a template isalnum(_CharT, const locale&);
> ^
> /usr/include/c++/4.2.1/bits/localefwd.h:101:21: error: too many arguments
> provided to function-like macro invocation toupper(_CharT, const locale&);
> ^
> /usr/include/c++/4.2.1/bits/localefwd.h:100:5: error: 'inline' can only
> appear on functions inline _CharT
> ^
> /usr/include/c++/4.2.1/bits/localefwd.h:101:5: error: variable 'toupper'
> declared as a template toupper(_CharT, const locale&);
> ^
> /usr/include/c++/4.2.1/bits/localefwd.h:105:21: error: too many arguments
> provided to function-like macro invocation tolower(_CharT, const locale&);
> ^
> fatal error: too many errors emitted, stopping now [-ferror-limit=]
> 1 warning and 20 errors generated.
> clang: warning: argument unused during compilation: '-mno-fused-madd'
> In file included from mahotas/_convex.cpp:7:
> In file included from mahotas/utils.hpp:6:
> In file included from
> /Library/Python/2.7/site-packages/numpy-1.8.0.dev_5c944b9_20120828-py2.7-ma
> cosx-10.8-x86_64.egg/numpy/core/include/numpy/ndarrayobject.h:17: In file
> included from
> /Library/Python/2.7/site-packages/numpy-1.8.0.dev_5c944b9_20120828-py2.7-ma
> cosx-10.8-x86_64.egg/numpy/core/include/numpy/ndarraytypes.h:1722:
> /Library/Python/2.7/site-packages/numpy-1.8.0.dev_5c944b9_20120828-py2.7-ma
> cosx-10.8-x86_64.egg/numpy/core/include/numpy/npy_deprecated_api.h:11:2:
> warning: "Using deprecated NumPy API, disable it by #defining
> NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION" [-W#warnings] #warning "Using
> deprecated NumPy API, disable it by #defining NPY_NO_DEPRECATED_API
> NPY_1_7_API_VERSION" ^
> In file included from mahotas/_convex.cpp:8:
> In file included from mahotas/numpypp/array.hpp:9:
> In file included from /usr/include/c++/4.2.1/iterator:69:
> In file included from /usr/include/c++/4.2.1/ostream:44:
> In file included from /usr/include/c++/4.2.1/ios:46:
> /usr/include/c++/4.2.1/bits/localefwd.h:57:21: error: too many arguments
> provided to function-like macro invocation isspace(_CharT, const locale&);
> ^
> /usr/include/c++/4.2.1/bits/localefwd.h:56:5: error: 'inline' can only
> appear on functions inline bool
> ^
> /usr/include/c++/4.2.1/bits/localefwd.h:57:5: error: variable 'isspace'
> declared as a template isspace(_CharT, const locale&);
> ^
> /usr/include/c++/4.2.1/bits/localefwd.h:69:21: error: too many arguments
> provided to function-like macro invocation isupper(_CharT, const locale&);
> ^
> /usr/include/c++/4.2.1/bits/localefwd.h:68:5: error: 'inline' can only
> appear on functions inline bool
> ^
> /usr/include/c++/4.2.1/bits/localefwd.h:69:5: error: variable 'isupper'
> declared as a template isupper(_CharT, const locale&);
> ^
> /usr/include/c++/4.2.1/bits/localefwd.h:73:21: error: too many arguments
> provided to function-like macro invocation islower(_CharT, const locale&);
> ^
> /usr/include/c++/4.2.1/bits/localefwd.h:72:5: error: 'inline' can only
> appear on functions inline bool
> ^
> /usr/include/c++/4.2.1/bits/localefwd.h:73:5: error: variable 'islower'
> declared as a template islower(_CharT, const locale&);
> ^
> /usr/include/c++/4.2.1/bits/localefwd.h:77:21: error: too many arguments
> provided to function-like macro invocation isalpha(_CharT, const locale&);
> ^
> /usr/include/c++/4.2.1/bits/localefwd.h:76:5: error: 'inline' can only
> appear on functions inline bool
> ^
> /usr/include/c++/4.2.1/bits/localefwd.h:77:5: error: variable 'isalpha'
> declared as a template isalpha(_CharT, const locale&);
> ^
> /usr/include/c++/4.2.1/bits/localefwd.h:93:21: error: too many arguments
> provided to function-like macro invocation isalnum(_CharT, const locale&);
> ^
> /usr/include/c++/4.2.1/bits/localefwd.h:92:5: error: 'inline' can only
> appear on functions inline bool
> ^
> /usr/include/c++/4.2.1/bits/localefwd.h:93:5: error: variable 'isalnum'
> declared as a template isalnum(_CharT, const locale&);
> ^
> /usr/include/c++/4.2.1/bits/localefwd.h:101:21: error: too many arguments
> provided to function-like macro invocation toupper(_CharT, const locale&);
> ^
> /usr/include/c++/4.2.1/bits/localefwd.h:100:5: error: 'inline' can only
> appear on functions inline _CharT
> ^
> /usr/include/c++/4.2.1/bits/localefwd.h:101:5: error: variable 'toupper'
> declared as a template toupper(_CharT, const locale&);
> ^
> /usr/include/c++/4.2.1/bits/localefwd.h:105:21: error: too many arguments
> provided to function-like macro invocation tolower(_CharT, const locale&);
> ^
> fatal error: too many errors emitted, stopping now [-ferror-limit=]
> 1 warning and 20 errors generated.
> error: 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 -Wshorten-64-to-32 -DNDEBUG -g -Os
> -Wall -Wstrict-prototypes -DENABLE_DTRACE -arch i386 -arch x86_64 -pipe
> -I/Library/Python/2.7/site-packages/numpy-1.8.0.dev_5c944b9_20120828-py2.7-
> macosx-10.8-x86_64.egg/numpy/core/include
> -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.
> 7 -c mahotas/_convex.cpp -o
> build/temp.macosx-10.8-intel-2.7/mahotas/_convex.o" failed with exit status
> 1
>
> Any help?
>
> d
>
> ---
> Davide Cittaro
> daweo...@gmail.com
> http://sites.google.com/site/davidecittaro/
--
Luis Pedro Coelho | Institute for Molecular Medicine | http://luispedro.org

Davide Cittaro

unread,
Aug 30, 2012, 2:39:40 PM8/30/12
to python...@googlegroups.com
On Aug 30, 2012, at 6:55 PM, Luis Pedro Coelho <lu...@luispedro.org> wrote:

> This is one of those Mac OS weirdnesses that I think can be fixed by shuffling
> the order of the #include<>s around (yes, really).
>

Changed the order of two lines:

--- mahotas/_convex.cpp 2012-08-30 20:37:48.000000000 +0200
+++ mahotas/_convex.cpp.orig 2012-08-30 20:39:08.000000000 +0200
@@ -4,8 +4,8 @@

#include <algorithm>
#include <vector>
-#include "numpypp/array.hpp"
#include "utils.hpp"
+#include "numpypp/array.hpp"

extern "C" {
#include <Python.h>


and it works!
Thanks

d

Luis Pedro Coelho

unread,
Aug 30, 2012, 7:03:20 PM8/30/12
to python...@googlegroups.com
Thanks. I fixed it on github.

Luis

Luis Pedro Coelho

unread,
Sep 1, 2012, 12:55:15 PM9/1/12
to python...@googlegroups.com
I also released a new version of mahotas, which is mostly because of
this fix for Mac OS. I really don't like it when the released version
does not compile on one of the major platforms. This way, if you get it
with pip or easy_install now, it should get the fixed version.

Also, it has some freeimage fixes for Windows from Christoph Gohlke.

Best,
Luis

Christoph Gohlke

unread,
Sep 1, 2012, 2:01:08 PM9/1/12
to python...@googlegroups.com
Hello,

this version crashes for me in _interpolate.pyd on win32.

python -c"import faulthandler;faulthandler.enable();import
mahotas;mahotas.test()"
...........E.....................F..................................................................................................Fatal
Python error: Segmentation fault

Current thread 0x0004f0f4:
File "X:\Python27\lib\site-packages\mahotas\interpolate.py", line 273
in shift
File "X:\Python27\lib\site-packages\mahotas\features\lbp.py", line 57
in lbp
File "X:\Python27\lib\site-packages\mahotas\tests\test_lbp.py", line
16 in test_nonzero
File "X:\Python27\lib\site-packages\nose\case.py", line 197 in runTest
File "X:\Python27\lib\unittest\case.py", line 327 in run
File "X:\Python27\lib\unittest\case.py", line 391 in __call__
File "X:\Python27\lib\site-packages\nose\case.py", line 151 in runTest
File "X:\Python27\lib\site-packages\nose\case.py", line 133 in run
File "X:\Python27\lib\site-packages\nose\case.py", line 45 in __call__
File "X:\Python27\lib\site-packages\nose\suite.py", line 223 in run
File "X:\Python27\lib\site-packages\nose\suite.py", line 176 in __call__
File "X:\Python27\lib\site-packages\nose\suite.py", line 223 in run
File "X:\Python27\lib\site-packages\nose\suite.py", line 176 in __call__
File "X:\Python27\lib\site-packages\nose\suite.py", line 223 in run
File "X:\Python27\lib\site-packages\nose\suite.py", line 176 in __call__
File "X:\Python27\lib\site-packages\nose\suite.py", line 223 in run
File "X:\Python27\lib\site-packages\nose\suite.py", line 176 in __call__
File "X:\Python27\lib\site-packages\nose\core.py", line 61 in run
File "X:\Python27\lib\site-packages\nose\core.py", line 197 in runTests
File "X:\Python27\lib\unittest\main.py", line 95 in __init__
File "X:\Python27\lib\site-packages\nose\core.py", line 118 in __init__
File "X:\Python27\lib\site-packages\nose\core.py", line 284 in run
File "X:\Python27\lib\site-packages\mahotas\tests\__init__.py", line
6 in run
File "<string>", line 1 in <module>

The debugger indicates the crash occurs during a new/malloc call with a
size of 4130559571.

Christoph

Luis Pedro Coelho

unread,
Sep 1, 2012, 6:42:38 PM9/1/12
to python...@googlegroups.com
On 09/01/2012 07:01 PM, Christoph Gohlke wrote:
> Hello,
>
> this version crashes for me in _interpolate.pyd on win32.

Aargh!

Can you try the attached patch? (I also committed to github, so you can
get it from there, if you prefer). This is a bona fides bug-fix, but I
am not 100% sure how it would crash your system.

Thanks for letting me know about this,
Luis

interporlate.patch

Christoph Gohlke

unread,
Sep 1, 2012, 8:54:00 PM9/1/12
to python...@googlegroups.com
Thanks, that works (no crash).

Christoph

Christoph Gohlke

unread,
Sep 1, 2012, 9:53:06 PM9/1/12
to python...@googlegroups.com
On 9/1/2012 3:42 PM, Luis Pedro Coelho wrote:
Hello,

I submitted tickets for three test errors/failures I see on Windows.

Christoph
Reply all
Reply to author
Forward
0 new messages