Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set up default allocator_library and global_allocator_library #2172

Merged
merged 8 commits into from
Sep 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions docs/flatten.md
Original file line number Diff line number Diff line change
Expand Up @@ -1225,7 +1225,7 @@ See `@rules_rust//rust:repositories.bzl` for examples of defining the `@rust_cpu
| Name | Description | Type | Mandatory | Default |
| :------------- | :------------- | :------------- | :------------- | :------------- |
| <a id="rust_toolchain-name"></a>name | A unique name for this target. | <a href="https://bazel.build/concepts/labels#target-names">Name</a> | required | |
| <a id="rust_toolchain-allocator_library"></a>allocator_library | Target that provides allocator functions when rust_library targets are embedded in a cc_binary. | <a href="https://bazel.build/concepts/labels">Label</a> | optional | <code>None</code> |
| <a id="rust_toolchain-allocator_library"></a>allocator_library | Target that provides allocator functions when rust_library targets are embedded in a cc_binary. | <a href="https://bazel.build/concepts/labels">Label</a> | optional | <code>@rules_rust//ffi/cc/allocator_library</code> |
| <a id="rust_toolchain-binary_ext"></a>binary_ext | The extension for binaries created from rustc. | String | required | |
| <a id="rust_toolchain-cargo"></a>cargo | The location of the <code>cargo</code> binary. Can be a direct source or a filegroup containing one item. | <a href="https://bazel.build/concepts/labels">Label</a> | optional | <code>None</code> |
| <a id="rust_toolchain-clippy_driver"></a>clippy_driver | The location of the <code>clippy-driver</code> binary. Can be a direct source or a filegroup containing one item. | <a href="https://bazel.build/concepts/labels">Label</a> | optional | <code>None</code> |
Expand All @@ -1237,7 +1237,7 @@ See `@rules_rust//rust:repositories.bzl` for examples of defining the `@rust_cpu
| <a id="rust_toolchain-experimental_use_cc_common_link"></a>experimental_use_cc_common_link | Label to a boolean build setting that controls whether cc_common.link is used to link rust binaries. | <a href="https://bazel.build/concepts/labels">Label</a> | optional | <code>//rust/settings:experimental_use_cc_common_link</code> |
| <a id="rust_toolchain-extra_exec_rustc_flags"></a>extra_exec_rustc_flags | Extra flags to pass to rustc in exec configuration | List of strings | optional | <code>[]</code> |
| <a id="rust_toolchain-extra_rustc_flags"></a>extra_rustc_flags | Extra flags to pass to rustc in non-exec configuration | List of strings | optional | <code>[]</code> |
| <a id="rust_toolchain-global_allocator_library"></a>global_allocator_library | Target that provides allocator functions for when a global allocator is present. | <a href="https://bazel.build/concepts/labels">Label</a> | optional | <code>None</code> |
| <a id="rust_toolchain-global_allocator_library"></a>global_allocator_library | Target that provides allocator functions for when a global allocator is present. | <a href="https://bazel.build/concepts/labels">Label</a> | optional | <code>@rules_rust//ffi/cc/global_allocator_library</code> |
| <a id="rust_toolchain-llvm_cov"></a>llvm_cov | The location of the <code>llvm-cov</code> binary. Can be a direct source or a filegroup containing one item. If None, rust code is not instrumented for coverage. | <a href="https://bazel.build/concepts/labels">Label</a> | optional | <code>None</code> |
| <a id="rust_toolchain-llvm_profdata"></a>llvm_profdata | The location of the <code>llvm-profdata</code> binary. Can be a direct source or a filegroup containing one item. If <code>llvm_cov</code> is None, this can be None as well and rust code is not instrumented for coverage. | <a href="https://bazel.build/concepts/labels">Label</a> | optional | <code>None</code> |
| <a id="rust_toolchain-llvm_tools"></a>llvm_tools | LLVM tools that are shipped with the Rust toolchain. | <a href="https://bazel.build/concepts/labels">Label</a> | optional | <code>None</code> |
Expand Down Expand Up @@ -1300,14 +1300,14 @@ A given instance of this rule should be accompanied by a toolchain_repository_pr
| Name | Description | Type | Mandatory | Default |
| :------------- | :------------- | :------------- | :------------- | :------------- |
| <a id="rust_toolchain_tools_repository-name"></a>name | A unique name for this repository. | <a href="https://bazel.build/concepts/labels#target-names">Name</a> | required | |
| <a id="rust_toolchain_tools_repository-allocator_library"></a>allocator_library | Target that provides allocator functions when rust_library targets are embedded in a cc_binary. | String | optional | <code>""</code> |
| <a id="rust_toolchain_tools_repository-allocator_library"></a>allocator_library | Target that provides allocator functions when rust_library targets are embedded in a cc_binary. | String | optional | <code>"@rules_rust//ffi/cc/allocator_library"</code> |
| <a id="rust_toolchain_tools_repository-auth"></a>auth | Auth object compatible with repository_ctx.download to use when downloading files. See [repository_ctx.download](https://docs.bazel.build/versions/main/skylark/lib/repository_ctx.html#download) for more details. | <a href="https://bazel.build/rules/lib/dict">Dictionary: String -> String</a> | optional | <code>{}</code> |
| <a id="rust_toolchain_tools_repository-dev_components"></a>dev_components | Whether to download the rustc-dev components (defaults to False). Requires version to be "nightly". | Boolean | optional | <code>False</code> |
| <a id="rust_toolchain_tools_repository-edition"></a>edition | The rust edition to be used by default (2015, 2018, or 2021). If absent, every rule is required to specify its <code>edition</code> attribute. | String | optional | <code>""</code> |
| <a id="rust_toolchain_tools_repository-exec_triple"></a>exec_triple | The Rust-style target that this compiler runs on | String | required | |
| <a id="rust_toolchain_tools_repository-extra_exec_rustc_flags"></a>extra_exec_rustc_flags | Extra flags to pass to rustc in exec configuration | List of strings | optional | <code>[]</code> |
| <a id="rust_toolchain_tools_repository-extra_rustc_flags"></a>extra_rustc_flags | Extra flags to pass to rustc in non-exec configuration | List of strings | optional | <code>[]</code> |
| <a id="rust_toolchain_tools_repository-global_allocator_library"></a>global_allocator_library | Target that provides allocator functions when a global allocator is used with cc_common.link. | String | optional | <code>""</code> |
| <a id="rust_toolchain_tools_repository-global_allocator_library"></a>global_allocator_library | Target that provides allocator functions when a global allocator is used with cc_common.link. | String | optional | <code>"@rules_rust//ffi/cc/global_allocator_library"</code> |
| <a id="rust_toolchain_tools_repository-iso_date"></a>iso_date | The date of the tool (or None, if the version is a specific version). | String | optional | <code>""</code> |
| <a id="rust_toolchain_tools_repository-opt_level"></a>opt_level | Rustc optimization levels. For more details see the documentation for <code>rust_toolchain.opt_level</code>. | <a href="https://bazel.build/rules/lib/dict">Dictionary: String -> String</a> | optional | <code>{}</code> |
| <a id="rust_toolchain_tools_repository-repo_mapping"></a>repo_mapping | A dictionary from local repository name to global repository name. This allows controls over workspace dependency resolution for dependencies of this repository.&lt;p&gt;For example, an entry <code>"@foo": "@bar"</code> declares that, for any time this repository depends on <code>@foo</code> (such as a dependency on <code>@foo//some:target</code>, it should actually resolve that dependency within globally-declared <code>@bar</code> (<code>@bar//some:target</code>). | <a href="https://bazel.build/rules/lib/dict">Dictionary: String -> String</a> | required | |
Expand Down
8 changes: 4 additions & 4 deletions docs/rust_repositories.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ See `@rules_rust//rust:repositories.bzl` for examples of defining the `@rust_cpu
| Name | Description | Type | Mandatory | Default |
| :------------- | :------------- | :------------- | :------------- | :------------- |
| <a id="rust_toolchain-name"></a>name | A unique name for this target. | <a href="https://bazel.build/concepts/labels#target-names">Name</a> | required | |
| <a id="rust_toolchain-allocator_library"></a>allocator_library | Target that provides allocator functions when rust_library targets are embedded in a cc_binary. | <a href="https://bazel.build/concepts/labels">Label</a> | optional | <code>None</code> |
| <a id="rust_toolchain-allocator_library"></a>allocator_library | Target that provides allocator functions when rust_library targets are embedded in a cc_binary. | <a href="https://bazel.build/concepts/labels">Label</a> | optional | <code>@rules_rust//ffi/cc/allocator_library</code> |
| <a id="rust_toolchain-binary_ext"></a>binary_ext | The extension for binaries created from rustc. | String | required | |
| <a id="rust_toolchain-cargo"></a>cargo | The location of the <code>cargo</code> binary. Can be a direct source or a filegroup containing one item. | <a href="https://bazel.build/concepts/labels">Label</a> | optional | <code>None</code> |
| <a id="rust_toolchain-clippy_driver"></a>clippy_driver | The location of the <code>clippy-driver</code> binary. Can be a direct source or a filegroup containing one item. | <a href="https://bazel.build/concepts/labels">Label</a> | optional | <code>None</code> |
Expand All @@ -105,7 +105,7 @@ See `@rules_rust//rust:repositories.bzl` for examples of defining the `@rust_cpu
| <a id="rust_toolchain-experimental_use_cc_common_link"></a>experimental_use_cc_common_link | Label to a boolean build setting that controls whether cc_common.link is used to link rust binaries. | <a href="https://bazel.build/concepts/labels">Label</a> | optional | <code>//rust/settings:experimental_use_cc_common_link</code> |
| <a id="rust_toolchain-extra_exec_rustc_flags"></a>extra_exec_rustc_flags | Extra flags to pass to rustc in exec configuration | List of strings | optional | <code>[]</code> |
| <a id="rust_toolchain-extra_rustc_flags"></a>extra_rustc_flags | Extra flags to pass to rustc in non-exec configuration | List of strings | optional | <code>[]</code> |
| <a id="rust_toolchain-global_allocator_library"></a>global_allocator_library | Target that provides allocator functions for when a global allocator is present. | <a href="https://bazel.build/concepts/labels">Label</a> | optional | <code>None</code> |
| <a id="rust_toolchain-global_allocator_library"></a>global_allocator_library | Target that provides allocator functions for when a global allocator is present. | <a href="https://bazel.build/concepts/labels">Label</a> | optional | <code>@rules_rust//ffi/cc/global_allocator_library</code> |
| <a id="rust_toolchain-llvm_cov"></a>llvm_cov | The location of the <code>llvm-cov</code> binary. Can be a direct source or a filegroup containing one item. If None, rust code is not instrumented for coverage. | <a href="https://bazel.build/concepts/labels">Label</a> | optional | <code>None</code> |
| <a id="rust_toolchain-llvm_profdata"></a>llvm_profdata | The location of the <code>llvm-profdata</code> binary. Can be a direct source or a filegroup containing one item. If <code>llvm_cov</code> is None, this can be None as well and rust code is not instrumented for coverage. | <a href="https://bazel.build/concepts/labels">Label</a> | optional | <code>None</code> |
| <a id="rust_toolchain-llvm_tools"></a>llvm_tools | LLVM tools that are shipped with the Rust toolchain. | <a href="https://bazel.build/concepts/labels">Label</a> | optional | <code>None</code> |
Expand Down Expand Up @@ -168,14 +168,14 @@ A given instance of this rule should be accompanied by a toolchain_repository_pr
| Name | Description | Type | Mandatory | Default |
| :------------- | :------------- | :------------- | :------------- | :------------- |
| <a id="rust_toolchain_tools_repository-name"></a>name | A unique name for this repository. | <a href="https://bazel.build/concepts/labels#target-names">Name</a> | required | |
| <a id="rust_toolchain_tools_repository-allocator_library"></a>allocator_library | Target that provides allocator functions when rust_library targets are embedded in a cc_binary. | String | optional | <code>""</code> |
| <a id="rust_toolchain_tools_repository-allocator_library"></a>allocator_library | Target that provides allocator functions when rust_library targets are embedded in a cc_binary. | String | optional | <code>"@rules_rust//ffi/cc/allocator_library"</code> |
| <a id="rust_toolchain_tools_repository-auth"></a>auth | Auth object compatible with repository_ctx.download to use when downloading files. See [repository_ctx.download](https://docs.bazel.build/versions/main/skylark/lib/repository_ctx.html#download) for more details. | <a href="https://bazel.build/rules/lib/dict">Dictionary: String -> String</a> | optional | <code>{}</code> |
| <a id="rust_toolchain_tools_repository-dev_components"></a>dev_components | Whether to download the rustc-dev components (defaults to False). Requires version to be "nightly". | Boolean | optional | <code>False</code> |
| <a id="rust_toolchain_tools_repository-edition"></a>edition | The rust edition to be used by default (2015, 2018, or 2021). If absent, every rule is required to specify its <code>edition</code> attribute. | String | optional | <code>""</code> |
| <a id="rust_toolchain_tools_repository-exec_triple"></a>exec_triple | The Rust-style target that this compiler runs on | String | required | |
| <a id="rust_toolchain_tools_repository-extra_exec_rustc_flags"></a>extra_exec_rustc_flags | Extra flags to pass to rustc in exec configuration | List of strings | optional | <code>[]</code> |
| <a id="rust_toolchain_tools_repository-extra_rustc_flags"></a>extra_rustc_flags | Extra flags to pass to rustc in non-exec configuration | List of strings | optional | <code>[]</code> |
| <a id="rust_toolchain_tools_repository-global_allocator_library"></a>global_allocator_library | Target that provides allocator functions when a global allocator is used with cc_common.link. | String | optional | <code>""</code> |
| <a id="rust_toolchain_tools_repository-global_allocator_library"></a>global_allocator_library | Target that provides allocator functions when a global allocator is used with cc_common.link. | String | optional | <code>"@rules_rust//ffi/cc/global_allocator_library"</code> |
| <a id="rust_toolchain_tools_repository-iso_date"></a>iso_date | The date of the tool (or None, if the version is a specific version). | String | optional | <code>""</code> |
| <a id="rust_toolchain_tools_repository-opt_level"></a>opt_level | Rustc optimization levels. For more details see the documentation for <code>rust_toolchain.opt_level</code>. | <a href="https://bazel.build/rules/lib/dict">Dictionary: String -> String</a> | optional | <code>{}</code> |
| <a id="rust_toolchain_tools_repository-repo_mapping"></a>repo_mapping | A dictionary from local repository name to global repository name. This allows controls over workspace dependency resolution for dependencies of this repository.&lt;p&gt;For example, an entry <code>"@foo": "@bar"</code> declares that, for any time this repository depends on <code>@foo</code> (such as a dependency on <code>@foo//some:target</code>, it should actually resolve that dependency within globally-declared <code>@bar</code> (<code>@bar//some:target</code>). | <a href="https://bazel.build/rules/lib/dict">Dictionary: String -> String</a> | required | |
Expand Down
7 changes: 0 additions & 7 deletions examples/android/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,10 @@ load("@build_bazel_rules_android//android:rules.bzl", "android_binary", "android
load("@rules_cc//cc:defs.bzl", "cc_library")
load("@rules_rust//rust:defs.bzl", "rust_library")

cc_library(
name = "allocator_library",
srcs = ["allocator_library.cc"],
visibility = ["//visibility:public"],
)

rust_library(
name = "rust_lib",
srcs = ["demo.rs"],
edition = "2018",
deps = [":allocator_library"],
)

cc_library(
Expand Down
54 changes: 0 additions & 54 deletions examples/android/allocator_library.cc

This file was deleted.

7 changes: 0 additions & 7 deletions examples/ios/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,11 @@ load("@build_bazel_rules_apple//apple:macos.bzl", "macos_application")
load("@rules_cc//cc:defs.bzl", "cc_library", "objc_library")
load("@rules_rust//rust:defs.bzl", "rust_library")

cc_library(
name = "allocator_library",
srcs = ["allocator_library.cc"],
tags = ["manual"],
)

rust_library(
name = "rust_lib",
srcs = ["demo.rs"],
edition = "2018",
tags = ["manual"],
deps = [":allocator_library"],
)

# TODO: Remove this once rules_rust doesn't support bazel 5.x
Expand Down
14 changes: 14 additions & 0 deletions ffi/cc/allocator_library/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
load("@rules_cc//cc:defs.bzl", "cc_library")

cc_library(
name = "allocator_library",
srcs = select({
# Windows doesn't support weak symbol linkage.
# If someone can make this work on Windows, please do!
# For now we will silently not supply any symbols, because it would be very messy to conditionally define the default allocator library on toolchains depending on the platform.
"@platforms//os:windows": ["empty.cc"],
"//conditions:default": ["allocator_library.cc"],
}),
tags = ["manual"],
visibility = ["//visibility:public"],
)
Empty file.
Loading
Loading