mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 21:19:50 +01:00
build: disable -fstrict-aliasing if gcc < 4.6.0
A compiler bug in older versions of gcc makes it do unsafe optimizations at -O1 and higher. This manifested itself with (at least) gcc 4.5.2 on SmartOS because it made V8 hang in a busy loop. See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45883
This commit is contained in:
parent
0613af0a20
commit
30b29d8f87
17
common.gypi
17
common.gypi
@ -1,5 +1,6 @@
|
||||
{
|
||||
'variables': {
|
||||
'strict_aliasing%': 'false', # turn on/off -fstrict-aliasing
|
||||
'visibility%': 'hidden', # V8's visibility setting
|
||||
'target_arch%': 'ia32', # set v8's target architecture
|
||||
'host_arch%': 'ia32', # set v8's host architecture
|
||||
@ -34,19 +35,17 @@
|
||||
},
|
||||
},
|
||||
'Release': {
|
||||
'cflags': [ '-O3', '-fdata-sections', '-ffunction-sections' ],
|
||||
'conditions': [
|
||||
[ 'OS!="solaris"', {
|
||||
'cflags': [ '-O3','-fomit-frame-pointer', '-fdata-sections', '-ffunction-sections' ],
|
||||
}],
|
||||
[ 'OS=="solaris" and gcc_optimize_level =="-O3"', {
|
||||
'cflags': [ '-O3', '-fdata-sections', '-ffunction-sections' ],
|
||||
}],
|
||||
[ 'OS=="solaris" and gcc_optimize_level =="-O"', {
|
||||
'cflags': [ '-O', '-fdata-sections', '-ffunction-sections' ], # For bug fix of #2830
|
||||
}],
|
||||
['target_arch=="x64"', {
|
||||
'msvs_configuration_platform': 'x64',
|
||||
}],
|
||||
['OS=="solaris"', {
|
||||
'cflags': [ '-fno-omit-frame-pointer' ],
|
||||
}],
|
||||
['strict_aliasing!="true"', {
|
||||
'cflags': [ '-fno-strict-aliasing' ],
|
||||
}],
|
||||
],
|
||||
'msvs_settings': {
|
||||
'VCCLCompilerTool': {
|
||||
|
31
configure
vendored
31
configure
vendored
@ -2,6 +2,7 @@
|
||||
import optparse
|
||||
import os
|
||||
import pprint
|
||||
import re
|
||||
import subprocess
|
||||
import sys
|
||||
from distutils.version import StrictVersion
|
||||
@ -185,17 +186,17 @@ def host_arch():
|
||||
def target_arch():
|
||||
return host_arch()
|
||||
|
||||
def gcc_optimize_level():
|
||||
cc = ['gcc']
|
||||
cmd = cc + [ '-dumpversion' ]
|
||||
p = subprocess.Popen(cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||
p.stdin.write('\n')
|
||||
out = p.communicate()[0]
|
||||
gcc_version = (str(out).split('\n'))[0]
|
||||
if StrictVersion(gcc_version) >= '4.6.1':
|
||||
return '-O3'
|
||||
else:
|
||||
return '-O'
|
||||
|
||||
def gcc_version():
|
||||
try:
|
||||
proc = subprocess.Popen('gcc -v'.split(), stderr=subprocess.PIPE)
|
||||
except OSError:
|
||||
return None
|
||||
version = proc.communicate()[1].split('\n')[-2]
|
||||
match = re.match('gcc version (\d+)\.(\d+)\.(\d+)', version)
|
||||
assert match, 'Failed to parse gcc version `%s`' % version
|
||||
return ['LLVM' in version] + map(int, match.groups())
|
||||
|
||||
|
||||
def configure_node(o):
|
||||
# TODO add gdb
|
||||
@ -207,10 +208,16 @@ def configure_node(o):
|
||||
o['variables']['target_arch'] = options.dest_cpu or target_arch()
|
||||
o['default_configuration'] = 'Debug' if options.debug else 'Release'
|
||||
|
||||
# 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://code.google.com/p/v8/issues/detail?id=884
|
||||
# TODO handle CC=clang
|
||||
o['variables']['strict_aliasing'] = b(gcc_version() >= (False, 4, 6, 0))
|
||||
|
||||
# TODO move to node.gyp
|
||||
if sys.platform == 'sunos5':
|
||||
o['variables']['visibility'] = '' # FIXME -fvisibility=hidden, should be a gcc check
|
||||
o['variables']['gcc_optimize_level'] = gcc_optimize_level() # For bug fix of #2830
|
||||
|
||||
|
||||
def configure_libz(o):
|
||||
o['variables']['node_shared_zlib'] = b(options.shared_zlib)
|
||||
|
Loading…
Reference in New Issue
Block a user