Add detection of whether LLVM has PTX in the windows build
This commit is contained in:
parent
f985d1b034
commit
01b55b48f7
3 changed files with 22 additions and 11 deletions
|
|
@ -1,8 +1,8 @@
|
||||||
import sys, os
|
import sys, os
|
||||||
|
|
||||||
def find_path_of(filename):
|
def find_path_of(filename, envvar='PATH'):
|
||||||
"""Finds the path from $PATH where the file exists, returns None if not found."""
|
"""Finds the path from $PATH where the file exists, returns None if not found."""
|
||||||
pathlist = os.getenv('PATH').split(os.pathsep)
|
pathlist = os.getenv(envvar).split(os.pathsep)
|
||||||
for path in pathlist:
|
for path in pathlist:
|
||||||
if os.path.exists(os.path.join(path, filename)):
|
if os.path.exists(os.path.join(path, filename)):
|
||||||
return os.path.abspath(path)
|
return os.path.abspath(path)
|
||||||
|
|
@ -50,6 +50,12 @@ Advapi32
|
||||||
Shell32
|
Shell32
|
||||||
""".split():
|
""".split():
|
||||||
print('-l%s' % lib)
|
print('-l%s' % lib)
|
||||||
|
# Look for the PTX .lib in %LIBPATH%
|
||||||
|
if find_path_of('LLVMPTXCodeGen.lib', 'LIBPATH') != None:
|
||||||
|
print('-lLLVMPTXAsmPrinter')
|
||||||
|
print('-lLLVMPTXCodeGen')
|
||||||
|
print('-lLLVMPTXDesc')
|
||||||
|
print('-lLLVMPTXInfo')
|
||||||
elif sys.argv[1] == '--includedir':
|
elif sys.argv[1] == '--includedir':
|
||||||
llvmbin = find_path_of('llvm-tblgen.exe')
|
llvmbin = find_path_of('llvm-tblgen.exe')
|
||||||
if llvmbin is None:
|
if llvmbin is None:
|
||||||
|
|
|
||||||
|
|
@ -45,15 +45,10 @@
|
||||||
#define LLVM_HAS_NVPTX 0
|
#define LLVM_HAS_NVPTX 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(_WIN32)
|
|
||||||
#define LLVM_DISABLE_PTX
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "llvm-c/Transforms/PassManagerBuilder.h"
|
#include "llvm-c/Transforms/PassManagerBuilder.h"
|
||||||
|
|
||||||
#include "llvm_c_extra.h"
|
#include "llvm_c_extra.h"
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
18
setup.py
18
setup.py
|
|
@ -68,7 +68,10 @@ if dynlink:
|
||||||
objs_core = []
|
objs_core = []
|
||||||
else:
|
else:
|
||||||
if sys.platform == 'win32':
|
if sys.platform == 'win32':
|
||||||
print('PTX is disabled on Win32 at the moment')
|
# XXX: If found, the PTX components are returned by llvm-config-win32.py,
|
||||||
|
# regardless of whether we ask for them. There should be a better way
|
||||||
|
# eventually.
|
||||||
|
print('PTX is included on Win32 at if found by llvm-config-win32.py')
|
||||||
ptx_components = []
|
ptx_components = []
|
||||||
elif llvm_version <= (3, 1): # select between PTX & NVPTX
|
elif llvm_version <= (3, 1): # select between PTX & NVPTX
|
||||||
print('Using PTX')
|
print('Using PTX')
|
||||||
|
|
@ -91,13 +94,20 @@ else:
|
||||||
'asmparser', 'linker', 'support', 'vectorize']
|
'asmparser', 'linker', 'support', 'vectorize']
|
||||||
+ ptx_components)
|
+ ptx_components)
|
||||||
|
|
||||||
|
macros = [('__STDC_CONSTANT_MACROS', None),
|
||||||
|
('__STDC_LIMIT_MACROS', None)]
|
||||||
|
if sys.platform == 'win32':
|
||||||
|
# If no PTX lib got added, disable PTX in the build
|
||||||
|
if 'LLVMPTXCodeGen' not in libs_core:
|
||||||
|
macros.append(('LLVM_DISABLE_PTX', None)),
|
||||||
|
else:
|
||||||
|
macros.append(('_GNU_SOURCE', None))
|
||||||
|
|
||||||
extra_link_args = ldflags.split()
|
extra_link_args = ldflags.split()
|
||||||
kwds = dict(ext_modules = [Extension(
|
kwds = dict(ext_modules = [Extension(
|
||||||
name='llvm._core',
|
name='llvm._core',
|
||||||
sources=['llvm/_core.cpp', 'llvm/wrap.cpp', 'llvm/extra.cpp'],
|
sources=['llvm/_core.cpp', 'llvm/wrap.cpp', 'llvm/extra.cpp'],
|
||||||
define_macros = [('__STDC_CONSTANT_MACROS', None),
|
define_macros = macros,
|
||||||
('__STDC_LIMIT_MACROS', None),
|
|
||||||
('_GNU_SOURCE', None)],
|
|
||||||
include_dirs = ['/usr/include', incdir],
|
include_dirs = ['/usr/include', incdir],
|
||||||
library_dirs = [libdir],
|
library_dirs = [libdir],
|
||||||
libraries = libs_core,
|
libraries = libs_core,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue