Skip to content

Commit 9b3de60

Browse files
committed
build: remove --unsafe-optimizations flag
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.
1 parent 588040d commit 9b3de60

2 files changed

Lines changed: 8 additions & 35 deletions

File tree

common.gypi

Lines changed: 8 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,6 @@
1111
'clang%': 0,
1212
'python%': 'python',
1313

14-
# Turn on optimizations that may trigger compiler bugs.
15-
# Use at your own risk. Do *NOT* report bugs if this option is enabled.
16-
'node_unsafe_optimizations%': 0,
17-
1814
# Enable V8's post-mortem debugging only on unix flavors.
1915
'conditions': [
2016
['OS == "win"', {
@@ -53,38 +49,23 @@
5349
},
5450
},
5551
'Release': {
52+
'cflags': [ '-O3', '-ffunction-sections', '-fdata-sections' ],
53+
'ldflags': [ '-Wl,--gc-sections' ],
5654
'conditions': [
5755
['target_arch=="x64"', {
5856
'msvs_configuration_platform': 'x64',
5957
}],
60-
['node_unsafe_optimizations==1', {
61-
'cflags': [ '-O3', '-ffunction-sections', '-fdata-sections' ],
62-
'ldflags': [ '-Wl,--gc-sections' ],
63-
}, {
64-
'cflags': [ '-O2', '-fno-strict-aliasing' ],
65-
'cflags!': [ '-O3', '-fstrict-aliasing' ],
66-
'conditions': [
67-
# Required by the dtrace post-processor. Unfortunately,
68-
# some gcc/binutils combos generate bad code when
69-
# -ffunction-sections is enabled. Let's hope for the best.
70-
['OS=="solaris"', {
71-
'cflags': [ '-ffunction-sections', '-fdata-sections' ],
72-
}, {
73-
'cflags!': [ '-ffunction-sections', '-fdata-sections' ],
74-
}],
75-
['clang == 0 and gcc_version >= 40', {
76-
'cflags': [ '-fno-tree-vrp' ],
77-
}],
78-
['clang == 0 and gcc_version <= 44', {
79-
'cflags': [ '-fno-tree-sink' ],
80-
}],
81-
],
82-
}],
8358
['OS=="solaris"', {
8459
'cflags': [ '-fno-omit-frame-pointer' ],
8560
# pull in V8's postmortem metadata
8661
'ldflags': [ '-Wl,-z,allextract' ]
8762
}],
63+
['clang == 0 and gcc_version >= 40', {
64+
'cflags': [ '-fno-tree-vrp' ], # Work around compiler bug.
65+
}],
66+
['clang == 0 and gcc_version <= 44', {
67+
'cflags': [ '-fno-tree-sink' ], # Work around compiler bug.
68+
}],
8869
],
8970
'msvs_settings': {
9071
'VCCLCompilerTool': {

configure

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -255,12 +255,6 @@ parser.add_option("--ninja",
255255
dest="use_ninja",
256256
help="Generate files for the ninja build system")
257257

258-
# Using --unsafe-optimizations voids your warranty.
259-
parser.add_option("--unsafe-optimizations",
260-
action="store_true",
261-
dest="unsafe_optimizations",
262-
help=optparse.SUPPRESS_HELP)
263-
264258
parser.add_option("--xcode",
265259
action="store_true",
266260
dest="use_xcode",
@@ -442,8 +436,6 @@ def configure_node(o):
442436
o['variables']['v8_no_strict_aliasing'] = 1 # work around compiler bugs
443437
o['variables']['node_prefix'] = os.path.expanduser(options.prefix or '')
444438
o['variables']['node_install_npm'] = b(not options.without_npm)
445-
o['variables']['node_unsafe_optimizations'] = (
446-
1 if options.unsafe_optimizations else 0)
447439
o['default_configuration'] = 'Debug' if options.debug else 'Release'
448440

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

0 commit comments

Comments
 (0)