# 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'])
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']
'/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
'/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)
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'])