Python numba / llvmlite on Debian 8 - i can't build llvmlite

允我心安 提交于 2020-01-14 22:48:18

问题


Im trying to install numba on a Debian 8 system as described here: http://llvmlite.pydata.org/en/latest/install/index.html (secion 2.2.3).

I have installed LLVM 3.5 and it seems to find it but i keep getting errors when building llvmlite with setup.py:

# python setup.py build

Here is the complete output:

running build
got version from VCS {'version': '0.9.0.dev+7.gf5a7007.dirty', 'full': 'f5a70072ce0e7f5e432d6645056a60b00f957c66.dirty'}
running build_ext
/usr/bin/python ffi/build.py
LLVM version... 3.5.0
# static-libstdc++ avoids runtime dependencies on a
# particular libstdc++ version.
g++ -static-libstdc++ -shared -flto `llvm-config-3.5 --cxxflags` -fno-rtti -g assembly.cpp bitcode.cpp core.cpp initfini.cpp module.cpp value.cpp executionengine.cpp transforms.cpp passmanagers.cpp targets.cpp dylib.cpp linker.cpp -o libllvmlite.so -flto `llvm-config-3.5 --ldflags` -Wl,--exclude-libs=ALL `llvm-config-3.5 --system-libs --libs all`
assembly.cpp: In function ‘LLVMOpaqueModule* LLVMPY_ParseAssembly(LLVMContextRef, const char*, const char**)’:
assembly.cpp:25:64: error: ‘parseAssemblyString’ was not declared in this scope
     Module *m = parseAssemblyString(ir, error, *unwrap(context)).release();
                                                                ^
bitcode.cpp: In function ‘void LLVMPY_WriteBitcodeToString(LLVMModuleRef, const char**, size_t*)’:
bitcode.cpp:13:62: error: ‘LLVMWriteBitcodeToMemoryBuffer’ was not declared in this scope
     LLVMMemoryBufferRef MB = LLVMWriteBitcodeToMemoryBuffer(M);
                                                              ^
core.cpp: In function ‘void LLVMPY_SetCommandLine(const char*, const char*)’:
core.cpp:36:46: error: ‘LLVMParseCommandLineOptions’ was not declared in this scope
     LLVMParseCommandLineOptions(2, argv, NULL);
                                              ^
module.cpp: In function ‘LLVMOpaqueModule* LLVMPY_CloneModule(LLVMModuleRef)’:
module.cpp:223:29: error: ‘LLVMCloneModule’ was not declared in this scope
     return LLVMCloneModule(M);
                             ^
executionengine.cpp: In function ‘LLVMOpaqueExecutionEngine* create_execution_engine(LLVMModuleRef, LLVMTargetMachineRef, char**)’:
executionengine.cpp:72:74: error: no matching function for call to ‘llvm::EngineBuilder::EngineBuilder(std::unique_ptr<llvm::Module>)’
     llvm::EngineBuilder eb(std::unique_ptr<llvm::Module>(llvm::unwrap(M)));
                                                                          ^
