X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=scons%2Fllvm.py;h=66f972df5fbfcc396fcdd1c92e22f7c2ea583f1d;hb=636d01bd61cac83e13c3c64874e7e34e828ca93a;hp=d88d6e3a5ad68ed58bc220c544258a25289b8774;hpb=8f3bdeaad610d7d5a5c6e73e1e9c721219595754;p=mesa.git diff --git a/scons/llvm.py b/scons/llvm.py index d88d6e3a5ad..66f972df5fb 100644 --- a/scons/llvm.py +++ b/scons/llvm.py @@ -38,6 +38,8 @@ import SCons.Util def generate(env): + env['llvm'] = False + try: llvm_dir = os.environ['LLVM'] except KeyError: @@ -64,13 +66,13 @@ def generate(env): # XXX: There is no llvm-config on Windows, so assume a standard layout if llvm_dir is None: print 'scons: LLVM environment variable must be specified when building for windows' - env.Exit(1) + return # Try to determine the LLVM version from llvm/Config/config.h llvm_config = os.path.join(llvm_dir, 'include/llvm/Config/config.h') if not os.path.exists(llvm_config): print 'scons: could not find %s' % llvm_config - env.Exit(1) + return llvm_version_re = re.compile(r'^#define PACKAGE_VERSION "([^"]*)"') llvm_version = None for line in open(llvm_config, 'rt'): @@ -81,7 +83,7 @@ def generate(env): break if llvm_version is None: print 'scons: could not determine the LLVM version from %s' % llvm_config - env.Exit(1) + return env.Prepend(CPPPATH = [os.path.join(llvm_dir, 'include')]) env.AppendUnique(CPPDEFINES = [ @@ -124,7 +126,7 @@ def generate(env): # Some of the LLVM C headers use the inline keyword without # defining it. env.Append(CPPDEFINES = [('inline', '__inline')]) - if env['debug']: + if env['build'] in ('debug', 'checked'): # LLVM libraries are static, build with /MT, and they # automatically link agains LIBCMT. When we're doing a # debug build we'll be linking against LIBCMTD, so disable @@ -133,22 +135,29 @@ def generate(env): else: if not env.Detect('llvm-config'): print 'scons: llvm-config script not found' % llvm_version - env.Exit(1) + return llvm_version = env.backtick('llvm-config --version').rstrip() llvm_version = distutils.version.LooseVersion(llvm_version) try: - env.ParseConfig('llvm-config --cppflags') - env.ParseConfig('llvm-config --libs jit interpreter nativecodegen bitwriter') + # Treat --cppflags specially to prevent NDEBUG from disabling + # assertion failures in debug builds. + cppflags = env.ParseFlags('!llvm-config --cppflags') + try: + cppflags['CPPDEFINES'].remove('NDEBUG') + except ValueError: + pass + env.MergeFlags(cppflags) + + env.ParseConfig('llvm-config --libs') env.ParseConfig('llvm-config --ldflags') except OSError: print 'scons: llvm-config version %s failed' % llvm_version - env.Exit(1) - else: - env['LINK'] = env['CXX'] + return assert llvm_version is not None + env['llvm'] = True print 'scons: Found LLVM version %s' % llvm_version env['LLVM_VERSION'] = llvm_version