From 534163cf4b38f2a235552ee9db5dff8b7a1da3ae Mon Sep 17 00:00:00 2001 From: Krystine Sherwin <93062060+KrystalDelusion@users.noreply.github.com> Date: Mon, 21 Jul 2025 10:34:54 +1200 Subject: [PATCH] source_location: Auto detect library Drop `ENABLE_SOURCE_LOCATION` flag. --- Makefile | 4 ---- kernel/register.h | 12 +++++++++--- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index 314daa05f..2673cff2a 100644 --- a/Makefile +++ b/Makefile @@ -532,10 +532,6 @@ LIBS_VERIFIC += -Wl,--whole-archive $(patsubst %,$(VERIFIC_DIR)/%/*-linux.a,$(VE endif endif -ifeq ($(ENABLE_SOURCE_LOCATION),1) -CXXFLAGS += -DYOSYS_ENABLE_SOURCE_LOCATION -endif - ifeq ($(ENABLE_COVER),1) CXXFLAGS += -DYOSYS_ENABLE_COVER endif diff --git a/kernel/register.h b/kernel/register.h index 82ff98781..07d6f09c1 100644 --- a/kernel/register.h +++ b/kernel/register.h @@ -23,10 +23,15 @@ #include "kernel/yosys_common.h" #include "kernel/yosys.h" -#ifdef YOSYS_ENABLE_SOURCE_LOCATION -#include -using std::experimental::source_location; +#include +#if __cpp_lib_source_location == 201907L + #include + using std::source_location; #else + #include +# ifdef __cpp_lib_experimental_source_location + using std::experimental::source_location; +# else struct source_location { // dummy placeholder int line() const { return 0; } int column() const { return 0; } @@ -34,6 +39,7 @@ struct source_location { // dummy placeholder const char* function_name() const { return "unknown"; } static const source_location current(...) { return source_location(); } }; +# endif #endif YOSYS_NAMESPACE_BEGIN