A cross toolchain collection based on LLVM with multi architecture and platform support.
Supported target platforms:
-
Linux: musl-libc, glibc
-
Android
-
Windows: MinGW, MSVC(Experiment)
-
Darwin: MacOSX, Mac-Catalyst, iOS, tvOS, watchOS
-
BSD: FreeBSD
-
WebAssembly(WASM): Emscripten, WAMR(with custom extensions)
The toolchain itself works on Linux, Windows and MacOSX now.
-
GCC or Clang that supports C++17 and later
-
CMake >= 3.15
-
Ninja
It can be installed via
pip:pip install ninja
-
Python 3 >= 3.7
Python >= 3.8 is required on Windows to support unelevated symlinks with developer mode
-
Golang(latest version recommended)
-
Some development libs:
| Lib | CentOS | Ubuntu/Debian |
|---|---|---|
| libz | zlib-devel | zlib1g-dev |
| liblzma | xz-devel | liblzma-dev |
| libxml2 | libxml2-devel | libxml2-dev |
-
Windows host:
- MSYS2
NOTE: To build in MSYS2, you can install the following packages with
pacman:curl rsync make patch mingw-w64-x86_64-gcc mingw-w64-x86_64-cmake mingw-w64-x86_64-ninja mingw-w64-x86_64-python3 mingw-w64-x86_64-zlib mingw-w64-x86_64-xz mingw-w64-x86_64-libxml2 mingw-w64-x86_64-polly- Windows subsystem for Linux(WSL) with any Linux distribution(Optional)
The file version contains the versions of some important toolchain components, such as glibc, musl-libc and so on.
The array variable CROSS_TARGETS in the file cross-targets defines all cross target triples to be built.
You can change version and cross-targets based on your need.
NOTE for MacOSX host: Linux kernel header must be built on Linux environment, it's recommended to build in Docker Linux image.
prebuilt-linux-header/build-linux-header.shNOTE: glibc must be built in glibc based Linux environment(eg. CentOS, Debian, Ubuntu).
Prerequisite development libs:
| Lib | CentOS | Ubuntu/Debian |
|---|---|---|
| libgmp | gmp-devel | libgmp-dev |
| libmpfr | mpfr-devel | libmpfr-dev |
| libmpc | libmpc-devel | libmpc-dev |
# Build glibc from source, it will take a long time
prebuilt-glibc/build-glibc.shPrerequisite: Android NDK >= r21e
# Set the installation path of Android NDK
export ANDROID_NDK_HOME=/path/to/android-ndk
# Extract Bionic headers and libs from NDK
prebuilt-bionic/extract_bionic_from_ndk.shMethod 1: (recommended)extract SDKs from Xcode.xip package
-
Download
Xcode.xipfrom official Apple Developer website -
Execute tool:
./prebuilt-darwin-sdk/extract_sdks_from_xcode_archive.sh /path/to/Xcode.xip- Check and modify values of
MACOSX_VERSION,IOS_VERSION,APPLE_TVOS_VERSION,APPLE_WATCHOS_VERSIONin fileversionto match those of extracted SDKs in dirprebuilt-darwin-sdk.
Method 2: (MacOSX host only)extract SDKs from installed Xcode
-
Install gnu-tar, it can be installed via homebrew:
brew install gnu-tar
Check if command
gtaris available. -
Execute tool:
prebuilt-darwin-sdk/extract_sdks_from_xcode.sh
-
Check and modify values of
MACOSX_VERSION,IOS_VERSION,APPLE_TVOS_VERSION,APPLE_WATCHOS_VERSIONin fileversionto match those of extracted SDKs in dirprebuilt-darwin-sdk.
NOTE for Windows host: cctools must be built in WSL.
Prerequisite:
- clang >= 4
- development libs:
| Lib | CentOS | Ubuntu/Debian |
|---|---|---|
| llvm | llvm-devel | llvm-dev |
| llvm(static libs) | llvm-static | llvm-dev |
| libuuid | libuuid-devel | uuid-dev |
| openssl | openssl-devel | libssl-dev |
Check if the following command works first:
llvm-config --link-static --libs ltoBuild cctools:
./prebuilt-cctools/build-cctools.sh-
Enter Visual Studio Developer Command Prompt first, then enter MSYS2/Cygwin shell.
-
Execute the shell script:
./prebuilt-msvc-sdk/extract_sdk_from_msvc.sh- Check and modify values of
VC_VERSION,WINDOWS_SDK_VERSIONin fileversionto match those of extracted SDKs in dirprebuilt-msvc-sdk.
./prebuilt-freebsd/prepare_sysroot.sh# Set the installation path of OHOS SDK
export OHOS_SDK_HOME=/path/to/ohos-sdk
# Extract headers and libs from SDK
prebuilt-ohos/extract_sdk.shExecute the script build-all.sh to start building.
./build-all.shThe output directory path is defined by variable OUTPUT_DIR in the file config.
After building has finished successfully, you can use tool strip_toolchain.sh to strip the output toolchain.