diff --git a/README.md b/README.md index e2d78fe19fd978a9e8514a1231a0c50b1ee31563..d560ee2c3c958c2f752ba9f7a7011732cf74a5e5 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,8 @@ # ``` +Please find READM.md in other languages: [简体中文](./README_zh_cn.md) + clang2mpl is a Clang-based frontend for the [Open Ark Compiler](https://gitee.com/openarkcompiler/OpenArkCompiler). ## Building clang2mpl diff --git a/README_zh_cn.md b/README_zh_cn.md new file mode 100644 index 0000000000000000000000000000000000000000..88aa8015a572dff5bebd9b9f7cad7abf7a91aebb --- /dev/null +++ b/README_zh_cn.md @@ -0,0 +1,94 @@ +``` +# +# Copyright (c) 2021 Futurewei Technologies, Inc. +# +# clang2mpl is licensed under Mulan PSL v2. +# You can use this software according to the terms and conditions of the Mulan +# PSL v2. You may obtain a copy of Mulan PSL v2 at: +# +# http://license.coscl.org.cn/MulanPSL2 +# +# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY +# KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO +# NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. See the +# Mulan PSL v2 for more details. +# +``` + +clang2mpl是[Open Ark Compiler](https://gitee.com/openarkcompiler/OpenArkCompiler)基于Clang的前端. + +## 构建 clang2mpl + +clang2mpl is setup as a clang tool. We will link with the libraries already checked out during your OAC installation. + +clang2mpl被安装成clang的一个工具。 我们将连接您在OAC安装过程中已checked out库。 + +构建前, 需要确保预安装的环境: + +```sh +sudo apt install libssl-dev +``` + +构建过程使用Maple中的环境变量来查找正确的包含和链接目录。 确保遵循OpenArkCompiler安装说明来设置环境(并构建所需的库)。 + +```sh +cd $MAPLE_ROOT +source build/envsetup.sh arm release +``` + +构建clang2mpl: + +```sh +cd clang2mpl/ +make setup +make +make install +``` + +完成此构建后,您应该在_ $ MAPLE_EXECUTE_BIN_中看到_clang2mpl_。 + +## 用法 + +作为Clang工具,clang2mpl使用标准命令行界面将标志flags传递给该工具并传递给clang: + +```sh +clang2mpl [] -- [] +``` + +clang2mpl的可用标志有: + +- `--ascii`: Generate ASCII maple in a .mpl file. Without this flag, binary maple will be generated in a .bpl file. +- `--verify`: Call the `Verify` method on the generated maple + +对于`--`之后的clang选项,您可以传递将传递给clang的所有标志(例如,-Wno-unused-value`),但是您应始终包含目标--target = aarch64 -linux-elf`。 + +典型用法如下: + +```sh +clang2mpl --ascii foo.c -- --target=aarch64-linux-elf +``` + +## 测试 + +### 单元测试 + +该工具的单元测试位于[test/](/../tree/master/test) 目录中。 单元测试依赖LLVM的[lit](https://llvm.org/docs/CommandGuide/lit.html) 和 [FileCheck](https://llvm.org/docs/CommandGuide/FileCheck.html)。 + +安装那些工具: + +```sh +# Install lit +pip install lit + +# Install FileCheck +sudo apt install llvm-10-tools +``` + +要运行测试: + +```sh +cd clang2mpl/test +lit . +``` + +这些测试应该全部通过并且应该在任何提交之前运行。 随着对该工具的增强,开发人员应该更新并添加这些测试。