Skip to content

Commit

Permalink
build: remove --unsafe-optimizations flag
Browse files Browse the repository at this point in the history
The previous commit removes our patch that builds V8 at -O2 rather
than -O3 so there is not much point in keeping the configure switch
around.

The reason it did so was to work around an assortment of compiler and
linker bugs. In particular, certain combinations of g++ and binutils
generate bad or no code when -ffunction-sections or -finline-functions
is enabled (which -O3 implicitly does.)

It was quite the problem back in the day because everyone and his dog
built from source. Now that we have prebuilt binaries and packages
available, there is no longer a pressing need to be so accommodating.

If you experience spurious (or possibly not so spurious) segmentation
faults after this commit, you need to upgrade your compiler/linker
toolchain.
  • Loading branch information
bnoordhuis committed Jul 6, 2013
1 parent 588040d commit 9b3de60
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 35 deletions.
35 changes: 8 additions & 27 deletions common.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@
'clang%': 0,
'python%': 'python',

# 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 @@ -53,38 +49,23 @@
},
},
'Release': {
'cflags': [ '-O3', '-ffunction-sections', '-fdata-sections' ],
'ldflags': [ '-Wl,--gc-sections' ],
'conditions': [
['target_arch=="x64"', {
'msvs_configuration_platform': 'x64',
}],
['node_unsafe_optimizations==1', {
'cflags': [ '-O3', '-ffunction-sections', '-fdata-sections' ],
'ldflags': [ '-Wl,--gc-sections' ],
}, {
'cflags': [ '-O2', '-fno-strict-aliasing' ],
'cflags!': [ '-O3', '-fstrict-aliasing' ],
'conditions': [
# Required by the dtrace post-processor. Unfortunately,
# some gcc/binutils combos generate bad code when
# -ffunction-sections is enabled. Let's hope for the best.
['OS=="solaris"', {
'cflags': [ '-ffunction-sections', '-fdata-sections' ],
}, {
'cflags!': [ '-ffunction-sections', '-fdata-sections' ],
}],
['clang == 0 and gcc_version >= 40', {
'cflags': [ '-fno-tree-vrp' ],
}],
['clang == 0 and gcc_version <= 44', {
'cflags': [ '-fno-tree-sink' ],
}],
],
}],
['OS=="solaris"', {
'cflags': [ '-fno-omit-frame-pointer' ],
# pull in V8's postmortem metadata
'ldflags': [ '-Wl,-z,allextract' ]
}],
['clang == 0 and gcc_version >= 40', {
'cflags': [ '-fno-tree-vrp' ], # Work around compiler bug.
}],
['clang == 0 and gcc_version <= 44', {
'cflags': [ '-fno-tree-sink' ], # Work around compiler bug.
}],
],
'msvs_settings': {
'VCCLCompilerTool': {
Expand Down
8 changes: 0 additions & 8 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -255,12 +255,6 @@ parser.add_option("--ninja",
dest="use_ninja",
help="Generate files for the ninja build system")

# Using --unsafe-optimizations voids your warranty.
parser.add_option("--unsafe-optimizations",
action="store_true",
dest="unsafe_optimizations",
help=optparse.SUPPRESS_HELP)

parser.add_option("--xcode",
action="store_true",
dest="use_xcode",
Expand Down Expand Up @@ -442,8 +436,6 @@ def configure_node(o):
o['variables']['v8_no_strict_aliasing'] = 1 # work around compiler bugs
o['variables']['node_prefix'] = os.path.expanduser(options.prefix or '')
o['variables']['node_install_npm'] = b(not options.without_npm)
o['variables']['node_unsafe_optimizations'] = (
1 if options.unsafe_optimizations else 0)
o['default_configuration'] = 'Debug' if options.debug else 'Release'

host_arch = host_arch_win() if os.name == 'nt' else host_arch_cc()
Expand Down

0 comments on commit 9b3de60

Please sign in to comment.