spomorski | ab39ffb | 2018-10-02 11:19:32 -0700 | [diff] [blame] | 1 | --- |
| 2 | layout: documentation |
rosica | 29e91ca | 2019-02-18 02:46:34 -0800 | [diff] [blame] | 3 | title: C++ toolchain configuration |
spomorski | ab39ffb | 2018-10-02 11:19:32 -0700 | [diff] [blame] | 4 | --- |
| 5 | |
rosica | 29e91ca | 2019-02-18 02:46:34 -0800 | [diff] [blame] | 6 | # C++ toolchain configuration |
spomorski | ab39ffb | 2018-10-02 11:19:32 -0700 | [diff] [blame] | 7 | |
laurentlb | 27bb948 | 2018-11-12 12:50:34 -0800 | [diff] [blame] | 8 | * ToC |
| 9 | {:toc} |
| 10 | |
spomorski | ab39ffb | 2018-10-02 11:19:32 -0700 | [diff] [blame] | 11 | |
spomorski | ab39ffb | 2018-10-02 11:19:32 -0700 | [diff] [blame] | 12 | ## Overview |
| 13 | |
rosica | 0e0f4a3 | 2019-02-19 11:27:52 -0800 | [diff] [blame] | 14 | To invoke the compiler with the right options, Bazel needs some knowledge about |
| 15 | the compiler internals, such as include directories and important flags. |
| 16 | In other words, Bazel needs a simplified model of the compiler to understand its |
| 17 | workings. |
| 18 | |
| 19 | Bazel needs to know the following: |
| 20 | |
| 21 | * Whether the compiler supports thinLTO, modules, dynamic linking, or PIC |
| 22 | (position independent code). |
| 23 | * Paths to the required tools such as gcc, ld, ar, objcopy, and so on. |
| 24 | * The built-in system include directories. Bazel needs these to validate that |
| 25 | all headers that were included in the source file were properly declared in |
| 26 | the build file. |
| 27 | * The default sysroot. |
| 28 | * Which flags to use for compilation, linking, archiving. |
| 29 | * Which flags to use for the supported compilation modes (opt, dbg, fastbuild). |
| 30 | * Make variables specifically required by the compiler. |
| 31 | |
| 32 | If the compiler has support for multiple architectures, Bazel needs to configure |
| 33 | them separately. |
| 34 | |
rosica | 29e91ca | 2019-02-18 02:46:34 -0800 | [diff] [blame] | 35 | [`CcToolchainConfigInfo`](skylark/lib/CcToolchainConfigInfo.html) is a provider that provides the necessary level of |
| 36 | granularity for configuring the behavior of Bazel's C++ rules. By default, |
| 37 | Bazel automatically configures `CcToolchainConfigInfo` for your build, but you |
| 38 | have the option to configure it manually. For that, you need a Starlark rule |
| 39 | that provides the `CcToolchainConfigInfo` and you need to point the |
| 40 | [`toolchain_config`](be/c-cpp.html#cc_toolchain.toolchain_config) attribute of the `cc_toolchain` to your rule. |
| 41 | You can create the `CcToolchainConfigInfo` by calling |
| 42 | [`cc_common.create_cc_toolchain_config_info()`](skylark/lib/cc_common.html#create_cc_toolchain_config_info). |
| 43 | You can find Starlark constructors for all structs you'll need in the process in |
Yannic | 75ae479 | 2020-02-18 06:00:09 -0800 | [diff] [blame] | 44 | [`@rules_cc//cc:cc_toolchain_config_lib.bzl`](https://github.com/bazelbuild/rules_cc/blob/master/cc/cc_toolchain_config_lib.bzl). |
rosica | 29e91ca | 2019-02-18 02:46:34 -0800 | [diff] [blame] | 45 | |
spomorski | ab39ffb | 2018-10-02 11:19:32 -0700 | [diff] [blame] | 46 | |
| 47 | When a C++ target enters the analysis phase, Bazel selects the appropriate |
rosica | 29e91ca | 2019-02-18 02:46:34 -0800 | [diff] [blame] | 48 | `cc_toolchain` target based on the BUILD file, and obtains the |
| 49 | `CcToolchainConfigInfo` provider from the target specified in the |
| 50 | `cc_toolchain.toolchain_config` attribute. The `cc_toolchain` target |
| 51 | passes this information to the C++ target through a `CcToolchainProvider`. |
spomorski | ab39ffb | 2018-10-02 11:19:32 -0700 | [diff] [blame] | 52 | |
| 53 | For example, a compile or link action, instantiated by a rule such as |
| 54 | `cc_binary` or `cc_library`, needs the following information: |
| 55 | |
| 56 | * The compiler or linker to use |
| 57 | * Command-line flags for the compiler/linker |
| 58 | * Configuration flags passed through the `--copt/--linkopt` options |
| 59 | * Environment variables |
| 60 | * Artifacts needed in the sandbox in which the action executes |
| 61 | |
spomorski | 20ca4e1 | 2018-10-03 07:44:47 -0700 | [diff] [blame] | 62 | All of the above information except the artifacts required in the sandbox is |
rosica | 29e91ca | 2019-02-18 02:46:34 -0800 | [diff] [blame] | 63 | specified in the Starlark target that the `cc_toolchain` points to. |
spomorski | ab39ffb | 2018-10-02 11:19:32 -0700 | [diff] [blame] | 64 | |
| 65 | The artifacts to be shipped to the sandbox are declared in the `cc_toolchain` |
| 66 | target. For example, with the `cc_toolchain.linker_files` attribute you can |
| 67 | specify the linker binary and toolchain libraries to ship into the sandbox. |
| 68 | |
spomorski | ab39ffb | 2018-10-02 11:19:32 -0700 | [diff] [blame] | 69 | ## Toolchain selection |
| 70 | |
| 71 | The toolchain selection logic operates as follows: |
| 72 | |
| 73 | 1. User specifies a `cc_toolchain_suite` target in the `BUILD` file and points |
| 74 | Bazel to the target using the |
Jingwen Chen | 0f4544d | 2018-12-14 16:28:16 -0800 | [diff] [blame] | 75 | [`--crosstool_top` option](user-manual.html#flag--crosstool_top). |
spomorski | ab39ffb | 2018-10-02 11:19:32 -0700 | [diff] [blame] | 76 | |
rosica | 29e91ca | 2019-02-18 02:46:34 -0800 | [diff] [blame] | 77 | 2. The `cc_toolchain_suite` target references multiple toolchains. The |
| 78 | values of the `--cpu` and `--compiler` flags determine which of those |
| 79 | toolchains is selected, either based only on the `--cpu` flag value, or |
| 80 | based on a joint `--cpu | --compiler` value. The selection process is as |
| 81 | follows: |
spomorski | ab39ffb | 2018-10-02 11:19:32 -0700 | [diff] [blame] | 82 | |
| 83 | * If the `--compiler` option is specified, Bazel selects the |
| 84 | corresponding entry from the `cc_toolchain_suite.toolchains` |
| 85 | attribute with `--cpu | --compiler`. If Bazel does not find |
| 86 | a corresponding entry, it throws an error. |
| 87 | |
| 88 | * If the `--compiler` option is not specified, Bazel selects |
| 89 | the corresponding entry from the `cc_toolchain_suite.toolchains` |
| 90 | attribute with just `--cpu`. |
| 91 | |
spomorski | ab39ffb | 2018-10-02 11:19:32 -0700 | [diff] [blame] | 92 | * If no flags are specified, Bazel inspects the host system and selects a |
| 93 | `--cpu` value based on its findings. See the |
| 94 | [inspection mechanism code](https://source.bazel.build/bazel/+/1b73bc37e184e71651eb631223dcce321ba16211:src/main/java/com/google/devtools/build/lib/analysis/config/AutoCpuConverter.java). |
| 95 | |
| 96 | Once a toolchain has been selected, corresponding `feature` and `action_config` |
rosica | 29e91ca | 2019-02-18 02:46:34 -0800 | [diff] [blame] | 97 | objects in the Starlark rule govern the configuration of the build (that is, |
| 98 | items described later in this document). These messages allow the |
spomorski | ab39ffb | 2018-10-02 11:19:32 -0700 | [diff] [blame] | 99 | implementation of fully fledged C++ features in Bazel without modifying the |
| 100 | Bazel binary. C++ rules support multiple unique actions documented in detail |
| 101 | [in the Bazel source code](https://source.bazel.build/bazel/+/4f547a7ea86df80e4c76145ffdbb0c8b75ba3afa:tools/build_defs/cc/action_names.bzl). |
| 102 | |
rosica | 29e91ca | 2019-02-18 02:46:34 -0800 | [diff] [blame] | 103 | ## Features |
spomorski | ab39ffb | 2018-10-02 11:19:32 -0700 | [diff] [blame] | 104 | |
hlopko | 0bd4b92 | 2018-12-20 06:01:40 -0800 | [diff] [blame] | 105 | A feature is an entity that requires command-line flags, actions, |
spomorski | ab39ffb | 2018-10-02 11:19:32 -0700 | [diff] [blame] | 106 | constraints on the execution environment, or dependency alterations. A feature |
| 107 | can be something as simple as allowing BUILD files to select configurations of |
| 108 | flags, such as `treat_warnings_as_errors`, or interact with the C++ rules and |
| 109 | include new compile actions and inputs to the compilation, such as |
| 110 | `header_modules` or `thin_lto`. |
| 111 | |
rosica | 29e91ca | 2019-02-18 02:46:34 -0800 | [diff] [blame] | 112 | Ideally, `CcToolchainConfigInfo` contains a list of features, where each |
hlopko | 0bd4b92 | 2018-12-20 06:01:40 -0800 | [diff] [blame] | 113 | feature consists of one or more flag groups, each defining a list of flags |
| 114 | that apply to specific Bazel actions. |
spomorski | ab39ffb | 2018-10-02 11:19:32 -0700 | [diff] [blame] | 115 | |
rosica | 29e91ca | 2019-02-18 02:46:34 -0800 | [diff] [blame] | 116 | A feature is specified by name, which allows full decoupling of the Starlark |
| 117 | rule configuration from Bazel releases. In other words, a Bazel release does not |
| 118 | affect the behavior of `CcToolchainConfigInfo` configurations as long as those |
spomorski | 20ca4e1 | 2018-10-03 07:44:47 -0700 | [diff] [blame] | 119 | configurations do not require the use of new features. |
spomorski | ab39ffb | 2018-10-02 11:19:32 -0700 | [diff] [blame] | 120 | |
hlopko | 0bd4b92 | 2018-12-20 06:01:40 -0800 | [diff] [blame] | 121 | A feature is enabled in one of the following ways: |
| 122 | |
rosica | 29e91ca | 2019-02-18 02:46:34 -0800 | [diff] [blame] | 123 | * The feature's `enabled` field is set to `true`. |
hlopko | 0bd4b92 | 2018-12-20 06:01:40 -0800 | [diff] [blame] | 124 | * Bazel or the rule owner explicitly enable it. |
| 125 | * The user enables it through the `--feature` Bazel option or `features` rule |
| 126 | attribute. |
spomorski | ab39ffb | 2018-10-02 11:19:32 -0700 | [diff] [blame] | 127 | |
| 128 | Features can have interdependencies, depend on command line flags, `BUILD` file |
| 129 | settings, and other variables. |
| 130 | |
| 131 | ### Feature relationships |
| 132 | |
| 133 | Dependencies are typically managed directly with Bazel, which simply enforces |
| 134 | the requirements and manages conflicts intrinsic to the nature of the features |
| 135 | defined in the build. The toolchain specification allows for more granular |
rosica | 29e91ca | 2019-02-18 02:46:34 -0800 | [diff] [blame] | 136 | constraints for use directly within the Starlark rule that govern feature |
spomorski | ab39ffb | 2018-10-02 11:19:32 -0700 | [diff] [blame] | 137 | support and expansion. These are: |
| 138 | |
| 139 | <table> |
| 140 | <col width="300"> |
| 141 | <col width="600"> |
| 142 | <tr> |
| 143 | <td><strong>Constraint</strong> |
| 144 | </td> |
| 145 | <td><strong>Description</strong> |
| 146 | </td> |
| 147 | </tr> |
| 148 | <tr> |
rosica | 29e91ca | 2019-02-18 02:46:34 -0800 | [diff] [blame] | 149 | <td><pre>requires = [ |
| 150 | feature_set (features = [ |
| 151 | 'feature-name-1', |
| 152 | 'feature-name-2' |
| 153 | ]), |
| 154 | ]</pre> |
spomorski | ab39ffb | 2018-10-02 11:19:32 -0700 | [diff] [blame] | 155 | </td> |
| 156 | <td>Feature-level. The feature is supported only if the specified required |
| 157 | features are enabled. For example, when a feature is only supported in |
rosica | 29e91ca | 2019-02-18 02:46:34 -0800 | [diff] [blame] | 158 | certain build modes (<code>opt</code>, <code>dbg</code>, or |
| 159 | <code>fastbuild</code>). If `requires` contains multiple `feature_set`s |
| 160 | the feature is supported if any of the `feature_set`s is satisfied |
| 161 | (when all specified features are enabled). |
spomorski | ab39ffb | 2018-10-02 11:19:32 -0700 | [diff] [blame] | 162 | </td> |
| 163 | </tr> |
| 164 | <tr> |
rosica | 29e91ca | 2019-02-18 02:46:34 -0800 | [diff] [blame] | 165 | <td><code>implies = ['feature']</code> |
spomorski | ab39ffb | 2018-10-02 11:19:32 -0700 | [diff] [blame] | 166 | </td> |
rosica | 29e91ca | 2019-02-18 02:46:34 -0800 | [diff] [blame] | 167 | <td><p>Feature-level. This feature implies the specified feature(s). |
| 168 | Enabling a feature also implicitly enables all features implied by it |
| 169 | (that is, it functions recursively).</p> |
Laszlo Csomor | b2f0e26 | 2018-12-20 02:56:25 -0800 | [diff] [blame] | 170 | <p>Also provides the ability to factor common subsets of functionality out of |
| 171 | a set of features, such as the common parts of sanitizers. Implied |
| 172 | features cannot be disabled.</p> |
spomorski | ab39ffb | 2018-10-02 11:19:32 -0700 | [diff] [blame] | 173 | </td> |
| 174 | </tr> |
| 175 | <tr> |
rosica | 29e91ca | 2019-02-18 02:46:34 -0800 | [diff] [blame] | 176 | <td><code>provides = ['feature']</code> |
spomorski | ab39ffb | 2018-10-02 11:19:32 -0700 | [diff] [blame] | 177 | </td> |
Laszlo Csomor | b2f0e26 | 2018-12-20 02:56:25 -0800 | [diff] [blame] | 178 | <td><p>Feature-level. Indicates that this feature is one of several mutually |
spomorski | ab39ffb | 2018-10-02 11:19:32 -0700 | [diff] [blame] | 179 | exclusive alternate features. For example, all of the sanitizers could |
rosica | 29e91ca | 2019-02-18 02:46:34 -0800 | [diff] [blame] | 180 | specify <code>provides = ["sanitizer"]</code>.</p> |
Laszlo Csomor | b2f0e26 | 2018-12-20 02:56:25 -0800 | [diff] [blame] | 181 | <p>This improves error handling by listing the alternatives if the user asks |
| 182 | for two or more mutually exclusive features at once.</p> |
spomorski | ab39ffb | 2018-10-02 11:19:32 -0700 | [diff] [blame] | 183 | </td> |
| 184 | </tr> |
| 185 | <tr> |
rosica | 29e91ca | 2019-02-18 02:46:34 -0800 | [diff] [blame] | 186 | <td><pre>with_features = [ |
| 187 | with_feature_set( |
| 188 | features = ['feature-1'], |
| 189 | not_features = ['feature-2'], |
| 190 | ), |
| 191 | ]</pre> |
spomorski | ab39ffb | 2018-10-02 11:19:32 -0700 | [diff] [blame] | 192 | </td> |
rosica | 29e91ca | 2019-02-18 02:46:34 -0800 | [diff] [blame] | 193 | <td>Flag set-level. A feature can specify multiple flag sets with multiple. |
| 194 | When <code>with_features</code> is specified, the flag set will only expand |
| 195 | to the build command if there is at least one <code>with_feature_set</code> |
| 196 | for which all of the features in the specified <code>features</code> set |
| 197 | are enabled, and all the features specified in <code>not_features</code> |
| 198 | set are disabled. |
| 199 | If <code>with_features</code> is not specified, the flag set will be |
| 200 | applied unconditionally for every action specified. |
spomorski | ab39ffb | 2018-10-02 11:19:32 -0700 | [diff] [blame] | 201 | </td> |
| 202 | </tr> |
| 203 | </table> |
| 204 | |
rosica | 29e91ca | 2019-02-18 02:46:34 -0800 | [diff] [blame] | 205 | ## Actions |
spomorski | ab39ffb | 2018-10-02 11:19:32 -0700 | [diff] [blame] | 206 | |
rosica | 29e91ca | 2019-02-18 02:46:34 -0800 | [diff] [blame] | 207 | Actions provide the flexibility to modify the circumstances under |
spomorski | ab39ffb | 2018-10-02 11:19:32 -0700 | [diff] [blame] | 208 | which an action executes without assuming how the action will be run. An |
spomorski | 20ca4e1 | 2018-10-03 07:44:47 -0700 | [diff] [blame] | 209 | `action_config` specifies the tool binary that an action invokes, while a |
| 210 | `feature` specifies the configuration (flags) that determine how that tool |
| 211 | behaves when the action is invoked. |
spomorski | ab39ffb | 2018-10-02 11:19:32 -0700 | [diff] [blame] | 212 | |
rosica | 29e91ca | 2019-02-18 02:46:34 -0800 | [diff] [blame] | 213 | [Features](#features) reference actions to signal which Bazel actions |
| 214 | they affect since actions can modify the Bazel action graph. The |
| 215 | `CcToolchainConfigInfo` provider contains actions that have flags and tools |
spomorski | 863bc87 | 2018-10-02 12:20:05 -0700 | [diff] [blame] | 216 | associated with them, such as `c++-compile`. Flags are assigned to each action |
| 217 | by associating them with a feature. |
spomorski | ab39ffb | 2018-10-02 11:19:32 -0700 | [diff] [blame] | 218 | |
rosica | 29e91ca | 2019-02-18 02:46:34 -0800 | [diff] [blame] | 219 | Each action name represents a single type of action performed by Bazel, such as |
| 220 | compiling or linking. There is, however, a many-to-one relationship between |
| 221 | actions and Bazel action types, where a Bazel action type refers to a Java class |
| 222 | that implements an action (such as `CppCompileAction`). In particular, the |
| 223 | "assembler actions" and "compiler actions" in the table below are |
| 224 | `CppCompileAction`, while the link actions are `CppLinkAction`. |
spomorski | ab39ffb | 2018-10-02 11:19:32 -0700 | [diff] [blame] | 225 | |
| 226 | ### Assembler actions |
| 227 | |
| 228 | <table> |
| 229 | <col width="300"> |
| 230 | <col width="600"> |
| 231 | <tr> |
| 232 | <td><strong>Action</strong> |
| 233 | </td> |
| 234 | <td><strong>Description</strong> |
| 235 | </td> |
| 236 | </tr> |
| 237 | <tr> |
| 238 | <td><code>preprocess-assemble</code> |
| 239 | </td> |
| 240 | <td>Assemble with preprocessing. Typically for <code>.S</code> files. |
| 241 | </td> |
| 242 | </tr> |
| 243 | <tr> |
| 244 | <td><code>assemble</code> |
| 245 | </td> |
| 246 | <td>Assemble without preprocessing. Typically for <code>.s</code> files. |
| 247 | </td> |
| 248 | </tr> |
| 249 | </table> |
| 250 | |
| 251 | ### Compiler actions |
| 252 | |
| 253 | <table> |
| 254 | <col width="300"> |
| 255 | <col width="600"> |
| 256 | <tr> |
| 257 | <td><strong>Action</strong> |
| 258 | </td> |
| 259 | <td><strong>Description</strong> |
| 260 | </td> |
| 261 | </tr> |
| 262 | <tr> |
| 263 | <td><code>cc-flags-make-variable</code> |
| 264 | </td> |
| 265 | <td>Propagates <code>CC_FLAGS</code> to genrules. |
| 266 | </td> |
| 267 | </tr> |
| 268 | <tr> |
| 269 | <td><code>c-compile</code> |
| 270 | </td> |
| 271 | <td>Compile as C. |
| 272 | </td> |
| 273 | </tr> |
| 274 | <tr> |
| 275 | <td><code>c++-compile</code> |
| 276 | </td> |
| 277 | <td>Compile as C++. |
| 278 | </td> |
| 279 | </tr> |
| 280 | <tr> |
| 281 | <td><code>c++-header-parsing</code> |
| 282 | </td> |
| 283 | <td>Run the compiler's parser on a header file to ensure that the header is |
| 284 | self-contained, as it will otherwise produce compilation errors. Applies |
| 285 | only to toolchains that support modules. |
| 286 | </td> |
| 287 | </tr> |
| 288 | </table> |
| 289 | |
| 290 | ### Link actions |
| 291 | |
| 292 | <table> |
| 293 | <col width="300"> |
| 294 | <col width="600"> |
| 295 | <tr> |
| 296 | <td><strong>Action</strong> |
| 297 | </td> |
| 298 | <td><strong>Description</strong> |
| 299 | </td> |
| 300 | </tr> |
| 301 | <tr> |
| 302 | <td><code>c++-link-dynamic-library</code> |
| 303 | </td> |
| 304 | <td>Link a shared library containing all of its dependencies. |
| 305 | </td> |
| 306 | </tr> |
| 307 | <tr> |
| 308 | <td><code>c++-link-nodeps-dynamic-library</code> |
| 309 | </td> |
| 310 | <td>Link a shared library only containing <code>cc_library</code> sources. |
| 311 | </td> |
| 312 | </tr> |
| 313 | <tr> |
| 314 | <td><code>c++-link-executable</code> |
| 315 | </td> |
| 316 | <td>Link a final ready-to-run library. |
| 317 | </td> |
| 318 | </tr> |
| 319 | </table> |
| 320 | |
| 321 | ### AR actions |
| 322 | |
| 323 | AR actions assemble object files into archive libraries (`.a` files) via `ar` |
| 324 | and encode some semantics into the name. |
| 325 | |
| 326 | <table> |
| 327 | <col width="300"> |
| 328 | <col width="600"> |
| 329 | <tr> |
| 330 | <td><strong>Action</strong> |
| 331 | </td> |
| 332 | <td><strong>Description</strong> |
| 333 | </td> |
| 334 | </tr> |
| 335 | <tr> |
| 336 | <td><code>c++-link-static-library</code> |
| 337 | </td> |
| 338 | <td>Create a static library (archive). |
| 339 | </td> |
| 340 | </tr> |
| 341 | </table> |
| 342 | |
| 343 | ### LTO actions |
| 344 | |
| 345 | <table> |
| 346 | <col width="300"> |
| 347 | <col width="600"> |
| 348 | <tr> |
| 349 | <td><strong>Action</strong> |
| 350 | </td> |
| 351 | <td><strong>Description</strong> |
| 352 | </td> |
| 353 | </tr> |
| 354 | <tr> |
| 355 | <td><code>lto-backend</code> |
| 356 | </td> |
| 357 | <td>ThinLTO action compiling bitcodes into native objects. |
| 358 | </td> |
| 359 | </tr> |
| 360 | <tr> |
| 361 | <td><code>lto-index</code> |
| 362 | </td> |
| 363 | <td>ThinLTO action generating global index. |
| 364 | </td> |
| 365 | </tr> |
| 366 | </table> |
| 367 | |
rosica | 29e91ca | 2019-02-18 02:46:34 -0800 | [diff] [blame] | 368 | ## Action config |
spomorski | ab39ffb | 2018-10-02 11:19:32 -0700 | [diff] [blame] | 369 | |
rosica | 29e91ca | 2019-02-18 02:46:34 -0800 | [diff] [blame] | 370 | A `action_config` is a Starlark struct that describes a Bazel action |
spomorski | 20ca4e1 | 2018-10-03 07:44:47 -0700 | [diff] [blame] | 371 | by specifying the tool (binary) to invoke during the action and sets of flags, |
rosica | 29e91ca | 2019-02-18 02:46:34 -0800 | [diff] [blame] | 372 | defined by features, that apply constraints to the action's execution. The |
| 373 | `action_config()` constructor has the following parameters: |
spomorski | ab39ffb | 2018-10-02 11:19:32 -0700 | [diff] [blame] | 374 | |
| 375 | <table> |
| 376 | <col width="300"> |
| 377 | <col width="600"> |
| 378 | <tr> |
| 379 | <td><strong>Attribute</strong> |
| 380 | </td> |
| 381 | <td><strong>Description</strong> |
| 382 | </td> |
| 383 | </tr> |
| 384 | <tr> |
| 385 | <td><code>action_name</code> |
| 386 | </td> |
rosica | 29e91ca | 2019-02-18 02:46:34 -0800 | [diff] [blame] | 387 | <td>The Bazel action to which this action corresponds. |
spomorski | 20ca4e1 | 2018-10-03 07:44:47 -0700 | [diff] [blame] | 388 | Bazel uses this attribute to discover per-action tool and execution |
| 389 | requirements. |
spomorski | ab39ffb | 2018-10-02 11:19:32 -0700 | [diff] [blame] | 390 | </td> |
| 391 | </tr> |
| 392 | <tr> |
rosica | 29e91ca | 2019-02-18 02:46:34 -0800 | [diff] [blame] | 393 | <td><code>tools</code> |
spomorski | ab39ffb | 2018-10-02 11:19:32 -0700 | [diff] [blame] | 394 | </td> |
rosica | 29e91ca | 2019-02-18 02:46:34 -0800 | [diff] [blame] | 395 | <td>The executable to invoke. The tool applied to the action will be the |
| 396 | first tool in the list with a feature set that matches the feature |
| 397 | configuration. Default value must be provided. |
spomorski | ab39ffb | 2018-10-02 11:19:32 -0700 | [diff] [blame] | 398 | </td> |
| 399 | </tr> |
| 400 | <tr> |
rosica | 29e91ca | 2019-02-18 02:46:34 -0800 | [diff] [blame] | 401 | <td><code>flag_sets</code> |
spomorski | ab39ffb | 2018-10-02 11:19:32 -0700 | [diff] [blame] | 402 | </td> |
rosica | 29e91ca | 2019-02-18 02:46:34 -0800 | [diff] [blame] | 403 | <td>A list of flags that applies to a group of actions. Same as for a |
| 404 | feature. |
spomorski | ab39ffb | 2018-10-02 11:19:32 -0700 | [diff] [blame] | 405 | </td> |
| 406 | </tr> |
| 407 | <tr> |
rosica | 29e91ca | 2019-02-18 02:46:34 -0800 | [diff] [blame] | 408 | <td><code>env_sets</code> |
spomorski | ab39ffb | 2018-10-02 11:19:32 -0700 | [diff] [blame] | 409 | </td> |
rosica | 29e91ca | 2019-02-18 02:46:34 -0800 | [diff] [blame] | 410 | <td>A list of environment constraints that applies to a group of actions. |
| 411 | Same as for a feature. |
spomorski | ab39ffb | 2018-10-02 11:19:32 -0700 | [diff] [blame] | 412 | </td> |
| 413 | </tr> |
| 414 | </table> |
| 415 | |
rosica | 29e91ca | 2019-02-18 02:46:34 -0800 | [diff] [blame] | 416 | An `action_config` can require and imply other features and |
spomorski | ab39ffb | 2018-10-02 11:19:32 -0700 | [diff] [blame] | 417 | <code>action_config</code>s as dictated by the |
| 418 | [feature relationships](#feature-relationships) described earlier. This behavior |
| 419 | is similar to that of a feature. |
| 420 | |
| 421 | The last two attributes are redundant against the corresponding attributes on |
| 422 | features and are included because some Bazel actions require certain flags or |
spomorski | 20ca4e1 | 2018-10-03 07:44:47 -0700 | [diff] [blame] | 423 | environment variables and we want to avoid unnecessary `action_config`+`feature` |
spomorski | ab39ffb | 2018-10-02 11:19:32 -0700 | [diff] [blame] | 424 | pairs. Typically, sharing a single feature across multiple `action_config`s is |
| 425 | preferred. |
| 426 | |
rosica | 29e91ca | 2019-02-18 02:46:34 -0800 | [diff] [blame] | 427 | You can not define more than one `action_config` with the same `action_name` |
| 428 | within the same toolchain. This prevents ambiguity in tool paths |
spomorski | ab39ffb | 2018-10-02 11:19:32 -0700 | [diff] [blame] | 429 | and enforces the intention behind `action_config` - that an action's properties |
| 430 | are clearly described in a single place in the toolchain. |
| 431 | |
rosica | 29e91ca | 2019-02-18 02:46:34 -0800 | [diff] [blame] | 432 | ### `tool` |
spomorski | ab39ffb | 2018-10-02 11:19:32 -0700 | [diff] [blame] | 433 | |
rosica | 29e91ca | 2019-02-18 02:46:34 -0800 | [diff] [blame] | 434 | An`action_config` can specify a set of tools via its `tools` parameter. |
| 435 | The `tool()` constructor takes in the following parameters: |
spomorski | ab39ffb | 2018-10-02 11:19:32 -0700 | [diff] [blame] | 436 | |
| 437 | |
| 438 | <table> |
| 439 | <col width="300"> |
| 440 | <col width="600"> |
| 441 | <tr> |
| 442 | <td><strong>Field</strong> |
| 443 | </td> |
| 444 | <td><strong>Description</strong> |
| 445 | </td> |
| 446 | </tr> |
| 447 | <tr> |
| 448 | <td><code>tool_path</code> |
| 449 | </td> |
rosica | 29e91ca | 2019-02-18 02:46:34 -0800 | [diff] [blame] | 450 | <td>Path to the tool in question (relative to the current location). |
spomorski | ab39ffb | 2018-10-02 11:19:32 -0700 | [diff] [blame] | 451 | </td> |
| 452 | </tr> |
| 453 | <tr> |
rosica | 29e91ca | 2019-02-18 02:46:34 -0800 | [diff] [blame] | 454 | <td><code>with_features</code> |
spomorski | ab39ffb | 2018-10-02 11:19:32 -0700 | [diff] [blame] | 455 | </td> |
rosica | 29e91ca | 2019-02-18 02:46:34 -0800 | [diff] [blame] | 456 | <td>A a list of feature sets out of which at least one must be satisfied |
| 457 | for this tool to apply. |
spomorski | ab39ffb | 2018-10-02 11:19:32 -0700 | [diff] [blame] | 458 | </td> |
| 459 | </tr> |
| 460 | </table> |
| 461 | |
rosica | 29e91ca | 2019-02-18 02:46:34 -0800 | [diff] [blame] | 462 | For a given `action_config`, only a single `tool` applies |
spomorski | 20ca4e1 | 2018-10-03 07:44:47 -0700 | [diff] [blame] | 463 | its tool path and execution requirements to the Bazel action. A tool is selected |
rosica | 29e91ca | 2019-02-18 02:46:34 -0800 | [diff] [blame] | 464 | by iterating through the `tools` attribute on an `action_config` until a tool |
| 465 | with a `with_feature` set matching the feature configuration is found |
spomorski | ab39ffb | 2018-10-02 11:19:32 -0700 | [diff] [blame] | 466 | (see [Feature relationships](#feature-relationships) earlier in this document |
| 467 | for more information). We recommend that you end your tool lists with a default |
| 468 | tool that corresponds to an empty feature configuration. |
| 469 | |
spomorski | ab39ffb | 2018-10-02 11:19:32 -0700 | [diff] [blame] | 470 | ### Example usage |
| 471 | |
rosica | 29e91ca | 2019-02-18 02:46:34 -0800 | [diff] [blame] | 472 | Features and actions can be used together to implement Bazel actions |
spomorski | ab39ffb | 2018-10-02 11:19:32 -0700 | [diff] [blame] | 473 | with diverse cross-platform semantics. For example, debug symbol generation on |
| 474 | macOS requires generating symbols in the compile action, then invoking a |
| 475 | specialized tool during the link action to create compressed dsym archive, and |
| 476 | then decompressing that archive to produce the application bundle and `.plist` |
| 477 | files consumable by Xcode. |
| 478 | |
| 479 | With Bazel, this process can instead be implemented as follows, with |
| 480 | `unbundle-debuginfo` being a Bazel action: |
| 481 | |
Yannic | 75ae479 | 2020-02-18 06:00:09 -0800 | [diff] [blame] | 482 | load("@rules_cc//cc:defs.bzl", "ACTION_NAMES") |
Laszlo Csomor | b2f0e26 | 2018-12-20 02:56:25 -0800 | [diff] [blame] | 483 | |
rosica | 29e91ca | 2019-02-18 02:46:34 -0800 | [diff] [blame] | 484 | action_configs = [ |
| 485 | action_config ( |
| 486 | config_name = "ACTION_NAMES.cpp_link_executable", |
| 487 | action_name = "ACTION_NAMES.cpp_link_executable", |
| 488 | tools = [ |
| 489 | tool( |
| 490 | with_features = [ |
| 491 | with_feature(features=["generate-debug-symbols"]), |
| 492 | ], |
| 493 | tool_path = "toolchain/mac/ld-with-dsym-packaging", |
| 494 | ), |
| 495 | tool (tool_path = "toolchain/mac/ld"), |
| 496 | ], |
| 497 | ), |
| 498 | ] |
Laszlo Csomor | b2f0e26 | 2018-12-20 02:56:25 -0800 | [diff] [blame] | 499 | |
rosica | 29e91ca | 2019-02-18 02:46:34 -0800 | [diff] [blame] | 500 | features = [ |
| 501 | feature( |
| 502 | name = "generate-debug-symbols", |
| 503 | flag_sets = [ |
| 504 | flag_set ( |
| 505 | actions = [ |
| 506 | "ACTION_NAMES.c_compile", |
| 507 | "ACTION_NAMES.cpp_compile" |
| 508 | ], |
| 509 | flag_groups = [ |
| 510 | flag_group( |
| 511 | flags = ["-g"], |
| 512 | ), |
| 513 | ], |
| 514 | ) |
| 515 | ], |
| 516 | implies = ["unbundle-debuginfo"], |
| 517 | ), |
| 518 | ] |
spomorski | ab39ffb | 2018-10-02 11:19:32 -0700 | [diff] [blame] | 519 | |
spomorski | ab39ffb | 2018-10-02 11:19:32 -0700 | [diff] [blame] | 520 | |
| 521 | This same feature can be implemented entirely differently for Linux, which uses |
| 522 | `fission`, or for Windows, which produces `.pdb` files. For example, the |
| 523 | implementation for `fission`-based debug symbol generation might look as |
| 524 | follows: |
| 525 | |
Yannic | 75ae479 | 2020-02-18 06:00:09 -0800 | [diff] [blame] | 526 | load("@rules_cc//cc:defs.bzl", "ACTION_NAMES") |
spomorski | ab39ffb | 2018-10-02 11:19:32 -0700 | [diff] [blame] | 527 | |
rosica | 29e91ca | 2019-02-18 02:46:34 -0800 | [diff] [blame] | 528 | action_configs = [ |
| 529 | action_config ( |
| 530 | name = "ACTION_NAMES.cpp_compile", |
| 531 | tools = [ |
| 532 | tool( |
| 533 | tool_path = "toolchain/bin/gcc", |
| 534 | ), |
| 535 | ], |
| 536 | ), |
| 537 | ] |
Laszlo Csomor | b2f0e26 | 2018-12-20 02:56:25 -0800 | [diff] [blame] | 538 | |
rosica | 29e91ca | 2019-02-18 02:46:34 -0800 | [diff] [blame] | 539 | features = [ |
| 540 | feature ( |
| 541 | name = "generate-debug-symbols", |
| 542 | requires = [with_feature_set(features = ["dbg"])], |
| 543 | flag_sets = [ |
| 544 | flag_set( |
| 545 | actions = ["ACTION_NAMES.cpp_compile"], |
| 546 | flag_groups = [ |
| 547 | flag_group( |
| 548 | flags = ["-gsplit-dwarf"], |
| 549 | ), |
| 550 | ], |
| 551 | ), |
| 552 | flag_set( |
| 553 | actions = ["ACTION_NAMES.cpp_link_executable"], |
| 554 | flag_groups = [ |
| 555 | flag_group( |
| 556 | flags = ["-Wl", "--gdb-index"], |
| 557 | ), |
| 558 | ], |
| 559 | ), |
| 560 | ], |
| 561 | ), |
| 562 | ] |
spomorski | ab39ffb | 2018-10-02 11:19:32 -0700 | [diff] [blame] | 563 | |
spomorski | ab39ffb | 2018-10-02 11:19:32 -0700 | [diff] [blame] | 564 | |
| 565 | ### Flag groups |
| 566 | |
rosica | 29e91ca | 2019-02-18 02:46:34 -0800 | [diff] [blame] | 567 | `CcToolchainConfigInfo` allows you to bundle flags into groups that serve a |
| 568 | specific purpose. You can specify a flag within using pre-defined variables |
spomorski | ab39ffb | 2018-10-02 11:19:32 -0700 | [diff] [blame] | 569 | within the flag value, which the compiler expands when adding the flag to the |
| 570 | build command. For example: |
| 571 | |
rosica | 29e91ca | 2019-02-18 02:46:34 -0800 | [diff] [blame] | 572 | flag_group ( |
| 573 | flags = ["%{output_file_path}"], |
| 574 | ) |
Laszlo Csomor | b2f0e26 | 2018-12-20 02:56:25 -0800 | [diff] [blame] | 575 | |
spomorski | ab39ffb | 2018-10-02 11:19:32 -0700 | [diff] [blame] | 576 | |
| 577 | In this case, the contents of the flag will be replaced by the output file path |
| 578 | of the action. |
| 579 | |
| 580 | Flag groups are expanded to the build command in the order in which they appear |
rosica | 29e91ca | 2019-02-18 02:46:34 -0800 | [diff] [blame] | 581 | in the list, top-to-bottom, left-to-right. |
spomorski | ab39ffb | 2018-10-02 11:19:32 -0700 | [diff] [blame] | 582 | |
| 583 | For flags that need to repeat with different values when added to the build |
| 584 | command, the flag group can iterate variables of type `list`. For example, the |
| 585 | variable `include_path` of type `list`: |
| 586 | |
rosica | 29e91ca | 2019-02-18 02:46:34 -0800 | [diff] [blame] | 587 | flag_group ( |
| 588 | iterate_over = "include_paths", |
| 589 | flags = ["-I%{include_paths}"], |
| 590 | ) |
spomorski | ab39ffb | 2018-10-02 11:19:32 -0700 | [diff] [blame] | 591 | |
| 592 | expands to `-I<path>` for each path element in the `include_paths` list. All |
| 593 | flags (or `flag_group`s) in the body of a flag group declaration are expanded as |
| 594 | a unit. For example: |
| 595 | |
rosica | 29e91ca | 2019-02-18 02:46:34 -0800 | [diff] [blame] | 596 | flag_group ( |
| 597 | iterate_over = "include_paths", |
| 598 | flags = ["-I", "%{include_paths}"], |
| 599 | ) |
spomorski | ab39ffb | 2018-10-02 11:19:32 -0700 | [diff] [blame] | 600 | |
| 601 | expands to `-I <path>` for each path element in the `include_paths` list. |
| 602 | |
| 603 | A variable can repeat multiple times. For example: |
| 604 | |
rosica | 29e91ca | 2019-02-18 02:46:34 -0800 | [diff] [blame] | 605 | flag_group ( |
| 606 | iterate_over = "include_paths", |
| 607 | flags = ["-iprefix=%{include_paths}", "-isystem=%{include_paths}"], |
| 608 | ) |
spomorski | ab39ffb | 2018-10-02 11:19:32 -0700 | [diff] [blame] | 609 | |
| 610 | expands to: |
| 611 | |
Laszlo Csomor | b2f0e26 | 2018-12-20 02:56:25 -0800 | [diff] [blame] | 612 | -iprefix=<inc0> -isystem=<inc0> -iprefix=<inc1> -isystem=<inc1> |
spomorski | ab39ffb | 2018-10-02 11:19:32 -0700 | [diff] [blame] | 613 | |
| 614 | Variables can correspond to structures accessible using dot-notation. For |
| 615 | example: |
| 616 | |
rosica | 29e91ca | 2019-02-18 02:46:34 -0800 | [diff] [blame] | 617 | flag_group ( |
| 618 | flags = ["-l%{libraries_to_link.name}"], |
| 619 | ) |
spomorski | ab39ffb | 2018-10-02 11:19:32 -0700 | [diff] [blame] | 620 | |
| 621 | Structures can be nested and may also contain sequences. To prevent name clashes |
| 622 | and to be explicit, you must specify the full path through the fields. For |
| 623 | example: |
| 624 | |
rosica | 29e91ca | 2019-02-18 02:46:34 -0800 | [diff] [blame] | 625 | flag_group ( |
| 626 | iterate_over = "libraries_to_link", |
| 627 | flag_groups = [ |
| 628 | flag_group ( |
| 629 | iterate_over = "libraries_to_link.shared_libraries", |
| 630 | flags = ["-l%{libraries_to_link.shared_libraries.name}"], |
| 631 | ), |
| 632 | ], |
| 633 | ) |
Laszlo Csomor | b2f0e26 | 2018-12-20 02:56:25 -0800 | [diff] [blame] | 634 | |
spomorski | ab39ffb | 2018-10-02 11:19:32 -0700 | [diff] [blame] | 635 | |
| 636 | ### Conditional expansion |
| 637 | |
| 638 | Flag groups support conditional expansion based on the presence of a particular |
rosica | 29e91ca | 2019-02-18 02:46:34 -0800 | [diff] [blame] | 639 | variable or its field using the `expand_if_available`, `expand_if_not_available`, |
| 640 | `expand_if_true`, `expand_if_false`, or `expand_if_equal` attributes. For example: |
spomorski | ab39ffb | 2018-10-02 11:19:32 -0700 | [diff] [blame] | 641 | |
Laszlo Csomor | b2f0e26 | 2018-12-20 02:56:25 -0800 | [diff] [blame] | 642 | |
rosica | 29e91ca | 2019-02-18 02:46:34 -0800 | [diff] [blame] | 643 | flag_group ( |
| 644 | iterate_over = "libraries_to_link", |
| 645 | flag_groups = [ |
| 646 | flag_group ( |
| 647 | iterate_over = "libraries_to_link.shared_libraries", |
| 648 | flag_groups = [ |
| 649 | flag_group ( |
| 650 | expand_if_available = "libraries_to_link.shared_libraries.is_whole_archive", |
| 651 | flags = ["--whole_archive"], |
| 652 | ), |
| 653 | flag_group ( |
| 654 | flags = ["-l%{libraries_to_link.shared_libraries.name}"], |
| 655 | ), |
| 656 | flag_group ( |
| 657 | expand_if_available = "libraries_to_link.shared_libraries.is_whole_archive", |
| 658 | flags = ["--no_whole_archive"], |
| 659 | ), |
| 660 | ], |
| 661 | ), |
| 662 | ], |
| 663 | ) |
spomorski | ab39ffb | 2018-10-02 11:19:32 -0700 | [diff] [blame] | 664 | |
| 665 | **Note:** The `--whole_archive` and `--no_whole_archive` options are added to |
| 666 | the build command only when a currently iterated library has an |
| 667 | `is_whole_archive` field. |
| 668 | |
rosica | 29e91ca | 2019-02-18 02:46:34 -0800 | [diff] [blame] | 669 | ## `CcToolchainConfigInfo` reference |
spomorski | ab39ffb | 2018-10-02 11:19:32 -0700 | [diff] [blame] | 670 | |
| 671 | This section provides a reference of build variables, features, and other |
rosica | 29e91ca | 2019-02-18 02:46:34 -0800 | [diff] [blame] | 672 | information required to successfully configure C++ rules. |
spomorski | ab39ffb | 2018-10-02 11:19:32 -0700 | [diff] [blame] | 673 | |
rosica | 29e91ca | 2019-02-18 02:46:34 -0800 | [diff] [blame] | 674 | ### `CcToolchainConfigInfo` build variables |
spomorski | ab39ffb | 2018-10-02 11:19:32 -0700 | [diff] [blame] | 675 | |
rosica | 29e91ca | 2019-02-18 02:46:34 -0800 | [diff] [blame] | 676 | The following is a reference of `CcToolchainConfigInfo` build variables. |
spomorski | ab39ffb | 2018-10-02 11:19:32 -0700 | [diff] [blame] | 677 | |
Laszlo Csomor | b2f0e26 | 2018-12-20 02:56:25 -0800 | [diff] [blame] | 678 | **Note:** The **Action** column indicates the relevant action type, if applicable. |
spomorski | ab39ffb | 2018-10-02 11:19:32 -0700 | [diff] [blame] | 679 | |
| 680 | <table> |
spomorski | ab39ffb | 2018-10-02 11:19:32 -0700 | [diff] [blame] | 681 | <tr> |
| 682 | <td><strong>Variable</strong> |
| 683 | </td> |
Laszlo Csomor | b2f0e26 | 2018-12-20 02:56:25 -0800 | [diff] [blame] | 684 | <td><strong>Action</strong> |
| 685 | </td> |
spomorski | ab39ffb | 2018-10-02 11:19:32 -0700 | [diff] [blame] | 686 | <td><strong>Description</strong> |
| 687 | </td> |
| 688 | </tr> |
| 689 | <tr> |
| 690 | <td><strong><code>source_file</code></strong> |
| 691 | </td> |
Laszlo Csomor | b2f0e26 | 2018-12-20 02:56:25 -0800 | [diff] [blame] | 692 | <td>compile</td> |
| 693 | <td>Source file to compile. |
spomorski | ab39ffb | 2018-10-02 11:19:32 -0700 | [diff] [blame] | 694 | </td> |
| 695 | </tr> |
| 696 | <tr> |
| 697 | <td><strong><code>input_file</code></strong> |
| 698 | </td> |
Laszlo Csomor | b2f0e26 | 2018-12-20 02:56:25 -0800 | [diff] [blame] | 699 | <td>strip</td> |
| 700 | <td>Artifact to strip. |
spomorski | ab39ffb | 2018-10-02 11:19:32 -0700 | [diff] [blame] | 701 | </td> |
| 702 | </tr> |
| 703 | <tr> |
| 704 | <td><strong><code>output_file</code></strong> |
| 705 | </td> |
Laszlo Csomor | b2f0e26 | 2018-12-20 02:56:25 -0800 | [diff] [blame] | 706 | <td>compile</td> |
| 707 | <td>Compilation output. |
spomorski | ab39ffb | 2018-10-02 11:19:32 -0700 | [diff] [blame] | 708 | </td> |
| 709 | </tr> |
| 710 | <tr> |
| 711 | <td><strong><code>output_assembly_file</code></strong> |
| 712 | </td> |
Laszlo Csomor | b2f0e26 | 2018-12-20 02:56:25 -0800 | [diff] [blame] | 713 | <td>compile</td> |
| 714 | <td>Emitted assembly file. Applies only when the |
spomorski | ab39ffb | 2018-10-02 11:19:32 -0700 | [diff] [blame] | 715 | <code>compile</code> action emits assembly text, typically when using the |
| 716 | <code>--save_temps</code> flag. The contents are the same as for |
| 717 | <code>output_file</code>. |
| 718 | </td> |
| 719 | </tr> |
| 720 | <tr> |
| 721 | <td><strong><code>output_preprocess_file</code></strong> |
| 722 | </td> |
Laszlo Csomor | b2f0e26 | 2018-12-20 02:56:25 -0800 | [diff] [blame] | 723 | <td>compile</td> |
| 724 | <td>Preprocessed output. Applies only to compile |
spomorski | ab39ffb | 2018-10-02 11:19:32 -0700 | [diff] [blame] | 725 | actions that only preprocess the source files, typically when using the |
| 726 | <code>--save_temps</code> flag. The contents are the same as for |
| 727 | <code>output_file</code>. |
| 728 | </td> |
| 729 | </tr> |
| 730 | <tr> |
| 731 | <td><strong><code>includes</code></strong> |
| 732 | </td> |
Laszlo Csomor | b2f0e26 | 2018-12-20 02:56:25 -0800 | [diff] [blame] | 733 | <td>compile</td> |
| 734 | <td>Sequence of files the compiler must |
spomorski | ab39ffb | 2018-10-02 11:19:32 -0700 | [diff] [blame] | 735 | unconditionally include in the compiled source. |
| 736 | </td> |
| 737 | </tr> |
| 738 | <tr> |
| 739 | <td><strong><code>include_paths</code></strong> |
| 740 | </td> |
Laszlo Csomor | b2f0e26 | 2018-12-20 02:56:25 -0800 | [diff] [blame] | 741 | <td>compile</td> |
| 742 | <td>Sequence directories in which the compiler |
spomorski | ab39ffb | 2018-10-02 11:19:32 -0700 | [diff] [blame] | 743 | searches for headers included using <code>#include<foo.h></code> |
| 744 | and <code>#include "foo.h"</code>. |
| 745 | </td> |
| 746 | </tr> |
| 747 | <tr> |
| 748 | <td><strong><code>quote_include_paths</code></strong> |
hlopko | 9a14e42 | 2019-03-05 06:14:12 -0800 | [diff] [blame] | 749 | </td> |
Laszlo Csomor | b2f0e26 | 2018-12-20 02:56:25 -0800 | [diff] [blame] | 750 | <td>compile</td> |
Laszlo Csomor | b2f0e26 | 2018-12-20 02:56:25 -0800 | [diff] [blame] | 751 | <td>Sequence of <code>-iquote</code> includes - |
spomorski | ab39ffb | 2018-10-02 11:19:32 -0700 | [diff] [blame] | 752 | directories in which the compiler searches for headers included using |
Brian Silverman | 5fdeb6c | 2020-01-02 07:05:49 -0800 | [diff] [blame] | 753 | <code>#include "foo.h"</code>. |
spomorski | ab39ffb | 2018-10-02 11:19:32 -0700 | [diff] [blame] | 754 | </td> |
| 755 | </tr> |
| 756 | <tr> |
| 757 | <td><strong><code>system_include_paths</code></strong> |
| 758 | </td> |
Laszlo Csomor | b2f0e26 | 2018-12-20 02:56:25 -0800 | [diff] [blame] | 759 | <td>compile</td> |
| 760 | <td>Sequence of <code>-isystem</code> includes - |
spomorski | ab39ffb | 2018-10-02 11:19:32 -0700 | [diff] [blame] | 761 | directories in which the compiler searches for headers included using |
Brian Silverman | 5fdeb6c | 2020-01-02 07:05:49 -0800 | [diff] [blame] | 762 | <code>#include <foo.h></code>. |
spomorski | ab39ffb | 2018-10-02 11:19:32 -0700 | [diff] [blame] | 763 | </td> |
| 764 | </tr> |
| 765 | <tr> |
| 766 | <td><strong><code>dependency_file</code></strong> |
| 767 | </td> |
Laszlo Csomor | b2f0e26 | 2018-12-20 02:56:25 -0800 | [diff] [blame] | 768 | <td>compile</td> |
| 769 | <td>The <code>.d</code> dependency file generated by the compiler. |
spomorski | ab39ffb | 2018-10-02 11:19:32 -0700 | [diff] [blame] | 770 | </td> |
| 771 | </tr> |
| 772 | <tr> |
| 773 | <td><strong><code>preprocessor_defines</code></strong> |
| 774 | </td> |
Laszlo Csomor | b2f0e26 | 2018-12-20 02:56:25 -0800 | [diff] [blame] | 775 | <td>compile</td> |
| 776 | <td>Sequence of <code>defines</code>, such as <code>--DDEBUG</code>. |
spomorski | ab39ffb | 2018-10-02 11:19:32 -0700 | [diff] [blame] | 777 | </td> |
| 778 | </tr> |
| 779 | <tr> |
| 780 | <td><strong><code>pic</code></strong> |
| 781 | </td> |
Laszlo Csomor | b2f0e26 | 2018-12-20 02:56:25 -0800 | [diff] [blame] | 782 | <td>compile</td> |
| 783 | <td>Compiles the output as position-independent code. |
spomorski | ab39ffb | 2018-10-02 11:19:32 -0700 | [diff] [blame] | 784 | </td> |
| 785 | </tr> |
| 786 | <tr> |
| 787 | <td><strong><code>gcov_gcno_file</code></strong> |
| 788 | </td> |
Laszlo Csomor | b2f0e26 | 2018-12-20 02:56:25 -0800 | [diff] [blame] | 789 | <td>compile</td> |
| 790 | <td>The <code>gcov</code> coverage file. |
spomorski | ab39ffb | 2018-10-02 11:19:32 -0700 | [diff] [blame] | 791 | </td> |
| 792 | </tr> |
| 793 | <tr> |
| 794 | <td><strong><code>per_object_debug_info_file</code></strong> |
| 795 | </td> |
Laszlo Csomor | b2f0e26 | 2018-12-20 02:56:25 -0800 | [diff] [blame] | 796 | <td>compile</td> |
| 797 | <td>The per-object debug info (<code>.dwp</code>) file. |
spomorski | ab39ffb | 2018-10-02 11:19:32 -0700 | [diff] [blame] | 798 | </td> |
| 799 | </tr> |
| 800 | <tr> |
| 801 | <td><strong><code>stripotps</code></strong> |
| 802 | </td> |
Laszlo Csomor | b2f0e26 | 2018-12-20 02:56:25 -0800 | [diff] [blame] | 803 | <td>strip</td> |
| 804 | <td>Sequence of <code>stripopts</code>. |
spomorski | ab39ffb | 2018-10-02 11:19:32 -0700 | [diff] [blame] | 805 | </td> |
| 806 | </tr> |
| 807 | <tr> |
| 808 | <td><strong><code>legacy_compile_flags</code></strong> |
| 809 | </td> |
Laszlo Csomor | b2f0e26 | 2018-12-20 02:56:25 -0800 | [diff] [blame] | 810 | <td>compile</td> |
| 811 | <td>Sequence of flags from legacy |
| 812 | <code>CROSSTOOL</code> fields such as <code>compiler_flag</code>, |
| 813 | <code>optional_compiler_flag</code>, <code>cxx_flag</code>, and |
| 814 | <code>optional_cxx_flag</code>. |
spomorski | ab39ffb | 2018-10-02 11:19:32 -0700 | [diff] [blame] | 815 | </td> |
| 816 | </tr> |
| 817 | <tr> |
| 818 | <td><strong><code>user_compile_flags</code></strong> |
| 819 | </td> |
Laszlo Csomor | b2f0e26 | 2018-12-20 02:56:25 -0800 | [diff] [blame] | 820 | <td>compile</td> |
| 821 | <td>Sequence of flags from either the |
spomorski | ab39ffb | 2018-10-02 11:19:32 -0700 | [diff] [blame] | 822 | <code>copt</code> rule attribute or the <code>--copt</code>, |
| 823 | <code>--cxxopt</code>, and <code>--conlyopt</code> flags. |
| 824 | </td> |
| 825 | </tr> |
| 826 | <tr> |
| 827 | <td><strong><code>unfiltered_compile_flags</code></strong> |
| 828 | </td> |
Laszlo Csomor | b2f0e26 | 2018-12-20 02:56:25 -0800 | [diff] [blame] | 829 | <td>compile</td> |
| 830 | <td>Sequence of flags from the |
spomorski | 20ca4e1 | 2018-10-03 07:44:47 -0700 | [diff] [blame] | 831 | <code>unfiltered_cxx_flag</code> legacy <code>CROSSTOOL</code> field or the |
Laszlo Csomor | b2f0e26 | 2018-12-20 02:56:25 -0800 | [diff] [blame] | 832 | <code>unfiltered_compile_flags</code> feature. These are not filtered by |
spomorski | ab39ffb | 2018-10-02 11:19:32 -0700 | [diff] [blame] | 833 | the <code>nocopts</code> rule attribute. |
| 834 | </td> |
| 835 | </tr> |
| 836 | <tr> |
| 837 | <td><strong><code>sysroot</code></strong> |
| 838 | </td> |
Laszlo Csomor | b2f0e26 | 2018-12-20 02:56:25 -0800 | [diff] [blame] | 839 | <td></td> |
spomorski | ab39ffb | 2018-10-02 11:19:32 -0700 | [diff] [blame] | 840 | <td>The <code>sysroot</code>. |
| 841 | </td> |
| 842 | </tr> |
| 843 | <tr> |
| 844 | <td><strong><code>runtime_library_search_directories</code></strong> |
| 845 | </td> |
Laszlo Csomor | b2f0e26 | 2018-12-20 02:56:25 -0800 | [diff] [blame] | 846 | <td>link</td> |
| 847 | <td>Entries in the linker runtime search path (usually |
spomorski | ab39ffb | 2018-10-02 11:19:32 -0700 | [diff] [blame] | 848 | set with the <code>-rpath</code> flag). |
| 849 | </td> |
| 850 | </tr> |
| 851 | <tr> |
| 852 | <td><strong><code>library_search_directories</code></strong> |
| 853 | </td> |
Laszlo Csomor | b2f0e26 | 2018-12-20 02:56:25 -0800 | [diff] [blame] | 854 | <td>link</td> |
| 855 | <td>Entries in the linker search path (usually set with |
spomorski | ab39ffb | 2018-10-02 11:19:32 -0700 | [diff] [blame] | 856 | the <code>-L</code> flag). |
| 857 | </td> |
| 858 | </tr> |
| 859 | <tr> |
| 860 | <td><strong><code>libraries_to_link</code></strong> |
| 861 | </td> |
Laszlo Csomor | b2f0e26 | 2018-12-20 02:56:25 -0800 | [diff] [blame] | 862 | <td>link</td> |
| 863 | <td>Flags providing files to link as inputs in the linker invocation. |
spomorski | ab39ffb | 2018-10-02 11:19:32 -0700 | [diff] [blame] | 864 | </td> |
| 865 | </tr> |
| 866 | <tr> |
| 867 | <td><strong><code>def_file_path</code></strong> |
| 868 | </td> |
Laszlo Csomor | b2f0e26 | 2018-12-20 02:56:25 -0800 | [diff] [blame] | 869 | <td>link</td> |
| 870 | <td>Location of def file used on Windows with MSVC. |
spomorski | ab39ffb | 2018-10-02 11:19:32 -0700 | [diff] [blame] | 871 | </td> |
| 872 | </tr> |
| 873 | <tr> |
| 874 | <td><strong><code>linker_param_file</code></strong> |
| 875 | </td> |
Laszlo Csomor | b2f0e26 | 2018-12-20 02:56:25 -0800 | [diff] [blame] | 876 | <td>link</td> |
| 877 | <td>Location of linker param file created by bazel to |
spomorski | ab39ffb | 2018-10-02 11:19:32 -0700 | [diff] [blame] | 878 | overcome command line length limit. |
| 879 | </td> |
| 880 | </tr> |
| 881 | <tr> |
| 882 | <td><strong><code>output_execpath</code></strong> |
| 883 | </td> |
Laszlo Csomor | b2f0e26 | 2018-12-20 02:56:25 -0800 | [diff] [blame] | 884 | <td>link</td> |
| 885 | <td>Execpath of the output of the linker. |
spomorski | ab39ffb | 2018-10-02 11:19:32 -0700 | [diff] [blame] | 886 | </td> |
| 887 | </tr> |
| 888 | <tr> |
| 889 | <td><strong><code>generate_interface_library</code></strong> |
| 890 | </td> |
Laszlo Csomor | b2f0e26 | 2018-12-20 02:56:25 -0800 | [diff] [blame] | 891 | <td>link</td> |
| 892 | <td><code>"yes"</code> or <code>"no"</code> depending on whether interface library should |
| 893 | be generated. |
spomorski | ab39ffb | 2018-10-02 11:19:32 -0700 | [diff] [blame] | 894 | </td> |
| 895 | </tr> |
| 896 | <tr> |
| 897 | <td><strong><code>interface_library_builder_path</code></strong> |
| 898 | </td> |
Laszlo Csomor | b2f0e26 | 2018-12-20 02:56:25 -0800 | [diff] [blame] | 899 | <td>link</td> |
| 900 | <td>Path to the interface library builder tool. |
spomorski | ab39ffb | 2018-10-02 11:19:32 -0700 | [diff] [blame] | 901 | </td> |
| 902 | </tr> |
| 903 | <tr> |
| 904 | <td><strong><code>interface_library_input_path</code></strong> |
| 905 | </td> |
Laszlo Csomor | b2f0e26 | 2018-12-20 02:56:25 -0800 | [diff] [blame] | 906 | <td>link</td> |
| 907 | <td>Input for the interface library <code>ifso</code> builder tool. |
spomorski | ab39ffb | 2018-10-02 11:19:32 -0700 | [diff] [blame] | 908 | </td> |
| 909 | </tr> |
| 910 | <tr> |
| 911 | <td><strong><code>interface_library_output_path</code></strong> |
| 912 | </td> |
Laszlo Csomor | b2f0e26 | 2018-12-20 02:56:25 -0800 | [diff] [blame] | 913 | <td>link</td> |
| 914 | <td>Path where to generate interface library using the <code>ifso</code> builder tool. |
spomorski | ab39ffb | 2018-10-02 11:19:32 -0700 | [diff] [blame] | 915 | </td> |
| 916 | </tr> |
| 917 | <tr> |
| 918 | <td><strong><code>legacy_link_flags</code></strong> |
| 919 | </td> |
Laszlo Csomor | b2f0e26 | 2018-12-20 02:56:25 -0800 | [diff] [blame] | 920 | <td>link</td> |
hlopko | 7019131 | 2018-12-28 07:44:21 -0800 | [diff] [blame] | 921 | <td>Linker flags coming from the legacy <code>CROSSTOOL</code> fields. |
spomorski | ab39ffb | 2018-10-02 11:19:32 -0700 | [diff] [blame] | 922 | </td> |
| 923 | </tr> |
| 924 | <tr> |
| 925 | <td><strong><code>user_link_flags</code></strong> |
| 926 | </td> |
Laszlo Csomor | b2f0e26 | 2018-12-20 02:56:25 -0800 | [diff] [blame] | 927 | <td>link</td> |
| 928 | <td>Linker flags coming from the <code>--linkopt</code> |
spomorski | ab39ffb | 2018-10-02 11:19:32 -0700 | [diff] [blame] | 929 | or <code>linkopts</code> attribute. |
| 930 | </td> |
| 931 | </tr> |
| 932 | <tr> |
| 933 | <td><strong><code>symbol_counts_output</code></strong> |
| 934 | </td> |
Laszlo Csomor | b2f0e26 | 2018-12-20 02:56:25 -0800 | [diff] [blame] | 935 | <td>link</td> |
| 936 | <td>Path to which to write symbol counts. |
spomorski | ab39ffb | 2018-10-02 11:19:32 -0700 | [diff] [blame] | 937 | </td> |
| 938 | </tr> |
| 939 | <tr> |
| 940 | <td><strong><code>linkstamp_paths</code></strong> |
| 941 | </td> |
Laszlo Csomor | b2f0e26 | 2018-12-20 02:56:25 -0800 | [diff] [blame] | 942 | <td>link</td> |
| 943 | <td>A build variable giving linkstamp paths. |
spomorski | ab39ffb | 2018-10-02 11:19:32 -0700 | [diff] [blame] | 944 | </td> |
| 945 | </tr> |
| 946 | <tr> |
| 947 | <td><strong><code>force_pic</code></strong> |
| 948 | </td> |
Laszlo Csomor | b2f0e26 | 2018-12-20 02:56:25 -0800 | [diff] [blame] | 949 | <td>link</td> |
hlopko | 7019131 | 2018-12-28 07:44:21 -0800 | [diff] [blame] | 950 | <td>Presence of this variable indicates that PIC/PIE code should |
| 951 | be generated (Bazel option `--force_pic` was passed). |
spomorski | ab39ffb | 2018-10-02 11:19:32 -0700 | [diff] [blame] | 952 | </td> |
| 953 | </tr> |
| 954 | <tr> |
| 955 | <td><strong><code>strip_debug_symbols</code></strong> |
| 956 | </td> |
Laszlo Csomor | b2f0e26 | 2018-12-20 02:56:25 -0800 | [diff] [blame] | 957 | <td>link</td> |
| 958 | <td>Presence of this variable indicates that the debug |
spomorski | ab39ffb | 2018-10-02 11:19:32 -0700 | [diff] [blame] | 959 | symbols should be stripped. |
| 960 | </td> |
| 961 | </tr> |
| 962 | <tr> |
| 963 | <td><strong><code>is_cc_test</code></strong> |
| 964 | </td> |
Laszlo Csomor | b2f0e26 | 2018-12-20 02:56:25 -0800 | [diff] [blame] | 965 | <td>link</td> |
| 966 | <td>Truthy when current action is a <code>cc_test</code> |
spomorski | ab39ffb | 2018-10-02 11:19:32 -0700 | [diff] [blame] | 967 | linking action, false otherwise. |
| 968 | </td> |
| 969 | </tr> |
| 970 | <tr> |
| 971 | <td><strong><code>is_using_fission</code></strong> |
| 972 | </td> |
hlopko | 123d5ac | 2019-03-06 05:59:21 -0800 | [diff] [blame] | 973 | <td>compile, link</td> |
| 974 | <td>Presence of this variable indicates that fission (per-object debug info) |
| 975 | is activated. Debug info will be in <code>.dwo</code> files instead |
| 976 | of <code>.o</code> files and the compiler and linker need to know this. |
spomorski | ab39ffb | 2018-10-02 11:19:32 -0700 | [diff] [blame] | 977 | </td> |
| 978 | </tr> |
Googler | 3eb2f51 | 2019-04-09 09:54:01 -0700 | [diff] [blame] | 979 | <tr> |
| 980 | <td><strong><code>fdo_instrument_path</code></strong> |
| 981 | </td> |
| 982 | <td>compile, link</td> |
| 983 | <td> Path to the directory that stores FDO instrumentation profile. |
| 984 | </td> |
| 985 | </tr> |
| 986 | <tr> |
| 987 | <td><strong><code>fdo_profile_path</code></strong> |
| 988 | </td> |
| 989 | <td>compile</td> |
| 990 | <td> Path to FDO profile. |
| 991 | </td> |
| 992 | </tr> |
| 993 | <tr> |
| 994 | <td><strong><code>fdo_prefetch_hints_path</code></strong> |
| 995 | </td> |
| 996 | <td>compile</td> |
| 997 | <td> Path to the cache prefetch profile. |
| 998 | </td> |
| 999 | </tr> |
| 1000 | <tr> |
| 1001 | <td><strong><code>csfdo_instrument_path</code></strong> |
| 1002 | </td> |
| 1003 | <td>compile, link</td> |
| 1004 | <td> Path to the directory that stores context sensitive FDO |
| 1005 | instrumentation profile. |
| 1006 | </td> |
| 1007 | </tr> |
spomorski | ab39ffb | 2018-10-02 11:19:32 -0700 | [diff] [blame] | 1008 | </table> |
| 1009 | |
| 1010 | |
| 1011 | |
hlopko | 0762948 | 2018-12-20 00:28:26 -0800 | [diff] [blame] | 1012 | ### Well-known features |
spomorski | ab39ffb | 2018-10-02 11:19:32 -0700 | [diff] [blame] | 1013 | |
rosica | 29e91ca | 2019-02-18 02:46:34 -0800 | [diff] [blame] | 1014 | The following is a reference of features and their activation |
spomorski | ab39ffb | 2018-10-02 11:19:32 -0700 | [diff] [blame] | 1015 | conditions. |
| 1016 | |
| 1017 | <table> |
| 1018 | <col width="300"> |
| 1019 | <col width="600"> |
| 1020 | <tr> |
| 1021 | <td><strong>Feature</strong> |
| 1022 | </td> |
hlopko | 0762948 | 2018-12-20 00:28:26 -0800 | [diff] [blame] | 1023 | <td><strong>Documentation</strong> |
spomorski | ab39ffb | 2018-10-02 11:19:32 -0700 | [diff] [blame] | 1024 | </td> |
| 1025 | </tr> |
| 1026 | <tr> |
| 1027 | <td><strong><code>opt | dbg | fastbuild</code></strong> |
| 1028 | </td> |
| 1029 | <td>Enabled by default based on compilation mode. |
| 1030 | </td> |
| 1031 | </tr> |
| 1032 | <tr> |
| 1033 | <td><strong><code>static_linking_mode | dynamic_linking_mode</code></strong> |
| 1034 | </td> |
| 1035 | <td>Enabled by default based on linking mode. |
| 1036 | </td> |
| 1037 | </tr> |
| 1038 | <tr> |
spomorski | ab39ffb | 2018-10-02 11:19:32 -0700 | [diff] [blame] | 1039 | <td><strong><code>per_object_debug_info</code></strong> |
| 1040 | </td> |
rosica | 29e91ca | 2019-02-18 02:46:34 -0800 | [diff] [blame] | 1041 | <td>Enabled if the <code>supports_fission</code> feature is specified and |
| 1042 | enabled and the current compilation mode is specified in the |
spomorski | 20ca4e1 | 2018-10-03 07:44:47 -0700 | [diff] [blame] | 1043 | <code>--fission</code> flag. |
spomorski | ab39ffb | 2018-10-02 11:19:32 -0700 | [diff] [blame] | 1044 | </td> |
| 1045 | </tr> |
| 1046 | <tr> |
hlopko | 0762948 | 2018-12-20 00:28:26 -0800 | [diff] [blame] | 1047 | <td><strong><code>supports_start_end_lib</code></strong> |
| 1048 | </td> |
| 1049 | <td>If enabled (and the option <code>--start_end_lib</code> is set), Bazel |
| 1050 | will not link against static libraries but instead use the |
| 1051 | <code>--start-lib/--end-lib</code> linker options to link against objects |
| 1052 | directly. This speeds up the build since Bazel doesn't have to build |
| 1053 | static libraries. |
| 1054 | </td> |
| 1055 | </tr> |
hlopko | a5ba344 | 2018-12-20 01:58:43 -0800 | [diff] [blame] | 1056 | <tr> |
| 1057 | <td><strong><code>supports_interface_shared_libraries</code></strong> |
| 1058 | </td> |
| 1059 | <td>If enabled (and the option <code>--interface_shared_objects</code> is |
| 1060 | set), Bazel will link targets that have <code>linkstatic</code> set to |
| 1061 | False (<code>cc_test</code>s by default) against interface shared |
| 1062 | libraries. This makes incremental relinking faster. |
| 1063 | </td> |
| 1064 | </tr> |
hlopko | 8098e59 | 2018-12-22 14:45:24 -0800 | [diff] [blame] | 1065 | <tr> |
| 1066 | <td><strong><code>supports_dynamic_linker</code></strong> |
| 1067 | </td> |
| 1068 | <td>If enabled, C++ rules will know the toolchain can produce shared |
| 1069 | libraries. |
| 1070 | </td> |
| 1071 | </tr> |
hlopko | d717118 | 2018-12-27 07:09:21 -0800 | [diff] [blame] | 1072 | <tr> |
| 1073 | <td><strong><code>static_link_cpp_runtimes</code></strong> |
| 1074 | </td> |
| 1075 | <td>If enabled, Bazel will link the C++ runtime statically in static linking |
| 1076 | mode and dynamically in dynamic linking mode. Artifacts |
| 1077 | specified in the <code>cc_toolchain.static_runtime_lib</code> or |
| 1078 | <code>cc_toolchain.dynamic_runtime_lib</code> attribute (depending on the |
| 1079 | linking mode) will be added to the linking actions. |
| 1080 | </td> |
| 1081 | </tr> |
hlopko | 7019131 | 2018-12-28 07:44:21 -0800 | [diff] [blame] | 1082 | <tr> |
| 1083 | <td><strong><code>supports_pic</code></strong> |
| 1084 | </td> |
| 1085 | <td>If enabled, toolchain will know to use PIC objects for dynamic libraries. |
| 1086 | The `pic` variable is present whenever PIC compilation is needed. If not enabled |
| 1087 | by default, and `--force_pic` is passed, Bazel will request `supports_pic` and |
| 1088 | validate that the feature is enabled. If the feature is missing, or couldn't |
| 1089 | be enabled, `--force_pic` cannot be used. |
| 1090 | </td> |
| 1091 | </tr> |
hlopko | ee8b357 | 2019-01-15 02:49:55 -0800 | [diff] [blame] | 1092 | <tr> |
| 1093 | <td> |
| 1094 | <strong><code>static_linking_mode | dynamic_linking_mode</code></strong> |
| 1095 | </td> |
| 1096 | <td>Enabled by default based on linking mode.</td> |
| 1097 | </tr> |
| 1098 | <tr> |
| 1099 | <td><strong><code>no_legacy_features</code></strong> |
| 1100 | </td> |
| 1101 | <td> |
| 1102 | Prevents Bazel from adding legacy features to |
rosica | 29e91ca | 2019-02-18 02:46:34 -0800 | [diff] [blame] | 1103 | the C++ configuration when present. See the complete list of |
hlopko | ee8b357 | 2019-01-15 02:49:55 -0800 | [diff] [blame] | 1104 | features below. |
| 1105 | </td> |
| 1106 | </tr> |
spomorski | ab39ffb | 2018-10-02 11:19:32 -0700 | [diff] [blame] | 1107 | </table> |
hlopko | ee8b357 | 2019-01-15 02:49:55 -0800 | [diff] [blame] | 1108 | |
| 1109 | #### Legacy features patching logic |
| 1110 | |
| 1111 | <p> |
| 1112 | Bazel does following changes to the features and their order to stay backwards |
| 1113 | compatible: |
| 1114 | |
| 1115 | <ul> |
| 1116 | <li>Moves <code>legacy_compile_flags</code> feature to the top of the toolchain</li> |
| 1117 | <li>Moves <code>default_compile_flags</code> feature to the top of the toolchain</li> |
| 1118 | <li>Adds <code>dependency_file</code> (if not present) feature to the top of the toolchain</li> |
| 1119 | <li>Adds <code>pic</code> (if not present) feature to the top of the toolchain</li> |
| 1120 | <li>Adds <code>per_object_debug_info</code> (if not present) feature to the top of the toolchain</li> |
| 1121 | <li>Adds <code>preprocessor_defines</code> (if not present) feature to the top of the toolchain</li> |
| 1122 | <li>Adds <code>includes</code> (if not present) feature to the top of the toolchain</li> |
| 1123 | <li>Adds <code>include_paths</code> (if not present) feature to the top of the toolchain</li> |
| 1124 | <li>Adds <code>fdo_instrument</code> (if not present) feature to the top of the toolchain</li> |
| 1125 | <li>Adds <code>fdo_optimize</code> (if not present) feature to the top of the toolchain</li> |
Googler | 3eb2f51 | 2019-04-09 09:54:01 -0700 | [diff] [blame] | 1126 | <li>Adds <code>cs_fdo_instrument</code> (if not present) feature to the top of the toolchain</li> |
| 1127 | <li>Adds <code>cs_fdo_optimize</code> (if not present) feature to the top of the toolchain</li> |
hlopko | ee8b357 | 2019-01-15 02:49:55 -0800 | [diff] [blame] | 1128 | <li>Adds <code>fdo_prefetch_hints</code> (if not present) feature to the top of the toolchain</li> |
| 1129 | <li>Adds <code>autofdo</code> (if not present) feature to the top of the toolchain</li> |
| 1130 | <li>Adds <code>build_interface_libraries</code> (if not present) feature to the top of the toolchain</li> |
| 1131 | <li>Adds <code>dynamic_library_linker_tool</code> (if not present) feature to the top of the toolchain</li> |
| 1132 | <li>Adds <code>symbol_counts</code> (if not present) feature to the top of the toolchain</li> |
| 1133 | <li>Adds <code>shared_flag</code> (if not present) feature to the top of the toolchain</li> |
| 1134 | <li>Adds <code>linkstamps</code> (if not present) feature to the top of the toolchain</li> |
| 1135 | <li>Adds <code>output_execpath_flags</code> (if not present) feature to the top of the toolchain</li> |
| 1136 | <li>Adds <code>runtime_library_search_directories</code> (if not present) feature to the top of the toolchain</li> |
| 1137 | <li>Adds <code>library_search_directories</code> (if not present) feature to the top of the toolchain</li> |
| 1138 | <li>Adds <code>archiver_flags</code> (if not present) feature to the top of the toolchain</li> |
| 1139 | <li>Adds <code>libraries_to_link</code> (if not present) feature to the top of the toolchain</li> |
| 1140 | <li>Adds <code>force_pic_flags</code> (if not present) feature to the top of the toolchain</li> |
| 1141 | <li>Adds <code>user_link_flags</code> (if not present) feature to the top of the toolchain</li> |
| 1142 | <li>Adds <code>legacy_link_flags</code> (if not present) feature to the top of the toolchain</li> |
| 1143 | <li>Adds <code>static_libgcc</code> (if not present) feature to the top of the toolchain</li> |
| 1144 | <li>Adds <code>fission_support</code> (if not present) feature to the top of the toolchain</li> |
| 1145 | <li>Adds <code>strip_debug_symbols</code> (if not present) feature to the top of the toolchain</li> |
| 1146 | <li>Adds <code>coverage</code> (if not present) feature to the top of the toolchain</li> |
| 1147 | <li>Adds <code>llvm_coverage_map_format</code> (if not present) feature to the top of the toolchain</li> |
| 1148 | <li>Adds <code>gcc_coverage_map_format</code> (if not present) feature to the top of the toolchain</li> |
| 1149 | <li>Adds <code>fully_static_link</code> (if not present) feature to the bottom of the toolchain</li> |
| 1150 | <li>Adds <code>user_compile_flags</code> (if not present) feature to the bottom of the toolchain</li> |
| 1151 | <li>Adds <code>sysroot</code> (if not present) feature to the bottom of the toolchain</li> |
| 1152 | <li>Adds <code>unfiltered_compile_flags</code> (if not present) feature to the bottom of the toolchain</li> |
| 1153 | <li>Adds <code>linker_param_file</code> (if not present) feature to the bottom of the toolchain</li> |
| 1154 | <li>Adds <code>compiler_input_flags</code> (if not present) feature to the bottom of the toolchain</li> |
| 1155 | <li>Adds <code>compiler_output_flags</code> (if not present) feature to the bottom of the toolchain</li> |
| 1156 | </ul> |
| 1157 | </p> |
| 1158 | |
| 1159 | This is a long list of features. The plan is to get rid of them once |
| 1160 | [Crosstool in Starlark](https://github.com/bazelbuild/bazel/issues/5380) is |
| 1161 | done. For the curious reader see the implementation in |
| 1162 | [CppActionConfigs](https://source.bazel.build/bazel/+/master:src/main/java/com/google/devtools/build/lib/rules/cpp/CppActionConfigs.java?q=cppactionconfigs&ss=bazel), |
| 1163 | and for production toolchains consider adding `no_legacy_features` to make |
| 1164 | the toolchain more standalone. |
| 1165 | |