From 6f42d9e176960afa14e77d0344d1bd08c3fa7114 Mon Sep 17 00:00:00 2001 From: Wen HU Date: Wed, 17 Mar 2021 12:04:23 -0400 Subject: [PATCH] support build riscv target: source build/envsetup.sh riscv release --- Makefile | 3 +- build/config/BUILDCONFIG.gn | 2 +- build/envsetup.sh | 9 ++--- src/mapleall/BUILD.gn | 22 ++++++++++- src/mapleall/maple_be/BUILD.gn | 62 +++++++++++++++++++++++------- src/mapleall/maple_driver/BUILD.gn | 2 - 6 files changed, 75 insertions(+), 25 deletions(-) diff --git a/Makefile b/Makefile index 3be57cb4fd..00e78acfd2 100644 --- a/Makefile +++ b/Makefile @@ -36,7 +36,8 @@ GN_OPTIONS := \ HOST_ARCH=$(HOST_ARCH) \ MIR_JAVA=$(MIR_JAVA) \ OPT="$(OPT)" \ - OPS_ANDROID=$(OPS_ANDROID) + OPS_ANDROID=$(OPS_ANDROID) \ + TARGET="$(TARGET_PROCESSOR)" \ .PHONY: default default: install diff --git a/build/config/BUILDCONFIG.gn b/build/config/BUILDCONFIG.gn index dc545010fd..06e1a56959 100755 --- a/build/config/BUILDCONFIG.gn +++ b/build/config/BUILDCONFIG.gn @@ -24,6 +24,7 @@ declare_args() { COV_CHECK = 0 OPS_ANDROID = 0 OPT = "O2" + TARGET = "" } # Define global args @@ -173,7 +174,6 @@ if (MARK_CYCLE_ROOTS) { cflags_cc += [ "-DMIR_FEATURE_FULL=1" ] if (MIR_JAVA == 1) { - TARGET = "aarch64" cflags_cc += [ "-DMIR_JAVA=1" ] } else { TARGET = "vm" diff --git a/build/envsetup.sh b/build/envsetup.sh index 5e6a761b92..8f5f788b7f 100644 --- a/build/envsetup.sh +++ b/build/envsetup.sh @@ -61,18 +61,15 @@ export QEMU_PATH=${QEMU_PATH} if [ $1 = "arm" ]; then PLATFORM=aarch64 USEOJ=0 +elif [ $1 = "riscv" ]; then + PLATFORM=riscv64 + USEOJ=0 elif [ $1 = "engine" ]; then PLATFORM=ark USEOJ=1 elif [ $1 = "ark" ]; then PLATFORM=ark USEOJ=1 -elif [ $1 = "ark2" ]; then - PLATFORM=ark - USEOJ=2 -elif [ $1 = "riscv" ]; then - PLATFORM=riscv64 - USEOJ=0 else print_usage return diff --git a/src/mapleall/BUILD.gn b/src/mapleall/BUILD.gn index 1e6969ef37..85f1a5ef5a 100644 --- a/src/mapleall/BUILD.gn +++ b/src/mapleall/BUILD.gn @@ -17,9 +17,29 @@ config("mapleallcompilecfg") { cflags_cc += [ "-std=c++17", "-fno-common", - "-DTARGAARCH64", ] + if(TARGET == "aarch64"){ + cflags_cc += [ + "-DTARGAARCH64", + "-DMAPLE_ROOT=\"${MAPLE_ROOT}\"", + ] + } + + if(TARGET == "riscv64"){ + cflags_cc += [ + "-DTARGRISCV64", + "-DMAPLE_ROOT=\"${MAPLE_ROOT}\"", + ] + } + + if(TARGET == "ark"){ + cflags_cc += [ + "-DTARGARK", + "-DMAPLE_ROOT=\"${MAPLE_ROOT}\"", + ] + } + if (GN_BUILD_TYPE == "DEBUG") { cflags_c += [ "-DDEBUG" ] cflags_cc += [ "-DDEBUG" ] diff --git a/src/mapleall/maple_be/BUILD.gn b/src/mapleall/maple_be/BUILD.gn index f6cf043be4..e399e2b24f 100644 --- a/src/mapleall/maple_be/BUILD.gn +++ b/src/mapleall/maple_be/BUILD.gn @@ -14,11 +14,9 @@ # include_directories = [ "${MAPLEALL_ROOT}/maple_be/include/cg", - "${MAPLEALL_ROOT}/maple_be/include/cg/aarch64", "${MAPLEALL_ROOT}/maple_be/include/ad", "${MAPLE_BUILD_OUTPUT}/common/target", "${MAPLEALL_ROOT}/maple_be/include/ad/target", - "${MAPLEALL_ROOT}/maple_be/include/be/aarch64", "${MAPLEALL_ROOT}/maple_be/include/be", "${MAPLEALL_ROOT}/maple_driver/include", "${MAPLEALL_ROOT}/maple_util/include", @@ -30,6 +28,36 @@ include_directories = [ "${MAPLE_ROOT}/third_party/bounds_checking_function/include", ] +deps_libcg = [] + +deps_libmplbe = [ + ":libcglowerer", +] + +if(TARGET == "aarch64"){ + include_directories += [ + "${MAPLEALL_ROOT}/maple_be/include/cg/aarch64", + "${MAPLEALL_ROOT}/maple_be/include/be/aarch64", + ] + deps_libcg += [ ":libcgaarch64", ] +} + +if(TARGET == "riscv64"){ + include_directories += [ + "${MAPLEALL_ROOT}/maple_be/include/cg/riscv64", + "${MAPLEALL_ROOT}/maple_be/include/be/riscv64", + ] + deps_libcg += [ ":libcgriscv64", ] +} + +if(TARGET == "ark"){ + include_directories += [ + "${MAPLEALL_ROOT}/maple_be/include/cg/ark", + "${MAPLEALL_ROOT}/maple_be/include/be/ark", + ] + deps_libcg += [ ":libcgark", ] +} + src_libmplad = [ "src/ad/mad.cpp" ] src_libcglowerer = [ @@ -44,11 +72,6 @@ src_libmplbe = [ "src/be/rt.cpp", ] -deps_libmplbe = [ - ":libcglowerer", - ":libbeaarch64", -] - src_libcgaarch64 = [ "src/cg/aarch64/aarch64_abi.cpp", "src/cg/aarch64/mpl_atomic.cpp", @@ -80,6 +103,14 @@ src_libcgaarch64 = [ "src/cg/aarch64/aarch64_lsra.cpp", ] +src_libcgriscv64 = [ + "src/cg/riscv64/foo.cpp", +] + +src_libcgark = [ + "src/cg/ark/foo.cpp", +] + src_libcg = [ "src/cg/args.cpp", "src/cg/cfgo.cpp", @@ -110,9 +141,6 @@ src_libcg = [ "src/cg/yieldpoint.cpp", ] -deps_libcg = [] -deps_libcg += [ ":libcgaarch64" ] - cflags_cc -= [ "-DRC_NO_MMAP" ] cflags_cc -= [ "-DMIR_JAVA=1" ] @@ -126,10 +154,6 @@ static_library("libmplad") { cflags_cc += [ "-DRC_NO_MMAP" ] } -source_set("libbeaarch64") { - include_dirs = include_directories -} - source_set("libcglowerer") { sources = src_libcglowerer include_dirs = include_directories @@ -147,6 +171,16 @@ source_set("libcgaarch64") { include_dirs = include_directories } +source_set("libcgriscv64") { + sources = src_libcgriscv64 + include_dirs = include_directories +} + +source_set("libcgark") { + sources = src_libcgark + include_dirs = include_directories +} + static_library("libcg") { sources = src_libcg include_dirs = include_directories diff --git a/src/mapleall/maple_driver/BUILD.gn b/src/mapleall/maple_driver/BUILD.gn index 0a163a5b70..35ed290dfd 100644 --- a/src/mapleall/maple_driver/BUILD.gn +++ b/src/mapleall/maple_driver/BUILD.gn @@ -14,8 +14,6 @@ # configs = [ "${MAPLEALL_ROOT}:mapleallcompilecfg" ] -cflags_cc += [ "-DMAPLE_ROOT=\"${MAPLE_ROOT}\"" ] - include_directories = [ "${MAPLEALL_ROOT}", "${MAPLEALL_ROOT}/maple_be/include", -- Gitee