andreasvc / disco-dop

Discontinuous Data-Oriented Parsing
http://discodop.readthedocs.io
GNU General Public License v2.0
46 stars 16 forks source link

cmath expressions not compiling #56

Closed bf777 closed 6 years ago

bf777 commented 6 years ago

The installation process for disco-dop on Mac OSX High Sierra (10.13.3) works until Cython creates pcfg.cpp; here I get this output:

(tensorflow) Brandons-MBP-2:disco-dop brandon$ env CC=gcc sudo python3 setup.py install
running install
running bdist_egg
running egg_info
writing disco_dop.egg-info/PKG-INFO
writing dependency_links to disco_dop.egg-info/dependency_links.txt
writing entry points to disco_dop.egg-info/entry_points.txt
writing requirements to disco_dop.egg-info/requires.txt
writing top-level names to disco_dop.egg-info/top_level.txt
reading manifest file 'disco_dop.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
warning: no files found matching '*.c' under directory 'discodop'
warning: no previously-included files matching '*.pyx' found under directory 'discodop'
warning: no previously-included files matching '*.pxi' found under directory 'discodop'
warning: no previously-included files matching '*.pxd' found under directory 'discodop'
warning: no previously-included files matching '*' found under directory 'web/grammars'
writing manifest file 'disco_dop.egg-info/SOURCES.txt'
installing library code to build/bdist.macosx-10.6-intel/egg
running install_lib
running build_py
running build_ext
building 'discodop.pcfg' extension
/usr/bin/clang -fno-strict-aliasing -Wsign-compare -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -arch i386 -arch x86_64 -g -I./discodop -Idiscodop -I/Library/Frameworks/Python.framework/Versions/3.6/include/python3.6m -c discodop/pcfg.cpp -o build/temp.macosx-10.6-intel-3.6/discodop/pcfg.o -Isparsepp/ -Wno-strict-prototypes -Wno-unused-function -Wno-unreachable-code -Wno-sign-compare -D__STDC_LIMIT_MACROS -O3 -march=native -DNDEBUG
In file included from discodop/pcfg.cpp:589:
In file included from ./discodop/_containers.h:14:
In file included from ./discodop/../cpp-btree/safe_btree_map.h:36:
In file included from ./discodop/../cpp-btree/btree_container.h:21:
./discodop/../cpp-btree/btree.h:872:10: warning: class 'btree_internal_locate_plain_compare' was previously declared as a struct [-Wmismatched-tags]
  friend class btree_internal_locate_plain_compare;
         ^
