From 15072fbde9b7d451aa4fde815d59a7454604036c Mon Sep 17 00:00:00 2001 From: Andrew Clayton Date: Sat, 2 Mar 2024 03:45:00 +0000 Subject: Enable optional 'debuggable' builds One issue you have when trying to debug Unit under say GDB is that at the default optimisation level we use of -O (-O1) the compiler will often optimise things out which means they are not available for inspection in the debugger. This patch allows you to pass 'D=1' to make, e.g $ make D=1 ... Which will set -O0 overriding the previously set -O, basically disabling optimisations, we could use -Og, but the clang(1) man page says this is best and it seems to not cause any issues when debugging GCC generated code. Co-developed-by: Alejandro Colomar Signed-off-by: Alejandro Colomar Signed-off-by: Andrew Clayton --- auto/make | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'auto/make') diff --git a/auto/make b/auto/make index 34335385..1d54ab40 100644 --- a/auto/make +++ b/auto/make @@ -52,6 +52,17 @@ ifeq (\$V,1) v := endif +# Optionally enable debugging builds with +# make D=1 ... +# -g is always used, this just changes the optimisation level. +# On GCC this would be -Og, however according to the clang(1) +# man page, -O0 'generates the most debuggable code'. +D := 0 + +ifeq (\$D,1) + CFLAGS += -O0 +endif + END fi -- cgit