@@ -142,6 +142,34 @@ supporting `<`, `<=`, `>`, `>=`, `==`, `!=`. Examples:
142142- ` latest:>17.0.4,!=19.1.7,<=20.1.0 `
143143- ` first:>=15.0.6,<16 `
144144
145+ It is further possible to provide the version or requirement from an environment
146+ variable with a fallback version or requirement. In this case it is important to
147+ also use the bazel flag ` --repo_env=LLVM_VERSION=version_or_requirement ` . It is
148+ important to use both correctly because otherwise the resulting builds are not
149+ reproducible. The main purpose of using an environment variable to encode the
150+ version for integration or batch testing on multiple platforms where multiple
151+ LLVM versions should be tested.
152+
153+ - ` getenv(ENVIRONMENT_VARIABLE_NAME,fallback) `
154+
155+ Example ` MODULE.bazel `
156+
157+ ``` starlark
158+ llvm.toolchain(
159+ name = " llvm_toolchain" ,
160+ llvm_versions = {
161+ " " : " getenv(LLVM_VERSION,latest:>=17.0.0,<20)" ,
162+ " darwin-x86_64" : " 15.0.7" , # Verify this works as opposed to using one version.
163+ },
164+ )
165+ ```
166+
167+ In this example, MacOS x86 machines have their LLVM version hard-coded to
168+ ` 15.0.7 ` . For all other targets the LLVM version is read from the environment
169+ variable ` LLVM_VERSION ` which must be referenced on the Bazel command line as
170+ explained above. If the variable is not present, then the LLVM version defaults
171+ to the requirement expression ` latest:>=17.0.0,<20 ` .
172+
145173### Selecting Toolchains
146174
147175If toolchains are registered (see Quickstart section above), you do not need to
0 commit comments