diff --git a/lld/Common/CommonLinkerContext.cpp b/lld/Common/CommonLinkerContext.cpp --- a/lld/Common/CommonLinkerContext.cpp +++ b/lld/Common/CommonLinkerContext.cpp @@ -10,6 +10,8 @@ #include "lld/Common/ErrorHandler.h" #include "lld/Common/Memory.h" +#include "llvm/CodeGen/CommandFlags.h" + using namespace llvm; using namespace lld; @@ -20,7 +22,11 @@ // state. static CommonLinkerContext *lctx; -CommonLinkerContext::CommonLinkerContext() { lctx = this; } +CommonLinkerContext::CommonLinkerContext() { + lctx = this; + // Fire off the static initializations in CGF's constructor. + codegen::RegisterCodeGenFlags CGF; +} CommonLinkerContext::~CommonLinkerContext() { assert(lctx); diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp --- a/lld/ELF/Writer.cpp +++ b/lld/ELF/Writer.cpp @@ -24,6 +24,7 @@ #include "lld/Common/Filesystem.h" #include "lld/Common/Strings.h" #include "llvm/ADT/StringMap.h" +#include "llvm/Support/MD5.h" #include "llvm/Support/Parallel.h" #include "llvm/Support/RandomNumberGenerator.h" #include "llvm/Support/SHA1.h" diff --git a/lld/MachO/ICF.cpp b/lld/MachO/ICF.cpp --- a/lld/MachO/ICF.cpp +++ b/lld/MachO/ICF.cpp @@ -12,6 +12,7 @@ #include "Symbols.h" #include "UnwindInfoSection.h" +#include "lld/Common/CommonLinkerContext.h" #include "llvm/Support/Parallel.h" #include "llvm/Support/TimeProfiler.h" diff --git a/lld/include/lld/Common/CommonLinkerContext.h b/lld/include/lld/Common/CommonLinkerContext.h --- a/lld/include/lld/Common/CommonLinkerContext.h +++ b/lld/include/lld/Common/CommonLinkerContext.h @@ -21,7 +21,6 @@ #include "lld/Common/ErrorHandler.h" #include "lld/Common/Memory.h" -#include "llvm/CodeGen/CommandFlags.h" #include "llvm/Support/StringSaver.h" namespace llvm { @@ -42,9 +41,6 @@ llvm::DenseMap instances; ErrorHandler e; - -private: - llvm::codegen::RegisterCodeGenFlags cgf; }; // Retrieve the global state. Currently only one state can exist per process,