aboutsummaryrefslogtreecommitdiffstats
path: root/scons
diff options
context:
space:
mode:
Diffstat (limited to 'scons')
-rw-r--r--scons/crossmingw.py2
-rw-r--r--scons/dxsdk.py15
-rw-r--r--scons/gallium.py38
-rw-r--r--scons/generic.py11
-rw-r--r--scons/llvm.py71
-rw-r--r--scons/winddk.py45
6 files changed, 135 insertions, 47 deletions
diff --git a/scons/crossmingw.py b/scons/crossmingw.py
index 3aed4843502..9cb0b89e3c7 100644
--- a/scons/crossmingw.py
+++ b/scons/crossmingw.py
@@ -177,7 +177,7 @@ def generate(env):
# default in recent gcc versions
env.AppendUnique(CFLAGS = ['-gstabs'])
- env.AppendUnique(LIBS = ['iberty'])
+ #env.AppendUnique(LIBS = ['iberty'])
env.AppendUnique(SHLINKFLAGS = ['-Wl,--enable-stdcall-fixup'])
#env.AppendUnique(SHLINKFLAGS = ['-Wl,--kill-at'])
diff --git a/scons/dxsdk.py b/scons/dxsdk.py
index de090e4f991..920cc2f689d 100644
--- a/scons/dxsdk.py
+++ b/scons/dxsdk.py
@@ -52,11 +52,20 @@ def generate(env):
target_cpu = 'x64'
else:
raise SCons.Errors.InternalError, "Unsupported target machine"
- include_dir = 'Include'
+
+ include_dir = os.path.join(dxsdk_root, 'Include')
+ lib_dir = os.path.join(dxsdk_root, 'Lib', target_cpu)
env.Append(CPPDEFINES = [('HAVE_DXSDK', '1')])
- env.Prepend(CPPPATH = [os.path.join(dxsdk_root, 'Include')])
- env.Prepend(LIBPATH = [os.path.join(dxsdk_root, 'Lib', target_cpu)])
+
+ gcc = 'gcc' in os.path.basename(env['CC']).split('-')
+ if gcc:
+ # Make GCC more forgiving towards Microsoft's headers
+ env.Prepend(CPPFLAGS = ['-isystem', include_dir])
+ else:
+ env.Prepend(CPPPATH = [include_dir])
+
+ env.Prepend(LIBPATH = [lib_dir])
def exists(env):
return get_dxsdk_root(env) is not None
diff --git a/scons/gallium.py b/scons/gallium.py
index bf6172b4d77..f4e82e8e0a5 100644
--- a/scons/gallium.py
+++ b/scons/gallium.py
@@ -263,7 +263,11 @@ def generate(env):
if msvc and env['toolchain'] != 'winddk':
cppdefines += [
'VC_EXTRALEAN',
+ '_USE_MATH_DEFINES',
+ '_CRT_SECURE_NO_WARNINGS',
'_CRT_SECURE_NO_DEPRECATE',
+ '_SCL_SECURE_NO_WARNINGS',
+ '_SCL_SECURE_NO_DEPRECATE',
]
if debug:
cppdefines += ['_DEBUG']
@@ -334,14 +338,27 @@ def generate(env):
else:
ccflags += ['-O3', '-g3']
if env['profile']:
- ccflags += ['-pg']
+ # See http://code.google.com/p/jrfonseca/wiki/Gprof2Dot#Which_options_should_I_pass_to_gcc_when_compiling_for_profiling?
+ ccflags += [
+ '-fno-omit-frame-pointer',
+ '-fno-optimize-sibling-calls',
+ ]
if env['machine'] == 'x86':
ccflags += [
'-m32',
#'-march=pentium4',
- '-mmmx', '-msse', '-msse2', # enable SIMD intrinsics
#'-mfpmath=sse',
]
+ if platform != 'windows':
+ # XXX: -mstackrealign causes stack corruption on MinGW. Ditto
+ # for -mincoming-stack-boundary=2. Still enable it on other
+ # platforms for now, but we can't rely on it for cross platform
+ # code. We have to use __attribute__((force_align_arg_pointer))
+ # instead.
+ ccflags += [
+ '-mmmx', '-msse', '-msse2', # enable SIMD intrinsics
+ '-mstackrealign', # ensure stack is aligned
+ ]
if env['machine'] == 'x86_64':
ccflags += ['-m64']
# See also:
@@ -349,10 +366,11 @@ def generate(env):
ccflags += [
'-Wall',
'-Wmissing-field-initializers',
- '-Wpointer-arith',
+ '-Werror=pointer-arith',
'-Wno-long-long',
'-ffast-math',
'-fmessage-length=0', # be nice to Eclipse
+ '-fno-strict-aliasing', # we violate strict pointer aliasing rules
]
cflags += [
'-Werror=declaration-after-statement',
@@ -373,20 +391,15 @@ def generate(env):
else:
ccflags += [
'/O2', # optimize for speed
- #'/fp:fast', # fast floating point
- ]
- if env['profile']:
- ccflags += [
- '/Gh', # enable _penter hook function
- '/GH', # enable _pexit hook function
+ '/GL', # enable whole program optimization
]
ccflags += [
+ '/fp:fast', # fast floating point
'/W3', # warning level
#'/Wp64', # enable 64 bit porting warnings
]
if env['machine'] == 'x86':
ccflags += [
- #'/QIfist', # Suppress _ftol
#'/arch:SSE2', # use the SSE2 instructions
]
if platform == 'windows':
@@ -464,6 +477,11 @@ def generate(env):
]
# Handle circular dependencies in the libraries
env['_LIBFLAGS'] = '-Wl,--start-group ' + env['_LIBFLAGS'] + ' -Wl,--end-group'
+ if msvc:
+ if not env['debug']:
+ # enable Link-time Code Generation
+ linkflags += ['/LTCG']
+ env.Append(ARFLAGS = ['/LTCG'])
if platform == 'windows' and msvc:
# See also:
# - http://msdn2.microsoft.com/en-us/library/y0zzbyt4.aspx
diff --git a/scons/generic.py b/scons/generic.py
index a9c2244a74f..859bf2ae64e 100644
--- a/scons/generic.py
+++ b/scons/generic.py
@@ -335,7 +335,11 @@ def generate(env):
if msvc:
cppdefines += [
'VC_EXTRALEAN',
+ '_USE_MATH_DEFINES',
+ '_CRT_SECURE_NO_WARNINGS',
'_CRT_SECURE_NO_DEPRECATE',
+ '_SCL_SECURE_NO_WARNINGS',
+ '_SCL_SECURE_NO_DEPRECATE',
]
if debug:
cppdefines += ['_DEBUG']
@@ -402,8 +406,6 @@ def generate(env):
ccflags += ['-O0', '-g3'] # mingw 4.2.1 optimizer is broken
else:
ccflags += ['-O3', '-g0']
- if env['profile']:
- ccflags += ['-pg']
if env['machine'] == 'x86':
ccflags += [
'-m32',
@@ -446,11 +448,6 @@ def generate(env):
'/Ot', # favor code speed
#'/fp:fast', # fast floating point
]
- if env['profile']:
- ccflags += [
- '/Gh', # enable _penter hook function
- '/GH', # enable _pexit hook function
- ]
ccflags += [
'/W3', # warning level
#'/Wp64', # enable 64 bit porting warnings
diff --git a/scons/llvm.py b/scons/llvm.py
index 702f1e354f6..7b266502907 100644
--- a/scons/llvm.py
+++ b/scons/llvm.py
@@ -29,6 +29,7 @@ Tool-specific initialization for LLVM
import os
import os.path
+import sys
import SCons.Errors
import SCons.Util
@@ -39,7 +40,7 @@ def generate(env):
llvm_dir = os.environ['LLVM']
except KeyError:
# Do nothing -- use the system headers/libs
- pass
+ llvm_dir = None
else:
if not os.path.isdir(llvm_dir):
raise SCons.Errors.InternalError, "Specified LLVM directory not found"
@@ -51,20 +52,68 @@ def generate(env):
llvm_bin_dir = os.path.join(llvm_dir, llvm_subdir, 'bin')
if not os.path.isdir(llvm_bin_dir):
- raise SCons.Errors.InternalError, "LLVM build directory not found"
+ llvm_bin_dir = os.path.join(llvm_dir, 'bin')
+ if not os.path.isdir(llvm_bin_dir):
+ raise SCons.Errors.InternalError, "LLVM binary directory not found"
env.PrependENVPath('PATH', llvm_bin_dir)
- if env.Detect('llvm-config'):
- try:
- env['LLVM_VERSION'] = env.backtick('llvm-config --version')
- except AttributeError:
- env['LLVM_VERSION'] = 'X.X'
+ if env['platform'] == 'windows':
+ # XXX: There is no llvm-config on Windows, so assume a standard layout
+ if llvm_dir is not None:
+ env.Prepend(CPPPATH = [os.path.join(llvm_dir, 'include')])
+ env.AppendUnique(CPPDEFINES = [
+ '__STDC_LIMIT_MACROS',
+ '__STDC_CONSTANT_MACROS',
+ ])
+ env.Prepend(LIBPATH = [os.path.join(llvm_dir, 'lib')])
+ 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',
+ 'imagehlp',
+ 'psapi',
+ ])
+ env['LLVM_VERSION'] = '2.6'
+ return
+ elif env.Detect('llvm-config'):
+ version = env.backtick('llvm-config --version').rstrip()
- env.ParseConfig('llvm-config --cppflags')
- env.ParseConfig('llvm-config --libs jit interpreter nativecodegen bitwriter')
- env.ParseConfig('llvm-config --ldflags')
- env['LINK'] = env['CXX']
+ try:
+ env.ParseConfig('llvm-config --cppflags')
+ env.ParseConfig('llvm-config --libs jit interpreter nativecodegen bitwriter')
+ env.ParseConfig('llvm-config --ldflags')
+ except OSError:
+ print 'llvm-config version %s failed' % version
+ else:
+ if env['platform'] == 'windows':
+ env.Append(LIBS = ['imagehlp', 'psapi'])
+ env['LINK'] = env['CXX']
+ env['LLVM_VERSION'] = version
def exists(env):
return True
diff --git a/scons/winddk.py b/scons/winddk.py
index afcea9909a6..4dac16ee66e 100644
--- a/scons/winddk.py
+++ b/scons/winddk.py
@@ -85,8 +85,6 @@ def get_winddk_paths(env, version, root):
else:
# TODO: take in consideration the host cpu
bin_dir = os.path.join(root, 'bin', 'win64', 'x86', cpu_bin(target_cpu))
-
- env.PrependENVPath('PATH', [bin_dir])
crt_inc_dir = os.path.join(root, 'inc', 'crt')
if version_major >= 6000:
@@ -98,17 +96,33 @@ def get_winddk_paths(env, version, root):
sdk_inc_dir = os.path.join(root, 'inc', target_os)
wdm_inc_dir = os.path.join(root, 'inc', 'ddk', 'wdm', target_os)
- env.PrependENVPath('INCLUDE', [
- wdm_inc_dir,
- ddk_inc_dir,
- crt_inc_dir,
- sdk_inc_dir,
- ])
+ if env['toolchain'] == 'winddk':
+ env.PrependENVPath('PATH', [bin_dir])
+ env.PrependENVPath('INCLUDE', [
+ wdm_inc_dir,
+ ddk_inc_dir,
+ crt_inc_dir,
+ sdk_inc_dir,
+ ])
+ env.PrependENVPath('LIB', [
+ os.path.join(root, 'lib', 'crt', target_cpu),
+ os.path.join(root, 'lib', target_os, target_cpu),
+ ])
+ elif env['toolchain'] == 'crossmingw':
+ env.Prepend(CPPFLAGS = [
+ '-isystem', ddk_inc_dir,
+ '-isystem', sdk_inc_dir,
+ ])
+ else:
+ env.Prepend(CPPPATH = [
+ wdm_inc_dir,
+ ddk_inc_dir,
+ sdk_inc_dir,
+ ])
+ env.Prepend(LIBPATH = [
+ os.path.join(root, 'lib', target_os, target_cpu),
+ ])
- env.PrependENVPath('LIB', [
- os.path.join(root, 'lib', 'crt', target_cpu),
- os.path.join(root, 'lib', target_os, target_cpu),
- ])
def generate(env):
if not env.has_key('ENV'):
@@ -120,9 +134,10 @@ def generate(env):
get_winddk_paths(env, version, root)
break
- msvc_sa.generate(env)
- mslib_sa.generate(env)
- mslink_sa.generate(env)
+ if env['toolchain'] == 'winddk':
+ msvc_sa.generate(env)
+ mslib_sa.generate(env)
+ mslink_sa.generate(env)
def exists(env):
for version in versions: