Skip to content

Commit

Permalink
Check cross-compiler only with 'arch-test' target
Browse files Browse the repository at this point in the history
  • Loading branch information
jserv committed Oct 9, 2023
1 parent f13c541 commit bbfe6dc
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
10 changes: 6 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ include mk/toolchain.mk
OUT ?= build
BIN := $(OUT)/rv32emu

-include $(OUT)/.config
CONFIG_FILE := $(OUT)/.config
-include $(CONFIG_FILE)

CFLAGS = -std=gnu99 -O2 -Wall -Wextra
CFLAGS += -Wno-unused-label
Expand Down Expand Up @@ -95,7 +96,7 @@ $(OUT)/emulate.o: CFLAGS += $(CFLAGS_NO_CET) -fomit-frame-pointer -fno-stack-che
# to the first target after .DEFAULT_GOAL is not set.
.DEFAULT_GOAL :=

all: $(BIN)
all: config $(BIN)

OBJS := \
map.o \
Expand All @@ -122,8 +123,9 @@ $(BIN): $(OBJS)
$(VECHO) " LD\t$@\n"
$(Q)$(CC) -o $@ $^ $(LDFLAGS)

config:
$(Q)echo "$(CFLAGS)" | xargs -n1 | sort | sed -n 's/^RV32_FEATURE/ENABLE/p' > $(OUT)/.config
config: $(CONFIG_FILE)
$(CONFIG_FILE):
$(Q)echo "$(CFLAGS)" | xargs -n1 | sort | sed -n 's/^RV32_FEATURE/ENABLE/p' > $@
$(VECHO) "Check the file $(OUT)/.config for configured items.\n"

# Tools
Expand Down
3 changes: 3 additions & 0 deletions mk/riscv-arch-test.mk
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ export WORK := $(TARGETDIR)/build/arch-test
export RISCV_DEVICE ?= IMCZicsrZifencei

arch-test: $(BIN)
ifeq ($(CROSS_COMPILE),)
$(error GNU Toolchain for RISC-V is required to build architecture tests. Please check package installation)
endif
git submodule update --init $(dir $(ARCH_TEST_DIR))
$(Q)python3 -B $(RISCV_TARGET)/setup.py --riscv_device=$(RISCV_DEVICE)
$(Q)riscof run --work-dir=$(WORK) \
Expand Down
3 changes: 0 additions & 3 deletions mk/toolchain.mk
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,5 @@ endef
# TODO: support clang/llvm based cross compilers
# TODO: support native RISC-V compilers
CROSS_COMPILE ?= $(word 1,$(foreach prefix,$(TOOLCHAIN_LIST),$(call check-cross-tools, $(prefix))))
ifeq ($(CROSS_COMPILE),)
$(warning GNU Toolchain for RISC-V is required to build architecture tests. Please check package installation)
endif

export CROSS_COMPILE

0 comments on commit bbfe6dc

Please sign in to comment.