./discodop/../cpp-btree/btree.h:847:8: note: previous use is here
struct btree_internal_locate_plain_compare {
       ^
./discodop/../cpp-btree/btree.h:872:10: note: did you mean struct here?
  friend class btree_internal_locate_plain_compare;
         ^~~~~
         struct
./discodop/../cpp-btree/btree.h:873:10: warning: class 'btree_internal_locate_compare_to' was previously declared as a struct [-Wmismatched-tags]
  friend class btree_internal_locate_compare_to;
         ^
./discodop/../cpp-btree/btree.h:855:8: note: previous use is here
struct btree_internal_locate_compare_to {
       ^
./discodop/../cpp-btree/btree.h:873:10: note: did you mean struct here?
  friend class btree_internal_locate_compare_to;
         ^~~~~
         struct
discodop/pcfg.cpp:5239:20: warning: comparison of 0 <= unsigned expression is always true [-Wtautological-compare]
    __pyx_t_1 = (0 <= __pyx_v_start);
                 ~ ^  ~~~~~~~~~~~~~
discodop/pcfg.cpp:8848:26: error: use of undeclared identifier 'isinf'
            __pyx_t_9 = (isinf(__pyx_v_prob) != 0);
                         ^
discodop/pcfg.cpp:8885:26: error: use of undeclared identifier 'isfinite'; did you mean 'std::isfinite'?
            __pyx_t_9 = (isfinite(__pyx_v_prob) != 0);
                         ^~~~~~~~
                         std::isfinite
/usr/include/c++/4.2.1/cmath:543:5: note: 'std::isfinite' declared here
    isfinite(_Tp __f) { return ::__gnu_cxx::__capture_isfinite(__f); }
    ^
discodop/pcfg.cpp:8980:22: error: use of undeclared identifier 'isinf'
        __pyx_t_4 = (isinf(__pyx_v_prevprob) != 0);
                     ^
discodop/pcfg.cpp:8986:22: error: use of undeclared identifier 'isfinite'; did you mean 'std::isfinite'?
        __pyx_t_4 = (isfinite(__pyx_f_8discodop_4pcfg_13DenseCFGChart__subtreeprob(__pyx_v_chart, __pyx_v_item)) != 0);
                     ^~~~~~~~
                     std::isfinite
/usr/include/c++/4.2.1/cmath:543:5: note: 'std::isfinite' declared here
    isfinite(_Tp __f) { return ::__gnu_cxx::__capture_isfinite(__f); }
    ^
discodop/pcfg.cpp:9752:26: error: use of undeclared identifier 'isinf'
            __pyx_t_9 = (isinf(__pyx_v_prob) != 0);
                         ^
discodop/pcfg.cpp:9789:26: error: use of undeclared identifier 'isfinite'; did you mean 'std::isfinite'?
            __pyx_t_9 = (isfinite(__pyx_v_prob) != 0);
                         ^~~~~~~~
                         std::isfinite
/usr/include/c++/4.2.1/cmath:543:5: note: 'std::isfinite' declared here
    isfinite(_Tp __f) { return ::__gnu_cxx::__capture_isfinite(__f); }
    ^
discodop/pcfg.cpp:9884:22: error: use of undeclared identifier 'isinf'
        __pyx_t_4 = (isinf(__pyx_v_prevprob) != 0);
                     ^
discodop/pcfg.cpp:9890:22: error: use of undeclared identifier 'isfinite'; did you mean 'std::isfinite'?
        __pyx_t_4 = (isfinite(__pyx_f_8discodop_4pcfg_14SparseCFGChart__subtreeprob(__pyx_v_chart, __pyx_v_item)) != 0);
                     ^~~~~~~~
                     std::isfinite
/usr/include/c++/4.2.1/cmath:543:5: note: 'std::isfinite' declared here
    isfinite(_Tp __f) { return ::__gnu_cxx::__capture_isfinite(__f); }
    ^
discodop/pcfg.cpp:10476:26: error: use of undeclared identifier 'isfinite'; did you mean 'std::isfinite'?
            __pyx_t_8 = (isfinite(__pyx_v_rightprob) != 0);
                         ^~~~~~~~
                         std::isfinite
/usr/include/c++/4.2.1/cmath:543:5: note: 'std::isfinite' declared here
    isfinite(_Tp __f) { return ::__gnu_cxx::__capture_isfinite(__f); }
    ^
3 warnings and 9 errors generated.
error: command '/usr/bin/clang' failed with exit status 1

I hotfixed the issue by replacing each isfinite and isinf with std::isfinite and std::isinf. However, considering that the code is machine-compiled this isn't a sustainable solution. There's a possibility that this could be a gcc problem (see here) but I haven't ascertained that yet.

andreasvc commented 6 years ago

Thanks for the report. I don't have a Mac to test with, unfortunately. Are you running that gcc version (4.3) with the problem you link to? Or are you actually running clang? I notice your log says /usr/bin/clang, even though you ask for gcc... Maybe try without that option? I just tried compiling with clang on Ubuntu 16.04 and it seems to works fine (clang 3.8).

andreasvc commented 6 years ago

I just added a workaround, let me know if this fixes the issue.

bf777 commented 6 years ago

The workaround worked! All good now, thanks!