From 0e825504295d5dcf8982770990558779fb2117c4 Mon Sep 17 00:00:00 2001 From: Alain Dargelas Date: Thu, 5 Dec 2024 13:29:27 -0800 Subject: [PATCH 1/2] Support for backtrace --- .gitmodules | 3 +++ Makefile | 4 +++- kernel/yosys.cc | 5 ++++- libs/backward-cpp | 1 + 4 files changed, 11 insertions(+), 2 deletions(-) create mode 160000 libs/backward-cpp diff --git a/.gitmodules b/.gitmodules index 9f3cb367a..cbbae7f31 100644 --- a/.gitmodules +++ b/.gitmodules @@ -11,3 +11,6 @@ [submodule "cxxopts"] path = libs/cxxopts url = https://github.com/jarro2783/cxxopts +[submodule "libs/backward-cpp"] + path = libs/backward-cpp + url = git@github.com:bombela/backward-cpp.git diff --git a/Makefile b/Makefile index eb4bae6bb..9a29b40dc 100644 --- a/Makefile +++ b/Makefile @@ -64,7 +64,7 @@ SANITIZER = # SANITIZER = cfi # Prefer using ENABLE_DEBUG over setting these -OPT_LEVEL := -O3 +OPT_LEVEL := -O3 -g GCC_LTO := CLANG_LTO := -flto=thin @@ -438,6 +438,8 @@ LIBS += -ldl endif endif +LIBS += -lbfd # SILIMATE: support for backward-cpp + ifeq ($(ENABLE_GLOB),1) CXXFLAGS += -DYOSYS_ENABLE_GLOB endif diff --git a/kernel/yosys.cc b/kernel/yosys.cc index 437d67ed1..4a9db0f1d 100644 --- a/kernel/yosys.cc +++ b/kernel/yosys.cc @@ -20,6 +20,9 @@ #include "kernel/yosys.h" #include "kernel/celltypes.h" +#define BACKWARD_HAS_BFD 1 +#include "libs/backward-cpp/backward.hpp" + #ifdef YOSYS_ENABLE_READLINE # include # include @@ -548,7 +551,7 @@ void yosys_setup() if(already_setup) return; already_setup = true; - + backward::SignalHandling* sh = new backward::SignalHandling; #ifdef WITH_PYTHON // With Python 3.12, calling PyImport_AppendInittab on an already // initialized platform fails (such as when libyosys is imported diff --git a/libs/backward-cpp b/libs/backward-cpp new file mode 160000 index 000000000..51f070045 --- /dev/null +++ b/libs/backward-cpp @@ -0,0 +1 @@ +Subproject commit 51f0700452cf71c57d43c2d028277b24cde32502 From fbf7734420b16aad42ffaf6b765c6d403676e216 Mon Sep 17 00:00:00 2001 From: Alain Dargelas Date: Thu, 5 Dec 2024 14:30:34 -0800 Subject: [PATCH 2/2] Excluded lbfd from MacOs build --- Makefile | 6 ++++-- kernel/yosys.cc | 1 - 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 9a29b40dc..0474ff924 100644 --- a/Makefile +++ b/Makefile @@ -156,6 +156,10 @@ else LINKFLAGS += -rdynamic ifneq ($(OS), OpenBSD) LIBS += -lrt + +LIBS += -lbfd # SILIMATE: support for backward-cpp +CXXFLAGS += -DBACKWARD_HAS_BFD # SILIMATE: support for backward-cpp + endif endif @@ -438,8 +442,6 @@ LIBS += -ldl endif endif -LIBS += -lbfd # SILIMATE: support for backward-cpp - ifeq ($(ENABLE_GLOB),1) CXXFLAGS += -DYOSYS_ENABLE_GLOB endif diff --git a/kernel/yosys.cc b/kernel/yosys.cc index 4a9db0f1d..097dd3a37 100644 --- a/kernel/yosys.cc +++ b/kernel/yosys.cc @@ -20,7 +20,6 @@ #include "kernel/yosys.h" #include "kernel/celltypes.h" -#define BACKWARD_HAS_BFD 1 #include "libs/backward-cpp/backward.hpp" #ifdef YOSYS_ENABLE_READLINE