Toolchains
By default, clang-build provides an llvm-clang toolchain (see the LLVM
class in
clang_build/toolchain.py).
But it also allows you to use custom ones, by passing passing the toolchain
command line argument, i.e. clang-build ... --toolchain /path/to/your_toolchain.py
.
The Python-file which you pass to clang-build must define a function with the
following signature:
import clang_build
def get_toolchain(environment) -> clang_build.toolchain.Toolchain:
toolchain = clang_build.toolchain.Toolchain()
#...
return toolchain
For a working example look at tests/toolchains/emscripten-toolchain.py.
The important part is the signature. You should derive from the Toolchain
base class and override the given defaults as needed:
- the build platform (on which clang-build is being run), e.g.
- windows
- osx
- linux
- the host platform (on which the build results may be run), e.g.
- windows
- osx
- linux
- web / browser
- the host architecture (on which to run the built binaries), e.g.
- x86
- GPU
- web / wasm
- a list of supported C-dialect languages, e.g.
- C
- C++
- CUDA-C
- CUDA-C++
- OpenCL
- Objective-C
- Objective-C++
- default compile and link flags for all target types (executable, ...) for all build types (debug, ...) for the available languages for the given combination of build and host platform