Skip to content

Commit

Permalink
Merge pull request #20335 from fzi-haxel/pr/native64-board
Browse files Browse the repository at this point in the history
native64: Separate board for 64-bit native
  • Loading branch information
benpicco authored Feb 5, 2024
2 parents 7bcad44 + d1f1f8a commit 4d9e8a8
Show file tree
Hide file tree
Showing 153 changed files with 491 additions and 392 deletions.
2 changes: 2 additions & 0 deletions .github/labeler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,9 @@

"Platform: native":
- "boards/native/**/*"
- "boards/native64/**/*"
- "cpu/native/**/*"
- "makefiles/arch/native.inc.mk"

"Platform: ARM":
- "cpu/arm7_common/**/*"
Expand Down
7 changes: 4 additions & 3 deletions .murdock
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ hifive1b
msb-430
msba2
native
native64
nrf52840dk
qn9080dk
samr21-xpro
Expand All @@ -38,7 +39,7 @@ esac

# temporarily disabling llvm builds until https://github.com/RIOT-OS/RIOT/pull/15595
# is in
: ${TEST_BOARDS_LLVM_COMPILE:="iotlab-m3 native nrf52dk mulle nucleo-f401re samr21-xpro slstk3402a"}
: ${TEST_BOARDS_LLVM_COMPILE:="iotlab-m3 native native64 nrf52dk mulle nucleo-f401re samr21-xpro slstk3402a"}

: ${TEST_WITH_CONFIG_SUPPORTED:="examples/suit_update tests/drivers/at86rf2xx_aes"}

Expand Down Expand Up @@ -380,9 +381,9 @@ compile() {
EMULATED=0
fi

if [ $RUN_TESTS -eq 1 -o "$board" = "native" -o "$EMULATED" = "1" ]; then
if [ $RUN_TESTS -eq 1 -o "$board" = "native" -o "$board" = "native64" -o "$EMULATED" = "1" ]; then
if [ -f "${BINDIR}/.test" ]; then
if [ "$board" = "native" -o "${EMULATED}" = "1" ]; then
if [ "$board" = "native" -o "$board" = "native64" -o "${EMULATED}" = "1" ]; then
# For native, we can run the test on the worker that also
# compiled it (`make -C${appdir} test`).
# "dwq-localjob" allows using some (locally run) command's
Expand Down
2 changes: 1 addition & 1 deletion Makefile.include
Original file line number Diff line number Diff line change
Expand Up @@ -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)"\
Expand Down
14 changes: 3 additions & 11 deletions boards/native/Makefile.features
Original file line number Diff line number Diff line change
@@ -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
177 changes: 0 additions & 177 deletions boards/native/Makefile.include
Original file line number Diff line number Diff line change
@@ -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)))
Expand Down Expand Up @@ -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)
Expand All @@ -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)
12 changes: 12 additions & 0 deletions boards/native/common_features.inc.mk
Original file line number Diff line number Diff line change
@@ -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
2 changes: 0 additions & 2 deletions boards/native/doc.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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

```
Expand Down
30 changes: 30 additions & 0 deletions boards/native64/Kconfig
Original file line number Diff line number Diff line change
@@ -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"
3 changes: 3 additions & 0 deletions boards/native64/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
DIRS = $(RIOTBOARD)/native

include $(RIOTBASE)/Makefile.base
1 change: 1 addition & 0 deletions boards/native64/Makefile.dep
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include $(RIOTBOARD)/native/Makefile.dep
6 changes: 6 additions & 0 deletions boards/native64/Makefile.features
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
CPU = native

FEATURES_PROVIDED += arch_64bit
NATIVE_ARCH_BIT = 64

include $(RIOTBOARD)/native/common_features.inc.mk
1 change: 1 addition & 0 deletions boards/native64/Makefile.include
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include $(RIOTBOARD)/native/Makefile.include
13 changes: 13 additions & 0 deletions boards/native64/doc.txt
Original file line number Diff line number Diff line change
@@ -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.

*/
4 changes: 2 additions & 2 deletions core/include/native_sched.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
extern "C" {
#endif

#ifdef BOARD_NATIVE
#ifdef CPU_NATIVE
#include <stdio.h>

/*
Expand Down Expand Up @@ -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
}
Expand Down
4 changes: 2 additions & 2 deletions cpu/native/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 1 addition & 6 deletions cpu/native/Makefile.features
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand Down
Loading

0 comments on commit 4d9e8a8

Please sign in to comment.