import SCons.Util
+required_llvm_version = '3.1'
+
+
def generate(env):
env['llvm'] = False
if llvm_version is None:
print 'scons: could not determine the LLVM version from %s' % llvm_config
return
+ if llvm_version < distutils.version.LooseVersion(required_llvm_version):
+ print 'scons: LLVM version %s found, but %s is required' % (llvm_version, required_llvm_version)
+ return
env.Prepend(CPPPATH = [os.path.join(llvm_dir, 'include')])
env.AppendUnique(CPPDEFINES = [
'LLVMAnalysis', 'LLVMTarget', 'LLVMMC', 'LLVMCore',
'LLVMSupport', 'LLVMRuntimeDyld', 'LLVMObject'
])
- elif llvm_version >= distutils.version.LooseVersion('3.0'):
- # 3.0
+ else:
+ # 3.1
env.Prepend(LIBS = [
'LLVMBitWriter', 'LLVMX86Disassembler', 'LLVMX86AsmParser',
'LLVMX86CodeGen', 'LLVMX86Desc', 'LLVMSelectionDAG',
'LLVMAnalysis', 'LLVMTarget', 'LLVMMC', 'LLVMCore',
'LLVMSupport'
])
- elif llvm_version >= distutils.version.LooseVersion('2.9'):
- # 2.9
- env.Prepend(LIBS = [
- 'LLVMObject', 'LLVMMCJIT', 'LLVMMCDisassembler',
- 'LLVMLinker', 'LLVMipo', 'LLVMInterpreter',
- 'LLVMInstrumentation', 'LLVMJIT', 'LLVMExecutionEngine',
- 'LLVMBitWriter', 'LLVMX86Disassembler', 'LLVMX86AsmParser',
- 'LLVMMCParser', 'LLVMX86AsmPrinter', 'LLVMX86CodeGen',
- 'LLVMSelectionDAG', 'LLVMX86Utils', 'LLVMX86Info', 'LLVMAsmPrinter',
- 'LLVMCodeGen', 'LLVMScalarOpts', 'LLVMInstCombine',
- 'LLVMTransformUtils', 'LLVMipa', 'LLVMAsmParser',
- 'LLVMArchive', 'LLVMBitReader', 'LLVMAnalysis', 'LLVMTarget',
- 'LLVMCore', 'LLVMMC', 'LLVMSupport',
- ])
- elif llvm_version >= distutils.version.LooseVersion('2.7'):
- # 2.7
- env.Prepend(LIBS = [
- 'LLVMLinker', 'LLVMipo', 'LLVMInterpreter',
- 'LLVMInstrumentation', 'LLVMJIT', 'LLVMExecutionEngine',
- 'LLVMBitWriter', 'LLVMX86Disassembler', 'LLVMX86AsmParser',
- 'LLVMMCParser', 'LLVMX86AsmPrinter', 'LLVMX86CodeGen',
- 'LLVMSelectionDAG', 'LLVMX86Info', 'LLVMAsmPrinter',
- 'LLVMCodeGen', 'LLVMScalarOpts', 'LLVMInstCombine',
- 'LLVMTransformUtils', 'LLVMipa', 'LLVMAsmParser',
- 'LLVMArchive', 'LLVMBitReader', 'LLVMAnalysis', 'LLVMTarget',
- 'LLVMMC', 'LLVMCore', 'LLVMSupport', 'LLVMSystem',
- ])
- else:
- # 2.6
- env.Prepend(LIBS = [
- 'LLVMX86AsmParser', 'LLVMX86AsmPrinter', 'LLVMX86CodeGen',
- 'LLVMX86Info', 'LLVMLinker', 'LLVMipo', 'LLVMInterpreter',
- 'LLVMInstrumentation', 'LLVMJIT', 'LLVMExecutionEngine',
- 'LLVMDebugger', 'LLVMBitWriter', 'LLVMAsmParser',
- 'LLVMArchive', 'LLVMBitReader', 'LLVMSelectionDAG',
- 'LLVMAsmPrinter', 'LLVMCodeGen', 'LLVMScalarOpts',
- 'LLVMTransformUtils', 'LLVMipa', 'LLVMAnalysis',
- 'LLVMTarget', 'LLVMMC', 'LLVMCore', 'LLVMSupport',
- 'LLVMSystem',
- ])
env.Append(LIBS = [
'imagehlp',
'psapi',
llvm_version = env.backtick('llvm-config --version').rstrip()
llvm_version = distutils.version.LooseVersion(llvm_version)
+ if llvm_version < distutils.version.LooseVersion(required_llvm_version):
+ print 'scons: LLVM version %s found, but %s is required' % (llvm_version, required_llvm_version)
+ return
+
try:
# Treat --cppflags specially to prevent NDEBUG from disabling
# assertion failures in debug builds.
components = ['engine', 'bitwriter', 'x86asmprinter']
- if llvm_version >= distutils.version.LooseVersion('3.1'):
- components.append('mcjit')
+ components.append('mcjit')
env.ParseConfig('llvm-config --libs ' + ' '.join(components))
env.ParseConfig('llvm-config --ldflags')