From 0c2cfe99e6984bfa03b31a1692db65686ca1e11e Mon Sep 17 00:00:00 2001 From: Frederik Haxel Date: Fri, 2 Feb 2024 15:41:31 +0100 Subject: [PATCH] native64: Add Linux/x86_64 board Adds a separate board for native64 instead of the `NATIVE_64BIT` workaround. The files in `boards/native64` are more or less dummy files and just include the `boards/native` logic (similar to `openlabs-kw41z-mini-256kib`). The main logic for native is in `makefiles/arch/native.inc.mk`, `cpu/native` and `boards/native`. The remaining changes concern the build system, and change native board checks to native CPU checks to cover both boards. --- Makefile.include | 2 +- boards/native/Makefile.features | 14 +- boards/native/Makefile.include | 177 ------------------ boards/native/common_features.inc.mk | 12 ++ boards/native/doc.txt | 2 - boards/native64/Kconfig | 30 +++ boards/native64/Makefile | 3 + boards/native64/Makefile.dep | 1 + boards/native64/Makefile.features | 6 + boards/native64/Makefile.include | 1 + boards/native64/doc.txt | 13 ++ core/include/native_sched.h | 4 +- cpu/native/Kconfig | 4 +- cpu/native/Makefile.features | 7 +- cpu/native/Makefile.include | 4 +- cpu/native/include/cpu_conf.h | 4 + cpu/native/irq_cpu.c | 4 +- makefiles/arch/native.inc.mk | 164 ++++++++++++++++ makefiles/ubsan.inc.mk | 2 +- pkg/flashdb/Makefile.dep | 2 +- pkg/jerryscript/Makefile | 4 +- pkg/libsocketcan/Kconfig | 4 +- pkg/tlsf/Kconfig | 4 +- pkg/tlsf/Makefile.dep | 2 +- .../patches/0002-fix-mbed-specific-code.patch | Bin 1281 -> 1277 bytes pkg/wolfssl/Makefile.wolfcrypt | 2 +- sys/Makefile.include | 2 +- sys/vfs/Makefile.dep | 2 +- 28 files changed, 260 insertions(+), 216 deletions(-) create mode 100644 boards/native/common_features.inc.mk create mode 100644 boards/native64/Kconfig create mode 100644 boards/native64/Makefile create mode 100644 boards/native64/Makefile.dep create mode 100644 boards/native64/Makefile.features create mode 100644 boards/native64/Makefile.include create mode 100644 boards/native64/doc.txt create mode 100644 makefiles/arch/native.inc.mk diff --git a/Makefile.include b/Makefile.include index c88f2baeb8..9b054e367d 100644 --- a/Makefile.include +++ b/Makefile.include @@ -204,7 +204,7 @@ include $(RIOTMAKE)/boards.inc.mk include $(RIOTMAKE)/dependencies_debug.inc.mk # Use TOOLCHAIN environment variable to select the toolchain to use. -ifeq ($(BOARD),native) +ifneq (,$(filter native native64,$(BOARD))) ifeq ($(OS),Darwin) $(shell $(COLOR_ECHO) "$(COLOR_RED)"Buildin on macOS is not supported."\ "We recommend vagrant for building:$(COLOR_RESET)"\ diff --git a/boards/native/Makefile.features b/boards/native/Makefile.features index c3242a2fc2..a7fbc80d14 100644 --- a/boards/native/Makefile.features +++ b/boards/native/Makefile.features @@ -1,14 +1,6 @@ CPU = native -# Put defined MCU peripherals here (in alphabetical order) -FEATURES_PROVIDED += periph_rtc -FEATURES_PROVIDED += periph_rtc_ms -FEATURES_PROVIDED += periph_timer -FEATURES_PROVIDED += periph_uart -FEATURES_PROVIDED += periph_gpio -FEATURES_PROVIDED += periph_pwm -FEATURES_PROVIDED += periph_qdec +FEATURES_PROVIDED += arch_32bit +NATIVE_ARCH_BIT = 32 -# Various other features (if any) -FEATURES_PROVIDED += ethernet -FEATURES_PROVIDED += motor_driver +include $(RIOTBOARD)/native/common_features.inc.mk diff --git a/boards/native/Makefile.include b/boards/native/Makefile.include index f25d47ab2d..d0f8eee0dc 100644 --- a/boards/native/Makefile.include +++ b/boards/native/Makefile.include @@ -1,17 +1,4 @@ -NATIVEINCLUDES += -DNATIVE_INCLUDES NATIVEINCLUDES += -I$(RIOTBOARD)/native/include/ -NATIVEINCLUDES += -I$(RIOTBASE)/core/lib/include/ -NATIVEINCLUDES += -I$(RIOTBASE)/core/include/ -NATIVEINCLUDES += -I$(RIOTBASE)/drivers/include/ - -# Set "NATIVE_64BIT=1" to compile for x86_64 -NATIVE_64BIT ?= 0 - -ifeq ($(OS),Darwin) - DEBUGGER ?= lldb -else - DEBUGGER ?= gdb -endif # only use pyterm wrapper if term target is requested ifeq (,$(filter term,$(MAKECMDGOALS))) @@ -48,93 +35,6 @@ else endif endif -export VALGRIND ?= valgrind -export CGANNOTATE ?= cg_annotate -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 -else - CFLAGS_OPT ?= -Og -endif - -# default std set to gnu11 if not overwritten by user -ifeq (,$(filter -std=%, $(CFLAGS))) - CFLAGS += -std=gnu11 -endif - -ifeq ($(OS_ARCH),x86_64) - ifeq ($(NATIVE_64BIT), 1) - CFLAGS += -m64 - else - CFLAGS += -m32 - endif -endif -ifneq (,$(filter -DDEVELHELP,$(CFLAGS))) - CFLAGS += -fstack-protector-all -endif -ifeq ($(OS),FreeBSD) - ifeq ($(OS_ARCH),amd64) - ifeq ($(NATIVE_64BIT), 1) - CFLAGS += -m64 - else - CFLAGS += -m32 -DCOMPAT_32BIT -B/usr/lib32 - endif - endif -endif -ifeq ($(OS),Darwin) - CFLAGS += -Wno-deprecated-declarations -endif - -# unwanted (CXXUWFLAGS) and extra (CXXEXFLAGS) flags for c++ -CXXUWFLAGS += -CXXEXFLAGS += - -ifeq ($(OS_ARCH),x86_64) - ifeq ($(NATIVE_64BIT), 1) - LINKFLAGS += -m64 - else - LINKFLAGS += -m32 - endif -endif -ifeq ($(OS),FreeBSD) - ifeq ($(OS_ARCH),amd64) - ifeq ($(NATIVE_64BIT), 1) - LINKFLAGS += -m64 - else - LINKFLAGS += -m32 -DCOMPAT_32BIT -L/usr/lib32 -B/usr/lib32 - endif - endif - LINKFLAGS += -L $(BINDIR) -else - LINKFLAGS += -ldl -endif - -# XFA (cross file array) support -LINKFLAGS += -T$(RIOTBASE)/cpu/native/ldscripts/xfa.ld - -# fix this warning: -# ``` -# /usr/bin/ld: examples/hello-world/bin/native/cpu/tramp.o: warning: relocation against `_native_saved_eip' in read-only section `.text' -# /usr/bin/ld: warning: creating DT_TEXTREL in a PIE -# ``` -LINKFLAGS += -no-pie - -# clean up unused functions -CFLAGS += -ffunction-sections -fdata-sections -ifeq ($(OS),Darwin) - LINKFLAGS += -Wl,-dead_strip -else - LINKFLAGS += -Wl,--gc-sections -endif -LINKFLAGS += -ffunction-sections - # set the tap interface for term/valgrind PORT ?= tap0 TERMFLAGS += $(PROCARGS) $(PORT) @@ -160,80 +60,3 @@ ifneq (,$(filter periph_can,$(FEATURES_USED))) PERIPH_CAN_FLAGS ?= --can $(VCAN_IFACE) TERMFLAGS += $(PERIPH_CAN_FLAGS) endif - - -ASFLAGS = -ifeq ($(shell basename $(DEBUGGER)),lldb) - DEBUGGER_FLAGS = -- $(ELFFILE) $(TERMFLAGS) -else - DEBUGGER_FLAGS = -q --args $(ELFFILE) $(TERMFLAGS) -endif -term-valgrind: export VALGRIND_FLAGS ?= \ - --leak-check=full \ - --track-origins=yes \ - --fullpath-after=$(RIOTBASE)/ \ - --read-var-info=yes -debug-valgrind-server: export VALGRIND_FLAGS ?= --vgdb=yes --vgdb-error=0 -v \ - --leak-check=full --track-origins=yes --fullpath-after=$(RIOTBASE) \ - --read-var-info=yes -term-cachegrind: export CACHEGRIND_FLAGS += --tool=cachegrind -term-gprof: TERMPROG = GMON_OUT_PREFIX=gmon.out $(ELFFILE) -all-valgrind: CFLAGS += -DHAVE_VALGRIND_H -all-valgrind: NATIVEINCLUDES += $(shell pkg-config valgrind --cflags) -all-gprof: CFLAGS += -pg -all-gprof: LINKFLAGS += -pg - -CFLAGS_ASAN += -fsanitize=address -fno-omit-frame-pointer -DNATIVE_MEMORY -LINKFLAGS_ASAN += -fsanitize=address -fno-omit-frame-pointer -all-asan: CFLAGS += $(CFLAGS_ASAN) -all-asan: LINKFLAGS += $(LINKFLAGS_ASAN) -all-asan: export AFL_USE_ASAN=1 - -INCLUDES += $(NATIVEINCLUDES) - -CFLAGS += -DDEBUG_ASSERT_VERBOSE - -# workaround for https://gcc.gnu.org/bugzilla/show_bug.cgi?id=52624 -ifneq ($(shell gcc --version | head -1 | grep -E ' (4.6|4.7)'),) - CFLAGS += -DHAVE_NO_BUILTIN_BSWAP16 -endif - -# clumsy way to enable building native on osx: -BUILDOSXNATIVE = 0 -ifeq ($(CPU),native) - ifeq ($(OS),Darwin) - BUILDOSXNATIVE = 1 - endif -endif - -all: # do not override first target - -all-gprof: all - -all-asan: all - -all-valgrind: all - -all-cachegrind: all - -term-valgrind: - $(VALGRIND) $(VALGRIND_FLAGS) $(ELFFILE) $(PORT) - -debug-valgrind-server: - $(VALGRIND) $(VALGRIND_FLAGS) $(ELFFILE) $(PORT) - -debug-valgrind: - $(eval VALGRIND_PID ?= $(shell pgrep -n memcheck-x86-li -u $(USER) | cut -d" " -f1)) - $(eval DEBUGGER_FLAGS := -ex "target remote | vgdb --pid=$(VALGRIND_PID)" $(DEBUGGER_FLAGS)) - $(DEBUGGER) $(DEBUGGER_FLAGS) - -term-cachegrind: - $(VALGRIND) $(CACHEGRIND_FLAGS) $(ELFFILE) $(PORT) - -term-gprof: term - -eval-gprof: - $(GPROF) $(ELFFILE) $(shell ls -rt gmon.out* | tail -1) - -eval-cachegrind: - $(CGANNOTATE) $(shell ls -rt cachegrind.out* | tail -1) diff --git a/boards/native/common_features.inc.mk b/boards/native/common_features.inc.mk new file mode 100644 index 0000000000..cbebc11020 --- /dev/null +++ b/boards/native/common_features.inc.mk @@ -0,0 +1,12 @@ +# Put defined MCU peripherals here (in alphabetical order) +FEATURES_PROVIDED += periph_rtc +FEATURES_PROVIDED += periph_rtc_ms +FEATURES_PROVIDED += periph_timer +FEATURES_PROVIDED += periph_uart +FEATURES_PROVIDED += periph_gpio +FEATURES_PROVIDED += periph_pwm +FEATURES_PROVIDED += periph_qdec + +# Various other features (if any) +FEATURES_PROVIDED += ethernet +FEATURES_PROVIDED += motor_driver diff --git a/boards/native/doc.txt b/boards/native/doc.txt index 7c77d09df3..0835128531 100644 --- a/boards/native/doc.txt +++ b/boards/native/doc.txt @@ -25,8 +25,6 @@ # Required packages -The `native` version of RIOT will produce a 32 bit binary by default. -To compile for x86_64 set the environment variable `NATIVE_64BIT=1`. On Debian/Ubuntu you can install the required libraries with ``` diff --git a/boards/native64/Kconfig b/boards/native64/Kconfig new file mode 100644 index 0000000000..a336e5903d --- /dev/null +++ b/boards/native64/Kconfig @@ -0,0 +1,30 @@ +# Copyright (c) 2020 HAW Hamburg +# +# This file is subject to the terms and conditions of the GNU Lesser +# General Public License v2.1. See the file LICENSE in the top level +# directory for more details. +# + +config BOARD + default "native64" if BOARD_NATIVE64 + +config BOARD_NATIVE64 + bool + default y + select CPU_MODEL_NATIVE + + # Put defined MCU peripherals here (in alphabetical order) + select HAS_PERIPH_RTC + select HAS_PERIPH_RTC_MS + select HAS_PERIPH_TIMER + select HAS_PERIPH_UART + select HAS_PERIPH_GPIO + select HAS_PERIPH_PWM + select HAS_PERIPH_QDEC + + # Various other features (if any) + select HAS_ETHERNET + select HAS_MOTOR_DRIVER + select HAVE_SDL + +rsource "../native/drivers/Kconfig" diff --git a/boards/native64/Makefile b/boards/native64/Makefile new file mode 100644 index 0000000000..23014a2c68 --- /dev/null +++ b/boards/native64/Makefile @@ -0,0 +1,3 @@ +DIRS = $(RIOTBOARD)/native + +include $(RIOTBASE)/Makefile.base diff --git a/boards/native64/Makefile.dep b/boards/native64/Makefile.dep new file mode 100644 index 0000000000..2494d8582b --- /dev/null +++ b/boards/native64/Makefile.dep @@ -0,0 +1 @@ +include $(RIOTBOARD)/native/Makefile.dep diff --git a/boards/native64/Makefile.features b/boards/native64/Makefile.features new file mode 100644 index 0000000000..ef67048084 --- /dev/null +++ b/boards/native64/Makefile.features @@ -0,0 +1,6 @@ +CPU = native + +FEATURES_PROVIDED += arch_64bit +NATIVE_ARCH_BIT = 64 + +include $(RIOTBOARD)/native/common_features.inc.mk diff --git a/boards/native64/Makefile.include b/boards/native64/Makefile.include new file mode 100644 index 0000000000..f7327bc5c6 --- /dev/null +++ b/boards/native64/Makefile.include @@ -0,0 +1 @@ +include $(RIOTBOARD)/native/Makefile.include diff --git a/boards/native64/doc.txt b/boards/native64/doc.txt new file mode 100644 index 0000000000..92ac1758ae --- /dev/null +++ b/boards/native64/doc.txt @@ -0,0 +1,13 @@ +/** +@defgroup boards_native64 Native64 Board +@ingroup boards +@brief Support for running RIOT in native64 + +[Family: native](https://github.com/RIOT-OS/RIOT/wiki/Family:-native) + +Same board as \ref boards_native "native", but compiled for 64-bit instead of 32-bit. +Currently only Linux x86-64 is supported, and Rust support is missing. +Otherwise, everything works the same as for the 32-bit version. +For more information on this board, see the \ref boards_native "native board" documentation. + + */ diff --git a/core/include/native_sched.h b/core/include/native_sched.h index c1b69e82eb..573b97095b 100644 --- a/core/include/native_sched.h +++ b/core/include/native_sched.h @@ -27,7 +27,7 @@ extern "C" { #endif -#ifdef BOARD_NATIVE +#ifdef CPU_NATIVE #include /* @@ -56,7 +56,7 @@ inline int sched_yield(void) * thread_arch.c. */ extern int sched_yield(void); -#endif /* BOARD_NATIVE */ +#endif /* CPU_NATIVE */ #ifdef __cplusplus } diff --git a/cpu/native/Kconfig b/cpu/native/Kconfig index bcc7b3f3ce..d1d8ac77f2 100644 --- a/cpu/native/Kconfig +++ b/cpu/native/Kconfig @@ -7,8 +7,8 @@ config CPU_ARCH_NATIVE bool - select HAS_ARCH_32BIT if "$(NATIVE_64BIT)" != "1" - select HAS_ARCH_64BIT if "$(NATIVE_64BIT)" = "1" + select HAS_ARCH_32BIT if BOARD_NATIVE + select HAS_ARCH_64BIT if BOARD_NATIVE64 select HAS_ARCH_NATIVE select HAS_CPP select HAS_CPU_NATIVE diff --git a/cpu/native/Makefile.features b/cpu/native/Makefile.features index f8b687c35e..2fdde8697a 100644 --- a/cpu/native/Makefile.features +++ b/cpu/native/Makefile.features @@ -2,11 +2,6 @@ ifeq (FreeBSD,$(OS)) DISABLE_LIBSTDCPP ?= 1 endif -ifeq ($(NATIVE_64BIT), 1) - FEATURES_PROVIDED += arch_64bit -else - FEATURES_PROVIDED += arch_32bit -endif FEATURES_PROVIDED += arch_native FEATURES_PROVIDED += cpp ifneq ($(DISABLE_LIBSTDCPP),1) @@ -25,7 +20,7 @@ FEATURES_PROVIDED += periph_timer_periodic FEATURES_PROVIDED += periph_timer_query_freqs ifeq ($(OS) $(OS_ARCH),Linux x86_64) # TODO: Add rust support for native 64 bit. - ifneq ($(NATIVE_64BIT), 1) + ifneq ($(BOARD),native64) FEATURES_PROVIDED += rust_target endif endif diff --git a/cpu/native/Makefile.include b/cpu/native/Makefile.include index c664b9cb15..63b2fa3a9a 100644 --- a/cpu/native/Makefile.include +++ b/cpu/native/Makefile.include @@ -1,4 +1,4 @@ -NATIVEINCLUDES += -I$(RIOTCPU)/native/include -I$(RIOTBASE)/sys/include +NATIVEINCLUDES += -I$(RIOTCPU)/native/include/ ifneq (,$(filter periph_can,$(USEMODULE))) ifeq (,$(filter libsocketcan,$(USEPKG))) @@ -17,3 +17,5 @@ ifeq ($(OS) $(OS_ARCH),Linux x86_64) RUST_TARGET = x86_64-unknown-linux-gnu endif endif + +include $(RIOTMAKE)/arch/native.inc.mk diff --git a/cpu/native/include/cpu_conf.h b/cpu/native/include/cpu_conf.h index e002f586b1..88d37cbb94 100644 --- a/cpu/native/include/cpu_conf.h +++ b/cpu/native/include/cpu_conf.h @@ -28,8 +28,12 @@ extern "C" { * @{ */ #ifndef THREAD_STACKSIZE_DEFAULT +#if (__SIZEOF_POINTER__ == 8) +#define THREAD_STACKSIZE_DEFAULT (16384) +#else #define THREAD_STACKSIZE_DEFAULT (8192) #endif +#endif #ifndef THREAD_STACKSIZE_IDLE #define THREAD_STACKSIZE_IDLE (THREAD_STACKSIZE_DEFAULT) #endif diff --git a/cpu/native/irq_cpu.c b/cpu/native/irq_cpu.c index 165a6eeb6b..030819c07b 100644 --- a/cpu/native/irq_cpu.c +++ b/cpu/native/irq_cpu.c @@ -49,7 +49,7 @@ volatile int _native_in_syscall; static sigset_t _native_sig_set, _native_sig_set_dint; -char __isr_stack[SIGSTKSZ]; +char __isr_stack[THREAD_STACKSIZE_DEFAULT]; ucontext_t native_isr_context; ucontext_t *_native_cur_ctx, *_native_isr_ctx; @@ -524,7 +524,7 @@ void native_interrupt_init(void) static stack_t sigstk; sigstk.ss_sp = sigalt_stk; - sigstk.ss_size = sizeof(__isr_stack); + sigstk.ss_size = sizeof(sigalt_stk); sigstk.ss_flags = 0; if (sigaltstack(&sigstk, NULL) < 0) { diff --git a/makefiles/arch/native.inc.mk b/makefiles/arch/native.inc.mk new file mode 100644 index 0000000000..78cbdbb3f2 --- /dev/null +++ b/makefiles/arch/native.inc.mk @@ -0,0 +1,164 @@ +NATIVEINCLUDES += -DNATIVE_INCLUDES +NATIVEINCLUDES += -I$(RIOTBASE)/core/lib/include/ +NATIVEINCLUDES += -I$(RIOTBASE)/core/include/ +NATIVEINCLUDES += -I$(RIOTBASE)/sys/include/ +NATIVEINCLUDES += -I$(RIOTBASE)/drivers/include/ + +ifeq ($(OS),Darwin) + DEBUGGER ?= lldb +else + DEBUGGER ?= gdb +endif + + +export VALGRIND ?= valgrind +export CGANNOTATE ?= cg_annotate +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 +else + CFLAGS_OPT ?= -Og +endif + +# default std set to gnu11 if not overwritten by user +ifeq (,$(filter -std=%, $(CFLAGS))) + CFLAGS += -std=gnu11 +endif + +ifeq ($(NATIVE_ARCH_BIT),64) + CFLAGS += -m64 + LINKFLAGS += -m64 +else ifeq ($(NATIVE_ARCH_BIT),32) + CFLAGS += -m32 + LINKFLAGS += -m32 +else + $(error Unsupported native architecture) +endif + +ifneq (,$(filter -DDEVELHELP,$(CFLAGS))) + CFLAGS += -fstack-protector-all +endif +ifeq ($(OS),FreeBSD) + ifeq ($(OS_ARCH),amd64) + ifeq ($(NATIVE_ARCH_BIT),32) + CFLAGS += -DCOMPAT_32BIT -B/usr/lib32 + LINKFLAGS += -DCOMPAT_32BIT -L/usr/lib32 -B/usr/lib32 + endif + endif +endif +ifeq ($(OS),Darwin) + CFLAGS += -Wno-deprecated-declarations +endif + +# unwanted (CXXUWFLAGS) and extra (CXXEXFLAGS) flags for c++ +CXXUWFLAGS += +CXXEXFLAGS += + +ifeq ($(OS),FreeBSD) + LINKFLAGS += -L $(BINDIR) +else + LINKFLAGS += -ldl +endif + +# XFA (cross file array) support +LINKFLAGS += -T$(RIOTBASE)/cpu/native/ldscripts/xfa.ld + +# fix this warning: +# ``` +# /usr/bin/ld: examples/hello-world/bin/native/cpu/tramp.o: warning: relocation against `_native_saved_eip' in read-only section `.text' +# /usr/bin/ld: warning: creating DT_TEXTREL in a PIE +# ``` +LINKFLAGS += -no-pie + +# clean up unused functions +CFLAGS += -ffunction-sections -fdata-sections +ifeq ($(OS),Darwin) + LINKFLAGS += -Wl,-dead_strip +else + LINKFLAGS += -Wl,--gc-sections +endif +LINKFLAGS += -ffunction-sections + + +ASFLAGS = +ifeq ($(shell basename $(DEBUGGER)),lldb) + DEBUGGER_FLAGS = -- $(ELFFILE) $(TERMFLAGS) +else + DEBUGGER_FLAGS = -q --args $(ELFFILE) $(TERMFLAGS) +endif +term-valgrind: export VALGRIND_FLAGS ?= \ + --leak-check=full \ + --track-origins=yes \ + --fullpath-after=$(RIOTBASE)/ \ + --read-var-info=yes +debug-valgrind-server: export VALGRIND_FLAGS ?= --vgdb=yes --vgdb-error=0 -v \ + --leak-check=full --track-origins=yes --fullpath-after=$(RIOTBASE) \ + --read-var-info=yes +term-cachegrind: export CACHEGRIND_FLAGS += --tool=cachegrind +term-gprof: TERMPROG = GMON_OUT_PREFIX=gmon.out $(ELFFILE) +all-valgrind: CFLAGS += -DHAVE_VALGRIND_H +all-valgrind: NATIVEINCLUDES += $(shell pkg-config valgrind --cflags) +all-gprof: CFLAGS += -pg +all-gprof: LINKFLAGS += -pg + +CFLAGS_ASAN += -fsanitize=address -fno-omit-frame-pointer -DNATIVE_MEMORY +LINKFLAGS_ASAN += -fsanitize=address -fno-omit-frame-pointer +all-asan: CFLAGS += $(CFLAGS_ASAN) +all-asan: LINKFLAGS += $(LINKFLAGS_ASAN) +all-asan: export AFL_USE_ASAN=1 + +INCLUDES += $(NATIVEINCLUDES) + +CFLAGS += -DDEBUG_ASSERT_VERBOSE + +# workaround for https://gcc.gnu.org/bugzilla/show_bug.cgi?id=52624 +ifneq ($(shell gcc --version | head -1 | grep -E ' (4.6|4.7)'),) + CFLAGS += -DHAVE_NO_BUILTIN_BSWAP16 +endif + +# clumsy way to enable building native on osx: +BUILDOSXNATIVE = 0 +ifeq ($(CPU),native) + ifeq ($(OS),Darwin) + BUILDOSXNATIVE = 1 + endif +endif + +all: # do not override first target + +all-gprof: all + +all-asan: all + +all-valgrind: all + +all-cachegrind: all + +term-valgrind: + $(VALGRIND) $(VALGRIND_FLAGS) $(ELFFILE) $(PORT) + +debug-valgrind-server: + $(VALGRIND) $(VALGRIND_FLAGS) $(ELFFILE) $(PORT) + +debug-valgrind: + $(eval VALGRIND_PID ?= $(shell pgrep -n memcheck-x86-li -u $(USER) | cut -d" " -f1)) + $(eval DEBUGGER_FLAGS := -ex "target remote | vgdb --pid=$(VALGRIND_PID)" $(DEBUGGER_FLAGS)) + $(DEBUGGER) $(DEBUGGER_FLAGS) + +term-cachegrind: + $(VALGRIND) $(CACHEGRIND_FLAGS) $(ELFFILE) $(PORT) + +term-gprof: term + +eval-gprof: + $(GPROF) $(ELFFILE) $(shell ls -rt gmon.out* | tail -1) + +eval-cachegrind: + $(CGANNOTATE) $(shell ls -rt cachegrind.out* | tail -1) diff --git a/makefiles/ubsan.inc.mk b/makefiles/ubsan.inc.mk index ff2cdbc980..53850d6531 100644 --- a/makefiles/ubsan.inc.mk +++ b/makefiles/ubsan.inc.mk @@ -11,7 +11,7 @@ UBSAN_MODE ?= msg_exit CFLAGS_UBSAN = -fsanitize=undefined ifeq (gnu,$(TOOLCHAIN)) - ifeq (native,$(BOARD)) + ifeq (native,$(CPU)) ifneq (,$(filter msg_%,$(UBSAN_MODE))) LINKFLAGS_UBSAN += -lubsan ifneq (msg_recover,$(UBSAN_MODE)) diff --git a/pkg/flashdb/Makefile.dep b/pkg/flashdb/Makefile.dep index e85e9b7ac8..d5b99a416e 100644 --- a/pkg/flashdb/Makefile.dep +++ b/pkg/flashdb/Makefile.dep @@ -24,7 +24,7 @@ ifneq (,$(filter flashdb_mtd,$(USEMODULE))) USEMODULE += flashdb_fal USEMODULE += mtd else - ifeq (native, $(BOARD)) + ifeq ($(CPU),native) CFLAGS += -DFDB_USING_FILE_POSIX_MODE else CFLAGS += -DFDB_USING_FILE_LIBC_MODE diff --git a/pkg/jerryscript/Makefile b/pkg/jerryscript/Makefile index a8afa8d787..e1a968ad02 100644 --- a/pkg/jerryscript/Makefile +++ b/pkg/jerryscript/Makefile @@ -16,10 +16,10 @@ EXT_CFLAGS := -D__TARGET_RIOT CFLAGS += -Wno-cast-align # disable warnings when compiling with LLVM for board native -ifeq ($(TOOLCHAIN)_$(BOARD),llvm_native) +ifeq ($(TOOLCHAIN)_$(CPU),llvm_native) CFLAGS += -Wno-macro-redefined -Wno-gnu-folding-constant EXT_CFLAGS += -Wno-conversion -else ifeq ($(OS)_$(BOARD),FreeBSD_native) +else ifeq ($(OS)_$(CPU),FreeBSD_native) EXT_CFLAGS += -Wno-conversion else ifeq (esp32,$(CPU)) # The ESP-IDF uses #include_next that causes errors when compiling with warnings diff --git a/pkg/libsocketcan/Kconfig b/pkg/libsocketcan/Kconfig index a5751cda0a..4b1d996ba5 100644 --- a/pkg/libsocketcan/Kconfig +++ b/pkg/libsocketcan/Kconfig @@ -6,5 +6,5 @@ # config PACKAGE_LIBSOCKETCAN - bool "libsocketcan2 32bit for native Linux builds" - depends on BOARD_NATIVE + bool "libsocketcan2 for native Linux builds" + depends on HAS_ARCH_NATIVE diff --git a/pkg/tlsf/Kconfig b/pkg/tlsf/Kconfig index f6b34d41b2..0a944fcc2d 100644 --- a/pkg/tlsf/Kconfig +++ b/pkg/tlsf/Kconfig @@ -16,9 +16,9 @@ if PACKAGE_TLSF config MODULE_TLSF_MALLOC bool "TLSF malloc" - depends on MODULE_NEWLIB || BOARD_NATIVE + depends on MODULE_NEWLIB || HAS_ARCH_NATIVE select MODULE_TLSF_MALLOC_NEWLIB if MODULE_NEWLIB - select MODULE_TLSF_MALLOC_NATIVE if BOARD_NATIVE + select MODULE_TLSF_MALLOC_NATIVE if HAS_ARCH_NATIVE config MODULE_TLSF_MALLOC_NEWLIB bool diff --git a/pkg/tlsf/Makefile.dep b/pkg/tlsf/Makefile.dep index 448c5d76a5..3e1709880f 100644 --- a/pkg/tlsf/Makefile.dep +++ b/pkg/tlsf/Makefile.dep @@ -1,7 +1,7 @@ ifneq (,$(filter tlsf-malloc,$(USEMODULE))) ifneq (,$(filter newlib,$(USEMODULE))) USEMODULE += tlsf-malloc_newlib - else ifneq (,$(filter native,$(BOARD))) + else ifneq (,$(filter native,$(CPU))) USEMODULE += tlsf-malloc_native else $(warning tlsf-malloc can only be used on native or on platforms using newlib) diff --git a/pkg/utensor/patches/0002-fix-mbed-specific-code.patch b/pkg/utensor/patches/0002-fix-mbed-specific-code.patch index 3c6b7e60a4e6a91ea6dba43d3c53cee1bf98591d..f841ace0d78931b4a7e831b8f82a44242d0f8483 100644 GIT binary patch delta 24 dcmZqV`pdbYkBQkiAawF%rr98RvoZ5IMgVGw2qORh delta 28 fcmey%*~qn_kBQaE-!aH#@