mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-06-17 21:48:22 +02:00
scons: Support clang.
clang is supports most gcc options / extensions, with a some exceptions. The biggest advantage of using clang is that compilation times are much short. One can tell scons to use clang when building by invoking it as CC=clang CXX=clang++ scons libgl-xlib
This commit is contained in:
parent
f0c296773d
commit
1687932d2b
4 changed files with 18 additions and 14 deletions
|
|
@ -152,7 +152,7 @@ def generate(env):
|
||||||
platform = env['platform']
|
platform = env['platform']
|
||||||
x86 = env['machine'] == 'x86'
|
x86 = env['machine'] == 'x86'
|
||||||
ppc = env['machine'] == 'ppc'
|
ppc = env['machine'] == 'ppc'
|
||||||
gcc = env['gcc']
|
gcc_compat = env['gcc'] or env['clang']
|
||||||
msvc = env['msvc']
|
msvc = env['msvc']
|
||||||
suncc = env['suncc']
|
suncc = env['suncc']
|
||||||
icc = env['icc']
|
icc = env['icc']
|
||||||
|
|
@ -279,7 +279,7 @@ def generate(env):
|
||||||
('_WIN32_WINNT', '0x0601'),
|
('_WIN32_WINNT', '0x0601'),
|
||||||
('WINVER', '0x0601'),
|
('WINVER', '0x0601'),
|
||||||
]
|
]
|
||||||
if gcc:
|
if gcc_compat:
|
||||||
cppdefines += [('__MSVCRT_VERSION__', '0x0700')]
|
cppdefines += [('__MSVCRT_VERSION__', '0x0700')]
|
||||||
if msvc:
|
if msvc:
|
||||||
cppdefines += [
|
cppdefines += [
|
||||||
|
|
@ -309,19 +309,20 @@ def generate(env):
|
||||||
cflags = [] # C
|
cflags = [] # C
|
||||||
cxxflags = [] # C++
|
cxxflags = [] # C++
|
||||||
ccflags = [] # C & C++
|
ccflags = [] # C & C++
|
||||||
if gcc:
|
if gcc_compat:
|
||||||
ccversion = env['CCVERSION']
|
ccversion = env['CCVERSION']
|
||||||
if env['build'] == 'debug':
|
if env['build'] == 'debug':
|
||||||
ccflags += ['-O0']
|
ccflags += ['-O0']
|
||||||
elif ccversion.startswith('4.2.'):
|
elif env['gcc'] and ccversion.startswith('4.2.'):
|
||||||
# gcc 4.2.x optimizer is broken
|
# gcc 4.2.x optimizer is broken
|
||||||
print "warning: gcc 4.2.x optimizer is broken -- disabling optimizations"
|
print "warning: gcc 4.2.x optimizer is broken -- disabling optimizations"
|
||||||
ccflags += ['-O0']
|
ccflags += ['-O0']
|
||||||
else:
|
else:
|
||||||
ccflags += ['-O3']
|
ccflags += ['-O3']
|
||||||
# gcc's builtin memcmp is slower than glibc's
|
if env['gcc']:
|
||||||
# http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43052
|
# gcc's builtin memcmp is slower than glibc's
|
||||||
ccflags += ['-fno-builtin-memcmp']
|
# http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43052
|
||||||
|
ccflags += ['-fno-builtin-memcmp']
|
||||||
# Work around aliasing bugs - developers should comment this out
|
# Work around aliasing bugs - developers should comment this out
|
||||||
ccflags += ['-fno-strict-aliasing']
|
ccflags += ['-fno-strict-aliasing']
|
||||||
ccflags += ['-g']
|
ccflags += ['-g']
|
||||||
|
|
@ -329,8 +330,9 @@ def generate(env):
|
||||||
# See http://code.google.com/p/jrfonseca/wiki/Gprof2Dot#Which_options_should_I_pass_to_gcc_when_compiling_for_profiling?
|
# See http://code.google.com/p/jrfonseca/wiki/Gprof2Dot#Which_options_should_I_pass_to_gcc_when_compiling_for_profiling?
|
||||||
ccflags += [
|
ccflags += [
|
||||||
'-fno-omit-frame-pointer',
|
'-fno-omit-frame-pointer',
|
||||||
'-fno-optimize-sibling-calls',
|
|
||||||
]
|
]
|
||||||
|
if env['gcc']:
|
||||||
|
ccflags += ['-fno-optimize-sibling-calls']
|
||||||
if env['machine'] == 'x86':
|
if env['machine'] == 'x86':
|
||||||
ccflags += [
|
ccflags += [
|
||||||
'-m32',
|
'-m32',
|
||||||
|
|
@ -448,7 +450,7 @@ def generate(env):
|
||||||
env.Append(SHCCFLAGS = ['/LD'])
|
env.Append(SHCCFLAGS = ['/LD'])
|
||||||
|
|
||||||
# Assembler options
|
# Assembler options
|
||||||
if gcc:
|
if gcc_compat:
|
||||||
if env['machine'] == 'x86':
|
if env['machine'] == 'x86':
|
||||||
env.Append(ASFLAGS = ['-m32'])
|
env.Append(ASFLAGS = ['-m32'])
|
||||||
if env['machine'] == 'x86_64':
|
if env['machine'] == 'x86_64':
|
||||||
|
|
@ -457,7 +459,7 @@ def generate(env):
|
||||||
# Linker options
|
# Linker options
|
||||||
linkflags = []
|
linkflags = []
|
||||||
shlinkflags = []
|
shlinkflags = []
|
||||||
if gcc:
|
if gcc_compat:
|
||||||
if env['machine'] == 'x86':
|
if env['machine'] == 'x86':
|
||||||
linkflags += ['-m32']
|
linkflags += ['-m32']
|
||||||
if env['machine'] == 'x86_64':
|
if env['machine'] == 'x86_64':
|
||||||
|
|
@ -495,7 +497,7 @@ def generate(env):
|
||||||
env.Append(SHLINKFLAGS = shlinkflags)
|
env.Append(SHLINKFLAGS = shlinkflags)
|
||||||
|
|
||||||
# We have C++ in several libraries, so always link with the C++ compiler
|
# We have C++ in several libraries, so always link with the C++ compiler
|
||||||
if env['gcc'] or env['clang']:
|
if gcc_compat:
|
||||||
env['LINK'] = env['CXX']
|
env['LINK'] = env['CXX']
|
||||||
|
|
||||||
# Default libs
|
# Default libs
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ if env['suncc']:
|
||||||
print 'warning: not building svga'
|
print 'warning: not building svga'
|
||||||
Return()
|
Return()
|
||||||
|
|
||||||
if env['gcc']:
|
if env['gcc'] or env['clang']:
|
||||||
env.Append(CPPDEFINES = [
|
env.Append(CPPDEFINES = [
|
||||||
'HAVE_STDINT_H',
|
'HAVE_STDINT_H',
|
||||||
'HAVE_SYS_TYPES_H',
|
'HAVE_SYS_TYPES_H',
|
||||||
|
|
|
||||||
|
|
@ -49,7 +49,8 @@ for s in mapi_sources:
|
||||||
#
|
#
|
||||||
# Assembly sources
|
# Assembly sources
|
||||||
#
|
#
|
||||||
if env['gcc'] and env['platform'] not in ('cygwin', 'darwin', 'windows'):
|
if (env['gcc'] or env['clang']) and \
|
||||||
|
env['platform'] not in ('cygwin', 'darwin', 'windows'):
|
||||||
GLAPI = '#src/mapi/glapi/'
|
GLAPI = '#src/mapi/glapi/'
|
||||||
|
|
||||||
if env['machine'] == 'x86':
|
if env['machine'] == 'x86':
|
||||||
|
|
|
||||||
|
|
@ -351,7 +351,8 @@ get_hash_header = env.CodeGenerate(
|
||||||
#
|
#
|
||||||
# Assembly sources
|
# Assembly sources
|
||||||
#
|
#
|
||||||
if env['gcc'] and env['platform'] not in ('cygwin', 'darwin', 'windows', 'haiku'):
|
if (env['gcc'] or env['clang']) and \
|
||||||
|
env['platform'] not in ('cygwin', 'darwin', 'windows', 'haiku'):
|
||||||
if env['machine'] == 'x86':
|
if env['machine'] == 'x86':
|
||||||
env.Append(CPPDEFINES = [
|
env.Append(CPPDEFINES = [
|
||||||
'USE_X86_ASM',
|
'USE_X86_ASM',
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue