diff options
author | Jose Fonseca <jfonseca@vmware.com> | 2016-04-18 16:55:44 +0100 |
---|---|---|
committer | Jose Fonseca <jfonseca@vmware.com> | 2016-04-26 17:17:00 +0100 |
commit | a2fe35bcdf3d383aaa5ad915b80630c8895d703d (patch) | |
tree | 7d4776b2d5c06ca48705ca37d930717b4606d152 | |
parent | dcc3baf7331f7cb920a73e0349a7622bfe46f647 (diff) |
scons: Support Clang on Windows.
- Introduce 'gcc_compat' env flag, for all compilers that define __GNUC__,
(which includes Clang when it's not emulating MSVC.)
- Clang doesn't support whole program optimization
- Disable enumerator value warnings (not sure why Clang warns about them,
as my understanding is that MSVC promotes enums to unsigned ints
automatically.)
This is not enough to build with Clang + AddressSanitizer though. More
follow up changes will be required for that.
Reviewed-by: Roland Scheidegger <sroland@vmware.com>
Reviewed-by: Brian Paul <brianp@vmware.com>
-rwxr-xr-x | scons/gallium.py | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/scons/gallium.py b/scons/gallium.py index 1a819622ce..5fc082d142 100755 --- a/scons/gallium.py +++ b/scons/gallium.py @@ -183,14 +183,15 @@ def generate(env): # Detect gcc/clang not by executable name, but through pre-defined macros # as autoconf does, to avoid drawing wrong conclusions when using tools # that overrice CC/CXX like scan-build. - env['gcc'] = 0 + env['gcc_compat'] = 0 env['clang'] = 0 env['msvc'] = 0 if host_platform.system() == 'Windows': env['msvc'] = check_cc(env, 'MSVC', 'defined(_MSC_VER)', '/E') if not env['msvc']: - env['gcc'] = check_cc(env, 'GCC', 'defined(__GNUC__) && !defined(__clang__)') - env['clang'] = check_cc(env, 'Clang', '__clang__') + env['gcc_compat'] = check_cc(env, 'GCC', 'defined(__GNUC__)') + env['clang'] = check_cc(env, 'Clang', '__clang__') + env['gcc'] = env['gcc_compat'] and not env['clang'] env['suncc'] = env['platform'] == 'sunos' and os.path.basename(env['CC']) == 'cc' env['icc'] = 'icc' == os.path.basename(env['CC']) @@ -203,7 +204,7 @@ def generate(env): platform = env['platform'] x86 = env['machine'] == 'x86' ppc = env['machine'] == 'ppc' - gcc_compat = env['gcc'] or env['clang'] + gcc_compat = env['gcc_compat'] msvc = env['msvc'] suncc = env['suncc'] icc = env['icc'] @@ -450,13 +451,13 @@ def generate(env): '/O2', # optimize for speed ] if env['build'] == 'release': - ccflags += [ - '/GL', # enable whole program optimization - ] + if not env['clang']: + ccflags += [ + '/GL', # enable whole program optimization + ] else: ccflags += [ '/Oy-', # disable frame pointer omission - '/GL-', # disable whole program optimization ] ccflags += [ '/W3', # warning level @@ -470,6 +471,10 @@ def generate(env): '/wd4800', # forcing value to bool 'true' or 'false' (performance warning) '/wd4996', # disable deprecated POSIX name warnings ] + if env['clang']: + ccflags += [ + '-Wno-microsoft-enum-value', # enumerator value is not representable in underlying type 'int' + ] if env['machine'] == 'x86': ccflags += [ '/arch:SSE2', # use the SSE2 instructions (default since MSVC 2012) @@ -556,7 +561,7 @@ def generate(env): shlinkflags += ['-Wl,--enable-stdcall-fixup'] #shlinkflags += ['-Wl,--kill-at'] if msvc: - if env['build'] == 'release': + if env['build'] == 'release' and not env['clang']: # enable Link-time Code Generation linkflags += ['/LTCG'] env.Append(ARFLAGS = ['/LTCG']) |