Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

makefiles/arch/riscv.inc.mk: Fix with BUILD_IN_DOCKER #18654

Merged
merged 1 commit into from
Sep 27, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion makefiles/arch/riscv.inc.mk
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ _TRIPLES_TO_TEST := \
riscv64-unknown-elf \
riscv64-elf

# Do not test at run time if building with docker: The host may have no
# RISC-V toolchain installed or a different one
ifeq (1,$(BUILD_IN_DOCKER))
TARGET_ARCH_RISCV := riscv-none-embed
endif

TARGET_ARCH_RISCV ?= \
$(strip \
$(subst -gcc,,\
Expand Down Expand Up @@ -61,8 +67,14 @@ ifeq ($(TOOLCHAIN),llvm)
TARGET_ARCH_LLVM := riscv32-none-elf
else
CFLAGS_CPU += -mcmodel=medlow -msmall-data-limit=8
ifneq (,$(shell $(TARGET_ARCH)-gcc --help=target | grep '\-malign-data='))
# We cannot invoke the compiler on the host system if build in docker.
# Instead, hard-code the required flags for the docker toolchain here
ifeq (1,$(BUILD_IN_DOCKER))
CFLAGS_CPU += -malign-data=natural
else
ifneq (,$(shell $(TARGET_ARCH)-gcc --help=target | grep '\-malign-data='))
CFLAGS_CPU += -malign-data=natural
endif
endif
endif
CFLAGS_LINK = -ffunction-sections -fdata-sections
Expand Down