Custom Toolchain Registration
What Is a Custom Toolchain?
You can add support for software build tools to MATLAB® Coder™ software. For example, you can add support for a third-party compiler/linker/archiver (toolchain) to your MATLAB Coder software. This customization can be useful when the added toolchain has support and optimizations for a specific type of processor or hardware. These added toolchains are called custom toolchains.
What Is a Factory Toolchain?
MATLAB Coder software includes factory-default support for a set of toolchains. These toolchains are called factory toolchains to distinguish them from custom toolchains. If you install factory toolchains on your host computer, MATLAB Coder can automatically detect and use them. Support for factory toolchains depends on the host operating system. Toolchains are identified by the compiler in the toolchain. A complete list of supported toolchains (compilers) is available at https://www.mathworks.com/support/compilers/.
What is a Toolchain Definition?
A toolchain definition provides MATLAB Coder software with information about the software build tools, such as the compiler, linker, archiver. MATLAB Coder software uses this information, along with a configuration object or project, to build the generated code. This approach can be used when generating static libraries, dynamic libraries, and executables. MEX-file generation uses a different approach. To specify which compiler to use for MEX-function generation, see Setting Up the C or C++ Compiler.
MATLAB Coder software comes with a set of registered factory toolchain definitions. You can create and register custom toolchain definitions. You can customize and manage toolchain definitions. You can share custom toolchain definitions with others running MATLAB Coder software.
If you install toolchain software for one of the factory toolchains, MATLAB Coder can automatically detect and use the toolchain software. For more information about factory toolchains in MATLAB Coder software, see https://www.mathworks.com/support/compilers/.
It is helpful to understand the following concepts:
Toolchain — Software that can create a binary executable and libraries from source code. A toolchain can include:
Prebuild tools that set up the environment
Build tools, such as an Assembler, C compiler, C++ Compiler, Linker, Archiver, that build a binary executable from source code
Postbuild tools that clean up the environment
Custom toolchain — A toolchain that you define and register for use by MATLAB Coder software
Factory toolchains — Toolchains that are predefined and registered in MATLAB Coder software
Registered toolchains — The sum of custom and factory toolchain definitions registered in MATLAB Coder software
ToolchainInfo object — An instance of the
coder.make.ToolchainInfoclass that contains a toolchain definition. You save the
ToolchainInfoobject as a MAT file, register the file with MATLAB Coder. Then you can configure MATLAB Coder to load the
ToolchainInfoobject during code generation.
Toolchain definition file — A MATLAB file that defines the properties of a toolchain. You use this file to create a
This documentation also refers to the
object as a
The typical workflow for creating and using a custom toolchain definition is:
Create and Edit Toolchain Definition File
Create a toolchain definition file that returns a
Update the file with information about the custom toolchain.
Create and Validate ToolchainInfo Object
Use the toolchain definition file to create a
ToolchainInfoobject in the MATLAB workspace.
Fix validation issues by updating the toolchain definition file, and creating/validating the updated
Create a valid
ToolchainInfoobject and save it to a MAT-file.
Create an rtwTargetInfo.m file and update it with information about the MAT-file.
Register the custom toolchain in MATLAB Coder software using the rtwTargetInfo.m file.
Configure MATLAB Coder software to use the custom toolchain.
Build and run an executable using the custom toolchain.
This workflow requires an iterative approach, with multiple cycles to arrive at a
finished version of the custom
ToolchainInfo object. You
will need access to detailed information about the custom toolchain.
For a tutorial example of this workflow, see Add Custom Toolchains to MATLAB® Coder™ Build Process.
For more information about the
see About coder.make.ToolchainInfo.