diff options
author | José Fonseca <jfonseca@vmware.com> | 2010-04-10 02:41:39 +0100 |
---|---|---|
committer | José Fonseca <jfonseca@vmware.com> | 2010-04-11 17:17:34 +0900 |
commit | ea532f0e725bd68e7784189c9b7f6f7bf7f9d901 (patch) | |
tree | 1b318d82380b08fb3f602597b61d797a2f5656bd | |
parent | 9fc93b80413d63aeb08b5a17602d111ed3899faf (diff) |
scons: Make LLVM a black-white dependency.
Now that draw depends on llvm it is very difficult to correctly handle
broken llvm installations. Either the user requests LLVM and it needs to
supply a working installation. Or it doesn't, and it gets no LLVM
accelerate pipe drivers.
-rw-r--r-- | SConstruct | 14 | ||||
-rw-r--r-- | common.py | 8 | ||||
-rw-r--r-- | configs/linux-llvm | 2 | ||||
-rw-r--r-- | scons/gallium.py | 6 | ||||
-rw-r--r-- | scons/llvm.py | 18 | ||||
-rw-r--r-- | src/gallium/auxiliary/SConscript | 2 | ||||
-rw-r--r-- | src/gallium/auxiliary/draw/draw_context.h | 2 | ||||
-rw-r--r-- | src/gallium/auxiliary/draw/draw_llvm.h | 4 | ||||
-rw-r--r-- | src/gallium/auxiliary/draw/draw_private.h | 4 | ||||
-rw-r--r-- | src/gallium/auxiliary/draw/draw_pt.c | 2 | ||||
-rw-r--r-- | src/gallium/auxiliary/draw/draw_vs_llvm.c | 2 | ||||
-rw-r--r-- | src/gallium/auxiliary/gallivm/lp_bld.h | 4 | ||||
-rw-r--r-- | src/gallium/drivers/llvmpipe/SConscript | 9 | ||||
-rw-r--r-- | src/gallium/drivers/sw/SConscript | 8 | ||||
-rw-r--r-- | src/gallium/state_trackers/python/SConscript | 1 | ||||
-rw-r--r-- | src/gallium/targets/dri-swrast/SConscript | 8 | ||||
-rw-r--r-- | src/gallium/targets/graw-xlib/SConscript | 8 | ||||
-rw-r--r-- | src/gallium/targets/libgl-gdi/SConscript | 6 | ||||
-rw-r--r-- | src/gallium/targets/libgl-xlib/SConscript | 8 |
19 files changed, 51 insertions, 65 deletions
diff --git a/SConstruct b/SConstruct index 8b7ae7d112..ebced16c0c 100644 --- a/SConstruct +++ b/SConstruct @@ -81,15 +81,6 @@ debug = env['debug'] dri = env['dri'] machine = env['machine'] platform = env['platform'] -drawllvm = 'llvmpipe' in env['drivers'] - -# LLVM support in the Draw module -if drawllvm: - env.Tool('llvm') - if not env.has_key('LLVM_VERSION'): - drawllvm = False -if drawllvm: - env.Append(CFLAGS = ['-DDRAW_LLVM=1']) # derived options x86 = machine == 'x86' @@ -102,7 +93,6 @@ Export([ 'x86', 'ppc', 'dri', - 'drawllvm', 'platform', 'gcc', 'msvc', @@ -167,10 +157,6 @@ if platform in ('posix', 'linux', 'freebsd', 'darwin'): 'dl', ]) -# LLVM support in the Draw module -if drawllvm: - env.Append(CPPDEFINES = ['DRAW_LLVM']) - # for debugging #print env.Dump() @@ -3,6 +3,7 @@ import os import os.path +import subprocess import sys import platform as _platform @@ -33,6 +34,11 @@ else: default_machine = _platform.machine() default_machine = _machine_map.get(default_machine, 'generic') +if 'LLVM' in os.environ or subprocess.call(['llvm-config', '--version'], stdout=subprocess.PIPE) == 0: + default_llvm = 'yes' +else: + default_llvm = 'no' + if default_platform in ('linux', 'freebsd'): default_dri = 'yes' elif default_platform in ('winddk', 'windows', 'wince', 'darwin'): @@ -61,5 +67,5 @@ def AddOptions(opts): opts.Add(EnumOption('platform', 'target platform', default_platform, allowed_values=('linux', 'cell', 'windows', 'winddk', 'wince', 'darwin', 'embedded'))) opts.Add('toolchain', 'compiler toolchain', 'default') - opts.Add(BoolOption('llvm', 'use LLVM', 'no')) + opts.Add(BoolOption('llvm', 'use LLVM', default_llvm)) opts.Add(BoolOption('dri', 'build DRI drivers', default_dri)) diff --git a/configs/linux-llvm b/configs/linux-llvm index 3a15f1d6d8..1b15a308f3 100644 --- a/configs/linux-llvm +++ b/configs/linux-llvm @@ -12,7 +12,7 @@ GALLIUM_DRIVERS_DIRS += llvmpipe OPT_FLAGS = -O3 -ansi -pedantic ARCH_FLAGS = -mmmx -msse -msse2 -mstackrealign -DEFINES += -DNDEBUG -DGALLIUM_LLVMPIPE -DDRAW_LLVM -DHAVE_UDIS86 +DEFINES += -DNDEBUG -DGALLIUM_LLVMPIPE -DHAVE_UDIS86 # override -std=c99 CFLAGS += -std=gnu99 diff --git a/scons/gallium.py b/scons/gallium.py index 925effc25d..dd7275460d 100644 --- a/scons/gallium.py +++ b/scons/gallium.py @@ -142,8 +142,6 @@ def generate(env): # configuration. See also http://www.scons.org/wiki/AdvancedBuildExample build_topdir = 'build' build_subdir = env['platform'] - if env['llvm']: - build_subdir += "-llvm" if env['machine'] != 'generic': build_subdir += '-' + env['machine'] if env['debug']: @@ -471,6 +469,10 @@ def generate(env): # Default libs env.Append(LIBS = []) + # Load LLVM + if env['llvm']: + env.Tool('llvm') + # Custom builders and methods env.Tool('custom') createInstallMethods(env) diff --git a/scons/llvm.py b/scons/llvm.py index 01eae2403a..d88d6e3a5a 100644 --- a/scons/llvm.py +++ b/scons/llvm.py @@ -63,13 +63,14 @@ def generate(env): if env['platform'] == 'windows': # XXX: There is no llvm-config on Windows, so assume a standard layout if llvm_dir is None: - return + print 'scons: LLVM environment variable must be specified when building for windows' + env.Exit(1) # 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 - return + env.Exit(1) llvm_version_re = re.compile(r'^#define PACKAGE_VERSION "([^"]*)"') llvm_version = None for line in open(llvm_config, 'rt'): @@ -80,7 +81,7 @@ def generate(env): break if llvm_version is None: print 'scons: could not determine the LLVM version from %s' % llvm_config - return + env.Exit(1) env.Prepend(CPPPATH = [os.path.join(llvm_dir, 'include')]) env.AppendUnique(CPPDEFINES = [ @@ -129,7 +130,11 @@ def generate(env): # debug build we'll be linking against LIBCMTD, so disable # that. env.Append(LINKFLAGS = ['/nodefaultlib:LIBCMT']) - elif env.Detect('llvm-config'): + else: + if not env.Detect('llvm-config'): + print 'scons: llvm-config script not found' % llvm_version + env.Exit(1) + llvm_version = env.backtick('llvm-config --version').rstrip() llvm_version = distutils.version.LooseVersion(llvm_version) @@ -138,11 +143,10 @@ def generate(env): env.ParseConfig('llvm-config --libs jit interpreter nativecodegen bitwriter') env.ParseConfig('llvm-config --ldflags') except OSError: - print 'llvm-config version %s failed' % llvm_version + print 'scons: llvm-config version %s failed' % llvm_version + env.Exit(1) else: env['LINK'] = env['CXX'] - else: - return assert llvm_version is not None diff --git a/src/gallium/auxiliary/SConscript b/src/gallium/auxiliary/SConscript index bd8139f1de..3ad0600326 100644 --- a/src/gallium/auxiliary/SConscript +++ b/src/gallium/auxiliary/SConscript @@ -191,7 +191,7 @@ source = [ 'target-helpers/wrap_screen.c', ] -if drawllvm: +if env['llvm']: source += [ 'gallivm/lp_bld_alpha.c', 'gallivm/lp_bld_arit.c', diff --git a/src/gallium/auxiliary/draw/draw_context.h b/src/gallium/auxiliary/draw/draw_context.h index a0e1c1c59b..1af4961716 100644 --- a/src/gallium/auxiliary/draw/draw_context.h +++ b/src/gallium/auxiliary/draw/draw_context.h @@ -196,7 +196,7 @@ boolean draw_need_pipeline(const struct draw_context *draw, const struct pipe_rasterizer_state *rasterizer, unsigned prim ); -#ifdef DRAW_LLVM +#ifdef HAVE_LLVM /******************************************************************************* * LLVM integration */ diff --git a/src/gallium/auxiliary/draw/draw_llvm.h b/src/gallium/auxiliary/draw/draw_llvm.h index d1cbac4af9..28b9044a81 100644 --- a/src/gallium/auxiliary/draw/draw_llvm.h +++ b/src/gallium/auxiliary/draw/draw_llvm.h @@ -1,5 +1,5 @@ -#ifndef DRAW_LLVM_H -#define DRAW_LLVM_H +#ifndef HAVE_LLVM_H +#define HAVE_LLVM_H #include "draw/draw_private.h" diff --git a/src/gallium/auxiliary/draw/draw_private.h b/src/gallium/auxiliary/draw/draw_private.h index 7e24e5fd6f..da64102d9d 100644 --- a/src/gallium/auxiliary/draw/draw_private.h +++ b/src/gallium/auxiliary/draw/draw_private.h @@ -46,7 +46,7 @@ #include "tgsi/tgsi_scan.h" -#ifdef DRAW_LLVM +#ifdef HAVE_LLVM #include <llvm-c/ExecutionEngine.h> #endif @@ -241,7 +241,7 @@ struct draw_context unsigned instance_id; -#ifdef DRAW_LLVM +#ifdef HAVE_LLVM LLVMExecutionEngineRef engine; #endif void *driver_private; diff --git a/src/gallium/auxiliary/draw/draw_pt.c b/src/gallium/auxiliary/draw/draw_pt.c index a60a3b2a2b..43f6c5650a 100644 --- a/src/gallium/auxiliary/draw/draw_pt.c +++ b/src/gallium/auxiliary/draw/draw_pt.c @@ -140,7 +140,7 @@ boolean draw_pt_init( struct draw_context *draw ) if (!draw->pt.middle.fetch_shade_emit) return FALSE; -#if DRAW_LLVM +#if HAVE_LLVM draw->pt.middle.general = draw_pt_fetch_pipeline_or_emit_llvm( draw ); #else draw->pt.middle.general = NULL; diff --git a/src/gallium/auxiliary/draw/draw_vs_llvm.c b/src/gallium/auxiliary/draw/draw_vs_llvm.c index 0c483de407..2a3b6b39b9 100644 --- a/src/gallium/auxiliary/draw/draw_vs_llvm.c +++ b/src/gallium/auxiliary/draw/draw_vs_llvm.c @@ -40,7 +40,7 @@ #include "tgsi/tgsi_parse.h" -#ifdef DRAW_LLVM +#ifdef HAVE_LLVM struct draw_llvm_vertex_shader { struct draw_vertex_shader base; diff --git a/src/gallium/auxiliary/gallivm/lp_bld.h b/src/gallium/auxiliary/gallivm/lp_bld.h index 70a4960f91..2fa682f400 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld.h +++ b/src/gallium/auxiliary/gallivm/lp_bld.h @@ -38,9 +38,9 @@ #include <llvm-c/Core.h> -/** Set version to 0 if missing to avoid #ifdef HAVE_LLVM everywhere */ +/** Ensure HAVE_LLVM is set to avoid #ifdef HAVE_LLVM everywhere */ #ifndef HAVE_LLVM -#define HAVE_LLVM 0x0207 +#error "HAVE_LLVM should be set with LLVM's version number, e.g. (0x0207 for 2.7)" #endif diff --git a/src/gallium/drivers/llvmpipe/SConscript b/src/gallium/drivers/llvmpipe/SConscript index f5a38d05d4..8e3267c843 100644 --- a/src/gallium/drivers/llvmpipe/SConscript +++ b/src/gallium/drivers/llvmpipe/SConscript @@ -1,12 +1,11 @@ Import('*') -env = env.Clone() - -env.Tool('llvm') -if not env.has_key('LLVM_VERSION'): - print 'warning: LLVM not found: not building llvmpipe' +if not env['llvm']: + print 'warning: LLVM disabled: not building llvmpipe' Return() +env = env.Clone() + env.Tool('udis86') env.Append(CPPPATH = ['.']) diff --git a/src/gallium/drivers/sw/SConscript b/src/gallium/drivers/sw/SConscript index 6fbbdf3cc4..cea237aa17 100644 --- a/src/gallium/drivers/sw/SConscript +++ b/src/gallium/drivers/sw/SConscript @@ -23,11 +23,9 @@ if 'softpipe' in env['drivers']: env.Prepend(LIBS = [softpipe]) if 'llvmpipe' in env['drivers']: - env.Tool('llvm') - if 'LLVM_VERSION' in env: - env.Append(CPPDEFINES = 'GALLIUM_LLVMPIPE') - env.Tool('udis86') - env.Prepend(LIBS = [llvmpipe]) + env.Append(CPPDEFINES = 'GALLIUM_LLVMPIPE') + env.Tool('udis86') + env.Prepend(LIBS = [llvmpipe]) if 'cell' in env['drivers']: env.Append(CPPDEFINES = 'GALLIUM_CELL') diff --git a/src/gallium/state_trackers/python/SConscript b/src/gallium/state_trackers/python/SConscript index 781f54bf2b..bff97079f6 100644 --- a/src/gallium/state_trackers/python/SConscript +++ b/src/gallium/state_trackers/python/SConscript @@ -46,7 +46,6 @@ if 'python' in env['statetrackers']: if 'llvmpipe' in env['drivers']: env.Append(CPPDEFINES = ['HAVE_LLVMPIPE']) - env.Tool('llvm') env.Prepend(LIBS = [llvmpipe]) if 'softpipe' in env['drivers']: env.Append(CPPDEFINES = ['HAVE_SOFTPIPE']) diff --git a/src/gallium/targets/dri-swrast/SConscript b/src/gallium/targets/dri-swrast/SConscript index 94ff99a0a9..9a3838d64e 100644 --- a/src/gallium/targets/dri-swrast/SConscript +++ b/src/gallium/targets/dri-swrast/SConscript @@ -25,11 +25,9 @@ if 'softpipe' in env['drivers']: env.Prepend(LIBS = [softpipe]) if 'llvmpipe' in env['drivers']: - env.Tool('llvm') - if 'LLVM_VERSION' in env: - env.Append(CPPDEFINES = 'GALLIUM_LLVMPIPE') - env.Tool('udis86') - env.Prepend(LIBS = [llvmpipe]) + env.Append(CPPDEFINES = 'GALLIUM_LLVMPIPE') + env.Tool('udis86') + env.Prepend(LIBS = [llvmpipe]) swrastg_sources = [ 'swrast_drm_api.c' diff --git a/src/gallium/targets/graw-xlib/SConscript b/src/gallium/targets/graw-xlib/SConscript index 24cea92f90..1b5350a9a4 100644 --- a/src/gallium/targets/graw-xlib/SConscript +++ b/src/gallium/targets/graw-xlib/SConscript @@ -33,11 +33,9 @@ if 'softpipe' in env['drivers']: env.Prepend(LIBS = [softpipe]) if 'llvmpipe' in env['drivers']: - env.Tool('llvm') - if 'LLVM_VERSION' in env: - env.Append(CPPDEFINES = 'GALLIUM_LLVMPIPE') - env.Tool('udis86') - env.Prepend(LIBS = [llvmpipe]) + env.Append(CPPDEFINES = 'GALLIUM_LLVMPIPE') + env.Tool('udis86') + env.Prepend(LIBS = [llvmpipe]) # Need this for trace, identity drivers referenced by # gallium_wrap_screen(). diff --git a/src/gallium/targets/libgl-gdi/SConscript b/src/gallium/targets/libgl-gdi/SConscript index 21b4eb2abe..a6ef1f2406 100644 --- a/src/gallium/targets/libgl-gdi/SConscript +++ b/src/gallium/targets/libgl-gdi/SConscript @@ -27,10 +27,8 @@ if env['platform'] == 'windows': drivers = [softpipe] if 'llvmpipe' in env['drivers']: - env.Tool('llvm') - if 'LLVM_VERSION' in env: - sources = ['gdi_llvmpipe_winsys.c'] - drivers = [llvmpipe] + sources = ['gdi_llvmpipe_winsys.c'] + drivers = [llvmpipe] if not sources or not drivers: print 'warning: softpipe or llvmpipe not selected, gdi winsys disabled' diff --git a/src/gallium/targets/libgl-xlib/SConscript b/src/gallium/targets/libgl-xlib/SConscript index c1614d4a9f..0d2ffd2070 100644 --- a/src/gallium/targets/libgl-xlib/SConscript +++ b/src/gallium/targets/libgl-xlib/SConscript @@ -50,11 +50,9 @@ if 'softpipe' in env['drivers']: env.Prepend(LIBS = [softpipe]) if 'llvmpipe' in env['drivers']: - env.Tool('llvm') - if 'LLVM_VERSION' in env: - env.Append(CPPDEFINES = 'GALLIUM_LLVMPIPE') - env.Tool('udis86') - env.Prepend(LIBS = [llvmpipe]) + env.Append(CPPDEFINES = 'GALLIUM_LLVMPIPE') + env.Tool('udis86') + env.Prepend(LIBS = [llvmpipe]) if 'cell' in env['drivers']: env.Append(CPPDEFINES = 'GALLIUM_CELL') |