Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Commit

Permalink
build: disable unsafe optimizations
Browse files Browse the repository at this point in the history
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 202df30
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 11 deletions.
20 changes: 14 additions & 6 deletions common.gypi
Expand Up @@ -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"', {
Expand Down Expand Up @@ -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',
'-fstrict-aliasing',
'-ffunction-sections',
'-fdata-sections' ],
}],
['target_arch=="x64"', {
'msvs_configuration_platform': 'x64',
}],
Expand Down
1 change: 0 additions & 1 deletion configure
Expand Up @@ -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.')
else:
Expand Down
4 changes: 0 additions & 4 deletions deps/v8/build/common.gypi
Expand Up @@ -332,10 +332,6 @@
'conditions': [
['OS=="linux" or OS=="freebsd" or OS=="openbsd" or OS=="netbsd" \
or OS=="android"', {
'cflags!': [
'-O2',
'-Os',
],
'cflags': [
'-fdata-sections',
'-ffunction-sections',
Expand Down

0 comments on commit 202df30

Please sign in to comment.