---
source: https://iinventedlight.com/library/notes/bazel-select.md
title: "Vary a Bazel attribute by configuration with select()"
license: CC-BY-4.0
license_url: https://creativecommons.org/licenses/by/4.0/
source_license: "Apache-2.0 (Bazel docs); Apache-2.0 (Bazel source); prose restates cited source lines in own words"
license_family: mixed-green
attribution: "Summary by iinventedlight (AI-assisted). Sources: Bazel docs, Configurable Build Attributes; Bazel source, SelectorList.java. Apache-2.0; Apache-2.0."
author: "iinventedlight (synthesis of cited sources); text drafted with AI assistance"
date: 2026-11-19
status: published
approved_by: "Cole Withington, 2026-11-20 13:14 PT: \"Publish the full batch and rewrite the 6 live notes\""
checked_on: 2026-11-19
as_of: 2026-11-19
confidence: medium
untested: "Not reproduced (2026-11-19). Official docs and source files were read; no test suite, server, or API call was run for this note."
category: coding-references
topic_area: "code-devops: Bazel select and configurable attributes"
tags: [bazel, select, config_setting, configurable-attributes]
client: Librarian
sources:
  - id: S1
    title: "Configurable Build Attributes"
    publisher: Bazel docs
    url: https://bazel.build/configure/attributes
    accessed: 2026-11-19
    license: "Apache-2.0"
  - id: S2
    title: "SelectorList.java"
    publisher: Bazel source
    url: https://raw.githubusercontent.com/bazelbuild/bazel/master/src/main/java/com/google/devtools/build/lib/packages/SelectorList.java
    accessed: 2026-11-19
    license: "Apache-2.0"
---
# Vary a Bazel attribute by configuration with select()
**Answer:** Configurable attributes, commonly known as `select()`, is a Bazel feature that lets users toggle attribute values at the command line. In source, `SelectorList` contains the implementation of the Starlark `select()` function exposed to BUILD and `.bzl` files.

## Conditions

`select()` is a placeholder whose value is chosen from configuration conditions. The conditions are labels that reference a `config_setting`. The example includes a `//conditions:default` key.

A `cc_binary` can choose `deps` from flags. With `--cpu=arm` the value is `[":arm_lib"]`. With `-c dbg` and `--cpu=x86` it is `[":x86_dev_lib"]`. With `--cpu=ppc` it is `[":generic_lib"]`, including when `-c dbg` is also set.

| deps | config_setting |
|---|---|
| `[":arm_lib"]` | `{"cpu": "arm"}` |
| `[":x86_dev_lib"]` | `{"cpu": "x86", "compilation_mode": "dbg"}` |
| `[":generic_lib"]` | `//conditions:default` |

## Empty dictionaries

The implementation reports that `select({})` with an empty dictionary can never resolve because it includes no conditions. `SelectorList` can wrap a single value. `SelectorList.concat` creates a list that concatenates two values.

## See also

- [bazel-visibility](https://iinventedlight.com/library/notes/bazel-visibility/)
- [bazel-sandboxing](https://iinventedlight.com/library/notes/bazel-sandboxing/)

## Claims

- id: C1
  claim: select() lets users toggle build rule attribute values from the command line.
  source: S1
  evidence: "lets users toggle the values of build rule attributes at the command line"

- id: C2
  claim: select() chooses among configuration conditions that are labels referencing config_setting.
  source: S1
  evidence: "which are labels referencing [`config_setting`]"

- id: C3
  claim: Bazel's SelectorList class implements the Starlark select() function for BUILD and .bzl files.
  source: S2
  evidence: "Implementation of the Starlark {@code select()} function exposed to BUILD and .bzl files."

## Sources

- [S1] Configurable Build Attributes. Bazel docs. https://bazel.build/configure/attributes . License: Apache-2.0. Accessed 2026-11-19.

- [S2] SelectorList.java. Bazel source. https://raw.githubusercontent.com/bazelbuild/bazel/master/src/main/java/com/google/devtools/build/lib/packages/SelectorList.java . License: Apache-2.0. Accessed 2026-11-19.

License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: Bazel docs, Configurable Build Attributes; Bazel source, SelectorList.java. Apache-2.0; Apache-2.0. Text was condensed and changed from the originals.

---

Agents: [/agents.md](/agents.md) | [/.well-known/agent-library.json](/.well-known/agent-library.json).
