mirror of
https://github.com/nodejs/node-v0.x-archive.git
synced 2026-04-28 03:01:10 -04:00
build: handle output of localized gcc or clang
Before this commit, we used to scan the output of `$CC -v` for strings like "gcc version x.y.z". It was pointed out that this approach fails with localized versions of gcc because those print (for example) "gcc versión x.y.z". Use the output of `$CC --version` instead and only look at the first line.
This commit is contained in:
34
configure
vendored
34
configure
vendored
@@ -262,22 +262,24 @@ def host_arch():
|
|||||||
def target_arch():
|
def target_arch():
|
||||||
return host_arch()
|
return host_arch()
|
||||||
|
|
||||||
|
|
||||||
def compiler_version():
|
def compiler_version():
|
||||||
try:
|
proc = subprocess.Popen(CC.split() + ['--version'], stdout=subprocess.PIPE)
|
||||||
proc = subprocess.Popen(CC.split() + ['-v'], stderr=subprocess.PIPE)
|
version_line = proc.communicate()[0].split('\n')[0]
|
||||||
except OSError:
|
|
||||||
return (False, False, None)
|
if 'clang' in version_line:
|
||||||
lines = proc.communicate()[1].split('\n')
|
version, is_clang = version_line.split()[2], True
|
||||||
version_line = None
|
elif 'gcc' in version_line:
|
||||||
for i, line in enumerate(lines):
|
version, is_clang = version_line.split()[-1], False
|
||||||
if 'version' in line:
|
else:
|
||||||
version_line = line
|
raise Exception(
|
||||||
if not version_line:
|
'Unknown compiler. Please open an issue at ' +
|
||||||
return (False, False, None)
|
'https://github.com/joyent/node/issues and ' +
|
||||||
version = version_line.split("version")[1].strip().split()[0].split(".")
|
'include the output of `%s --version`' % CC)
|
||||||
if not version:
|
|
||||||
return (False, False, None)
|
version = tuple(map(int, version.split('.')))
|
||||||
return ('LLVM' in version_line, 'clang' in CC, tuple(version))
|
return (version, is_clang)
|
||||||
|
|
||||||
|
|
||||||
def configure_node(o):
|
def configure_node(o):
|
||||||
# TODO add gdb
|
# TODO add gdb
|
||||||
@@ -288,7 +290,7 @@ def configure_node(o):
|
|||||||
o['variables']['target_arch'] = options.dest_cpu or target_arch()
|
o['variables']['target_arch'] = options.dest_cpu or target_arch()
|
||||||
o['default_configuration'] = 'Debug' if options.debug else 'Release'
|
o['default_configuration'] = 'Debug' if options.debug else 'Release'
|
||||||
|
|
||||||
is_llvm, is_clang, cc_version = compiler_version()
|
cc_version, is_clang = compiler_version()
|
||||||
|
|
||||||
# turn off strict aliasing if gcc < 4.6.0 unless it's llvm-gcc
|
# turn off strict aliasing if gcc < 4.6.0 unless it's llvm-gcc
|
||||||
# see http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45883
|
# see http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45883
|
||||||
|
|||||||
Reference in New Issue
Block a user