Skip to content

Commit e3c4b67

Browse files
committed
src: workaround MSVC compiler bug
PR-URL: nodejs#25596 Fixes: nodejs#25593 Refs: https://developercommunity.visualstudio.com/content/problem/432157/dynamic-initializers-out-of-order.html Reviewed-By: Bartosz Sosnowski <[email protected]> Reviewed-By: Anna Henningsen <[email protected]>
1 parent ca9e24e commit e3c4b67

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

src/node_options.cc

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,20 @@ void EnvironmentOptions::CheckOptions(std::vector<std::string>* errors) {
107107

108108
namespace options_parser {
109109

110+
// Explicitly access the singelton instances in their dependancy order.
111+
// This was moved here to workaround a compiler bug.
112+
// Refs: https://github.com/nodejs/node/issues/25593
113+
114+
#if HAVE_INSPECTOR
115+
const DebugOptionsParser DebugOptionsParser::instance;
116+
#endif // HAVE_INSPECTOR
117+
118+
const EnvironmentOptionsParser EnvironmentOptionsParser::instance;
119+
120+
const PerIsolateOptionsParser PerIsolateOptionsParser::instance;
121+
122+
const PerProcessOptionsParser PerProcessOptionsParser::instance;
123+
110124
// XXX: If you add an option here, please also add it to doc/node.1 and
111125
// doc/api/cli.md
112126
// TODO(addaleax): Make that unnecessary.
@@ -143,10 +157,6 @@ DebugOptionsParser::DebugOptionsParser() {
143157
AddAlias("--debug-brk=", { "--inspect-port", "--debug-brk" });
144158
}
145159

146-
#if HAVE_INSPECTOR
147-
const DebugOptionsParser DebugOptionsParser::instance;
148-
#endif // HAVE_INSPECTOR
149-
150160
EnvironmentOptionsParser::EnvironmentOptionsParser() {
151161
AddOption("--experimental-modules",
152162
"experimental ES Module support and caching modules",
@@ -282,8 +292,6 @@ EnvironmentOptionsParser::EnvironmentOptionsParser() {
282292
#endif // HAVE_INSPECTOR
283293
}
284294

285-
const EnvironmentOptionsParser EnvironmentOptionsParser::instance;
286-
287295
PerIsolateOptionsParser::PerIsolateOptionsParser() {
288296
AddOption("--track-heap-objects",
289297
"track heap object allocations for heap snapshots",
@@ -341,8 +349,6 @@ PerIsolateOptionsParser::PerIsolateOptionsParser() {
341349
&PerIsolateOptions::get_per_env_options);
342350
}
343351

344-
const PerIsolateOptionsParser PerIsolateOptionsParser::instance;
345-
346352
PerProcessOptionsParser::PerProcessOptionsParser() {
347353
AddOption("--title",
348354
"the process title to use on startup",
@@ -449,8 +455,6 @@ PerProcessOptionsParser::PerProcessOptionsParser() {
449455
&PerProcessOptions::get_per_isolate_options);
450456
}
451457

452-
const PerProcessOptionsParser PerProcessOptionsParser::instance;
453-
454458
inline std::string RemoveBrackets(const std::string& host) {
455459
if (!host.empty() && host.front() == '[' && host.back() == ']')
456460
return host.substr(1, host.size() - 2);

0 commit comments

Comments
 (0)