Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

src: mitigate MSVC dynamic initialization bug #25596

Merged
merged 1 commit into from
Jan 31, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 14 additions & 10 deletions src/node_options.cc
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,20 @@ void EnvironmentOptions::CheckOptions(std::vector<std::string>* errors) {

namespace options_parser {

// Explicitly access the singelton instances in their dependancy order.
// This was moved here to workaround a compiler bug.
// Refs: https://github.com/nodejs/node/issues/25593

#if HAVE_INSPECTOR
const DebugOptionsParser DebugOptionsParser::instance;
#endif // HAVE_INSPECTOR

const EnvironmentOptionsParser EnvironmentOptionsParser::instance;

const PerIsolateOptionsParser PerIsolateOptionsParser::instance;

const PerProcessOptionsParser PerProcessOptionsParser::instance;

// XXX: If you add an option here, please also add it to doc/node.1 and
// doc/api/cli.md
// TODO(addaleax): Make that unnecessary.
Expand Down Expand Up @@ -143,10 +157,6 @@ DebugOptionsParser::DebugOptionsParser() {
AddAlias("--debug-brk=", { "--inspect-port", "--debug-brk" });
}

#if HAVE_INSPECTOR
const DebugOptionsParser DebugOptionsParser::instance;
#endif // HAVE_INSPECTOR

EnvironmentOptionsParser::EnvironmentOptionsParser() {
AddOption("--experimental-modules",
"experimental ES Module support and caching modules",
Expand Down Expand Up @@ -282,8 +292,6 @@ EnvironmentOptionsParser::EnvironmentOptionsParser() {
#endif // HAVE_INSPECTOR
}

const EnvironmentOptionsParser EnvironmentOptionsParser::instance;

PerIsolateOptionsParser::PerIsolateOptionsParser() {
AddOption("--track-heap-objects",
"track heap object allocations for heap snapshots",
Expand Down Expand Up @@ -341,8 +349,6 @@ PerIsolateOptionsParser::PerIsolateOptionsParser() {
&PerIsolateOptions::get_per_env_options);
}

const PerIsolateOptionsParser PerIsolateOptionsParser::instance;

PerProcessOptionsParser::PerProcessOptionsParser() {
AddOption("--title",
"the process title to use on startup",
Expand Down Expand Up @@ -449,8 +455,6 @@ PerProcessOptionsParser::PerProcessOptionsParser() {
&PerProcessOptions::get_per_isolate_options);
}

const PerProcessOptionsParser PerProcessOptionsParser::instance;

inline std::string RemoveBrackets(const std::string& host) {
if (!host.empty() && host.front() == '[' && host.back() == ']')
return host.substr(1, host.size() - 2);
Expand Down