Browse Source

build: disable unsafe optimizations

Compile at -O2 and disable optimizations that trigger gcc bugs.

Some people still reported mksnapshot crashes after commit b40f813 ("build: fix
spurious mksnapshot crashes for good" - so much for that).

Average performance of the -O2 binary is on par with the -O3 binary. Variance
on the http_simple bytes/8 benchmark appears to be slightly greater but small
enough that the possibly of it being noise cannot be excluded.

The new binary very slightly but consistently outperforms the -O3 binary (by
about 0.5%) on the mostly CPU-bound bytes/102400 benchmark. That could be an
artifact of the system I benchmarked it on, a Core 2 Duo with a puny 32 kB of
L1 instruction cache. The smaller binary seems to play nicer with the cache.
v0.8.7-release
Ben Noordhuis 13 years ago
parent
commit
202df30aab
  1. 20
      common.gypi
  2. 1
      configure
  3. 4
      deps/v8/build/common.gypi

20
common.gypi

@ -8,6 +8,10 @@
'component%': 'static_library', # NB. these names match with what V8 expects 'component%': 'static_library', # NB. these names match with what V8 expects
'msvs_multi_core_compile': '0', # we do enable multicore compiles, but not using the V8 way 'msvs_multi_core_compile': '0', # we do enable multicore compiles, but not using the V8 way
# Turn on optimizations that may trigger compiler bugs.
# Use at your own risk. Do *NOT* report bugs if this option is enabled.
'node_unsafe_optimizations%': 0,
# Enable V8's post-mortem debugging only on unix flavors. # Enable V8's post-mortem debugging only on unix flavors.
'conditions': [ 'conditions': [
['OS != "win"', { ['OS != "win"', {
@ -41,13 +45,17 @@
}, },
}, },
'Release': { 'Release': {
# Do *NOT* enable -ffunction-sections or -fdata-sections again.
# We don't link with -Wl,--gc-sections so they're effectively no-ops.
# Worse, they trigger very nasty bugs in some versions of gcc, notably
# v4.4.6 on x86_64-redhat-linux (i.e. RHEL and CentOS).
'cflags!': [ '-ffunction-sections', '-fdata-sections' ],
'cflags': [ '-O3' ],
'conditions': [ 'conditions': [
['node_unsafe_optimizations==1', {
'cflags': [ '-O3', '-ffunction-sections', '-fdata-sections' ],
'ldflags': [ '-Wl,--gc-sections' ],
}, {
'cflags': [ '-O2', '-fno-strict-aliasing', '-fno-tree-vrp' ],
'cflags!': [ '-O3',
'-fstrict-aliasing',
'-ffunction-sections',
'-fdata-sections' ],
}],
['target_arch=="x64"', { ['target_arch=="x64"', {
'msvs_configuration_platform': 'x64', 'msvs_configuration_platform': 'x64',
}], }],

1
configure

@ -297,7 +297,6 @@ def configure_node(o):
# SunOS, and we haven't implemented it.) # SunOS, and we haven't implemented it.)
if sys.platform.startswith('sunos'): if sys.platform.startswith('sunos'):
o['variables']['node_use_dtrace'] = b(not options.without_dtrace) o['variables']['node_use_dtrace'] = b(not options.without_dtrace)
o['variables']['v8_no_strict_aliasing'] = 1 # work around compiler bug
elif b(options.with_dtrace) == 'true': elif b(options.with_dtrace) == 'true':
raise Exception('DTrace is currently only supported on SunOS systems.') raise Exception('DTrace is currently only supported on SunOS systems.')
else: else:

4
deps/v8/build/common.gypi

@ -332,10 +332,6 @@
'conditions': [ 'conditions': [
['OS=="linux" or OS=="freebsd" or OS=="openbsd" or OS=="netbsd" \ ['OS=="linux" or OS=="freebsd" or OS=="openbsd" or OS=="netbsd" \
or OS=="android"', { or OS=="android"', {
'cflags!': [
'-O2',
'-Os',
],
'cflags': [ 'cflags': [
'-fdata-sections', '-fdata-sections',
'-ffunction-sections', '-ffunction-sections',

Loading…
Cancel
Save