From 4d645a23aa6526d369993ed155e6521830f74a2b Mon Sep 17 00:00:00 2001 From: Karl Fessel Date: Wed, 3 Mar 2021 21:57:09 +0100 Subject: [PATCH 1/6] board/native: add basic debugging compatible optimization adds -Og to board/native CFLAGS --- boards/native/Makefile.include | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/boards/native/Makefile.include b/boards/native/Makefile.include index 10dab68a1d..c391521c27 100644 --- a/boards/native/Makefile.include +++ b/boards/native/Makefile.include @@ -20,8 +20,9 @@ export CGANNOTATE ?= cg_annotate export GPROF ?= gprof # basic cflags: -CFLAGS += -Wall -Wextra -pedantic $(CFLAGS_DBG) +CFLAGS += -Wall -Wextra -pedantic $(CFLAGS_DBG) $(CFLAGS_OPT) CFLAGS_DBG ?= -g3 +CFLAGS_OPT ?= -Og # default std set to gnu11 if not overwritten by user ifeq (,$(filter -std=%, $(CFLAGS))) From cfaa57fe6cd63952290e956beb1e4d58e7fd60f5 Mon Sep 17 00:00:00 2001 From: Karl Fessel Date: Thu, 11 Mar 2021 15:44:10 +0100 Subject: [PATCH 2/6] board/native: no omit frame pointer if backtrace is used this makes riots test work but may have different result than O0 see man 3 backtrace #NOTES --- boards/native/Makefile.include | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/boards/native/Makefile.include b/boards/native/Makefile.include index c391521c27..cad532db2f 100644 --- a/boards/native/Makefile.include +++ b/boards/native/Makefile.include @@ -22,7 +22,12 @@ export GPROF ?= gprof # basic cflags: CFLAGS += -Wall -Wextra -pedantic $(CFLAGS_DBG) $(CFLAGS_OPT) CFLAGS_DBG ?= -g3 -CFLAGS_OPT ?= -Og +ifneq (,$(filter backtrace,$(USEMODULE))) + $(warning module backtrace is used, do not omit frame pointers) + CFLAGS_OPT ?= -Og -fno-omit-frame-pointer +else + CFLAGS_OPT ?= -Og +endif # default std set to gnu11 if not overwritten by user ifeq (,$(filter -std=%, $(CFLAGS))) From 2bd2384bc051ad6adf42215505cd6834275cffec Mon Sep 17 00:00:00 2001 From: Karl Fessel Date: Fri, 12 Mar 2021 13:13:32 +0100 Subject: [PATCH 3/6] examples/filesystem: posix open needs mode if O_CREATE umask is applied to mode (mode & ~umask) -> 00777 is a good default see: man 2 open --- examples/filesystem/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/filesystem/main.c b/examples/filesystem/main.c index 759d61c4ab..add2dda4ec 100644 --- a/examples/filesystem/main.c +++ b/examples/filesystem/main.c @@ -287,7 +287,7 @@ static int _tee(int argc, char **argv) } fclose(f); #else - int fd = open(argv[1], O_RDWR | O_CREAT); + int fd = open(argv[1], O_RDWR | O_CREAT, 00777); if (fd < 0) { printf("error while trying to create %s\n", argv[1]); return 1; From a6bf4444894bc507a37f531bbdfa3a2d48e01c95 Mon Sep 17 00:00:00 2001 From: Karl Fessel Date: Fri, 12 Mar 2021 18:23:13 +0100 Subject: [PATCH 4/6] board/native: undefine FORTIFY_SOURCE to avoid printf replace printf may be replaced by libc printf_chk if _FORTIFY_SOURCE is defiend. This undefines it --- boards/native/Makefile.include | 2 ++ 1 file changed, 2 insertions(+) diff --git a/boards/native/Makefile.include b/boards/native/Makefile.include index cad532db2f..48474fb055 100644 --- a/boards/native/Makefile.include +++ b/boards/native/Makefile.include @@ -21,7 +21,9 @@ export GPROF ?= gprof # basic cflags: CFLAGS += -Wall -Wextra -pedantic $(CFLAGS_DBG) $(CFLAGS_OPT) +CFLAGS += -U_FORTIFY_SOURCE CFLAGS_DBG ?= -g3 + ifneq (,$(filter backtrace,$(USEMODULE))) $(warning module backtrace is used, do not omit frame pointers) CFLAGS_OPT ?= -Og -fno-omit-frame-pointer From 21ce589bec56d816eee0f96902c9c24aa29b9d2e Mon Sep 17 00:00:00 2001 From: Karl Fessel Date: Fri, 12 Mar 2021 19:34:13 +0100 Subject: [PATCH 5/6] unittests/tests-ieee802154: remove stack_smasher from unitest test_ieee802154_set_frame_hdr_flags0_non_beacon_non_ack buffer given to ieee802154_set_frame_hdr has to be at least 2 bytes see /sys/net/link_layer/ieee802154/ieee802154.c l32 --- tests/unittests/tests-ieee802154/tests-ieee802154.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/unittests/tests-ieee802154/tests-ieee802154.c b/tests/unittests/tests-ieee802154/tests-ieee802154.c index b966cb8ad1..ee202466a5 100644 --- a/tests/unittests/tests-ieee802154/tests-ieee802154.c +++ b/tests/unittests/tests-ieee802154/tests-ieee802154.c @@ -44,10 +44,10 @@ static void test_ieee802154_set_frame_hdr_flags0_non_beacon_non_ack(void) const le_uint16_t src_pan = byteorder_htols(0); const le_uint16_t dst_pan = byteorder_htols(0); const uint8_t flags = IEEE802154_FCF_TYPE_DATA; - uint8_t res; + uint8_t res[2]; TEST_ASSERT_EQUAL_INT(0, - ieee802154_set_frame_hdr(&res, NULL, 0, + ieee802154_set_frame_hdr(res, NULL, 0, NULL, 0, src_pan, dst_pan, flags, TEST_UINT8)); From 6588db65805c01c8ceb8d6c7cddb41602b30d1f7 Mon Sep 17 00:00:00 2001 From: Karl Fessel Date: Sat, 13 Mar 2021 16:00:02 +0100 Subject: [PATCH 6/6] pkg/qcbor,wakaama,wolfssl: remove maybe-uninitialized warning some variable seem uninitialized to gcc with -Og but aren't https://gcc.gnu.org/bugzilla/buglist.cgi?quicksearch=may%20be%20used%20uninitialized https://gcc.gnu.org/bugzilla/show_bug.cgi?id=42145 especialy: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90710#c1 --- pkg/qcbor/Makefile | 6 ++++++ pkg/wakaama/Makefile | 6 ++++++ pkg/wolfssl/Makefile | 6 ++++++ 3 files changed, 18 insertions(+) diff --git a/pkg/qcbor/Makefile b/pkg/qcbor/Makefile index a995413d6a..41f7bf5817 100644 --- a/pkg/qcbor/Makefile +++ b/pkg/qcbor/Makefile @@ -5,5 +5,11 @@ PKG_LICENSE = BSD-3-Clause include $(RIOTBASE)/pkg/pkg.mk +# some variable seem uninitialized to gcc with -Og but are not +# https://gcc.gnu.org/bugzilla/buglist.cgi?quicksearch=may%20be%20used%20uninitialized +# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=42145 +# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90710#c1 +CFLAGS += -Wno-maybe-uninitialized + all: "$(MAKE)" -C $(PKG_SOURCE_DIR)/src -f $(RIOTBASE)/Makefile.base MODULE=$(PKG_NAME) diff --git a/pkg/wakaama/Makefile b/pkg/wakaama/Makefile index 0238324760..5cea8c9bae 100644 --- a/pkg/wakaama/Makefile +++ b/pkg/wakaama/Makefile @@ -5,6 +5,12 @@ PKG_LICENSE=EDL-1.0,EPL-1.0 include $(RIOTBASE)/pkg/pkg.mk +# some variable seem uninitialized to gcc with -Og but are not +# https://gcc.gnu.org/bugzilla/buglist.cgi?quicksearch=may%20be%20used%20uninitialized +# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=42145 +# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90710#c1 +CFLAGS += -Wno-maybe-uninitialized + all: "$(MAKE)" -C $(PKG_SOURCE_DIR)/core -f $(RIOTBASE)/Makefile.base MODULE=wakaama_core "$(MAKE)" -C $(PKG_SOURCE_DIR)/core/er-coap-13 -f $(RIOTBASE)/Makefile.base MODULE=wakaama_core_coap13 diff --git a/pkg/wolfssl/Makefile b/pkg/wolfssl/Makefile index 109e9de4b4..4e57baab62 100644 --- a/pkg/wolfssl/Makefile +++ b/pkg/wolfssl/Makefile @@ -5,6 +5,12 @@ PKG_LICENSE=GPLv2 include $(RIOTBASE)/pkg/pkg.mk +# some variable seem uninitialized to gcc with -Og but are not +# https://gcc.gnu.org/bugzilla/buglist.cgi?quicksearch=may%20be%20used%20uninitialized +# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=42145 +# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90710#c1 +CFLAGS += -Wno-maybe-uninitialized + .PHONY: wolfcrypt% all: $(filter wolfcrypt wolfcrypt-test wolfcrypt-benchmark,$(USEMODULE))