[llvm] [orc-rt] Move ORC_RT_LOG_ENABLED into config.h. (PR #226617)
Lang Hames via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 25 18:06:32 PDT 2026
https://github.com/lhames created https://github.com/llvm/llvm-project/pull/226617
ORC_RT_LOG_ENABLED depends only on the logging configuration values defined in config.h, but was defined in Logging.h, so checking whether a log level is compiled in required pulling in the logging backend's headers (e.g. <os/log.h>).
This commit moves ORC_RT_LOG_ENABLED (and its level-token aliases) into config.h, so that headers can check the logging configuration without including Logging.h.
>From abbd829a9b640bfacca67fb23aacd153bc059a24 Mon Sep 17 00:00:00 2001
From: Lang Hames <lhames at gmail.com>
Date: Sat, 26 Sep 2026 11:00:49 +1000
Subject: [PATCH] [orc-rt] Move ORC_RT_LOG_ENABLED into config.h.
ORC_RT_LOG_ENABLED depends only on the logging configuration values defined
in config.h, but was defined in Logging.h, so checking whether a log level
is compiled in required pulling in the logging backend's headers (e.g.
<os/log.h>).
This commit moves ORC_RT_LOG_ENABLED (and its level-token aliases) into
config.h, so that headers can check the logging configuration without
including Logging.h.
---
orc-rt/include/orc-rt-c/config.h.in | 32 +++++++++++++++++++++++
orc-rt/include/orc-rt-c/support/Logging.h | 28 ++------------------
2 files changed, 34 insertions(+), 26 deletions(-)
diff --git a/orc-rt/include/orc-rt-c/config.h.in b/orc-rt/include/orc-rt-c/config.h.in
index c4ff9a0fb4cd2..7af7b4b2bc565 100644
--- a/orc-rt/include/orc-rt-c/config.h.in
+++ b/orc-rt/include/orc-rt-c/config.h.in
@@ -38,4 +38,36 @@
#endif
#define ORC_RT_LOG_BACKEND @ORC_RT_LOG_BACKEND_VALUE@
+/*
+ * ORC_RT_LOG_ENABLED(Level) is true (1) if log sites at the given level are
+ * compiled in, and false (0) if they're compiled out, either because the
+ * backend is none or because the level is below the ORC_RT_LOG_LEVEL floor. It
+ * takes the same level token as ORC_RT_LOG (see orc-rt-c/support/Logging.h),
+ * and can be used in preprocessor conditionals:
+ *
+ * #if ORC_RT_LOG_ENABLED(Error)
+ * ...
+ * #endif
+ *
+ * It's defined here, rather than in Logging.h, so that it can be used without
+ * pulling in the logging backend's headers (e.g. <os/log.h>).
+ *
+ * Code that relies on logging to surface something important (e.g. an error
+ * reporter that logs) can use this to pick an alternative when logging is
+ * compiled out. Note that a compiled-in level may still be suppressed at
+ * runtime (e.g. by the printf backend's runtime threshold).
+ *
+ * The ORC_RT_LOG_LEVEL_VALUE_<Level> aliases map ORC_RT_LOG's level tokens to
+ * the ORC_RT_LOG_LEVEL_<LEVEL> values above. An unrecognized level token
+ * pastes to an undefined identifier, which evaluates to 0 in #if.
+ */
+#define ORC_RT_LOG_LEVEL_VALUE_Debug ORC_RT_LOG_LEVEL_DEBUG
+#define ORC_RT_LOG_LEVEL_VALUE_Info ORC_RT_LOG_LEVEL_INFO
+#define ORC_RT_LOG_LEVEL_VALUE_Warning ORC_RT_LOG_LEVEL_WARNING
+#define ORC_RT_LOG_LEVEL_VALUE_Error ORC_RT_LOG_LEVEL_ERROR
+
+#define ORC_RT_LOG_ENABLED(Level) \
+ (ORC_RT_LOG_BACKEND != ORC_RT_LOG_BACKEND_NONE && \
+ ORC_RT_LOG_LEVEL_VALUE_##Level >= ORC_RT_LOG_LEVEL)
+
#endif /* ORC_RT_C_CONFIG_H */
diff --git a/orc-rt/include/orc-rt-c/support/Logging.h b/orc-rt/include/orc-rt-c/support/Logging.h
index 8797283523096..9b7413766b330 100644
--- a/orc-rt/include/orc-rt-c/support/Logging.h
+++ b/orc-rt/include/orc-rt-c/support/Logging.h
@@ -135,33 +135,9 @@ int orc_rt_log_formatCheck(const char *Fmt, ...) ORC_RT_FORMAT_PRINTF(1, 2);
ORC_RT_LOG_##Level(orc_rt_log_Category_##Category, __VA_ARGS__))
/*
- * ORC_RT_LOG_ENABLED(Level) is true (1) if log sites at the given level are
- * compiled in, and false (0) if they're compiled out, either because the
- * backend is none or because the level is below the ORC_RT_LOG_LEVEL floor. It
- * takes the same level token as ORC_RT_LOG, and can be used in preprocessor
- * conditionals:
- *
- * #if ORC_RT_LOG_ENABLED(Error)
- * ...
- * #endif
- *
- * Code that relies on logging to surface something important (e.g. an error
- * reporter that logs) can use this to pick an alternative when logging is
- * compiled out. Note that a compiled-in level may still be suppressed at
- * runtime (e.g. by the printf backend's runtime threshold).
- *
- * The ORC_RT_LOG_LEVEL_VALUE_<Level> aliases map ORC_RT_LOG's level tokens to
- * the ORC_RT_LOG_LEVEL_<LEVEL> values from config.h. An unrecognized level
- * token pastes to an undefined identifier, which evaluates to 0 in #if.
+ * To check whether a level is compiled in, use ORC_RT_LOG_ENABLED(Level),
+ * defined in orc-rt-c/config.h.
*/
-#define ORC_RT_LOG_LEVEL_VALUE_Debug ORC_RT_LOG_LEVEL_DEBUG
-#define ORC_RT_LOG_LEVEL_VALUE_Info ORC_RT_LOG_LEVEL_INFO
-#define ORC_RT_LOG_LEVEL_VALUE_Warning ORC_RT_LOG_LEVEL_WARNING
-#define ORC_RT_LOG_LEVEL_VALUE_Error ORC_RT_LOG_LEVEL_ERROR
-
-#define ORC_RT_LOG_ENABLED(Level) \
- (ORC_RT_LOG_BACKEND != ORC_RT_LOG_BACKEND_NONE && \
- ORC_RT_LOG_LEVEL_VALUE_##Level >= ORC_RT_LOG_LEVEL)
/**
* \def ORC_RT_LOG_PUB_S
More information about the llvm-commits
mailing list