Skip to content
This repository has been archived by the owner. It is now read-only.
Browse files

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.
  • Loading branch information...
bnoordhuis committed Jul 12, 2012
1 parent d2e40f6 commit 202df30aabc78fa571cf77ad93146b3c4d99fc6e
Showing with 14 additions and 11 deletions.
  1. +14 −6 common.gypi
  2. +0 −1 configure
  3. +0 −4 deps/v8/build/common.gypi
@@ -8,6 +8,10 @@
'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

# 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.
'conditions': [
['OS != "win"', {
@@ -41,13 +45,17 @@
'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': [
['node_unsafe_optimizations==1', {
'cflags': [ '-O3', '-ffunction-sections', '-fdata-sections' ],
'ldflags': [ '-Wl,--gc-sections' ],
}, {
'cflags': [ '-O2', '-fno-strict-aliasing', '-fno-tree-vrp' ],
'cflags!': [ '-O3',
'-fdata-sections' ],
['target_arch=="x64"', {
'msvs_configuration_platform': 'x64',
@@ -297,7 +297,6 @@ def configure_node(o):
# SunOS, and we haven't implemented it.)
if sys.platform.startswith('sunos'):
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':
raise Exception('DTrace is currently only supported on SunOS systems.')
@@ -332,10 +332,6 @@
'conditions': [
['OS=="linux" or OS=="freebsd" or OS=="openbsd" or OS=="netbsd" \
or OS=="android"', {
'cflags!': [
'cflags': [

0 comments on commit 202df30

Please sign in to comment.
You can’t perform that action at this time.