# clang2mpl **Repository Path**: zongfanglin/clang2mpl ## Basic Information - **Project Name**: clang2mpl - **Description**: No description available - **Primary Language**: C++ - **License**: MulanPSL-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 1 - **Forks**: 6 - **Created**: 2021-05-18 - **Last Updated**: 2024-06-03 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README ``` # # 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. # ``` 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 clang2mpl is setup as a clang tool. We will link with the libraries already checked out during your OAC installation. Before building, make sure you have the prerequisites: ```sh sudo apt-get install libssl-dev ``` The build process uses the environment variables from Maple to find the proper include and link directories. Be sure to follow the OpenArkCompiler installation instructions to setup the environment (and build the required libraries). ```sh cd $MAPLE_ROOT source build/envsetup.sh arm release ``` Build clang2mpl: ```sh cd clang2mpl/ make setup make make install ``` When this build completes, you should see _clang2mpl_ in _$MAPLE_EXECUTE_BIN_. ## Usage As a Clang tool, clang2mpl uses the standard command line interface to pass flags to the tool and into clang: ```sh clang2mpl [] -- [] ``` The available flags for clang2mpl are: - `--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 For the clang options after the `--`, you can pass any flags that you would pass to clang (for example, `-Wno-unused-value`), but you should always include the target, `--target=aarch64-linux-elf`. A typical usage would look like this: ```sh clang2mpl --ascii foo.c -- --target=aarch64-linux-elf ``` ## Testing ### Unit Testing Unit tests for this tool are found in the [test/](/../tree/master/test) directory in the repository. The unit tests rely on LLVM's [lit](https://llvm.org/docs/CommandGuide/lit.html) and [FileCheck](https://llvm.org/docs/CommandGuide/FileCheck.html) tools. To install those tools: ```sh # Install lit pip install lit # Install FileCheck sudo apt install llvm-10-tools ``` To run the tests: ```sh cd clang2mpl/test lit . ``` These tests should all pass and should be run before any commits. As enhancements are made to the tool, developers should update and add to these tests.