build: improve c compiler detection
This commit is contained in:
Родитель
9ae6d8fee3
Коммит
c9676c9147
|
@ -224,18 +224,22 @@ def host_arch():
|
||||||
def target_arch():
|
def target_arch():
|
||||||
return host_arch()
|
return host_arch()
|
||||||
|
|
||||||
|
def cc_version():
|
||||||
def gcc_version():
|
|
||||||
try:
|
try:
|
||||||
proc = subprocess.Popen([CC, '-v'], stderr=subprocess.PIPE)
|
proc = subprocess.Popen([CC, '-v'], stderr=subprocess.PIPE)
|
||||||
except OSError:
|
except OSError:
|
||||||
return None
|
return None
|
||||||
# TODO parse clang output
|
lines = proc.communicate()[1].split('\n')
|
||||||
version = proc.communicate()[1].split('\n')[-2]
|
version_line = None
|
||||||
match = re.match('gcc version (\d+)\.(\d+)\.(\d+)', version)
|
for i, line in enumerate(lines):
|
||||||
if not match: return None
|
if 'version' in line:
|
||||||
return ['LLVM' in version] + map(int, match.groups())
|
version_line = line
|
||||||
|
if not version_line:
|
||||||
|
return None
|
||||||
|
version = version_line.split("version")[1].strip().split()[0].split(".")
|
||||||
|
if not version:
|
||||||
|
return None
|
||||||
|
return ['LLVM' in version_line] + version
|
||||||
|
|
||||||
def configure_node(o):
|
def configure_node(o):
|
||||||
# TODO add gdb
|
# TODO add gdb
|
||||||
|
@ -250,10 +254,10 @@ def configure_node(o):
|
||||||
# see http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45883
|
# see http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45883
|
||||||
# see http://code.google.com/p/v8/issues/detail?id=884
|
# see http://code.google.com/p/v8/issues/detail?id=884
|
||||||
o['variables']['strict_aliasing'] = b(
|
o['variables']['strict_aliasing'] = b(
|
||||||
'clang' in CC or gcc_version() >= [False, 4, 6, 0])
|
'clang' in CC or cc_version() >= [False, 4, 6, 0])
|
||||||
|
|
||||||
# clang has always supported -fvisibility=hidden, right?
|
# clang has always supported -fvisibility=hidden, right?
|
||||||
if 'clang' not in CC and gcc_version() < [False, 4, 0, 0]:
|
if 'clang' not in CC and cc_version() < [False, 4, 0, 0]:
|
||||||
o['variables']['visibility'] = ''
|
o['variables']['visibility'] = ''
|
||||||
|
|
||||||
# By default, enable DTrace on SunOS systems. Don't allow it on other
|
# By default, enable DTrace on SunOS systems. Don't allow it on other
|
||||||
|
|
Загрузка…
Ссылка в новой задаче