summaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
authorBin Meng <bmeng@tinylab.org>2023-02-27 05:35:06 +0300
committerAnup Patel <anup@brainfault.org>2023-03-01 06:53:17 +0300
commit4b28afc98bbe406e3ad6f4a97d0fe96a882e83a1 (patch)
tree6a6b1941a635022a3c3d011cf86bc15a1a7d5540 /Makefile
parent908be1b85c8ff0695ea226fbbf0ff24a779cdece (diff)
downloadopensbi-4b28afc98bbe406e3ad6f4a97d0fe96a882e83a1.tar.xz
make: Add a command line option for debugging OpenSBI
Add a new make command line option "make DEBUG=1" to prevent compiler optimizations using -O2. Signed-off-by: Bin Meng <bmeng@tinylab.org> Reviewed-by: Xiang W <wxjstz@126.com> Reviewed-by: Anup Patel <anup@brainfault.org>
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile7
1 files changed, 6 insertions, 1 deletions
diff --git a/Makefile b/Makefile
index b20404f..a26a39b 100644
--- a/Makefile
+++ b/Makefile
@@ -331,7 +331,12 @@ GENFLAGS += $(libsbiutils-genflags-y)
GENFLAGS += $(platform-genflags-y)
GENFLAGS += $(firmware-genflags-y)
-CFLAGS = -g -Wall -Werror -ffreestanding -nostdlib -fno-stack-protector -fno-strict-aliasing -O2
+CFLAGS = -g -Wall -Werror -ffreestanding -nostdlib -fno-stack-protector -fno-strict-aliasing
+ifneq ($(DEBUG),)
+CFLAGS += -O0
+else
+CFLAGS += -O2
+endif
CFLAGS += -fno-omit-frame-pointer -fno-optimize-sibling-calls -mstrict-align
# enable -m(no-)save-restore option by CC_SUPPORT_SAVE_RESTORE
ifeq ($(CC_SUPPORT_SAVE_RESTORE),y)