From bc23fcd79739683100a4fb8f10a28d2d57d49992 Mon Sep 17 00:00:00 2001 From: "moiz.hussain" Date: Fri, 11 Aug 2023 14:44:49 +0500 Subject: [PATCH] added support for RISCV CFLAGS & native compile + cross compile options --- Makefile | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/Makefile b/Makefile index b750540fe..8b8de67e2 100644 --- a/Makefile +++ b/Makefile @@ -35,6 +35,11 @@ ifndef UNAME_M UNAME_M := $(shell uname -m) endif +ifdef RISCV_CROSS_COMPILE +CC := riscv64-unknown-linux-gnu-gcc +CXX := riscv64-unknown-linux-gnu-g++ +endif + CCV := $(shell $(CC) --version | head -n 1) CXXV := $(shell $(CXX) --version | head -n 1) @@ -145,6 +150,9 @@ endif # Architecture specific # TODO: probably these flags need to be tweaked on some architectures # feel free to update the Makefile for your architecture and send a pull request or issue + +ifndef RISCV + ifeq ($(UNAME_M),$(filter $(UNAME_M),x86_64 i686 amd64)) # Use all CPU extensions that are available: CFLAGS += -march=native -mtune=native @@ -193,6 +201,11 @@ ifneq ($(filter ppc64%,$(UNAME_M)),) endif endif +else + CFLAGS += -march=rv64gcv -mabi=lp64d + CXXFLAGS += -march=rv64gcv -mabi=lp64d +endif + ifndef LLAMA_NO_K_QUANTS CFLAGS += -DGGML_USE_K_QUANTS CXXFLAGS += -DGGML_USE_K_QUANTS