mirror of https://github.com/Icinga/icinga2.git
Merge pull request #6591 from Icinga/bugfix/lto-builds-static-initialize-namespaces
Fix static initializer priority for namespaces in LTO builds
This commit is contained in:
commit
1c2a59bf63
|
@ -72,6 +72,7 @@ private:
|
|||
bool side_effect_free, bool deprecated);
|
||||
};
|
||||
|
||||
/* Ensure that the priority is lower than the basic namespace initialization in scriptframe.cpp. */
|
||||
#define REGISTER_FUNCTION(ns, name, callback, args) \
|
||||
INITIALIZE_ONCE_WITH_PRIORITY([]() { \
|
||||
Function::Ptr sf = new icinga::Function(#ns "#" #name, callback, String(args).Split(":"), false); \
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
|
||||
using namespace icinga;
|
||||
|
||||
/* Ensure that the priority is lower than the basic namespace initialization in scriptframe.cpp. */
|
||||
INITIALIZE_ONCE_WITH_PRIORITY([]() {
|
||||
Type::Ptr type = new ObjectType();
|
||||
type->SetPrototype(Object::GetPrototype());
|
||||
|
|
|
@ -48,6 +48,7 @@ private:
|
|||
ObjectFactory m_Factory;
|
||||
};
|
||||
|
||||
/* Ensure that the priority is lower than the basic namespace initialization in scriptframe.cpp. */
|
||||
#define REGISTER_BUILTIN_TYPE(type, prototype) \
|
||||
INITIALIZE_ONCE_WITH_PRIORITY([]() { \
|
||||
icinga::Type::Ptr t = new PrimitiveType(#type, "None"); \
|
||||
|
|
|
@ -29,6 +29,10 @@ boost::thread_specific_ptr<std::stack<ScriptFrame *> > ScriptFrame::m_ScriptFram
|
|||
|
||||
static auto l_InternalNSBehavior = new ConstNamespaceBehavior();
|
||||
|
||||
/* Ensure that this gets called with highest priority
|
||||
* and wins against other static initializers in lib/icinga, etc.
|
||||
* LTO-enabled builds will cause trouble otherwise, see GH #6575.
|
||||
*/
|
||||
INITIALIZE_ONCE_WITH_PRIORITY([]() {
|
||||
Namespace::Ptr globalNS = ScriptGlobal::GetGlobals();
|
||||
|
||||
|
@ -51,7 +55,7 @@ INITIALIZE_ONCE_WITH_PRIORITY([]() {
|
|||
|
||||
Namespace::Ptr internalNS = new Namespace(l_InternalNSBehavior);
|
||||
globalNS->SetAttribute("Internal", std::make_shared<ConstEmbeddedNamespaceValue>(internalNS));
|
||||
}, 50);
|
||||
}, 1000);
|
||||
|
||||
INITIALIZE_ONCE_WITH_PRIORITY([]() {
|
||||
l_InternalNSBehavior->Freeze();
|
||||
|
|
|
@ -26,6 +26,7 @@ using namespace icinga;
|
|||
|
||||
Type::Ptr Type::TypeInstance;
|
||||
|
||||
/* Ensure that the priority is lower than the basic namespace initialization in scriptframe.cpp. */
|
||||
INITIALIZE_ONCE_WITH_PRIORITY([]() {
|
||||
Type::Ptr type = new TypeType();
|
||||
type->SetPrototype(TypeType::GetPrototype());
|
||||
|
|
|
@ -138,6 +138,7 @@ class TypeImpl
|
|||
{
|
||||
};
|
||||
|
||||
/* Ensure that the priority is lower than the basic namespace initialization in scriptframe.cpp. */
|
||||
#define REGISTER_TYPE(type) \
|
||||
INITIALIZE_ONCE_WITH_PRIORITY([]() { \
|
||||
icinga::Type::Ptr t = new TypeImpl<type>(); \
|
||||
|
|
|
@ -21,11 +21,11 @@
|
|||
#include "base/utility.hpp"
|
||||
#include "base/logger.hpp"
|
||||
#include "base/application.hpp"
|
||||
#include "base/scriptglobal.hpp"
|
||||
#include "config/configcompiler.hpp"
|
||||
#include "config/configcompilercontext.hpp"
|
||||
#include "config/configitembuilder.hpp"
|
||||
|
||||
|
||||
using namespace icinga;
|
||||
|
||||
static bool ExecuteExpression(Expression *expression)
|
||||
|
@ -146,6 +146,9 @@ bool DaemonUtility::ValidateConfigFiles(const std::vector<std::string>& configs,
|
|||
return false;
|
||||
|
||||
Namespace::Ptr systemNS = ScriptGlobal::Get("System");
|
||||
VERIFY(systemNS);
|
||||
|
||||
/* This is initialized inside the IcingaApplication class. */
|
||||
Value vAppType;
|
||||
VERIFY(systemNS->Get("ApplicationType", &vAppType));
|
||||
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#include "base/exception.hpp"
|
||||
#include "base/application.hpp"
|
||||
|
||||
/* Ensure that the priority is lower than the basic namespace initialization in scriptframe.cpp. */
|
||||
#define REGISTER_CONFIG_FRAGMENT(name, fragment) \
|
||||
INITIALIZE_ONCE_WITH_PRIORITY([]() { \
|
||||
std::unique_ptr<icinga::Expression> expression = icinga::ConfigCompiler::CompileText(name, fragment); \
|
||||
|
|
|
@ -41,6 +41,7 @@ using namespace icinga;
|
|||
static Timer::Ptr l_RetentionTimer;
|
||||
|
||||
REGISTER_TYPE(IcingaApplication);
|
||||
/* Ensure that the priority is lower than the basic System namespace initialization in scriptframe.cpp. */
|
||||
INITIALIZE_ONCE_WITH_PRIORITY(&IcingaApplication::StaticInitialize, 50);
|
||||
|
||||
void IcingaApplication::StaticInitialize()
|
||||
|
@ -59,11 +60,15 @@ void IcingaApplication::StaticInitialize()
|
|||
|
||||
ScriptGlobal::Set("NodeName", node_name);
|
||||
|
||||
ScriptGlobal::Set("System.ApplicationType", "IcingaApplication", true);
|
||||
Namespace::Ptr systemNS = ScriptGlobal::Get("System");
|
||||
/* Ensure that the System namespace is already initialized. Otherwise this is a programming error. */
|
||||
VERIFY(systemNS);
|
||||
|
||||
ScriptGlobal::Set("System.ApplicationVersion", Application::GetAppVersion(), true);
|
||||
systemNS->Set("ApplicationType", "IcingaApplication", true);
|
||||
systemNS->Set("ApplicationVersion", Application::GetAppVersion(), true);
|
||||
|
||||
Namespace::Ptr globalNS = ScriptGlobal::GetGlobals();
|
||||
VERIFY(globalNS);
|
||||
|
||||
auto icingaNSBehavior = new ConstNamespaceBehavior();
|
||||
icingaNSBehavior->Freeze();
|
||||
|
|
Loading…
Reference in New Issue