Skip to content

Commit

Permalink
🚩 Lift flags to configurations (#240)
Browse files Browse the repository at this point in the history
Previously we passed Nix-specific configuration globally to Bazel's
`action_env`. This caused every change in the Nix configs to invalidate
the entire build graph.

The new setup no longer influences any `rules_cc` invocations and
selectively injects flags only into the transitioned `ll_toolchains`
when they're actually needed. This maximizes the potential for cache
reuse after changing the nix configuration and is overall a more modular
and idiomatic approach.

The new flags may be manually overridden via e.g.
`--@rules_ll//ll:LL_CFLAGS=x:y:z`.

This change also introduces `*_string_flags` attributes for `ll_*` rules
which may be used to pass in Bazel-Skylib's `string_flag` targets to
`ll_*` targets. These new flags follow the common pattern of supporting
multiple arguments, separated by colons.
  • Loading branch information
aaronmondal committed May 18, 2024
1 parent df72102 commit 5ac0546
Show file tree
Hide file tree
Showing 22 changed files with 307 additions and 143 deletions.
1 change: 1 addition & 0 deletions .github/styles/config/vocabularies/eomii/accept.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ backend
buildable
bundler
eomii
glibc
hermeticity
intrinsics
lockfile
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ share caches.
and set `comment.allowUnfree` and `config.cudaSupport` in `flake.nix`.

> [!WARNING]
> Don't use the tags or releases from the GitHub repository. They're an artifact
> from old versions of `rules_ll` and probably in a broken state. We'll remove
> them at some point. Use a pinned commit instead.
> Don't use the tags or releases from the GitHub repository. They were used in
> old versions of `rules_ll` and probably in a broken state. Use a pinned commit
> instead.
3. Enter the `rules_ll` development shell:
Expand Down
2 changes: 1 addition & 1 deletion devtools/up.nix
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ let
nix = pkgs.nix;

# The specific commit to use
nativelinkCommit = "8a632953b86395088e4ab8c1e160a650739549b7";
nativelinkCommit = "75105df746c626da76f74e412764e6755296a8ab";

# Base URL for GitHub access
githubBaseUrl = "github:TraceMachina/nativelink/";
Expand Down
2 changes: 1 addition & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ dependency graph.
- [Examples](https://github.com/eomii/rules_ll/tree/main/examples)
- [Guides](guides/index.md)

If you have questions regarding remote execution, consider asking for help in
If you have questions about remote execution, consider asking for help in
the [NativeLink Slack](https://nativelink.slack.com/join/shared_invite/zt-281qk1ho0-krT7HfTUIYfQMdwflRuq7A#/shared-invite/email).
33 changes: 21 additions & 12 deletions docs/reference/defs.md

Large diffs are not rendered by default.

33 changes: 21 additions & 12 deletions docs/reference/ll.md

Large diffs are not rendered by default.

22 changes: 16 additions & 6 deletions docs/reference/toolchain.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,28 @@ This file declares the `ll_toolchain` rule.

## `ll_toolchain`

<pre><code>ll_toolchain(<a href="#ll_toolchain-name">name</a>, <a href="#ll_toolchain-address_sanitizer">address_sanitizer</a>, <a href="#ll_toolchain-archiver">archiver</a>, <a href="#ll_toolchain-bitcode_linker">bitcode_linker</a>, <a href="#ll_toolchain-builtin_includes">builtin_includes</a>, <a href="#ll_toolchain-c_driver">c_driver</a>,
<a href="#ll_toolchain-clang_tidy">clang_tidy</a>, <a href="#ll_toolchain-clang_tidy_runner">clang_tidy_runner</a>, <a href="#ll_toolchain-compiler_runtime">compiler_runtime</a>, <a href="#ll_toolchain-cov">cov</a>, <a href="#ll_toolchain-cpp_abihdrs">cpp_abihdrs</a>, <a href="#ll_toolchain-cpp_abilib">cpp_abilib</a>,
<a href="#ll_toolchain-cpp_driver">cpp_driver</a>, <a href="#ll_toolchain-cpp_stdhdrs">cpp_stdhdrs</a>, <a href="#ll_toolchain-cpp_stdlib">cpp_stdlib</a>, <a href="#ll_toolchain-hip_libraries">hip_libraries</a>, <a href="#ll_toolchain-hip_runtime">hip_runtime</a>, <a href="#ll_toolchain-leak_sanitizer">leak_sanitizer</a>, <a href="#ll_toolchain-linker">linker</a>,
<a href="#ll_toolchain-linker_wrapper">linker_wrapper</a>, <a href="#ll_toolchain-llvm_project_deps">llvm_project_deps</a>, <a href="#ll_toolchain-machine_code_tool">machine_code_tool</a>, <a href="#ll_toolchain-memory_sanitizer">memory_sanitizer</a>, <a href="#ll_toolchain-objcopy">objcopy</a>,
<a href="#ll_toolchain-offload_bundler">offload_bundler</a>, <a href="#ll_toolchain-offload_packager">offload_packager</a>, <a href="#ll_toolchain-opt">opt</a>, <a href="#ll_toolchain-profdata">profdata</a>, <a href="#ll_toolchain-profile">profile</a>, <a href="#ll_toolchain-rocm_device_libs">rocm_device_libs</a>, <a href="#ll_toolchain-symbolizer">symbolizer</a>,
<a href="#ll_toolchain-thread_sanitizer">thread_sanitizer</a>, <a href="#ll_toolchain-undefined_behavior_sanitizer">undefined_behavior_sanitizer</a>, <a href="#ll_toolchain-unwind_library">unwind_library</a>)</code></pre>
<pre><code>ll_toolchain(<a href="#ll_toolchain-name">name</a>, <a href="#ll_toolchain-LL_AMD_INCLUDES">LL_AMD_INCLUDES</a>, <a href="#ll_toolchain-LL_AMD_LIBRARIES">LL_AMD_LIBRARIES</a>, <a href="#ll_toolchain-LL_CFLAGS">LL_CFLAGS</a>, <a href="#ll_toolchain-LL_CUDA_DRIVER">LL_CUDA_DRIVER</a>, <a href="#ll_toolchain-LL_CUDA_RUNTIME">LL_CUDA_RUNTIME</a>,
<a href="#ll_toolchain-LL_CUDA_TOOLKIT">LL_CUDA_TOOLKIT</a>, <a href="#ll_toolchain-LL_DYNAMIC_LINKER">LL_DYNAMIC_LINKER</a>, <a href="#ll_toolchain-LL_LDFLAGS">LL_LDFLAGS</a>, <a href="#ll_toolchain-address_sanitizer">address_sanitizer</a>, <a href="#ll_toolchain-archiver">archiver</a>,
<a href="#ll_toolchain-bitcode_linker">bitcode_linker</a>, <a href="#ll_toolchain-builtin_includes">builtin_includes</a>, <a href="#ll_toolchain-c_driver">c_driver</a>, <a href="#ll_toolchain-clang_tidy">clang_tidy</a>, <a href="#ll_toolchain-clang_tidy_runner">clang_tidy_runner</a>,
<a href="#ll_toolchain-compiler_runtime">compiler_runtime</a>, <a href="#ll_toolchain-cov">cov</a>, <a href="#ll_toolchain-cpp_abihdrs">cpp_abihdrs</a>, <a href="#ll_toolchain-cpp_abilib">cpp_abilib</a>, <a href="#ll_toolchain-cpp_driver">cpp_driver</a>, <a href="#ll_toolchain-cpp_stdhdrs">cpp_stdhdrs</a>, <a href="#ll_toolchain-cpp_stdlib">cpp_stdlib</a>,
<a href="#ll_toolchain-hip_libraries">hip_libraries</a>, <a href="#ll_toolchain-hip_runtime">hip_runtime</a>, <a href="#ll_toolchain-leak_sanitizer">leak_sanitizer</a>, <a href="#ll_toolchain-linker">linker</a>, <a href="#ll_toolchain-linker_wrapper">linker_wrapper</a>, <a href="#ll_toolchain-llvm_project_deps">llvm_project_deps</a>,
<a href="#ll_toolchain-machine_code_tool">machine_code_tool</a>, <a href="#ll_toolchain-memory_sanitizer">memory_sanitizer</a>, <a href="#ll_toolchain-objcopy">objcopy</a>, <a href="#ll_toolchain-offload_bundler">offload_bundler</a>, <a href="#ll_toolchain-offload_packager">offload_packager</a>, <a href="#ll_toolchain-opt">opt</a>,
<a href="#ll_toolchain-profdata">profdata</a>, <a href="#ll_toolchain-profile">profile</a>, <a href="#ll_toolchain-rocm_device_libs">rocm_device_libs</a>, <a href="#ll_toolchain-symbolizer">symbolizer</a>, <a href="#ll_toolchain-thread_sanitizer">thread_sanitizer</a>,
<a href="#ll_toolchain-undefined_behavior_sanitizer">undefined_behavior_sanitizer</a>, <a href="#ll_toolchain-unwind_library">unwind_library</a>)</code></pre>

`attributes`

| Name | Description |
| :---- | :---------- |
| <a id="ll_toolchain-name"></a>`name` | <code><a href="https://bazel.build/concepts/labels#target-names">Name</a></code>, required.<br><br> A unique name for this target. |
| <a id="ll_toolchain-LL_AMD_INCLUDES"></a>`LL_AMD_INCLUDES` | <code><a href="https://bazel.build/concepts/labels">Label</a></code>, optional, defaults to <code>None</code>.<br><br> System includes for dependencies making use of AMD toolchains.<br><br>Affects the `hip_amdgpu` and `hip_nvptx` toolchains. |
| <a id="ll_toolchain-LL_AMD_LIBRARIES"></a>`LL_AMD_LIBRARIES` | <code><a href="https://bazel.build/concepts/labels">Label</a></code>, optional, defaults to <code>None</code>.<br><br> Link search paths for dependencies making use of AMD toolchains.<br><br>Affects the `hip_amdgpu` toolchain. |
| <a id="ll_toolchain-LL_CFLAGS"></a>`LL_CFLAGS` | <code><a href="https://bazel.build/concepts/labels">Label</a></code>, optional, defaults to <code>None</code>.<br><br> Arbitrary flags added to all compile actions. |
| <a id="ll_toolchain-LL_CUDA_DRIVER"></a>`LL_CUDA_DRIVER` | <code><a href="https://bazel.build/concepts/labels">Label</a></code>, optional, defaults to <code>None</code>.<br><br> The path to the CUDA driver.<br><br>Affects the `cuda_nvptx` and `hip_nvptx` toolchains. |
| <a id="ll_toolchain-LL_CUDA_RUNTIME"></a>`LL_CUDA_RUNTIME` | <code><a href="https://bazel.build/concepts/labels">Label</a></code>, optional, defaults to <code>None</code>.<br><br> The path to the CUDA runtime.<br><br>Affects the `cuda_nvptx` and `hip_nvptx` toolchains. |
| <a id="ll_toolchain-LL_CUDA_TOOLKIT"></a>`LL_CUDA_TOOLKIT` | <code><a href="https://bazel.build/concepts/labels">Label</a></code>, optional, defaults to <code>None</code>.<br><br> The path to the CUDA toolkit.<br><br>Affects the `cuda_nvptx` and `hip_nvptx` toolchains. |
| <a id="ll_toolchain-LL_DYNAMIC_LINKER"></a>`LL_DYNAMIC_LINKER` | <code><a href="https://bazel.build/concepts/labels">Label</a></code>, optional, defaults to <code>None</code>.<br><br> The linker from the glibc we compile and link against. |
| <a id="ll_toolchain-LL_LDFLAGS"></a>`LL_LDFLAGS` | <code><a href="https://bazel.build/concepts/labels">Label</a></code>, optional, defaults to <code>None</code>.<br><br> Arbitrary flags added to all link actions. |
| <a id="ll_toolchain-address_sanitizer"></a>`address_sanitizer` | <code><a href="https://bazel.build/concepts/labels">List of labels</a></code>, optional, defaults to <code>[]</code>.<br><br> AddressSanitizer libraries. |
| <a id="ll_toolchain-archiver"></a>`archiver` | <code><a href="https://bazel.build/concepts/labels">Label</a></code>, optional, defaults to <code>"@llvm-project//llvm:llvm-ar"</code>.<br><br> The archiver. |
| <a id="ll_toolchain-bitcode_linker"></a>`bitcode_linker` | <code><a href="https://bazel.build/concepts/labels">Label</a></code>, optional, defaults to <code>"@llvm-project//llvm:llvm-link"</code>.<br><br> The linker for LLVM bitcode files. |
Expand Down
Loading

0 comments on commit 5ac0546

Please sign in to comment.