From 84bd1fe6174d3636c2f7ee6bbfe8a0a330324341 Mon Sep 17 00:00:00 2001 From: Vincenzo Eduardo Padulano Date: Tue, 19 Dec 2023 18:14:16 +0100 Subject: [PATCH] [core] Materialize symbols for TError variables The variables present in TError.h are used throughout the ROOT libraries. Anytime one of these variables is requested, e.g. with a simple test such as `python -c "import ROOT; ROOT.kError"`, the interpreter will lookup the corresponding symbol. Previously, the variables were declared and defined in the header directly but were not generating any symbol since the linkage was internal. With this commit, provide external linkage to these variables so that the corresponding symbols are materialized in libCore.so. As a consequence, a huge number of extra lookups by cling is avoided. --- core/foundation/inc/TError.h | 17 ++++++++--------- core/foundation/src/RLogger.cxx | 2 +- core/foundation/src/TError.cxx | 9 +++++++++ 3 files changed, 18 insertions(+), 10 deletions(-) diff --git a/core/foundation/inc/TError.h b/core/foundation/inc/TError.h index 0099d8e538704..2948a70e6844e 100644 --- a/core/foundation/inc/TError.h +++ b/core/foundation/inc/TError.h @@ -39,15 +39,14 @@ class TVirtualMutex; -constexpr Int_t kUnset = -1; -constexpr Int_t kPrint = 0; -constexpr Int_t kInfo = 1000; -constexpr Int_t kWarning = 2000; -constexpr Int_t kError = 3000; -constexpr Int_t kBreak = 4000; -constexpr Int_t kSysError = 5000; -constexpr Int_t kFatal = 6000; - +R__EXTERN const Int_t kUnset; +R__EXTERN const Int_t kPrint; +R__EXTERN const Int_t kInfo; +R__EXTERN const Int_t kWarning; +R__EXTERN const Int_t kError; +R__EXTERN const Int_t kBreak; +R__EXTERN const Int_t kSysError; +R__EXTERN const Int_t kFatal; // TROOT sets the error ignore level handler, the system error message handler, and the error abort handler on // construction such that the "Root.ErrorIgnoreLevel" environment variable is used for the ignore level diff --git a/core/foundation/src/RLogger.cxx b/core/foundation/src/RLogger.cxx index de9eb939ab8ec..18ba9f954d959 100644 --- a/core/foundation/src/RLogger.cxx +++ b/core/foundation/src/RLogger.cxx @@ -52,7 +52,7 @@ inline bool RLogHandlerDefault::Emit(const RLogEntry &entry) if (!entry.fLocation.fFuncName.empty()) strm << " in " << entry.fLocation.fFuncName; - static constexpr const int errorLevelOld[] = {kFatal /*unset*/, kFatal, kError, kWarning, kInfo, kInfo /*debug*/}; + static const int errorLevelOld[] = {kFatal /*unset*/, kFatal, kError, kWarning, kInfo, kInfo /*debug*/}; (*::GetErrorHandler())(errorLevelOld[cappedLevel], entry.fLevel == ELogLevel::kFatal, strm.str().c_str(), entry.fMessage.c_str()); return true; diff --git a/core/foundation/src/TError.cxx b/core/foundation/src/TError.cxx index a989d0ea40fc2..27158ecdf6051 100644 --- a/core/foundation/src/TError.cxx +++ b/core/foundation/src/TError.cxx @@ -31,6 +31,15 @@ to be replaced by the proper DefaultErrorHandler() // Deprecated TVirtualMutex *gErrorMutex = nullptr; +const Int_t kUnset = -1; +const Int_t kPrint = 0; +const Int_t kInfo = 1000; +const Int_t kWarning = 2000; +const Int_t kError = 3000; +const Int_t kBreak = 4000; +const Int_t kSysError = 5000; +const Int_t kFatal = 6000; + Int_t gErrorIgnoreLevel = kUnset; Int_t gErrorAbortLevel = kSysError+1; Bool_t gPrintViaErrorHandler = kFALSE;