aboutsummaryrefslogtreecommitdiffhomepage
path: root/site
diff options
context:
space:
mode:
authorGravatar jcater <jcater@google.com>2018-06-12 08:28:48 -0700
committerGravatar Copybara-Service <copybara-piper@google.com>2018-06-12 08:30:28 -0700
commit06325053ff3ccfd3f6b119a57b6ebd3d8cfc6efb (patch)
tree0ee5f9211f8222ed6274993ad5603634eec79b89 /site
parent2eff4fdbd1dd89877098010ab3f672687fc008b6 (diff)
Platform documentation fixes.
PiperOrigin-RevId: 200218884
Diffstat (limited to 'site')
-rw-r--r--site/docs/platforms.md16
-rw-r--r--site/docs/toolchains.md35
2 files changed, 33 insertions, 18 deletions
diff --git a/site/docs/platforms.md b/site/docs/platforms.md
index 8cdc3d7e3f..c746b189c2 100644
--- a/site/docs/platforms.md
+++ b/site/docs/platforms.md
@@ -16,7 +16,8 @@ Bazel can build and test code on a variety of operating systems and hardware
using many different build tools, such as linkers and compilers. These
combinations of software and hardware are what Bazel considers *platforms*.
One major use for specifying a platform for a build is automatic
-[toolchain](toolchains.html) selection.
+[toolchain](toolchains.html)
+selection.
Bazel recognizes the following types of platforms:
@@ -46,14 +47,11 @@ version of a build tool, such as a linker or compiler.
You define a platform in a `BUILD` file using the following Bazel rules:
-* [`constraint_setting`](be/platform.html#constraint_setting) - defines a
- constraint.
+* [`constraint_setting`](be/platform.html#constraint_setting) - defines a constraint.
-* [`constraint_value`](be/platform.html#constraint_value) - defines an allowed
- value for a constraint.
+* [`constraint_value`](be/platform.html#constraint_value) - defines an allowed value for a constraint.
-* [`platform`](be/platform.html#platform) - defines a platform by specifying
- a set of constraints and their values.
+* [`platform`](be/platform.html#platform) - defines a platform by specifying a set of constraints and their values.
The following example defines the `glibc_version` constraint and its two allowed
values. It then defines a platform that uses the `glibc_version` constraint
@@ -129,5 +127,7 @@ command-line flags:
* `--platforms` - defaults to `@bazel_tools//platforms:target_platform`
Platforms can also be used with the `config_setting` rule to define configurable
-attributes. See [config_setting](be/general.html#config_setting) for more
+attributes. See
+[config_setting](be/general.html#config_setting)
+for more
details.
diff --git a/site/docs/toolchains.md b/site/docs/toolchains.md
index 0458ea6860..4a06771bc4 100644
--- a/site/docs/toolchains.md
+++ b/site/docs/toolchains.md
@@ -16,14 +16,17 @@ title: Toolchains
## Overview
-A *Bazel toolchain* is a configuration [provider](skylark/rules.html#providers)
+A *Bazel toolchain* is a configuration
+[provider](skylark/rules.html#providers)
that tells a build rule what build tools, such as compilers and linkers, to use
and how to configure them using parameters defined by the rule's creator.
When a build runs, Bazel performs toolchain resolution based on the specified
-[execution and target platforms](platforms.html) to determine and apply the
+[execution and target platforms](platforms.html)
+to determine and apply the
toolchain most appropriate to that build. It does so by matching the
-[constraints](platforms.html#defining-a-platform) specified in the project's
+[constraints](platforms.html#defining-a-platform)
+specified in the project's
`BUILD` file(s) with the constraints specified in the toolchain definition.
## Toolchain Resolution
@@ -34,13 +37,21 @@ platform and a toolchain type-to-toolchain map. Toolchain resolution works as fo
1. Collect all available execution platforms, including the host. This is an ordered list.
- Execution platforms are collected from the following sources:
- 1. Any extra execution platforms given on the command line via the [--extra_execution_platforms](https://docs.bazel.build/versions/master/command-line-reference.html#flag--extra_execution_platforms) flag.
- 2. Any execution platforms in the `WORKSPACE` file, via the [register_execution_platforms](https://docs.bazel.build/versions/master/skylark/lib/globals.html#register_execution_platforms) function.
+ 1. Any extra execution platforms given on the command line via the
+ [`--extra_execution_platforms`](https://docs.bazel.build/versions/master/command-line-reference.html#flag--extra_execution_platforms)
+ flag.
+ 2. Any execution platforms in the `WORKSPACE` file, via the
+ [`register_execution_platforms`](https://docs.bazel.build/versions/master/skylark/lib/globals.html#register_execution_platforms)
+ function.
3. The host platform.
2. Collect all available toolchains. This is also an ordered list.
- Toolchains are collected from the following sources:
- 1. Any extra toolchains given on the command line via the [--extra_toolchains](https://docs.bazel.build/versions/master/command-line-reference.html#flag--extra_toolchains)` flag.
- 2. Any toolchains in the `WORKSPACE` file, via the [register_toolchains](https://docs.bazel.build/versions/master/skylark/lib/globals.html#register_toolchains) function.
+ 1. Any extra toolchains given on the command line via the
+ [`--extra_toolchains`](https://docs.bazel.build/versions/master/command-line-reference.html#flag--extra_toolchains)
+ flag.
+ 2. Any toolchains in the `WORKSPACE` file, via the
+ [`register_toolchains`](https://docs.bazel.build/versions/master/skylark/lib/globals.html#register_toolchains)
+ function.
3. For each toolchain type and execution platform, select the first toolchain that matches the execution platform and target platform.
4. With the full set of toolchains and execution platforms for each type, select the first execution platform that can satisfy all toolchain types.
@@ -58,14 +69,18 @@ Defining a toolchain requires the following:
* **Toolchain rule** - a rule invoked in a custom build or test rule that
specifies the build tool configuration options particular to the toolchain
- and supported [platforms](platforms.html) (for example, [`go_toolchain`](https://github.com/bazelbuild/rules_go/blob/master/go/private/go_toolchain.bzl)).
- This rule must return a [`ToolchainInfo` provider](skylark/lib/platform_common.html#ToolchainInfo).
+ and supported
+ [platforms](platforms.html)
+ (for example, [`go_toolchain`](https://github.com/bazelbuild/rules_go/blob/master/go/private/go_toolchain.bzl)).
+ This rule must return a
+ [`ToolchainInfo` provider](skylark/lib/platform_common.html#ToolchainInfo).
The toolchain rule is lazily instantiated by Bazel on an as-needed basis.
Because of this, a toolchain rule's dependencies can be as complex as needed,
including reliance on remote repositories, without affecting builds that do
not use them.
-* **Toolchain definition** - tells Bazel which [platform constraints](platforms.html#defining-a-platform)
+* **Toolchain definition** - tells Bazel which
+ [platform constraints](platforms.html#defining-a-platform)
apply to the toolchain using the `toolchain()` rule. This rule must specify a
unique toolchain type label, which is used as input during toolchain
resolution.