From 2a5d49ee3b3a94caa4a02ac18009e006deb769d7 Mon Sep 17 00:00:00 2001 From: Sam Stenvall Date: Fri, 28 Jun 2024 09:31:20 +0300 Subject: [PATCH 1/2] Don't build with -O2 unconditionally --- src/Makefile.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Makefile.in b/src/Makefile.in index 6548d1d4b7..c8ca1462c8 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -16,7 +16,7 @@ AXE=@AXE@ DDCI=0 T2MI=0 -CFLAGS?=-Wall -Wno-switch -ggdb -fPIC -fno-common -Warray-bounds -O2 +CFLAGS?=-Wall -Wno-switch -ggdb -fPIC -fno-common -Warray-bounds CFLAGS += -I../src CFLAGS += $(EXTRA_CFLAGS) @CFLAGS@ LDFLAGS += @LDFLAGS@ -lpthread From e490f7a6818ae29894e8d7957f344bf80b4253b4 Mon Sep 17 00:00:00 2001 From: Sam Stenvall Date: Fri, 28 Jun 2024 09:33:59 +0300 Subject: [PATCH 2/2] Make debug builds more usable by only applying -O2 to normal builds Removes some misleading cruft as well. Closes #1108 --- README.md | 6 ++++++ src/Makefile.in | 10 +++++----- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index a7a3e0a3f1..8f19c3ebc0 100644 --- a/README.md +++ b/README.md @@ -301,6 +301,12 @@ make EXTRA_CFLAGS="-DNEEDS_SENDMMSG_SHIM" The above command is useful if you're getting errors like `sendmmsg(): errno 38: Function not implemented` (usually only concerns really old systems). +To make a debug build (useful if minisatip crashes and you want to diagnose the issue): + +```bash +make debug +``` + ## Building a Debian package: ```bash diff --git a/src/Makefile.in b/src/Makefile.in index c8ca1462c8..d0ec12253d 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -134,8 +134,12 @@ SOURCES-$(AXE) += axe.c CFLAGS-$(AXE) += -DAXE CFLAGS-$(EMBEDDED) += -DNO_BACKTRACE -CFLAGS-$(DEBUG) += -fsanitize=address -fno-omit-frame-pointer -fsanitize=leak -fsanitize=undefined -static-libasan -static-libubsan -static-liblsan -fstack-protector-all +ifeq ($(DEBUG),1) +CFLAGS += -fsanitize=address -fno-omit-frame-pointer -fsanitize=leak -fsanitize=undefined -static-libasan -static-libubsan -static-liblsan -fstack-protector-all +else +CFLAGS += -O2 +endif ifeq ($(STATIC),1) LDFLAGS+=$(addsuffix .a,$(addprefix -l:lib,$(LIBS))) @@ -166,10 +170,6 @@ all: $(TARGET) clean: rm -rf $(BUILDDIR) $(TARGET) >> /dev/null -debug: - CFLAGS+=-fsanitize=address -fno-omit-frame-pointer -fsanitize=leak -fsanitize=null - @(MAKE) all - # pull in dependency info for *existing* .o files ifneq "$(MAKECMDGOALS)" "clean" -include $(DEPS)