Open shiwanlin opened 6 years ago
This is still an issue as of 04/08/2020. Was just about to create a new issue when I saw this, here are some more details:
Steps to reproduce:
1). Install Visual Studio (I'm using VS2017 community edition I think) and Anaconda 3 on a Windows machine
2). Clone or download the pyhsmm
repo
3). Run the following:-
conda create -n test pip future cython`
conda activate test
cd <pyhsmm repo directory>
pip install -v -e .
Expected behaviour: pyhsmm installs correctly.
Actual behaviour: build fails due to MSVC not defining __builtin_expect. See below command prompt excerpt:-
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.15.26726\bin\HostX86\x64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -Ideps/ -Ipyhsmm\internals -IC:\Users\LSPS2\Anaconda3\envs\test\include -IC:\Users\LSPS2\Anaconda3\envs\test\include -IC:\Users\LSPS2\Anaconda3\envs\test\lib\site-packages\numpy\core\include "-IC:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.15.26726\ATLMFC\include" "-IC:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.15.26726\include" "-IC:\Program Files (x86)\Windows Kits\NETFXSDK\4.6.1\include\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17134.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17134.0\shared" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17134.0\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17134.0\winrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17134.0\cppwinrt" /EHsc /Tppyhsmm\internals\hmm_messages_interface.cpp /Fobuild\temp.win-amd64-3.8\Release\pyhsmm\internals\hmm_messages_interface.obj -std=c++11 -O3 -w -DNDEBUG -DHMM_TEMPS_ON_HEAP
cl : Command line warning D9025 : overriding '/W3' with '/w'
cl : Command line warning D9002 : ignoring unknown option '-std=c++11'
cl : Command line warning D9002 : ignoring unknown option '-O3'
hmm_messages_interface.cpp
c:\users\lsps2\anaconda3\envs\test\lib\site-packages\numpy\core\include\numpy\npy_1_7_deprecated_api.h(14) : Warning Msg: Using deprecated NumPy API, disable it with #define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION
c:\users\lsps2\documents\python\pyhsmm\pyhsmm\internals\hmm_messages.h(147): error C3861: '__builtin_expect': identifier not found
c:\users\lsps2\documents\python\pyhsmm\pyhsmm\internals\hmm_messages.h(281): note: see reference to function template instantiation 'Type hmm::messages_forwards_normalized<FloatType>(bool,int,int,Type *,Type *,Type *,Type *)' being compiled
with
[
Type=double,
FloatType=double
]
c:\users\lsps2\documents\python\pyhsmm\pyhsmm\internals\hmm_messages.h(281): note: while compiling class template member function 'FloatType hmmc<FloatType,int32_t>::messages_forwards_normalized(bool,int,int,FloatType *,FloatType *,FloatType *,FloatType *)'
with
[
FloatType=double
]
pyhsmm\internals\hmm_messages_interface.cpp(9205): note: see reference to function template instantiation 'FloatType hmmc<FloatType,int32_t>::messages_forwards_normalized(bool,int,int,FloatType *,FloatType *,FloatType *,FloatType *)' being compiled
with
[
FloatType=double
]
pyhsmm\internals\hmm_messages_interface.cpp(3748): note: see reference to class template instantiation 'hmmc<double,int32_t>' being compiled
c:\users\lsps2\documents\python\pyhsmm\pyhsmm\internals\hmm_messages.h(157): error C3861: '__builtin_expect': identifier not found
c:\users\lsps2\documents\python\pyhsmm\pyhsmm\internals\hmm_messages.h(69): error C3861: '__builtin_expect': identifier not found
c:\users\lsps2\documents\python\pyhsmm\pyhsmm\internals\hmm_messages.h(271): note: see reference to function template instantiation 'void hmm::messages_forwards_log<FloatType>(bool,int,int,Type *,Type *,Type *,Type *)' being compiled
with
[
FloatType=double,
Type=double
]
c:\users\lsps2\documents\python\pyhsmm\pyhsmm\internals\hmm_messages.h(271): note: while compiling class template member function 'void hmmc<double,int32_t>::messages_forwards_log(bool,int,int,FloatType *,FloatType *,FloatType *,FloatType *)'
with
[
FloatType=double
]
pyhsmm\internals\hmm_messages_interface.cpp(5073): note: see reference to function template instantiation 'void hmmc<double,int32_t>::messages_forwards_log(bool,int,int,FloatType *,FloatType *,FloatType *,FloatType *)' being compiled
with
[
FloatType=double
]
Creating c:\users\lsps2\anaconda3\envs\test\lib\site-packages\pyhsmm.egg-link (link to .)
Adding pyhsmm 0.1.6 to easy-install.pth file
Installed c:\users\lsps2\documents\python\pyhsmm
C:\Users\LSPS2\Documents\Python\pyhsmm\setup.py:44: UserWarning: Failed to build extension modules
warn('Failed to build extension modules')
Traceback (most recent call last):
File "C:\Users\LSPS2\Anaconda3\envs\test\lib\distutils\_msvccompiler.py", line 438, in compile
self.spawn(args)
File "C:\Users\LSPS2\Anaconda3\envs\test\lib\distutils\_msvccompiler.py", line 557, in spawn
return super().spawn(cmd)
File "C:\Users\LSPS2\Anaconda3\envs\test\lib\distutils\ccompiler.py", line 910, in spawn
spawn(cmd, dry_run=self.dry_run)
File "C:\Users\LSPS2\Anaconda3\envs\test\lib\distutils\spawn.py", line 38, in spawn
_spawn_nt(cmd, search_path, dry_run=dry_run)
File "C:\Users\LSPS2\Anaconda3\envs\test\lib\distutils\spawn.py", line 80, in _spawn_nt
raise DistutilsExecError(
distutils.errors.DistutilsExecError: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Community\\VC\\Tools\\MSVC\\14.15.26726\\bin\\HostX86\\x64\\cl.exe' failed with exit status 2
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\LSPS2\Documents\Python\pyhsmm\setup.py", line 42, in run
_build_ext.run(self)
File "C:\Users\LSPS2\Anaconda3\envs\test\lib\site-packages\Cython\Distutils\old_build_ext.py", line 186, in run
_build_ext.build_ext.run(self)
File "C:\Users\LSPS2\Anaconda3\envs\test\lib\distutils\command\build_ext.py", line 340, in run
self.build_extensions()
File "C:\Users\LSPS2\Anaconda3\envs\test\lib\site-packages\Cython\Distutils\old_build_ext.py", line 195, in build_extensions
_build_ext.build_ext.build_extensions(self)
File "C:\Users\LSPS2\Anaconda3\envs\test\lib\distutils\command\build_ext.py", line 449, in build_extensions
self._build_extensions_serial()
File "C:\Users\LSPS2\Anaconda3\envs\test\lib\distutils\command\build_ext.py", line 474, in _build_extensions_serial
self.build_extension(ext)
File "C:\Users\LSPS2\Anaconda3\envs\test\lib\distutils\command\build_ext.py", line 528, in build_extension
objects = self.compiler.compile(sources,
File "C:\Users\LSPS2\Anaconda3\envs\test\lib\distutils\_msvccompiler.py", line 440, in compile
raise CompileError(msg)
distutils.errors.CompileError: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Community\\VC\\Tools\\MSVC\\14.15.26726\\bin\\HostX86\\x64\\cl.exe' failed with exit status 2
Successfully installed cycler-0.10.0 kiwisolver-1.2.0 matplotlib-3.2.1 nose-1.3.7 numpy-1.18.2 pybasicbayes-0.2.2 pyhsmm pyparsing-2.4.7 python-dateutil-2.8.1 scipy-1.4.1 six-1.14.0
Cleaning up...
Removed build tracker: 'C:\\Users\\LSPS2\\AppData\\Local\\Temp\\pip-req-tracker-ip9edlam'
Applying @shiwanlin 's change fixes the build.
I met the same issue, how do you address this issue?
pyhsmm/internals/util.h
needs to protect the gnu builtin just like in other files in the same directory:
define likely(x) __builtin_expect(!!(x),true)
define unlikely(x) __builtin_expect(!!(x),false)
======>
/ Test for GCC > 2.95 /
if defined(GNUC) && (GNUC > 2 || (GNUC == 2 && (__GNUC_MINOR__ > 95)))
define likely(x) __builtin_expect(!!(x),true)
define unlikely(x) __builtin_expect(!!(x),false)
else / !GNUC or GCC < 2.95 /
define likely(x) (x)
define unlikely(x) (x)
endif / GNUC /