From 2575f87381ee58d14bfcca47f4ce9bdd8234159a Mon Sep 17 00:00:00 2001 From: Krystine Sherwin <93062060+KrystalDelusion@users.noreply.github.com> Date: Fri, 21 Mar 2025 10:26:11 +1300 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 8a3f19fa8..bbcadf712 100644 --- a/Makefile +++ b/Makefile @@ -519,10 +519,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 9830b1d13..5f5d33cff 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