summaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
authorAnup Patel <anup.patel@wdc.com>2019-02-08 10:17:01 +0300
committerAnup Patel <anup@brainfault.org>2019-02-12 13:25:15 +0300
commitc5467fce469f0a5da868f1c9f90f9e4e549cb660 (patch)
tree12c4f51bc71fa844d55bfda460ea0692094337ef /Makefile
parent84169e2e691183594d0ba3b2acd85024c65b7370 (diff)
downloadopensbi-c5467fce469f0a5da868f1c9f90f9e4e549cb660.tar.xz
Makefile: Set ABI, ISA and Code Model in top-level make
This patch introduces following optional PLATFORM options: PLATFORM_RISCV_XLEN -> RISC-V register width PLATFORM_RISCV_ABI -> RISC-V GCC ABI PLATFORM_RISCV_ISA -> RISC-V GCC ISA string PLATFORM_RISCV_CODE_MODEL -> RISC-V GCC Code Model If the above options are not provided by platform config.mk or by command-line parameters then: 1. PLATFORM_RISCV_XLEN will be determined using toolchain capability 2. PLATFORM_RISCV_ABI, PLATFORM_RISCV_ISA, and PLATFORM_RISCV_CODE_MODEL is set to value best suited for generic libsbi.a As a result of these optional PLATFORM options, the platform-cflags-y and platform-asflags-y is further simplified for platform config.mk. Signed-off-by: Anup Patel <anup.patel@wdc.com>
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile26
1 files changed, 26 insertions, 0 deletions
diff --git a/Makefile b/Makefile
index a447a73..d775e4e 100644
--- a/Makefile
+++ b/Makefile
@@ -119,10 +119,34 @@ DTC = dtc
# Guess the compillers xlen
OPENSBI_CC_XLEN = `expr substr \`$(CC) -dumpmachine\` 6 2`
+# Setup platform XLEN, ABI, ISA and Code Model
+ifndef PLATFORM_RISCV_XLEN
+ ifeq ($(OPENSBI_CC_XLEN), 32)
+ PLATFORM_RISCV_XLEN = 32
+ else
+ PLATFORM_RISCV_XLEN = 64
+ endif
+endif
+ifndef PLATFORM_RISCV_ABI
+ ifeq ($(PLATFORM_RISCV_XLEN), 32)
+ PLATFORM_RISCV_ABI = ilp$(PLATFORM_RISCV_XLEN)
+ else
+ PLATFORM_RISCV_ABI = lp$(PLATFORM_RISCV_XLEN)
+ endif
+endif
+ifndef PLATFORM_RISCV_ISA
+ PLATFORM_RISCV_ISA = rv$(PLATFORM_RISCV_XLEN)imafdc
+endif
+ifndef PLATFORM_RISCV_CODE_MODEL
+ PLATFORM_RISCV_CODE_MODEL = medany
+endif
+
# Setup compilation commands flags
CFLAGS = -g -Wall -Werror -nostdlib -fno-strict-aliasing -O2
CFLAGS += -fno-omit-frame-pointer -fno-optimize-sibling-calls
CFLAGS += -mno-save-restore -mstrict-align
+CFLAGS += -mabi=$(PLATFORM_RISCV_ABI) -march=$(PLATFORM_RISCV_ISA)
+CFLAGS += -mcmodel=$(PLATFORM_RISCV_CODE_MODEL)
CFLAGS += $(GENFLAGS)
CFLAGS += $(platform-cflags-y)
CFLAGS += $(firmware-cflags-y)
@@ -134,6 +158,8 @@ CPPFLAGS += $(firmware-cppflags-y)
ASFLAGS = -g -Wall -nostdlib -D__ASSEMBLY__
ASFLAGS += -fno-omit-frame-pointer -fno-optimize-sibling-calls
ASFLAGS += -mno-save-restore -mstrict-align
+ASFLAGS += -mabi=$(PLATFORM_RISCV_ABI) -march=$(PLATFORM_RISCV_ISA)
+ASFLAGS += -mcmodel=$(PLATFORM_RISCV_CODE_MODEL)
ASFLAGS += $(GENFLAGS)
ASFLAGS += $(platform-asflags-y)
ASFLAGS += $(firmware-asflags-y)