Skip to content

Commit

Permalink
🥬 Add cuda_nvptx_nvcc toolchain (#245)
Browse files Browse the repository at this point in the history
This is an initial take on a CUDA toolchain that uses `nvcc` as device
compiler. Since `nvcc` doesn't properly work with `libcxx` this
toolchain builds against `libstdc++` from nixpkgs.
  • Loading branch information
aaronmondal authored May 29, 2024
1 parent 2fce774 commit c4c768a
Show file tree
Hide file tree
Showing 16 changed files with 184 additions and 77 deletions.
6 changes: 3 additions & 3 deletions docs/reference/defs.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ Example:
| <a id="ll_binary-data"></a>`data` | <code><a href="https://bazel.build/concepts/labels">List of labels</a></code>, optional, defaults to <code>[]</code>.<br><br> Extra files made available to compilation and linking steps.<br><br>Not appended to the default command line arguments, but available to actions. Reference these files manually for instance in the `includes`, and `compile_flags` attributes.<br><br>Use this attribute to make intermediary outputs from non-ll targets, for example from `rules_cc` or `filegroup`, available to the rule. |
| <a id="ll_binary-hdrs"></a>`hdrs` | <code><a href="https://bazel.build/concepts/labels">List of labels</a></code>, optional, defaults to <code>[]</code>.<br><br> Header files for this target.<br><br>When including a header file with a nested path, for instance `#include "some/path/myheader.h"`, add `"some/path"` to `includes` to make it visible to the rule.<br><br>Unavailable to downstream targets. |
| <a id="ll_binary-angled_includes"></a>`angled_includes` | <code>List of strings</code>, optional, defaults to <code>[]</code>.<br><br> Angled include paths, relative to the target workspace.<br><br>Useful if you require include prefix stripping for dynamic paths, for instance the ones generated by `bzlmod`. Instead of `compile_flags = ["-Iexternal/mydep.someversion/include"]`, use `angled_includes = ["include"]` to add the path to the workspace automatically.<br><br>Expands paths starting with `$(GENERATED)` to the workspace location in the `GENDIR` path.<br><br>Unavailable to downstream targets. |
| <a id="ll_binary-compilation_mode"></a>`compilation_mode` | <code>String</code>, optional, defaults to <code>"cpp"</code>.<br><br> Enables compilation of heterogeneous single source files.<br><br>Prefer this attribute over adding SYCL/HIP/CUDA flags manually in the `compile_flags` and `link_flags`.<br><br>See [CUDA and HIP](../guides/cuda_and_hip.md).<br><br>`"cpp"` The default C++ toolchain.<br><br>`"cuda_nvptx"` The CUDA toolchain.<br><br>`"hip_nvptx"` The HIP toolchain.<br><br>`"bootstrap"` The bootstrap toolchain used by internal dependencies of the `ll_toolchain`. |
| <a id="ll_binary-compilation_mode"></a>`compilation_mode` | <code>String</code>, optional, defaults to <code>"cpp"</code>.<br><br> Enables compilation of heterogeneous single source files.<br><br>Prefer this attribute over adding SYCL/HIP/CUDA flags manually in the `compile_flags` and `link_flags`.<br><br>See [CUDA and HIP](../guides/cuda_and_hip.md).<br><br>`"cpp"` The default C++ toolchain.<br><br>`"cuda_nvptx"` The CUDA toolchain.<br><br>`"cuda_nvptx_nvcc"` The CUDA toolchain with `nvcc` as device compiler.<br><br>`"hip_nvptx"` The HIP toolchain.<br><br>`"bootstrap"` The bootstrap toolchain used by internal dependencies of the `ll_toolchain`. |
| <a id="ll_binary-compile_flags"></a>`compile_flags` | <code>List of strings</code>, optional, defaults to <code>[]</code>.<br><br> Flags for the compiler.<br><br>Pass a list of strings here. For instance `["-O3", "-std=c++20"]`.<br><br>Split flag pairs `-Xclang -somearg` into separate flags `["-Xclang", "-somearg"]`.<br><br>Unavailable to downstream targets. |
| <a id="ll_binary-compile_string_flags"></a>`compile_string_flags` | <code><a href="https://bazel.build/concepts/labels">List of labels</a></code>, optional, defaults to <code>[]</code>.<br><br> Flags for the compiler in the form of `string_flag`s.<br><br>Splits the values of each `string_flag` along colons like so:<br><br><pre><code class="language-python">load("@bazel_skylib//rules:common_settings.bzl", "string_flag")&#10;&#10;string_flag(&#10; name = "myflags",&#10; build_setting_default = "a:b:c",&#10;)&#10;&#10;ll_library(&#10; # ...&#10; # Equivalent to `compile_flags = ["a", "b", "c"]`&#10; compile_string_flags = [":myflags"],&#10;)</code></pre><br><br>Useful for externally configurable build attributes, such as generated flags from Nix environments. |
| <a id="ll_binary-defines"></a>`defines` | <code>List of strings</code>, optional, defaults to <code>[]</code>.<br><br> Defines for this target.<br><br>Pass a list of strings here. For instance `["MYDEFINE_1", "MYDEFINE_2"]`.<br><br>Unavailable to downstream targets. |
Expand Down Expand Up @@ -120,7 +120,7 @@ Example:
| <a id="ll_library-data"></a>`data` | <code><a href="https://bazel.build/concepts/labels">List of labels</a></code>, optional, defaults to <code>[]</code>.<br><br> Extra files made available to compilation and linking steps.<br><br>Not appended to the default command line arguments, but available to actions. Reference these files manually for instance in the `includes`, and `compile_flags` attributes.<br><br>Use this attribute to make intermediary outputs from non-ll targets, for example from `rules_cc` or `filegroup`, available to the rule. |
| <a id="ll_library-hdrs"></a>`hdrs` | <code><a href="https://bazel.build/concepts/labels">List of labels</a></code>, optional, defaults to <code>[]</code>.<br><br> Header files for this target.<br><br>When including a header file with a nested path, for instance `#include "some/path/myheader.h"`, add `"some/path"` to `includes` to make it visible to the rule.<br><br>Unavailable to downstream targets. |
| <a id="ll_library-angled_includes"></a>`angled_includes` | <code>List of strings</code>, optional, defaults to <code>[]</code>.<br><br> Angled include paths, relative to the target workspace.<br><br>Useful if you require include prefix stripping for dynamic paths, for instance the ones generated by `bzlmod`. Instead of `compile_flags = ["-Iexternal/mydep.someversion/include"]`, use `angled_includes = ["include"]` to add the path to the workspace automatically.<br><br>Expands paths starting with `$(GENERATED)` to the workspace location in the `GENDIR` path.<br><br>Unavailable to downstream targets. |
| <a id="ll_library-compilation_mode"></a>`compilation_mode` | <code>String</code>, optional, defaults to <code>"cpp"</code>.<br><br> Enables compilation of heterogeneous single source files.<br><br>Prefer this attribute over adding SYCL/HIP/CUDA flags manually in the `compile_flags` and `link_flags`.<br><br>See [CUDA and HIP](../guides/cuda_and_hip.md).<br><br>`"cpp"` The default C++ toolchain.<br><br>`"cuda_nvptx"` The CUDA toolchain.<br><br>`"hip_nvptx"` The HIP toolchain.<br><br>`"bootstrap"` The bootstrap toolchain used by internal dependencies of the `ll_toolchain`. |
| <a id="ll_library-compilation_mode"></a>`compilation_mode` | <code>String</code>, optional, defaults to <code>"cpp"</code>.<br><br> Enables compilation of heterogeneous single source files.<br><br>Prefer this attribute over adding SYCL/HIP/CUDA flags manually in the `compile_flags` and `link_flags`.<br><br>See [CUDA and HIP](../guides/cuda_and_hip.md).<br><br>`"cpp"` The default C++ toolchain.<br><br>`"cuda_nvptx"` The CUDA toolchain.<br><br>`"cuda_nvptx_nvcc"` The CUDA toolchain with `nvcc` as device compiler.<br><br>`"hip_nvptx"` The HIP toolchain.<br><br>`"bootstrap"` The bootstrap toolchain used by internal dependencies of the `ll_toolchain`. |
| <a id="ll_library-compile_flags"></a>`compile_flags` | <code>List of strings</code>, optional, defaults to <code>[]</code>.<br><br> Flags for the compiler.<br><br>Pass a list of strings here. For instance `["-O3", "-std=c++20"]`.<br><br>Split flag pairs `-Xclang -somearg` into separate flags `["-Xclang", "-somearg"]`.<br><br>Unavailable to downstream targets. |
| <a id="ll_library-compile_string_flags"></a>`compile_string_flags` | <code><a href="https://bazel.build/concepts/labels">List of labels</a></code>, optional, defaults to <code>[]</code>.<br><br> Flags for the compiler in the form of `string_flag`s.<br><br>Splits the values of each `string_flag` along colons like so:<br><br><pre><code class="language-python">load("@bazel_skylib//rules:common_settings.bzl", "string_flag")&#10;&#10;string_flag(&#10; name = "myflags",&#10; build_setting_default = "a:b:c",&#10;)&#10;&#10;ll_library(&#10; # ...&#10; # Equivalent to `compile_flags = ["a", "b", "c"]`&#10; compile_string_flags = [":myflags"],&#10;)</code></pre><br><br>Useful for externally configurable build attributes, such as generated flags from Nix environments. |
| <a id="ll_library-defines"></a>`defines` | <code>List of strings</code>, optional, defaults to <code>[]</code>.<br><br> Defines for this target.<br><br>Pass a list of strings here. For instance `["MYDEFINE_1", "MYDEFINE_2"]`.<br><br>Unavailable to downstream targets. |
Expand Down Expand Up @@ -177,7 +177,7 @@ Example:
| <a id="ll_test-data"></a>`data` | <code><a href="https://bazel.build/concepts/labels">List of labels</a></code>, optional, defaults to <code>[]</code>.<br><br> Extra files made available to compilation and linking steps.<br><br>Not appended to the default command line arguments, but available to actions. Reference these files manually for instance in the `includes`, and `compile_flags` attributes.<br><br>Use this attribute to make intermediary outputs from non-ll targets, for example from `rules_cc` or `filegroup`, available to the rule. |
| <a id="ll_test-hdrs"></a>`hdrs` | <code><a href="https://bazel.build/concepts/labels">List of labels</a></code>, optional, defaults to <code>[]</code>.<br><br> Header files for this target.<br><br>When including a header file with a nested path, for instance `#include "some/path/myheader.h"`, add `"some/path"` to `includes` to make it visible to the rule.<br><br>Unavailable to downstream targets. |
| <a id="ll_test-angled_includes"></a>`angled_includes` | <code>List of strings</code>, optional, defaults to <code>[]</code>.<br><br> Angled include paths, relative to the target workspace.<br><br>Useful if you require include prefix stripping for dynamic paths, for instance the ones generated by `bzlmod`. Instead of `compile_flags = ["-Iexternal/mydep.someversion/include"]`, use `angled_includes = ["include"]` to add the path to the workspace automatically.<br><br>Expands paths starting with `$(GENERATED)` to the workspace location in the `GENDIR` path.<br><br>Unavailable to downstream targets. |
| <a id="ll_test-compilation_mode"></a>`compilation_mode` | <code>String</code>, optional, defaults to <code>"cpp"</code>.<br><br> Enables compilation of heterogeneous single source files.<br><br>Prefer this attribute over adding SYCL/HIP/CUDA flags manually in the `compile_flags` and `link_flags`.<br><br>See [CUDA and HIP](../guides/cuda_and_hip.md).<br><br>`"cpp"` The default C++ toolchain.<br><br>`"cuda_nvptx"` The CUDA toolchain.<br><br>`"hip_nvptx"` The HIP toolchain.<br><br>`"bootstrap"` The bootstrap toolchain used by internal dependencies of the `ll_toolchain`. |
| <a id="ll_test-compilation_mode"></a>`compilation_mode` | <code>String</code>, optional, defaults to <code>"cpp"</code>.<br><br> Enables compilation of heterogeneous single source files.<br><br>Prefer this attribute over adding SYCL/HIP/CUDA flags manually in the `compile_flags` and `link_flags`.<br><br>See [CUDA and HIP](../guides/cuda_and_hip.md).<br><br>`"cpp"` The default C++ toolchain.<br><br>`"cuda_nvptx"` The CUDA toolchain.<br><br>`"cuda_nvptx_nvcc"` The CUDA toolchain with `nvcc` as device compiler.<br><br>`"hip_nvptx"` The HIP toolchain.<br><br>`"bootstrap"` The bootstrap toolchain used by internal dependencies of the `ll_toolchain`. |
| <a id="ll_test-compile_flags"></a>`compile_flags` | <code>List of strings</code>, optional, defaults to <code>[]</code>.<br><br> Flags for the compiler.<br><br>Pass a list of strings here. For instance `["-O3", "-std=c++20"]`.<br><br>Split flag pairs `-Xclang -somearg` into separate flags `["-Xclang", "-somearg"]`.<br><br>Unavailable to downstream targets. |
| <a id="ll_test-compile_string_flags"></a>`compile_string_flags` | <code><a href="https://bazel.build/concepts/labels">List of labels</a></code>, optional, defaults to <code>[]</code>.<br><br> Flags for the compiler in the form of `string_flag`s.<br><br>Splits the values of each `string_flag` along colons like so:<br><br><pre><code class="language-python">load("@bazel_skylib//rules:common_settings.bzl", "string_flag")&#10;&#10;string_flag(&#10; name = "myflags",&#10; build_setting_default = "a:b:c",&#10;)&#10;&#10;ll_library(&#10; # ...&#10; # Equivalent to `compile_flags = ["a", "b", "c"]`&#10; compile_string_flags = [":myflags"],&#10;)</code></pre><br><br>Useful for externally configurable build attributes, such as generated flags from Nix environments. |
| <a id="ll_test-defines"></a>`defines` | <code>List of strings</code>, optional, defaults to <code>[]</code>.<br><br> Defines for this target.<br><br>Pass a list of strings here. For instance `["MYDEFINE_1", "MYDEFINE_2"]`.<br><br>Unavailable to downstream targets. |
Expand Down
Loading

0 comments on commit c4c768a

Please sign in to comment.