[Mesa-dev] [PATCH v2] scons: Recognize LLVM_CONFIG environment variable.

Jose Fonseca jfonseca at vmware.com
Wed Nov 23 20:10:43 UTC 2016


On 23/11/16 20:09, Vinson Lee wrote:
> Signed-off-by: Vinson Lee <vlee at freedesktop.org>
> Reviewed-by: Emil Velikov <emil.velikov at collabora.com>
> ---
> v2
> Use LLVM_CONFIG for swr too.
> Update common.py.
> Use local variable llvm_config instead of env['LLVM_CONFIG'].
>
>  common.py                          |  2 +-
>  scons/llvm.py                      | 17 +++++++++--------
>  src/gallium/drivers/swr/SConscript |  3 ++-
>  3 files changed, 12 insertions(+), 10 deletions(-)
>
> diff --git a/common.py b/common.py
> index 704ad2e..24a7e8a 100644
> --- a/common.py
> +++ b/common.py
> @@ -59,7 +59,7 @@ if target_platform == 'windows' and host_platform != 'windows':
>
>
>  # find default_llvm value
> -if 'LLVM' in os.environ:
> +if 'LLVM' in os.environ or 'LLVM_CONFIG' in os.environ:
>      default_llvm = 'yes'
>  else:
>      default_llvm = 'no'
> diff --git a/scons/llvm.py b/scons/llvm.py
> index 977e47a..2d0f05b 100644
> --- a/scons/llvm.py
> +++ b/scons/llvm.py
> @@ -194,11 +194,12 @@ def generate(env):
>                  # that.
>                  env.Append(LINKFLAGS = ['/nodefaultlib:LIBCMT'])
>      else:
> -        if not env.Detect('llvm-config'):
> -            print 'scons: llvm-config script not found'
> +        llvm_config = os.environ.get('LLVM_CONFIG', 'llvm-config')
> +        if not env.Detect(llvm_config):
> +            print 'scons: %s script not found' % llvm_config
>              return
>
> -        llvm_version = env.backtick('llvm-config --version').rstrip()
> +        llvm_version = env.backtick('%s --version' % llvm_config).rstrip()
>          llvm_version = distutils.version.LooseVersion(llvm_version)
>
>          if llvm_version < distutils.version.LooseVersion(required_llvm_version):
> @@ -208,7 +209,7 @@ def generate(env):
>          try:
>              # Treat --cppflags specially to prevent NDEBUG from disabling
>              # assertion failures in debug builds.
> -            cppflags = env.ParseFlags('!llvm-config --cppflags')
> +            cppflags = env.ParseFlags('!%s --cppflags' % llvm_config)
>              try:
>                  cppflags['CPPDEFINES'].remove('NDEBUG')
>              except ValueError:
> @@ -216,16 +217,16 @@ def generate(env):
>              env.MergeFlags(cppflags)
>
>              # Match llvm --fno-rtti flag
> -            cxxflags = env.backtick('llvm-config --cxxflags').split()
> +            cxxflags = env.backtick('%s --cxxflags' % llvm_config).split()
>              if '-fno-rtti' in cxxflags:
>                  env.Append(CXXFLAGS = ['-fno-rtti'])
>
>              components = ['engine', 'mcjit', 'bitwriter', 'x86asmprinter', 'mcdisassembler', 'irreader']
>
> -            env.ParseConfig('llvm-config --libs ' + ' '.join(components))
> -            env.ParseConfig('llvm-config --ldflags')
> +            env.ParseConfig('%s --libs ' % llvm_config + ' '.join(components))
> +            env.ParseConfig('%s --ldflags' % llvm_config)
>              if llvm_version >= distutils.version.LooseVersion('3.5'):
> -                env.ParseConfig('llvm-config --system-libs')
> +                env.ParseConfig('%s --system-libs' % llvm_config)
>                  env.Append(CXXFLAGS = ['-std=c++11'])
>          except OSError:
>              print 'scons: llvm-config version %s failed' % llvm_version
> diff --git a/src/gallium/drivers/swr/SConscript b/src/gallium/drivers/swr/SConscript
> index 0de51a7..3f0517b 100644
> --- a/src/gallium/drivers/swr/SConscript
> +++ b/src/gallium/drivers/swr/SConscript
> @@ -31,7 +31,8 @@ if env['platform'] == 'windows':
>      # on windows there is no llvm-config, so LLVM is defined
>      llvm_includedir = os.path.join(os.environ['LLVM'], 'include')
>  else:
> -    llvm_includedir = env.backtick('llvm-config --includedir').rstrip()
> +    llvm_config = os.environ.get('LLVM_CONFIG', 'llvm-config')
> +    llvm_includedir = env.backtick('%s --includedir' % llvm_config).rstrip()
>      print "llvm include dir %s" % llvm_includedir
>
>  # the loader is included in the mesa lib itself
>

Looks great.  Thanks for the update Vinson.

Reviewed-by: Jose Fonseca <jfonseca at vmware.com>


More information about the mesa-dev mailing list