From cab9819e1341768f8f48790e24513c1d0b76e30a Mon Sep 17 00:00:00 2001 From: Philip Wiese Date: Wed, 23 Nov 2022 14:36:33 +0100 Subject: [PATCH 1/4] Fix problems when using cMake - Copy missing riscv.ld file to gcc riscv32-unknown-elf library folder This is required for cMake to successfully perform the auto configuration --- Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 28f730921..7ebb1cca8 100644 --- a/Makefile +++ b/Makefile @@ -78,7 +78,8 @@ tc-riscv-gcc: mkdir -p $(GCC_INSTALL_DIR) cd $(CURDIR)/toolchain/riscv-gnu-toolchain && rm -rf build && mkdir -p build && cd build && \ ../configure --prefix=$(GCC_INSTALL_DIR) --with-arch=rv32im --with-cmodel=medlow --enable-multilib && \ - $(MAKE) MAKEINFO=true -j4 + $(MAKE) MAKEINFO=true -j4 && \ + cp ../riscv.ld $(GCC_INSTALL_DIR)/riscv32-unknown-elf/lib tc-llvm: mkdir -p $(LLVM_INSTALL_DIR) From 024e120f307efaff1a58c560a82176c8ee4b27f3 Mon Sep 17 00:00:00 2001 From: Philip Wiese Date: Sat, 10 Dec 2022 15:07:07 +0100 Subject: [PATCH 2/4] Fixed compiler optimization problems - Disabled tree-loop-distribute-patterns, builtin-memcpy, builtin-memset --- software/runtime/runtime.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/software/runtime/runtime.mk b/software/runtime/runtime.mk index 74fe9401c..e5d3a91d4 100644 --- a/software/runtime/runtime.mk +++ b/software/runtime/runtime.mk @@ -85,7 +85,7 @@ RISCV_LLVM_TARGET ?= --target=$(RISCV_TARGET) --sysroot=$(GCC_INSTALL_DIR)/$(RI RISCV_WARNINGS += -Wunused-variable -Wconversion -Wall -Wextra # -Werror RISCV_FLAGS_COMMON_TESTS ?= -march=$(RISCV_ARCH) -mabi=$(RISCV_ABI) -I$(ROOT_DIR) -I$(HALIDE_INCLUDE) -static -RISCV_FLAGS_COMMON ?= $(RISCV_FLAGS_COMMON_TESTS) -g -std=gnu99 -O3 -ffast-math -fno-common -fno-builtin-printf $(DEFINES) $(RISCV_WARNINGS) +RISCV_FLAGS_COMMON ?= $(RISCV_FLAGS_COMMON_TESTS) -g -std=gnu99 -O3 -fno-tree-loop-distribute-patterns -fno-builtin-memcpy -fno-builtin-memset -ffast-math -fno-common -fno-builtin-printf $(DEFINES) $(RISCV_WARNINGS) RISCV_FLAGS_GCC ?= -mcmodel=medany -Wa,-march=$(RISCV_ARCH_AS) -mtune=mempool # -falign-loops=32 -falign-jumps=32 RISCV_FLAGS_LLVM ?= -mcmodel=small -mcpu=mempool-rv32 -mllvm -misched-topdown From 57b25d885a61e270218b7c96d59e6abf188ad4e7 Mon Sep 17 00:00:00 2001 From: Philip Wiese Date: Sat, 10 Dec 2022 15:33:50 +0100 Subject: [PATCH 3/4] Updated infos for PR --- CHANGELOG.md | 3 +++ CONTRIBUTORS.md | 1 + 2 files changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ad0949741..c1a764d1b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ### Fixed - Measure the `wfi` stalls and stalls caused by `opc` properly - Fix the allocator initialization +- After building GCC, copy `riscv.ld` required for cMake to install folder +- Disable GCC tree-loop-distribute-patterns optimizations causing stack overflows +- Disable problematic GCC `memset` and `memcpy` built-in functions ### Changed - Increase the default AXI width to 512 for MemPool and TeraPool diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index e9d157650..35d800382 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -11,5 +11,6 @@ Thanks to all. * Luca Rufer * Marc Gantenbein * Marco Bertuletti +* Philip Wiese * Sergio Mazzola * Yichao Zhang From a9ada7e8b2e2ed6e531d29d9417be3fe99cbb6fe Mon Sep 17 00:00:00 2001 From: Philip Wiese Date: Fri, 30 Dec 2022 16:10:34 +0100 Subject: [PATCH 4/4] Fix GCC-specific specific flag --- software/runtime/runtime.mk | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/software/runtime/runtime.mk b/software/runtime/runtime.mk index e5d3a91d4..b6e89cd48 100644 --- a/software/runtime/runtime.mk +++ b/software/runtime/runtime.mk @@ -85,8 +85,8 @@ RISCV_LLVM_TARGET ?= --target=$(RISCV_TARGET) --sysroot=$(GCC_INSTALL_DIR)/$(RI RISCV_WARNINGS += -Wunused-variable -Wconversion -Wall -Wextra # -Werror RISCV_FLAGS_COMMON_TESTS ?= -march=$(RISCV_ARCH) -mabi=$(RISCV_ABI) -I$(ROOT_DIR) -I$(HALIDE_INCLUDE) -static -RISCV_FLAGS_COMMON ?= $(RISCV_FLAGS_COMMON_TESTS) -g -std=gnu99 -O3 -fno-tree-loop-distribute-patterns -fno-builtin-memcpy -fno-builtin-memset -ffast-math -fno-common -fno-builtin-printf $(DEFINES) $(RISCV_WARNINGS) -RISCV_FLAGS_GCC ?= -mcmodel=medany -Wa,-march=$(RISCV_ARCH_AS) -mtune=mempool # -falign-loops=32 -falign-jumps=32 +RISCV_FLAGS_COMMON ?= $(RISCV_FLAGS_COMMON_TESTS) -g -std=gnu99 -O3 -fno-builtin-memcpy -fno-builtin-memset -ffast-math -fno-common -fno-builtin-printf $(DEFINES) $(RISCV_WARNINGS) +RISCV_FLAGS_GCC ?= -mcmodel=medany -Wa,-march=$(RISCV_ARCH_AS) -mtune=mempool -fno-tree-loop-distribute-patterns # -falign-loops=32 -falign-jumps=32 RISCV_FLAGS_LLVM ?= -mcmodel=small -mcpu=mempool-rv32 -mllvm -misched-topdown ifeq ($(COMPILER),gcc)