ARMmbed / mbed-os

Arm Mbed OS is a platform operating system designed for the internet of things
https://mbed.com
Other
4.65k stars 2.97k forks source link

CMake: Improve toolchain handling #14518

Open rwalton-arm opened 3 years ago

rwalton-arm commented 3 years ago

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:

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.

ciarmcom commented 3 years ago

Thank you for raising this detailed GitHub issue. I am now notifying our internal issue triagers. Internal Jira reference: https://jira.arm.com/browse/IOTOSM-3782