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.
This commit is contained in:
14
SConstruct
14
SConstruct
@@ -81,15 +81,6 @@ debug = env['debug']
|
|||||||
dri = env['dri']
|
dri = env['dri']
|
||||||
machine = env['machine']
|
machine = env['machine']
|
||||||
platform = env['platform']
|
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
|
# derived options
|
||||||
x86 = machine == 'x86'
|
x86 = machine == 'x86'
|
||||||
@@ -102,7 +93,6 @@ Export([
|
|||||||
'x86',
|
'x86',
|
||||||
'ppc',
|
'ppc',
|
||||||
'dri',
|
'dri',
|
||||||
'drawllvm',
|
|
||||||
'platform',
|
'platform',
|
||||||
'gcc',
|
'gcc',
|
||||||
'msvc',
|
'msvc',
|
||||||
@@ -167,10 +157,6 @@ if platform in ('posix', 'linux', 'freebsd', 'darwin'):
|
|||||||
'dl',
|
'dl',
|
||||||
])
|
])
|
||||||
|
|
||||||
# LLVM support in the Draw module
|
|
||||||
if drawllvm:
|
|
||||||
env.Append(CPPDEFINES = ['DRAW_LLVM'])
|
|
||||||
|
|
||||||
# for debugging
|
# for debugging
|
||||||
#print env.Dump()
|
#print env.Dump()
|
||||||
|
|
||||||
|
@@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
import os
|
import os
|
||||||
import os.path
|
import os.path
|
||||||
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
import platform as _platform
|
import platform as _platform
|
||||||
|
|
||||||
@@ -33,6 +34,11 @@ else:
|
|||||||
default_machine = _platform.machine()
|
default_machine = _platform.machine()
|
||||||
default_machine = _machine_map.get(default_machine, 'generic')
|
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'):
|
if default_platform in ('linux', 'freebsd'):
|
||||||
default_dri = 'yes'
|
default_dri = 'yes'
|
||||||
elif default_platform in ('winddk', 'windows', 'wince', 'darwin'):
|
elif default_platform in ('winddk', 'windows', 'wince', 'darwin'):
|
||||||
@@ -61,5 +67,5 @@ def AddOptions(opts):
|
|||||||
opts.Add(EnumOption('platform', 'target platform', default_platform,
|
opts.Add(EnumOption('platform', 'target platform', default_platform,
|
||||||
allowed_values=('linux', 'cell', 'windows', 'winddk', 'wince', 'darwin', 'embedded')))
|
allowed_values=('linux', 'cell', 'windows', 'winddk', 'wince', 'darwin', 'embedded')))
|
||||||
opts.Add('toolchain', 'compiler toolchain', 'default')
|
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))
|
opts.Add(BoolOption('dri', 'build DRI drivers', default_dri))
|
||||||
|
@@ -12,7 +12,7 @@ GALLIUM_DRIVERS_DIRS += llvmpipe
|
|||||||
OPT_FLAGS = -O3 -ansi -pedantic
|
OPT_FLAGS = -O3 -ansi -pedantic
|
||||||
ARCH_FLAGS = -mmmx -msse -msse2 -mstackrealign
|
ARCH_FLAGS = -mmmx -msse -msse2 -mstackrealign
|
||||||
|
|
||||||
DEFINES += -DNDEBUG -DGALLIUM_LLVMPIPE -DDRAW_LLVM -DHAVE_UDIS86
|
DEFINES += -DNDEBUG -DGALLIUM_LLVMPIPE -DHAVE_UDIS86
|
||||||
|
|
||||||
# override -std=c99
|
# override -std=c99
|
||||||
CFLAGS += -std=gnu99
|
CFLAGS += -std=gnu99
|
||||||
|
@@ -142,8 +142,6 @@ def generate(env):
|
|||||||
# configuration. See also http://www.scons.org/wiki/AdvancedBuildExample
|
# configuration. See also http://www.scons.org/wiki/AdvancedBuildExample
|
||||||
build_topdir = 'build'
|
build_topdir = 'build'
|
||||||
build_subdir = env['platform']
|
build_subdir = env['platform']
|
||||||
if env['llvm']:
|
|
||||||
build_subdir += "-llvm"
|
|
||||||
if env['machine'] != 'generic':
|
if env['machine'] != 'generic':
|
||||||
build_subdir += '-' + env['machine']
|
build_subdir += '-' + env['machine']
|
||||||
if env['debug']:
|
if env['debug']:
|
||||||
@@ -471,6 +469,10 @@ def generate(env):
|
|||||||
# Default libs
|
# Default libs
|
||||||
env.Append(LIBS = [])
|
env.Append(LIBS = [])
|
||||||
|
|
||||||
|
# Load LLVM
|
||||||
|
if env['llvm']:
|
||||||
|
env.Tool('llvm')
|
||||||
|
|
||||||
# Custom builders and methods
|
# Custom builders and methods
|
||||||
env.Tool('custom')
|
env.Tool('custom')
|
||||||
createInstallMethods(env)
|
createInstallMethods(env)
|
||||||
|
@@ -63,13 +63,14 @@ def generate(env):
|
|||||||
if env['platform'] == 'windows':
|
if env['platform'] == 'windows':
|
||||||
# XXX: There is no llvm-config on Windows, so assume a standard layout
|
# XXX: There is no llvm-config on Windows, so assume a standard layout
|
||||||
if llvm_dir is None:
|
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
|
# Try to determine the LLVM version from llvm/Config/config.h
|
||||||
llvm_config = os.path.join(llvm_dir, 'include/llvm/Config/config.h')
|
llvm_config = os.path.join(llvm_dir, 'include/llvm/Config/config.h')
|
||||||
if not os.path.exists(llvm_config):
|
if not os.path.exists(llvm_config):
|
||||||
print 'scons: could not find %s' % 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_re = re.compile(r'^#define PACKAGE_VERSION "([^"]*)"')
|
||||||
llvm_version = None
|
llvm_version = None
|
||||||
for line in open(llvm_config, 'rt'):
|
for line in open(llvm_config, 'rt'):
|
||||||
@@ -80,7 +81,7 @@ def generate(env):
|
|||||||
break
|
break
|
||||||
if llvm_version is None:
|
if llvm_version is None:
|
||||||
print 'scons: could not determine the LLVM version from %s' % llvm_config
|
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.Prepend(CPPPATH = [os.path.join(llvm_dir, 'include')])
|
||||||
env.AppendUnique(CPPDEFINES = [
|
env.AppendUnique(CPPDEFINES = [
|
||||||
@@ -129,7 +130,11 @@ def generate(env):
|
|||||||
# debug build we'll be linking against LIBCMTD, so disable
|
# debug build we'll be linking against LIBCMTD, so disable
|
||||||
# that.
|
# that.
|
||||||
env.Append(LINKFLAGS = ['/nodefaultlib:LIBCMT'])
|
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 = env.backtick('llvm-config --version').rstrip()
|
||||||
llvm_version = distutils.version.LooseVersion(llvm_version)
|
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 --libs jit interpreter nativecodegen bitwriter')
|
||||||
env.ParseConfig('llvm-config --ldflags')
|
env.ParseConfig('llvm-config --ldflags')
|
||||||
except OSError:
|
except OSError:
|
||||||
print 'llvm-config version %s failed' % llvm_version
|
print 'scons: llvm-config version %s failed' % llvm_version
|
||||||
|
env.Exit(1)
|
||||||
else:
|
else:
|
||||||
env['LINK'] = env['CXX']
|
env['LINK'] = env['CXX']
|
||||||
else:
|
|
||||||
return
|
|
||||||
|
|
||||||
assert llvm_version is not None
|
assert llvm_version is not None
|
||||||
|
|
||||||
|
@@ -191,7 +191,7 @@ source = [
|
|||||||
'target-helpers/wrap_screen.c',
|
'target-helpers/wrap_screen.c',
|
||||||
]
|
]
|
||||||
|
|
||||||
if drawllvm:
|
if env['llvm']:
|
||||||
source += [
|
source += [
|
||||||
'gallivm/lp_bld_alpha.c',
|
'gallivm/lp_bld_alpha.c',
|
||||||
'gallivm/lp_bld_arit.c',
|
'gallivm/lp_bld_arit.c',
|
||||||
|
@@ -196,7 +196,7 @@ boolean draw_need_pipeline(const struct draw_context *draw,
|
|||||||
const struct pipe_rasterizer_state *rasterizer,
|
const struct pipe_rasterizer_state *rasterizer,
|
||||||
unsigned prim );
|
unsigned prim );
|
||||||
|
|
||||||
#ifdef DRAW_LLVM
|
#ifdef HAVE_LLVM
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* LLVM integration
|
* LLVM integration
|
||||||
*/
|
*/
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
#ifndef DRAW_LLVM_H
|
#ifndef HAVE_LLVM_H
|
||||||
#define DRAW_LLVM_H
|
#define HAVE_LLVM_H
|
||||||
|
|
||||||
#include "draw/draw_private.h"
|
#include "draw/draw_private.h"
|
||||||
|
|
||||||
|
@@ -46,7 +46,7 @@
|
|||||||
|
|
||||||
#include "tgsi/tgsi_scan.h"
|
#include "tgsi/tgsi_scan.h"
|
||||||
|
|
||||||
#ifdef DRAW_LLVM
|
#ifdef HAVE_LLVM
|
||||||
#include <llvm-c/ExecutionEngine.h>
|
#include <llvm-c/ExecutionEngine.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -241,7 +241,7 @@ struct draw_context
|
|||||||
|
|
||||||
unsigned instance_id;
|
unsigned instance_id;
|
||||||
|
|
||||||
#ifdef DRAW_LLVM
|
#ifdef HAVE_LLVM
|
||||||
LLVMExecutionEngineRef engine;
|
LLVMExecutionEngineRef engine;
|
||||||
#endif
|
#endif
|
||||||
void *driver_private;
|
void *driver_private;
|
||||||
|
@@ -140,7 +140,7 @@ boolean draw_pt_init( struct draw_context *draw )
|
|||||||
if (!draw->pt.middle.fetch_shade_emit)
|
if (!draw->pt.middle.fetch_shade_emit)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
#if DRAW_LLVM
|
#if HAVE_LLVM
|
||||||
draw->pt.middle.general = draw_pt_fetch_pipeline_or_emit_llvm( draw );
|
draw->pt.middle.general = draw_pt_fetch_pipeline_or_emit_llvm( draw );
|
||||||
#else
|
#else
|
||||||
draw->pt.middle.general = NULL;
|
draw->pt.middle.general = NULL;
|
||||||
|
@@ -40,7 +40,7 @@
|
|||||||
|
|
||||||
#include "tgsi/tgsi_parse.h"
|
#include "tgsi/tgsi_parse.h"
|
||||||
|
|
||||||
#ifdef DRAW_LLVM
|
#ifdef HAVE_LLVM
|
||||||
|
|
||||||
struct draw_llvm_vertex_shader {
|
struct draw_llvm_vertex_shader {
|
||||||
struct draw_vertex_shader base;
|
struct draw_vertex_shader base;
|
||||||
|
@@ -38,9 +38,9 @@
|
|||||||
#include <llvm-c/Core.h>
|
#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
|
#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
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
@@ -1,12 +1,11 @@
|
|||||||
Import('*')
|
Import('*')
|
||||||
|
|
||||||
env = env.Clone()
|
if not env['llvm']:
|
||||||
|
print 'warning: LLVM disabled: not building llvmpipe'
|
||||||
env.Tool('llvm')
|
|
||||||
if not env.has_key('LLVM_VERSION'):
|
|
||||||
print 'warning: LLVM not found: not building llvmpipe'
|
|
||||||
Return()
|
Return()
|
||||||
|
|
||||||
|
env = env.Clone()
|
||||||
|
|
||||||
env.Tool('udis86')
|
env.Tool('udis86')
|
||||||
|
|
||||||
env.Append(CPPPATH = ['.'])
|
env.Append(CPPPATH = ['.'])
|
||||||
|
@@ -23,11 +23,9 @@ if 'softpipe' in env['drivers']:
|
|||||||
env.Prepend(LIBS = [softpipe])
|
env.Prepend(LIBS = [softpipe])
|
||||||
|
|
||||||
if 'llvmpipe' in env['drivers']:
|
if 'llvmpipe' in env['drivers']:
|
||||||
env.Tool('llvm')
|
env.Append(CPPDEFINES = 'GALLIUM_LLVMPIPE')
|
||||||
if 'LLVM_VERSION' in env:
|
env.Tool('udis86')
|
||||||
env.Append(CPPDEFINES = 'GALLIUM_LLVMPIPE')
|
env.Prepend(LIBS = [llvmpipe])
|
||||||
env.Tool('udis86')
|
|
||||||
env.Prepend(LIBS = [llvmpipe])
|
|
||||||
|
|
||||||
if 'cell' in env['drivers']:
|
if 'cell' in env['drivers']:
|
||||||
env.Append(CPPDEFINES = 'GALLIUM_CELL')
|
env.Append(CPPDEFINES = 'GALLIUM_CELL')
|
||||||
|
@@ -46,7 +46,6 @@ if 'python' in env['statetrackers']:
|
|||||||
|
|
||||||
if 'llvmpipe' in env['drivers']:
|
if 'llvmpipe' in env['drivers']:
|
||||||
env.Append(CPPDEFINES = ['HAVE_LLVMPIPE'])
|
env.Append(CPPDEFINES = ['HAVE_LLVMPIPE'])
|
||||||
env.Tool('llvm')
|
|
||||||
env.Prepend(LIBS = [llvmpipe])
|
env.Prepend(LIBS = [llvmpipe])
|
||||||
if 'softpipe' in env['drivers']:
|
if 'softpipe' in env['drivers']:
|
||||||
env.Append(CPPDEFINES = ['HAVE_SOFTPIPE'])
|
env.Append(CPPDEFINES = ['HAVE_SOFTPIPE'])
|
||||||
|
@@ -25,11 +25,9 @@ if 'softpipe' in env['drivers']:
|
|||||||
env.Prepend(LIBS = [softpipe])
|
env.Prepend(LIBS = [softpipe])
|
||||||
|
|
||||||
if 'llvmpipe' in env['drivers']:
|
if 'llvmpipe' in env['drivers']:
|
||||||
env.Tool('llvm')
|
env.Append(CPPDEFINES = 'GALLIUM_LLVMPIPE')
|
||||||
if 'LLVM_VERSION' in env:
|
env.Tool('udis86')
|
||||||
env.Append(CPPDEFINES = 'GALLIUM_LLVMPIPE')
|
env.Prepend(LIBS = [llvmpipe])
|
||||||
env.Tool('udis86')
|
|
||||||
env.Prepend(LIBS = [llvmpipe])
|
|
||||||
|
|
||||||
swrastg_sources = [
|
swrastg_sources = [
|
||||||
'swrast_drm_api.c'
|
'swrast_drm_api.c'
|
||||||
|
@@ -33,11 +33,9 @@ if 'softpipe' in env['drivers']:
|
|||||||
env.Prepend(LIBS = [softpipe])
|
env.Prepend(LIBS = [softpipe])
|
||||||
|
|
||||||
if 'llvmpipe' in env['drivers']:
|
if 'llvmpipe' in env['drivers']:
|
||||||
env.Tool('llvm')
|
env.Append(CPPDEFINES = 'GALLIUM_LLVMPIPE')
|
||||||
if 'LLVM_VERSION' in env:
|
env.Tool('udis86')
|
||||||
env.Append(CPPDEFINES = 'GALLIUM_LLVMPIPE')
|
env.Prepend(LIBS = [llvmpipe])
|
||||||
env.Tool('udis86')
|
|
||||||
env.Prepend(LIBS = [llvmpipe])
|
|
||||||
|
|
||||||
# Need this for trace, identity drivers referenced by
|
# Need this for trace, identity drivers referenced by
|
||||||
# gallium_wrap_screen().
|
# gallium_wrap_screen().
|
||||||
|
@@ -27,10 +27,8 @@ if env['platform'] == 'windows':
|
|||||||
drivers = [softpipe]
|
drivers = [softpipe]
|
||||||
|
|
||||||
if 'llvmpipe' in env['drivers']:
|
if 'llvmpipe' in env['drivers']:
|
||||||
env.Tool('llvm')
|
sources = ['gdi_llvmpipe_winsys.c']
|
||||||
if 'LLVM_VERSION' in env:
|
drivers = [llvmpipe]
|
||||||
sources = ['gdi_llvmpipe_winsys.c']
|
|
||||||
drivers = [llvmpipe]
|
|
||||||
|
|
||||||
if not sources or not drivers:
|
if not sources or not drivers:
|
||||||
print 'warning: softpipe or llvmpipe not selected, gdi winsys disabled'
|
print 'warning: softpipe or llvmpipe not selected, gdi winsys disabled'
|
||||||
|
@@ -50,11 +50,9 @@ if 'softpipe' in env['drivers']:
|
|||||||
env.Prepend(LIBS = [softpipe])
|
env.Prepend(LIBS = [softpipe])
|
||||||
|
|
||||||
if 'llvmpipe' in env['drivers']:
|
if 'llvmpipe' in env['drivers']:
|
||||||
env.Tool('llvm')
|
env.Append(CPPDEFINES = 'GALLIUM_LLVMPIPE')
|
||||||
if 'LLVM_VERSION' in env:
|
env.Tool('udis86')
|
||||||
env.Append(CPPDEFINES = 'GALLIUM_LLVMPIPE')
|
env.Prepend(LIBS = [llvmpipe])
|
||||||
env.Tool('udis86')
|
|
||||||
env.Prepend(LIBS = [llvmpipe])
|
|
||||||
|
|
||||||
if 'cell' in env['drivers']:
|
if 'cell' in env['drivers']:
|
||||||
env.Append(CPPDEFINES = 'GALLIUM_CELL')
|
env.Append(CPPDEFINES = 'GALLIUM_CELL')
|
||||||
|
Reference in New Issue
Block a user