|
| 1 | +# Toolchain Profiles User Perspective |
| 2 | + |
| 3 | +A Toolchain or build system Profile is a set of flags that is garenteed to be passed to the underlieing compiler suite. |
| 4 | +These flags are stored in a JSON file that may be merged with other JSON files of the same structure. |
| 5 | + |
| 6 | +## JSON Toolchain Profile Format |
| 7 | + |
| 8 | +The JSON object that represents a Toolchain Profile is a dict mapping from Toolchains, like `GCC_ARM`, to their flags, like `-O3`. |
| 9 | +The structure is as follows: Each toolchain supported by a Toolchain Profile has an dict in the root dict. |
| 10 | +This dict contains a mapping from a flag type to a list of flags that should be passed the corresponding part of the compiler suite. |
| 11 | +The required flag types are: |
| 12 | + |
| 13 | +| Key | Description | |
| 14 | +|:---------|:--------------------------------------| |
| 15 | +| `c` | Flags for the C Compiler | |
| 16 | +| `cxx` | Flags for the C++ Compiler | |
| 17 | +| `common` | Flags for both the C and C++ Compilers| |
| 18 | +| `asm` | Flags for the Assembler | |
| 19 | + |
| 20 | +## Example |
| 21 | + |
| 22 | +An example of a Toolchain Profile is given below: |
| 23 | +```json |
| 24 | +{ |
| 25 | + "GCC_ARM": { |
| 26 | + "common": ["-c", "-Wall", "-Wextra", |
| 27 | + "-Wno-unused-parameter", "-Wno-missing-field-initializers", |
| 28 | + "-fmessage-length=0", "-fno-exceptions", "-fno-builtin", |
| 29 | + "-ffunction-sections", "-fdata-sections", "-funsigned-char", |
| 30 | + "-MMD", "-fno-delete-null-pointer-checks", |
| 31 | + "-fomit-frame-pointer", "-Os"], |
| 32 | + "asm": ["-x", "assembler-with-cpp"], |
| 33 | + "c": ["-std=gnu99"], |
| 34 | + "cxx": ["-std=gnu++98", "-fno-rtti", "-Wvla"], |
| 35 | + "ld": ["-Wl,--gc-sections", "-Wl,--wrap,main", "-Wl,--wrap,_malloc_r", |
| 36 | + "-Wl,--wrap,_free_r", "-Wl,--wrap,_realloc_r", |
| 37 | + "-Wl,--wrap,_calloc_r", "-Wl,--wrap,exit", "-Wl,--wrap,atexit"] |
| 38 | + }, |
| 39 | + "ARM": { |
| 40 | + "common": ["-c", "--gnu", "-Otime", "--split_sections", |
| 41 | + "--apcs=interwork", "--brief_diagnostics", "--restrict", |
| 42 | + "--multibyte_chars", "-O3"], |
| 43 | + "asm": [], |
| 44 | + "c": ["--md", "--no_depend_system_headers", "--c99", "-D__ASSERT_MSG"], |
| 45 | + "cxx": ["--cpp", "--no_rtti", "--no_vla"], |
| 46 | + "ld": [] |
| 47 | + }, |
| 48 | + "IAR": { |
| 49 | + "common": [ |
| 50 | + "--no_wrap_diagnostics", "non-native end of line sequence", "-e", |
| 51 | + "--diag_suppress=Pa050,Pa084,Pa093,Pa082", "-Oh"], |
| 52 | + "asm": [], |
| 53 | + "c": ["--vla"], |
| 54 | + "cxx": ["--guard_calls", "--no_static_destruction"], |
| 55 | + "ld": ["--skip_dynamic_initialization", "--threaded_lib"] |
| 56 | + } |
| 57 | +} |
| 58 | +``` |
| 59 | + |
| 60 | +From this Toolchain profile, we can tell that: |
| 61 | + - `GCC_ARM`, `ARM`, and `IAR` compiler suites are supported. |
| 62 | + - The `ARM` C and C++ Compilers will be using optimization level `-O3` |
| 63 | + - The `IAR` linker will skip dynamic initialization |
| 64 | + - etc. |
| 65 | + |
| 66 | +# Toolchain Profile API Perspective |
| 67 | + |
| 68 | +The Toolchains no longer take in an optional argument, `build_profile`, that will contain a map from flag types to lists of flags. |
| 69 | +This looks exactly the same in python as it does in the JSON format above. |
| 70 | +The meaning of the flags, and which ones are required is the same as the User Perspective |
| 71 | +A developer using the API must parse the User provided files themselves and extract the appropriate sub-dict from the file afterwards. |
| 72 | +A convienence function that does this for a developer is `tools.options.extract_profile` and will call args_error when a Toolchain Profile JSON file does not provide flags for the selected Toolchain. |
0 commit comments