executionengine.cpp:72:74: note: candidates are:
In file included from executionengine.cpp:6:0:
/usr/lib/llvm-3.5/include/llvm/ExecutionEngine/ExecutionEngine.h:594:3: note: llvm::EngineBuilder::EngineBuilder(llvm::Module*)
   EngineBuilder(Module *m) : M(m) {
   ^
/usr/lib/llvm-3.5/include/llvm/ExecutionEngine/ExecutionEngine.h:594:3: note:   no known conversion for argument 1 from ‘std::unique_ptr<llvm::Module>’ to ‘llvm::Module*’
/usr/lib/llvm-3.5/include/llvm/ExecutionEngine/ExecutionEngine.h:570:7: note: llvm::EngineBuilder::EngineBuilder(const llvm::EngineBuilder&)
 class EngineBuilder {
       ^
/usr/lib/llvm-3.5/include/llvm/ExecutionEngine/ExecutionEngine.h:570:7: note:   no known conversion for argument 1 from ‘std::unique_ptr<llvm::Module>’ to ‘const llvm::EngineBuilder&’
/usr/lib/llvm-3.5/include/llvm/ExecutionEngine/ExecutionEngine.h:570:7: note: llvm::EngineBuilder::EngineBuilder(llvm::EngineBuilder&&)
/usr/lib/llvm-3.5/include/llvm/ExecutionEngine/ExecutionEngine.h:570:7: note:   no known conversion for argument 1 from ‘std::unique_ptr<llvm::Module>’ to ‘llvm::EngineBuilder&&’
executionengine.cpp: In function ‘uint64_t LLVMPY_GetGlobalValueAddress(LLVMExecutionEngineRef, const char*)’:
executionengine.cpp:107:46: error: ‘LLVMGetGlobalValueAddress’ was not declared in this scope
     return LLVMGetGlobalValueAddress(EE, Name);
                                              ^
executionengine.cpp: In function ‘uint64_t LLVMPY_GetFunctionAddress(LLVMExecutionEngineRef, const char*)’:
executionengine.cpp:114:43: error: ‘LLVMGetFunctionAddress’ was not declared in this scope
     return LLVMGetFunctionAddress(EE, Name);
                                           ^
executionengine.cpp: At global scope:
executionengine.cpp:187:45: error: ‘llvm::MemoryBufferRef’ has not been declared
                                       llvm::MemoryBufferRef MBR)
                                             ^
executionengine.cpp:200:49: error: conflicting return type specified for ‘virtual std::unique_ptr<llvm::MemoryBuffer> LLVMPYObjectCache::getObject(const llvm::Module*)’
     virtual std::unique_ptr<llvm::MemoryBuffer> getObject(const llvm::Module* M)
                                                 ^
In file included from executionengine.cpp:8:0:
/usr/lib/llvm-3.5/include/llvm/ExecutionEngine/ObjectCache.h:36:25: error:   overriding ‘virtual llvm::MemoryBuffer* llvm::ObjectCache::getObject(const llvm::Module*)’
   virtual MemoryBuffer* getObject(const Module* M) = 0;
                         ^
/usr/lib/llvm-3.5/include/llvm/ExecutionEngine/ObjectCache.h:30:16: warning: ‘virtual void llvm::ObjectCache::notifyObjectCompiled(const llvm::Module*, const llvm::MemoryBuffer*)’ was hidden [-Woverloaded-virtual]
   virtual void notifyObjectCompiled(const Module *M, const MemoryBuffer *Obj) = 0;
                ^
executionengine.cpp:186:18: warning:   by ‘virtual void LLVMPYObjectCache::notifyObjectCompiled(const llvm::Module*, int)’ [-Woverloaded-virtual]
     virtual void notifyObjectCompiled(const llvm::Module *M,
                  ^
executionengine.cpp: In member function ‘virtual void LLVMPYObjectCache::notifyObjectCompiled(const llvm::Module*, int)’:
executionengine.cpp:191:42: error: request for member ‘getBufferStart’ in ‘MBR’, which is of non-class type ‘int’
                                      MBR.getBufferStart(),
                                          ^
executionengine.cpp:192:42: error: request for member ‘getBufferSize’ in ‘MBR’, which is of non-class type ‘int’
                                      MBR.getBufferSize() };
                                          ^
executionengine.cpp: In member function ‘virtual std::unique_ptr<llvm::MemoryBuffer> LLVMPYObjectCache::getObject(const llvm::Module*)’:
executionengine.cpp:211:21: error: no match for ‘operator=’ (operand types are ‘std::unique_ptr<llvm::MemoryBuffer>’ and ‘llvm::MemoryBuffer*’)
                 res = llvm::MemoryBuffer::getMemBufferCopy(
                     ^
executionengine.cpp:211:21: note: candidates are:
In file included from /usr/include/c++/4.9/memory:81:0,
                 from /usr/lib/llvm-3.5/include/llvm/ADT/SmallVector.h:28,
                 from /usr/lib/llvm-3.5/include/llvm/IR/DataLayout.h:24,
                 from /usr/lib/llvm-3.5/include/llvm/IR/Module.h:20,
                 from executionengine.cpp:5:
/usr/include/c++/4.9/bits/unique_ptr.h:249:7: note: std::unique_ptr<_Tp, _Dp>& std::unique_ptr<_Tp, _Dp>::operator=(std::unique_ptr<_Tp, _Dp>&&) [with _Tp = llvm::MemoryBuffer; _Dp = std::default_delete<llvm::MemoryBuffer>]
       operator=(unique_ptr&& __u) noexcept
       ^
/usr/include/c++/4.9/bits/unique_ptr.h:249:7: note:   no known conversion for argument 1 from ‘llvm::MemoryBuffer*’ to ‘std::unique_ptr<llvm::MemoryBuffer>&&’
/usr/include/c++/4.9/bits/unique_ptr.h:269:2: note: template<class _Up, class _Ep> typename std::enable_if<std::__and_<std::is_convertible<typename std::unique_ptr<_Up, _Ep>::pointer, typename std::unique_ptr<_Tp, _Dp>::_Pointer::type>, std::__not_<std::is_array<_Up> > >::value, std::unique_ptr<_Tp, _Dp>&>::type std::unique_ptr<_Tp, _Dp>::operator=(std::unique_ptr<_Up, _Ep>&&) [with _Up = _Up; _Ep = _Ep; _Tp = llvm::MemoryBuffer; _Dp = std::default_delete<llvm::MemoryBuffer>]
  operator=(unique_ptr<_Up, _Ep>&& __u) noexcept
  ^
/usr/include/c++/4.9/bits/unique_ptr.h:269:2: note:   template argument deduction/substitution failed:
executionengine.cpp:211:21: note:   mismatched types ‘std::unique_ptr<_Tp, _Dp>’ and ‘llvm::MemoryBuffer*’
                 res = llvm::MemoryBuffer::getMemBufferCopy(
                     ^
In file included from /usr/include/c++/4.9/memory:81:0,
                 from /usr/lib/llvm-3.5/include/llvm/ADT/SmallVector.h:28,
                 from /usr/lib/llvm-3.5/include/llvm/IR/DataLayout.h:24,
                 from /usr/lib/llvm-3.5/include/llvm/IR/Module.h:20,
                 from executionengine.cpp:5:
/usr/include/c++/4.9/bits/unique_ptr.h:278:7: note: std::unique_ptr<_Tp, _Dp>& std::unique_ptr<_Tp, _Dp>::operator=(std::nullptr_t) [with _Tp = llvm::MemoryBuffer; _Dp = std::default_delete<llvm::MemoryBuffer>; std::nullptr_t = std::nullptr_t]
       operator=(nullptr_t) noexcept
       ^
/usr/include/c++/4.9/bits/unique_ptr.h:278:7: note:   no known conversion for argument 1 from ‘llvm::MemoryBuffer*’ to ‘std::nullptr_t’
executionengine.cpp: In function ‘LLVMPYObjectCache* LLVMPY_CreateObjectCache(ObjectCacheNotifyFunc, ObjectCacheGetObjectFunc, void*)’:
executionengine.cpp:233:72: error: invalid new-expression of abstract class type ‘LLVMPYObjectCache’
     return new LLVMPYObjectCache(notify_func, getobject_func, user_data);
                                                                        ^
executionengine.cpp:176:7: note:   because the following virtual functions are pure within ‘LLVMPYObjectCache’:
 class LLVMPYObjectCache : public llvm::ObjectCache {
       ^
In file included from executionengine.cpp:8:0:
/usr/lib/llvm-3.5/include/llvm/ExecutionEngine/ObjectCache.h:30:16: note:   virtual void llvm::ObjectCache::notifyObjectCompiled(const llvm::Module*, const llvm::MemoryBuffer*)
   virtual void notifyObjectCompiled(const Module *M, const MemoryBuffer *Obj) = 0;
                ^
linker.cpp: In function ‘int LLVMPY_LinkModules(LLVMModuleRef, LLVMModuleRef, int, const char**)’:
linker.cpp:19:32: error: ‘DiagnosticInfo’ does not name a type
     auto diagnose = [&] (const DiagnosticInfo &DI) {
                                ^
linker.cpp:30:6: error: expected ‘)’ before ‘;’ token
     };
      ^
linker.cpp: In lambda function:
linker.cpp:30:6: error: expected ‘{’ before ‘;’ token
linker.cpp: In function ‘int LLVMPY_LinkModules(LLVMModuleRef, LLVMModuleRef, int, const char**)’:
linker.cpp:32:34: error: ‘LLVMCloneModule’ was not declared in this scope
         Src = LLVMCloneModule(Src);
                                  ^
linker.cpp:33:74: error: no matching function for call to ‘llvm::Linker::LinkModules(llvm::Module*, llvm::Module*, LLVMPY_LinkModules(LLVMModuleRef, LLVMModuleRef, int, const char**)::<lambda(int)>&)’
     bool failed = Linker::LinkModules(unwrap(Dest), unwrap(Src), diagnose);
                                                                          ^
linker.cpp:33:74: note: candidate is:
In file included from linker.cpp:4:0:
/usr/lib/llvm-3.5/include/llvm/Linker/Linker.h:51:17: note: static bool llvm::Linker::LinkModules(llvm::Module*, llvm::Module*, unsigned int, std::string*)
     static bool LinkModules(Module *Dest, Module *Src, unsigned Mode,
                 ^
/usr/lib/llvm-3.5/include/llvm/Linker/Linker.h:51:17: note:   candidate expects 4 arguments, 3 provided
Makefile.linux:17: recipe for target 'libllvmlite.so' failed
make: *** [libllvmlite.so] Error 1
Traceback (most recent call last):
  File "ffi/build.py", line 114, in <module>
    main()
  File "ffi/build.py", line 104, in main
    main_posix('linux', '.so')
  File "ffi/build.py", line 96, in main_posix
    subprocess.check_call(['make', '-f', makefile])
  File "/usr/lib/python2.7/subprocess.py", line 540, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['make', '-f', 'Makefile.linux']' returned non-zero exit status 2
error: command '/usr/bin/python' failed with exit status 1

Can anybody help me figure out what i have missed?

[UPDATE]

I fixed it by using llvm 3.6 by installing the package ´llmv-3.6-dev´ and changing the ´LLVM_CONFIG´ variable in ´ffi/Makefile.linux´ to ´llvm-config-3.6´.

But now i get the following error:

running build
got version from VCS {'version': '0.9.0.dev+7.gf5a7007.dirty', 'full': 'f5a70072ce0e7f5e432d6645056a60b00f957c66.dirty'}
running build_ext
/usr/bin/python ffi/build.py
LLVM version... 3.6.2
# static-libstdc++ avoids runtime dependencies on a
# particular libstdc++ version.
g++ -static-libstdc++ -shared -flto `llvm-config-3.6 --cxxflags` -fno-rtti -g assembly.cpp bitcode.cpp core.cpp initfini.cpp module.cpp value.cpp executionengine.cpp transforms.cpp passmanagers.cpp targets.cpp dylib.cpp linker.cpp -o libllvmlite.so -flto `llvm-config-3.6 --ldflags` -Wl,--exclude-libs=ALL `llvm-config-3.6 --system-libs --libs all`
/usr/bin/ld: cannot find -lz
collect2: error: ld returned 1 exit status
Makefile.linux:17: recipe for target 'libllvmlite.so' failed
make: *** [libllvmlite.so] Error 1
Traceback (most recent call last):
  File "ffi/build.py", line 114, in <module>
    main()
  File "ffi/build.py", line 104, in main
    main_posix('linux', '.so')
  File "ffi/build.py", line 96, in main_posix
    subprocess.check_call(['make', '-f', makefile])
  File "/usr/lib/python2.7/subprocess.py", line 540, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['make', '-f', 'Makefile.linux']' returned non-zero exit status 2
error: command '/usr/bin/python' failed with exit status 1 

I'm unsure what the error means and my google foo is not strong enough to find any kind of a solution. Any help?


回答1:


To get llvm 3.6 you can add a /etc/apt/sources.list.d/llvm.list file with::

# cat /etc/apt/sources.list.d/llvm.list
   deb http://llvm.org/apt/jessie/ llvm-toolchain-jessie main
   deb-src http://llvm.org/apt/jessie/ llvm-toolchain-jessie main
   # 3.6
   deb http://llvm.org/apt/jessie/ llvm-toolchain-jessie-3.6 main
   deb-src http://llvm.org/apt/jessie/ llvm-toolchain-jessie-3.6 main

You need to add the key too::

# gpg --keyserver pgpkeys.mit.edu --recv-key 15CF4D18AF4F7421
# gpg -a --export 15CF4D18AF4F7421 | apt-key add -

apt-get update and install llvm-3.6::

apt-get update
apt-get install cython python-llvm build-essential libedit-dev
apt-get install llvm-3.6 llvm-3.6-dev llvm-dev

Then on your virtualenv::

pip install enum34
LLVM_CONFIG=/usr/lib/llvm-3.6/bin/llvm-config pip install llvmlite
LLVM_CONFIG=/usr/lib/llvm-3.6/bin/llvm-config pip install numba


来源:https://stackoverflow.com/questions/34495356/python-numba-llvmlite-on-debian-8-i-cant-build-llvmlite

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!