Hi, am trying to port a model (hello_world from the examples section) into bare-metal Risc-V but when executing the makefile at some point I get the following
./tensorflow/lite/kernels/internal/cppmath.h: In function 'T tflite::TfLiteRound(T)': ./tensorflow/lite/kernels/internal/cppmath.h:35:41: error: 'round' is not a member of 'std'; did you mean 'round'? 35 | DECLARE_STD_GLOBAL_SWITCH1(TfLiteRound, round); | ^~~~~ ./tensorflow/lite/kernels/internal/cppmath.h:32:39: note: in definition of macro 'DECLARE_STD_GLOBAL_SWITCH1' 32 | return TF_LITE_GLOBAL_STD_PREFIX::std_name(x); \ | ^~~~~~~~ In file included from /opt/riscv/riscv32-unknown-elf/include/c++/12.1.0/cmath:45, from ./tensorflow/lite/kernels/internal/quantization_util.h:18: /opt/riscv/riscv32-unknown-elf/include/math.h:318:15: note: 'round' declared here 318 | extern double round (double); | ^~~~~ ./tensorflow/lite/kernels/internal/cppmath.h: In function 'T tflite::TfLiteExpm1(T)': ./tensorflow/lite/kernels/internal/cppmath.h:36:41: error: 'expm1' is not a member of 'std'; did you mean 'exp'? 36 | DECLARE_STD_GLOBAL_SWITCH1(TfLiteExpm1, expm1); | ^~~~~ ./tensorflow/lite/kernels/internal/cppmath.h:32:39: note: in definition of macro 'DECLARE_STD_GLOBAL_SWITCH1' 32 | return TF_LITE_GLOBAL_STD_PREFIX::std_name(x); \ | ^~~~~~~~ make: *** [tensorflow/lite/micro/tools/make/Makefile:646: gen/serv_mcu_x86_64_default/obj/core/tensorflow/lite/kernels/internal/quantization_util.o] Error 1
Am using this prebuilt toolchain rv32i-4.0.0 to compile. I have my own makefile (mostly based upon the risc32_mcu_makefile.inc as shown below.
# Settings for RISCV 32-bit MCU toolchain.
TARGET_ARCH := serv
TARGET_TOOLCHAIN_PREFIX := riscv32-unknown-elf-
DOWNLOAD_RESULT := $(shell $(MAKEFILE_DIR)/renode_download.sh ${MAKEFILE_DIR}/downloads)
ifneq ($(DOWNLOAD_RESULT), SUCCESS)
$(error Something went wrong with the renode download: $(DOWNLOAD_RESULT))
endif
PLATFORM_FLAGS = \
-march=rv32i \
-mabi=ilp32 \
CCFLAGS += $(PLATFORM_FLAGS)
BUILD_TYPE := micro
LDFLAGS += \
-T $(MAKEFILE_DIR)/targets/serv/link.ld \
# Use startup files from BSP
LDFLAGS += -nostartfiles
# Don't link against standard libraries, especially libstdc++
LDFLAGS += -nostdlib
# flatbuffer_utils_test and micro_allocator_test need to link against libstdc++.
# This is problematic because our toolchain's libstdc++ was compiled with exceptions,
# so when we try to link against it, the linker tries to put the exception handling
# related sections in the binary, which we don't want.
#
# The other two excluded tests also fail on other platforms, so disable them for now.
EXCLUDED_TESTS := \
tensorflow/lite/micro/flatbuffer_utils_test.cc \
tensorflow/lite/micro/micro_interpreter_test.cc \
tensorflow/lite/micro/memory_arena_threshold_test.cc \
tensorflow/lite/micro/micro_allocator_test.cc
MICROLITE_TEST_SRCS := $(filter-out $(EXCLUDED_TESTS), $(MICROLITE_TEST_SRCS))
# We actually only want to to disable simple_features_generator_test, which is part
# of the micro_speech example, but there's currently no way to disable individual
# tests within an example in a similar way to EXCLUDED_TESTS above.
#
# simple_features_generator_test passes, but it takes a very long time
# (~8 minutes on a regular PC), which is why we want to disable it.
#
# TODO: Come up with a way of excluding individual tests within an example.
EXCLUDED_EXAMPLE_TESTS := \
tensorflow/lite/micro/examples/micro_speech/Makefile.inc
MICRO_LITE_EXAMPLE_TESTS := $(filter-out $(EXCLUDED_EXAMPLE_TESTS), $(MICRO_LITE_EXAMPLE_TESTS))
TEST_SCRIPT := tensorflow/lite/micro/testing/test_with_renode.sh
# We are setting this variable to non-zero to allow us to have a custom
# implementation of `make test` for our target
TARGET_SPECIFIC_MAKE_TEST := 1
TEST_TARGET_BINARIES = $(shell ls -1 $(BINDIR)/*_test)
test: build
$(TEST_SCRIPT) "$(TEST_TARGET_BINARIES)" $(TEST_PASS_STRING) $(TARGET)
I am indeed able to execute and compile into any other target, just when I try mine with it’s own linker it fails.
Any help or guide would be greatly appreciated.