This readme briefly describes the functionality of our LLVM toolchain and how to build it
Ubuntu >= 16.04
MacOS X >= 10.15.4
ubuntu
sudo apt-get install build-essential swig python3-dev libedit-dev libncurses5-dev binutils-dev gcc-multilib abigail-tools elfutils pkg-config autoconf autoconf-archive
mac
brew install swig git-lfs java coreutils wget
repo init -u https://gitee.com/OpenHarmony/manifest.git -b master -m llvm-toolchain.xml
repo sync -c
repo forall -c 'git lfs pull'
Here is an example of starting build process on Linux or MacOS:
# update prebuilts, no need to run each time
./toolchain/llvm-project/llvm-build/env_prepare.sh
# build
python3 ./toolchain/llvm-project/llvm-build/build.py
env_prepare (one time only)
build
build.py options:
--skip-build # skip compile and goto package step
--skip-package # do compile without package step
--enable-assertions # enable assertion when compiling
--build-name # specify release package name
--debug # build debug version llvm toolchain
--target-debug # build debug version of target llvm libraries, runtimes, and lldb-server
--strip # strip llvm toolchain binaries
--no-strip-libs # used with -- strip to preserve the symbols of the lib library
--no-build-arm # skip triplet arm
--no-build-aarch64 # skip triplet arm64
--no-build-x86_64 # skip triplet x86_64
--no-lto # disable LTO optimization when build toolchain
--build-instrumented # enable instrument pgo when build toolchain
--xunit-xml-output # specify LLVM unit test XML report path
--build-lldb-static # build statically lldb tool for ARM and AARCH64
--build-python # build python (not using prebuilt one, currently effective for Windows and OHOS)
--build-ncurses # build ncurses tool for linux, Mac x86-64 or M1
--build-libedit # build libedit tool for linux, Mac x86-64 or M1
--build-libxml2 # build libxml2 tool for linux, windows, Mac x86_64 or M1
--lldb-timeout # automatically exit when timeout (currently effective for lldb-server)
--no-build # optional, skip some targets
windows
libs
lldb-server
linux
check-api
--build-clean # delete out folder after build packages
--build_libs_flags # which kind of flags for build_crts and build_runtimes
OH
LLVM
BOTH
--build-only # build only some targets, skip building windows, lldb-server and package step
lld
llvm-readelf
llvm-objdump
musl
compiler-rt
libcxx
--enable-check-abi # Check libc++_shared.so ABI. If the ABI was changed then interrupt a build process and report an error.
When build successfully completed. following artifacts will be available in out
directory
sysroot
-> sysroots for OHOS targets
install
-> toolchain build
*.tar.bz2
-> archived versions of toolchain and sysroots
contains:
1. toolchain which provides clang compiler, lldb(-mi), clang-tidy etc. tools
2. libc++/clang_rt/asan/fuzzer libs for target device
OHOS sync from: https://mirrors.huaweicloud.com/openharmony/compiler/clang/
Which is the same as: out/clang-dev-${platform}-${arch}.tar.bz2
OHOS archive to: prebuilts/clang/ohos//${platform}/llvm
License: Apache License v2.0 with LLVM Exceptions
contains: provide libc++ for ndk in target device
OHOS fetch prebuilts from: https://mirrors.huaweicloud.com/openharmony/compiler/clang/ and archive it to prebuilts/clang/ohos//${platform}/libcxx-ndk. This tar is
License: Apache License v2.0 with LLVM Exceptions
First build toolchain on Linux. Here is an example of starting build process on Linux:
# build
python3 ./toolchain/llvm-project/llvm-build/build-ohos-aarch64.py
build-ohos-aarch64.py options:
--enable-assertions # enable assertion when compiling
--debug # build debug version llvm toolchain
--strip # strip llvm toolchain binaries
--build-python # build python and enable script in debugger
--build-ncurses # build ncurses and enable ncurses in debugger
--build-libedit # build libedit and enable libedit in debugger
--build-libxml2 # build libxml2 and enable libxml in debugger
When build successfully completed, artifacts will be available in out/ohos-aarch64-install
directory, including clang, lld, runtimes, LLVM tools and libLLVM.so for aarch64.
First build toolchain on Linux. Here is an example of starting build process on Linux:
# build
python3 ./toolchain/llvm-project/llvm-build/build-ohos-arm.py
build-ohos-arm.py options:
--build-python # build python and enable script in debugger
--build-ncurses # build ncurses and enable ncurses in debugger
--build-libedit # build libedit and enable libedit in debugger
--build-libxml2 # build libxml2 and enable libxml in debugger
When build successfully completed, artifacts will be available in out/ohos-arm-install
directory, including lldb for arm.
First build toolchain on Linux. Install additional package libstdc++-11-dev-arm64-cross.
Here is an example of starting build process on Linux:
# build
python3 ./toolchain/llvm-project/llvm-build/build-linux-aarch64.py
build-linux-aarch64.py options:
--enable-assertions # enable assertion when compiling
--debug # build debug version llvm toolchain
--strip # strip llvm toolchain binaries
--build-python # build python and enable script in debugger
--build-ncurses # build ncurses and enable ncurses in debugger
--build-libedit # build libedit and enable libedit in debugger
--build-libxml2 # build libxml2 and enable libxml in debugger
When build successfully completed, artifacts will be available in out/linux-aarch64-install
directory, including clang, lld, runtimes, LLVM tools and libLLVM.so for aarch64.
The LLVM toolchain is built based on LLVM 15.0.4. It is used to provide capability of building ohos image. For detailed information about LLVM 15.0.4, please refer to LLVM 15.0.4.
Despite all the components provided by LLVM community, we included several triplets for different types of ohos devices to our LLVM toochain, listed as below. For specification, liteos is a newly included OS name which indicate the simplified linux kernel.
Triplet Name | Architecture | System Kernel | System |
---|---|---|---|
arm-liteos-ohos | ARM 32bits | LiteOS | Small system |
arm-linux-ohos | ARM 32bits | Linux | Small system |
arm-linux-ohos | ARM 32bits | Linux | Standard system |
aarch64-linux-ohos | ARM 64bits | Linux | Standard system |
For detailed definition of Small System and Standard System, please refer to System Types.
Toolchain build process includes musl libc build. libc.so is available in sysroot. Sometimes it's needed to build libc tests.
Here is an example of starting build process on Linux:
# build
python3 ./toolchain/llvm-project/llvm-build/build-libc-test.py
When build successfully completed, artifacts will be available in out/llvm_build/musl
directory, including test libraries, libc tests and musl_unittest.
Scripts to execute libc tests could be found in third_party/musl/scripts
directory.
For detailed information about musl, please refer to third_party_musl.
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。