Skip to content

CMake: Improve toolchain handling #14518

Open
@rwalton-arm

Description

@rwalton-arm

Description of defect

All flags required by the toolchain should be encapsulated in toolchain files. We should ideally keep logic and exported functions out of toolchain files. Toolchain files should not have dependencies, and the build system should not have a hard dependency on non-standard variables or functions defined in toolchain files. This allows us to swap toolchains easily and enables Mbed OS to interoperate with many standard toolchain files a user might define.

Currently we include our toolchain files rather than passing them in on the command line. This means we enforce the order in which Mbed OS is added to the project at the top level. We also export various functions from our toolchain files that the user must call to enable certain features, such as minimal-printf and the "small" c-lib. Generally these functions will just add extra compile options. Part of the solution is to define interface libraries for minimal-printf and c-lib which forward their required flags. We should then look at removing the toolchain.cmake layer and make our actual toolchain files self contained so they can be passed on the command line.

The benefits of this change include:

  • Easier to change between native and cross-compiles
  • Easier to build unit tests and develop mbed-os
  • Removes requirement for specific ordering of CMake directives in top level application (toolchain file must be processed before compiler language is enabled)
  • Easier to add new toolchain support (all we would need is another toolchain file)

Target(s) affected by this defect ?

All

Toolchain(s) (name and version) displaying this defect ?

All

What version of Mbed-os are you using (tag or sha) ?

master

What version(s) of tools are you using. List all that apply (E.g. mbed-cli)

All

How is this defect reproduced ?

Forget to include app.cmake in your application CMakeLists, or call project before including it.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions