commit 0a7004d9ad91577a885b3bdc19f05871fc6756d1
parent 2c25f54093c2c023dde69b0bfdd00813d324972d
Author: Ryan Sepassi <rsepassi@gmail.com>
Date: Wed, 27 May 2026 15:53:12 -0700
core: add cfree_debug_getenv weak hook alongside cfree_debug_printf
Diffstat:
2 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/include/cfree/core.h b/include/cfree/core.h
@@ -332,9 +332,10 @@ CFREE_API CfreeSlice cfree_compiler_file_name(CfreeCompiler*, uint32_t file_id);
CFREE_API CfreeSym cfree_sym_intern(CfreeCompiler*, CfreeSlice);
CFREE_API CfreeSlice cfree_sym_str(CfreeCompiler*, CfreeSym);
-/* Optional host-provided debug stream for temporary libcfree instrumentation.
- * libcfree supplies a weak no-op fallback; hosted binaries may override it. */
+/* Optional host-provided debug hooks for temporary libcfree instrumentation.
+ * libcfree supplies weak no-op fallbacks; hosted binaries may override them. */
CFREE_API void cfree_debug_printf(const char* fmt, ...);
+CFREE_API const char* cfree_debug_getenv(const char* name);
CFREE_API CfreeStatus cfree_writer_mem(CfreeHeap*, CfreeWriter** out);
CFREE_API const uint8_t* cfree_writer_mem_bytes(CfreeWriter*, size_t* len_out);
diff --git a/src/core/core.c b/src/core/core.c
@@ -23,6 +23,14 @@ void cfree_debug_printf(const char* fmt, ...) {
(void)fmt;
}
+#if defined(__GNUC__) || defined(__clang__) || defined(__cfree__)
+__attribute__((weak))
+#endif
+const char* cfree_debug_getenv(const char* name) {
+ (void)name;
+ return NULL;
+}
+
SourceManager* source_new(Compiler*);
void source_free(SourceManager*);