From f42ed8a2182f016e99133085b531dbcfae7f7cad Mon Sep 17 00:00:00 2001 From: Corentin Kerisit Date: Fri, 10 May 2024 11:52:03 +0200 Subject: [PATCH 1/3] Add support for cc_library.alwayslink --- rust/private/rust.bzl | 9 +++++++++ rust/private/rustc.bzl | 2 ++ 2 files changed, 11 insertions(+) diff --git a/rust/private/rust.bzl b/rust/private/rust.bzl index afe1f129d3..945d206801 100644 --- a/rust/private/rust.bzl +++ b/rust/private/rust.bzl @@ -556,6 +556,15 @@ _common_attrs = { These are other `rust_library` targets and will be presented as the new name given. """), ), + "alwayslink": attr.bool( + doc = dedent("""\ + If 1, any binary that depends (directly or indirectly) on this library + will link in all the object files even if some contain no symbols referenced by the binary. + + This attribute is used by the C++ Starlark API when passing CcInfo providers. + """), + default = False, + ), "compile_data": attr.label_list( doc = dedent("""\ List of files used by this rule at compile time. diff --git a/rust/private/rustc.bzl b/rust/private/rustc.bzl index 474d1a6141..07f68bea85 100644 --- a/rust/private/rustc.bzl +++ b/rust/private/rustc.bzl @@ -1595,6 +1595,7 @@ def establish_cc_info(ctx, attr, crate_info, toolchain, cc_toolchain, feature_co static_library = crate_info.output, # TODO(hlopko): handle PIC/NOPIC correctly pic_static_library = crate_info.output, + alwayslink = getattr(ctx.attr, "alwayslink", False), ) elif crate_info.type in ("rlib", "lib"): # bazel hard-codes a check for endswith((".a", ".pic.a", @@ -1610,6 +1611,7 @@ def establish_cc_info(ctx, attr, crate_info, toolchain, cc_toolchain, feature_co static_library = dot_a, # TODO(hlopko): handle PIC/NOPIC correctly pic_static_library = dot_a, + alwayslink = getattr(ctx.attr, "alwayslink", False), ) elif crate_info.type == "cdylib": library_to_link = cc_common.create_library_to_link( From d998ef80bb68a4ae0d3d00bd66bbe7c8fa62e08b Mon Sep 17 00:00:00 2001 From: Corentin Kerisit Date: Mon, 13 May 2024 12:19:15 +0200 Subject: [PATCH 2/3] Apply suggestions from code review Co-authored-by: scentini --- rust/private/rustc.bzl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rust/private/rustc.bzl b/rust/private/rustc.bzl index 07f68bea85..48c6ccfa10 100644 --- a/rust/private/rustc.bzl +++ b/rust/private/rustc.bzl @@ -1595,7 +1595,7 @@ def establish_cc_info(ctx, attr, crate_info, toolchain, cc_toolchain, feature_co static_library = crate_info.output, # TODO(hlopko): handle PIC/NOPIC correctly pic_static_library = crate_info.output, - alwayslink = getattr(ctx.attr, "alwayslink", False), + alwayslink = getattr(attr, "alwayslink", False), ) elif crate_info.type in ("rlib", "lib"): # bazel hard-codes a check for endswith((".a", ".pic.a", @@ -1611,7 +1611,7 @@ def establish_cc_info(ctx, attr, crate_info, toolchain, cc_toolchain, feature_co static_library = dot_a, # TODO(hlopko): handle PIC/NOPIC correctly pic_static_library = dot_a, - alwayslink = getattr(ctx.attr, "alwayslink", False), + alwayslink = getattr(attr, "alwayslink", False), ) elif crate_info.type == "cdylib": library_to_link = cc_common.create_library_to_link( From c642a89a7e7bce51469fb7798974a2f67acba1c1 Mon Sep 17 00:00:00 2001 From: Corentin Kerisit Date: Mon, 17 Jun 2024 18:39:59 +0200 Subject: [PATCH 3/3] Regenerate documentation --- docs/defs.md | 44 ++++++++++++++++++++++++++------------------ docs/flatten.md | 44 ++++++++++++++++++++++++++------------------ 2 files changed, 52 insertions(+), 36 deletions(-) diff --git a/docs/defs.md b/docs/defs.md index 90fee223d0..94f058b018 100644 --- a/docs/defs.md +++ b/docs/defs.md @@ -91,9 +91,10 @@ Add additional rustc_flags from the command line with `--@rules_rust//:extra_rus ## rust_binary
-rust_binary(name, aliases, compile_data, crate_features, crate_name, crate_root, crate_type, data,
-            deps, edition, env, experimental_use_cc_common_link, linker_script, malloc, out_binary,
-            platform, proc_macro_deps, rustc_env, rustc_env_files, rustc_flags, srcs, stamp, version)
+rust_binary(name, aliases, alwayslink, compile_data, crate_features, crate_name, crate_root,
+            crate_type, data, deps, edition, env, experimental_use_cc_common_link, linker_script,
+            malloc, out_binary, platform, proc_macro_deps, rustc_env, rustc_env_files, rustc_flags,
+            srcs, stamp, version)
 
Builds a Rust binary crate. @@ -190,6 +191,7 @@ is available under the key `dsym_folder` in `OutputGroupInfo`. | :------------- | :------------- | :------------- | :------------- | :------------- | | name | A unique name for this target. | Name | required | | | aliases | Remap crates to a new name or moniker for linkage to this target

These are other rust_library targets and will be presented as the new name given. | Dictionary: Label -> String | optional | {} | +| alwayslink | If 1, any binary that depends (directly or indirectly) on this library will link in all the object files even if some contain no symbols referenced by the binary.

This attribute is used by the C++ Starlark API when passing CcInfo providers. | Boolean | optional | False | | compile_data | List of files used by this rule at compile time.

This attribute can be used to specify any data files that are embedded into the library, such as via the [include_str!](https://doc.rust-lang.org/std/macro.include_str!.html) macro. | List of labels | optional | [] | | crate_features | List of features to enable for this crate.

Features are defined in the code using the #[cfg(feature = "foo")] configuration option. The features listed here will be passed to rustc with --cfg feature="${feature_name}" flags. | List of strings | optional | [] | | crate_name | Crate name to use for this target.

This must be a valid Rust identifier, i.e. it may contain only alphanumeric characters and underscores. Defaults to the target name, with any hyphens replaced by underscores. | String | optional | "" | @@ -218,9 +220,9 @@ is available under the key `dsym_folder` in `OutputGroupInfo`. ## rust_library
-rust_library(name, aliases, compile_data, crate_features, crate_name, crate_root, data, deps,
-             disable_pipelining, edition, proc_macro_deps, rustc_env, rustc_env_files, rustc_flags,
-             srcs, stamp, version)
+rust_library(name, aliases, alwayslink, compile_data, crate_features, crate_name, crate_root, data,
+             deps, disable_pipelining, edition, proc_macro_deps, rustc_env, rustc_env_files,
+             rustc_flags, srcs, stamp, version)
 
Builds a Rust library crate. @@ -294,6 +296,7 @@ INFO: Elapsed time: 1.245s, Critical Path: 1.01s | :------------- | :------------- | :------------- | :------------- | :------------- | | name | A unique name for this target. | Name | required | | | aliases | Remap crates to a new name or moniker for linkage to this target

These are other rust_library targets and will be presented as the new name given. | Dictionary: Label -> String | optional | {} | +| alwayslink | If 1, any binary that depends (directly or indirectly) on this library will link in all the object files even if some contain no symbols referenced by the binary.

This attribute is used by the C++ Starlark API when passing CcInfo providers. | Boolean | optional | False | | compile_data | List of files used by this rule at compile time.

This attribute can be used to specify any data files that are embedded into the library, such as via the [include_str!](https://doc.rust-lang.org/std/macro.include_str!.html) macro. | List of labels | optional | [] | | crate_features | List of features to enable for this crate.

Features are defined in the code using the #[cfg(feature = "foo")] configuration option. The features listed here will be passed to rustc with --cfg feature="${feature_name}" flags. | List of strings | optional | [] | | crate_name | Crate name to use for this target.

This must be a valid Rust identifier, i.e. it may contain only alphanumeric characters and underscores. Defaults to the target name, with any hyphens replaced by underscores. | String | optional | "" | @@ -367,9 +370,9 @@ rust_library( ## rust_proc_macro
-rust_proc_macro(name, aliases, compile_data, crate_features, crate_name, crate_root, data, deps,
-                edition, proc_macro_deps, rustc_env, rustc_env_files, rustc_flags, srcs, stamp,
-                version)
+rust_proc_macro(name, aliases, alwayslink, compile_data, crate_features, crate_name, crate_root,
+                data, deps, edition, proc_macro_deps, rustc_env, rustc_env_files, rustc_flags, srcs,
+                stamp, version)
 
Builds a Rust proc-macro crate. @@ -382,6 +385,7 @@ Builds a Rust proc-macro crate. | :------------- | :------------- | :------------- | :------------- | :------------- | | name | A unique name for this target. | Name | required | | | aliases | Remap crates to a new name or moniker for linkage to this target

These are other rust_library targets and will be presented as the new name given. | Dictionary: Label -> String | optional | {} | +| alwayslink | If 1, any binary that depends (directly or indirectly) on this library will link in all the object files even if some contain no symbols referenced by the binary.

This attribute is used by the C++ Starlark API when passing CcInfo providers. | Boolean | optional | False | | compile_data | List of files used by this rule at compile time.

This attribute can be used to specify any data files that are embedded into the library, such as via the [include_str!](https://doc.rust-lang.org/std/macro.include_str!.html) macro. | List of labels | optional | [] | | crate_features | List of features to enable for this crate.

Features are defined in the code using the #[cfg(feature = "foo")] configuration option. The features listed here will be passed to rustc with --cfg feature="${feature_name}" flags. | List of strings | optional | [] | | crate_name | Crate name to use for this target.

This must be a valid Rust identifier, i.e. it may contain only alphanumeric characters and underscores. Defaults to the target name, with any hyphens replaced by underscores. | String | optional | "" | @@ -403,9 +407,9 @@ Builds a Rust proc-macro crate. ## rust_shared_library
-rust_shared_library(name, aliases, compile_data, crate_features, crate_name, crate_root, data, deps,
-                    edition, experimental_use_cc_common_link, malloc, platform, proc_macro_deps,
-                    rustc_env, rustc_env_files, rustc_flags, srcs, stamp, version)
+rust_shared_library(name, aliases, alwayslink, compile_data, crate_features, crate_name, crate_root,
+                    data, deps, edition, experimental_use_cc_common_link, malloc, platform,
+                    proc_macro_deps, rustc_env, rustc_env_files, rustc_flags, srcs, stamp, version)
 
Builds a Rust shared library. @@ -426,6 +430,7 @@ When building the whole binary in Bazel, use `rust_library` instead. | :------------- | :------------- | :------------- | :------------- | :------------- | | name | A unique name for this target. | Name | required | | | aliases | Remap crates to a new name or moniker for linkage to this target

These are other rust_library targets and will be presented as the new name given. | Dictionary: Label -> String | optional | {} | +| alwayslink | If 1, any binary that depends (directly or indirectly) on this library will link in all the object files even if some contain no symbols referenced by the binary.

This attribute is used by the C++ Starlark API when passing CcInfo providers. | Boolean | optional | False | | compile_data | List of files used by this rule at compile time.

This attribute can be used to specify any data files that are embedded into the library, such as via the [include_str!](https://doc.rust-lang.org/std/macro.include_str!.html) macro. | List of labels | optional | [] | | crate_features | List of features to enable for this crate.

Features are defined in the code using the #[cfg(feature = "foo")] configuration option. The features listed here will be passed to rustc with --cfg feature="${feature_name}" flags. | List of strings | optional | [] | | crate_name | Crate name to use for this target.

This must be a valid Rust identifier, i.e. it may contain only alphanumeric characters and underscores. Defaults to the target name, with any hyphens replaced by underscores. | String | optional | "" | @@ -450,9 +455,9 @@ When building the whole binary in Bazel, use `rust_library` instead. ## rust_static_library
-rust_static_library(name, aliases, compile_data, crate_features, crate_name, crate_root, data, deps,
-                    edition, platform, proc_macro_deps, rustc_env, rustc_env_files, rustc_flags, srcs,
-                    stamp, version)
+rust_static_library(name, aliases, alwayslink, compile_data, crate_features, crate_name, crate_root,
+                    data, deps, edition, platform, proc_macro_deps, rustc_env, rustc_env_files,
+                    rustc_flags, srcs, stamp, version)
 
Builds a Rust static library. @@ -473,6 +478,7 @@ When building the whole binary in Bazel, use `rust_library` instead. | :------------- | :------------- | :------------- | :------------- | :------------- | | name | A unique name for this target. | Name | required | | | aliases | Remap crates to a new name or moniker for linkage to this target

These are other rust_library targets and will be presented as the new name given. | Dictionary: Label -> String | optional | {} | +| alwayslink | If 1, any binary that depends (directly or indirectly) on this library will link in all the object files even if some contain no symbols referenced by the binary.

This attribute is used by the C++ Starlark API when passing CcInfo providers. | Boolean | optional | False | | compile_data | List of files used by this rule at compile time.

This attribute can be used to specify any data files that are embedded into the library, such as via the [include_str!](https://doc.rust-lang.org/std/macro.include_str!.html) macro. | List of labels | optional | [] | | crate_features | List of features to enable for this crate.

Features are defined in the code using the #[cfg(feature = "foo")] configuration option. The features listed here will be passed to rustc with --cfg feature="${feature_name}" flags. | List of strings | optional | [] | | crate_name | Crate name to use for this target.

This must be a valid Rust identifier, i.e. it may contain only alphanumeric characters and underscores. Defaults to the target name, with any hyphens replaced by underscores. | String | optional | "" | @@ -495,9 +501,10 @@ When building the whole binary in Bazel, use `rust_library` instead. ## rust_test
-rust_test(name, aliases, compile_data, crate, crate_features, crate_name, crate_root, data, deps,
-          edition, env, experimental_use_cc_common_link, malloc, platform, proc_macro_deps, rustc_env,
-          rustc_env_files, rustc_flags, srcs, stamp, use_libtest_harness, version)
+rust_test(name, aliases, alwayslink, compile_data, crate, crate_features, crate_name, crate_root,
+          data, deps, edition, env, experimental_use_cc_common_link, malloc, platform,
+          proc_macro_deps, rustc_env, rustc_env_files, rustc_flags, srcs, stamp, use_libtest_harness,
+          version)
 
Builds a Rust test crate. @@ -626,6 +633,7 @@ Run the test with `bazel test //hello_lib:greeting_test`. | :------------- | :------------- | :------------- | :------------- | :------------- | | name | A unique name for this target. | Name | required | | | aliases | Remap crates to a new name or moniker for linkage to this target

These are other rust_library targets and will be presented as the new name given. | Dictionary: Label -> String | optional | {} | +| alwayslink | If 1, any binary that depends (directly or indirectly) on this library will link in all the object files even if some contain no symbols referenced by the binary.

This attribute is used by the C++ Starlark API when passing CcInfo providers. | Boolean | optional | False | | compile_data | List of files used by this rule at compile time.

This attribute can be used to specify any data files that are embedded into the library, such as via the [include_str!](https://doc.rust-lang.org/std/macro.include_str!.html) macro. | List of labels | optional | [] | | crate | Target inline tests declared in the given crate

These tests are typically those that would be held out under #[cfg(test)] declarations. | Label | optional | None | | crate_features | List of features to enable for this crate.

Features are defined in the code using the #[cfg(feature = "foo")] configuration option. The features listed here will be passed to rustc with --cfg feature="${feature_name}" flags. | List of strings | optional | [] | diff --git a/docs/flatten.md b/docs/flatten.md index 3d3210a412..b75753a1cf 100644 --- a/docs/flatten.md +++ b/docs/flatten.md @@ -231,9 +231,10 @@ A toolchain for [rust-analyzer](https://rust-analyzer.github.io/). ## rust_binary
-rust_binary(name, aliases, compile_data, crate_features, crate_name, crate_root, crate_type, data,
-            deps, edition, env, experimental_use_cc_common_link, linker_script, malloc, out_binary,
-            platform, proc_macro_deps, rustc_env, rustc_env_files, rustc_flags, srcs, stamp, version)
+rust_binary(name, aliases, alwayslink, compile_data, crate_features, crate_name, crate_root,
+            crate_type, data, deps, edition, env, experimental_use_cc_common_link, linker_script,
+            malloc, out_binary, platform, proc_macro_deps, rustc_env, rustc_env_files, rustc_flags,
+            srcs, stamp, version)
 
Builds a Rust binary crate. @@ -330,6 +331,7 @@ is available under the key `dsym_folder` in `OutputGroupInfo`. | :------------- | :------------- | :------------- | :------------- | :------------- | | name | A unique name for this target. | Name | required | | | aliases | Remap crates to a new name or moniker for linkage to this target

These are other rust_library targets and will be presented as the new name given. | Dictionary: Label -> String | optional | {} | +| alwayslink | If 1, any binary that depends (directly or indirectly) on this library will link in all the object files even if some contain no symbols referenced by the binary.

This attribute is used by the C++ Starlark API when passing CcInfo providers. | Boolean | optional | False | | compile_data | List of files used by this rule at compile time.

This attribute can be used to specify any data files that are embedded into the library, such as via the [include_str!](https://doc.rust-lang.org/std/macro.include_str!.html) macro. | List of labels | optional | [] | | crate_features | List of features to enable for this crate.

Features are defined in the code using the #[cfg(feature = "foo")] configuration option. The features listed here will be passed to rustc with --cfg feature="${feature_name}" flags. | List of strings | optional | [] | | crate_name | Crate name to use for this target.

This must be a valid Rust identifier, i.e. it may contain only alphanumeric characters and underscores. Defaults to the target name, with any hyphens replaced by underscores. | String | optional | "" | @@ -645,9 +647,9 @@ rust_binary( ## rust_library
-rust_library(name, aliases, compile_data, crate_features, crate_name, crate_root, data, deps,
-             disable_pipelining, edition, proc_macro_deps, rustc_env, rustc_env_files, rustc_flags,
-             srcs, stamp, version)
+rust_library(name, aliases, alwayslink, compile_data, crate_features, crate_name, crate_root, data,
+             deps, disable_pipelining, edition, proc_macro_deps, rustc_env, rustc_env_files,
+             rustc_flags, srcs, stamp, version)
 
Builds a Rust library crate. @@ -721,6 +723,7 @@ INFO: Elapsed time: 1.245s, Critical Path: 1.01s | :------------- | :------------- | :------------- | :------------- | :------------- | | name | A unique name for this target. | Name | required | | | aliases | Remap crates to a new name or moniker for linkage to this target

These are other rust_library targets and will be presented as the new name given. | Dictionary: Label -> String | optional | {} | +| alwayslink | If 1, any binary that depends (directly or indirectly) on this library will link in all the object files even if some contain no symbols referenced by the binary.

This attribute is used by the C++ Starlark API when passing CcInfo providers. | Boolean | optional | False | | compile_data | List of files used by this rule at compile time.

This attribute can be used to specify any data files that are embedded into the library, such as via the [include_str!](https://doc.rust-lang.org/std/macro.include_str!.html) macro. | List of labels | optional | [] | | crate_features | List of features to enable for this crate.

Features are defined in the code using the #[cfg(feature = "foo")] configuration option. The features listed here will be passed to rustc with --cfg feature="${feature_name}" flags. | List of strings | optional | [] | | crate_name | Crate name to use for this target.

This must be a valid Rust identifier, i.e. it may contain only alphanumeric characters and underscores. Defaults to the target name, with any hyphens replaced by underscores. | String | optional | "" | @@ -794,9 +797,9 @@ rust_library( ## rust_proc_macro
-rust_proc_macro(name, aliases, compile_data, crate_features, crate_name, crate_root, data, deps,
-                edition, proc_macro_deps, rustc_env, rustc_env_files, rustc_flags, srcs, stamp,
-                version)
+rust_proc_macro(name, aliases, alwayslink, compile_data, crate_features, crate_name, crate_root,
+                data, deps, edition, proc_macro_deps, rustc_env, rustc_env_files, rustc_flags, srcs,
+                stamp, version)
 
Builds a Rust proc-macro crate. @@ -809,6 +812,7 @@ Builds a Rust proc-macro crate. | :------------- | :------------- | :------------- | :------------- | :------------- | | name | A unique name for this target. | Name | required | | | aliases | Remap crates to a new name or moniker for linkage to this target

These are other rust_library targets and will be presented as the new name given. | Dictionary: Label -> String | optional | {} | +| alwayslink | If 1, any binary that depends (directly or indirectly) on this library will link in all the object files even if some contain no symbols referenced by the binary.

This attribute is used by the C++ Starlark API when passing CcInfo providers. | Boolean | optional | False | | compile_data | List of files used by this rule at compile time.

This attribute can be used to specify any data files that are embedded into the library, such as via the [include_str!](https://doc.rust-lang.org/std/macro.include_str!.html) macro. | List of labels | optional | [] | | crate_features | List of features to enable for this crate.

Features are defined in the code using the #[cfg(feature = "foo")] configuration option. The features listed here will be passed to rustc with --cfg feature="${feature_name}" flags. | List of strings | optional | [] | | crate_name | Crate name to use for this target.

This must be a valid Rust identifier, i.e. it may contain only alphanumeric characters and underscores. Defaults to the target name, with any hyphens replaced by underscores. | String | optional | "" | @@ -904,9 +908,9 @@ rust_binary( ## rust_shared_library
-rust_shared_library(name, aliases, compile_data, crate_features, crate_name, crate_root, data, deps,
-                    edition, experimental_use_cc_common_link, malloc, platform, proc_macro_deps,
-                    rustc_env, rustc_env_files, rustc_flags, srcs, stamp, version)
+rust_shared_library(name, aliases, alwayslink, compile_data, crate_features, crate_name, crate_root,
+                    data, deps, edition, experimental_use_cc_common_link, malloc, platform,
+                    proc_macro_deps, rustc_env, rustc_env_files, rustc_flags, srcs, stamp, version)
 
Builds a Rust shared library. @@ -927,6 +931,7 @@ When building the whole binary in Bazel, use `rust_library` instead. | :------------- | :------------- | :------------- | :------------- | :------------- | | name | A unique name for this target. | Name | required | | | aliases | Remap crates to a new name or moniker for linkage to this target

These are other rust_library targets and will be presented as the new name given. | Dictionary: Label -> String | optional | {} | +| alwayslink | If 1, any binary that depends (directly or indirectly) on this library will link in all the object files even if some contain no symbols referenced by the binary.

This attribute is used by the C++ Starlark API when passing CcInfo providers. | Boolean | optional | False | | compile_data | List of files used by this rule at compile time.

This attribute can be used to specify any data files that are embedded into the library, such as via the [include_str!](https://doc.rust-lang.org/std/macro.include_str!.html) macro. | List of labels | optional | [] | | crate_features | List of features to enable for this crate.

Features are defined in the code using the #[cfg(feature = "foo")] configuration option. The features listed here will be passed to rustc with --cfg feature="${feature_name}" flags. | List of strings | optional | [] | | crate_name | Crate name to use for this target.

This must be a valid Rust identifier, i.e. it may contain only alphanumeric characters and underscores. Defaults to the target name, with any hyphens replaced by underscores. | String | optional | "" | @@ -951,9 +956,9 @@ When building the whole binary in Bazel, use `rust_library` instead. ## rust_static_library
-rust_static_library(name, aliases, compile_data, crate_features, crate_name, crate_root, data, deps,
-                    edition, platform, proc_macro_deps, rustc_env, rustc_env_files, rustc_flags, srcs,
-                    stamp, version)
+rust_static_library(name, aliases, alwayslink, compile_data, crate_features, crate_name, crate_root,
+                    data, deps, edition, platform, proc_macro_deps, rustc_env, rustc_env_files,
+                    rustc_flags, srcs, stamp, version)
 
Builds a Rust static library. @@ -974,6 +979,7 @@ When building the whole binary in Bazel, use `rust_library` instead. | :------------- | :------------- | :------------- | :------------- | :------------- | | name | A unique name for this target. | Name | required | | | aliases | Remap crates to a new name or moniker for linkage to this target

These are other rust_library targets and will be presented as the new name given. | Dictionary: Label -> String | optional | {} | +| alwayslink | If 1, any binary that depends (directly or indirectly) on this library will link in all the object files even if some contain no symbols referenced by the binary.

This attribute is used by the C++ Starlark API when passing CcInfo providers. | Boolean | optional | False | | compile_data | List of files used by this rule at compile time.

This attribute can be used to specify any data files that are embedded into the library, such as via the [include_str!](https://doc.rust-lang.org/std/macro.include_str!.html) macro. | List of labels | optional | [] | | crate_features | List of features to enable for this crate.

Features are defined in the code using the #[cfg(feature = "foo")] configuration option. The features listed here will be passed to rustc with --cfg feature="${feature_name}" flags. | List of strings | optional | [] | | crate_name | Crate name to use for this target.

This must be a valid Rust identifier, i.e. it may contain only alphanumeric characters and underscores. Defaults to the target name, with any hyphens replaced by underscores. | String | optional | "" | @@ -1015,9 +1021,10 @@ A dedicated filegroup-like rule for Rust stdlib artifacts. ## rust_test
-rust_test(name, aliases, compile_data, crate, crate_features, crate_name, crate_root, data, deps,
-          edition, env, experimental_use_cc_common_link, malloc, platform, proc_macro_deps, rustc_env,
-          rustc_env_files, rustc_flags, srcs, stamp, use_libtest_harness, version)
+rust_test(name, aliases, alwayslink, compile_data, crate, crate_features, crate_name, crate_root,
+          data, deps, edition, env, experimental_use_cc_common_link, malloc, platform,
+          proc_macro_deps, rustc_env, rustc_env_files, rustc_flags, srcs, stamp, use_libtest_harness,
+          version)
 
Builds a Rust test crate. @@ -1146,6 +1153,7 @@ Run the test with `bazel test //hello_lib:greeting_test`. | :------------- | :------------- | :------------- | :------------- | :------------- | | name | A unique name for this target. | Name | required | | | aliases | Remap crates to a new name or moniker for linkage to this target

These are other rust_library targets and will be presented as the new name given. | Dictionary: Label -> String | optional | {} | +| alwayslink | If 1, any binary that depends (directly or indirectly) on this library will link in all the object files even if some contain no symbols referenced by the binary.

This attribute is used by the C++ Starlark API when passing CcInfo providers. | Boolean | optional | False | | compile_data | List of files used by this rule at compile time.

This attribute can be used to specify any data files that are embedded into the library, such as via the [include_str!](https://doc.rust-lang.org/std/macro.include_str!.html) macro. | List of labels | optional | [] | | crate | Target inline tests declared in the given crate

These tests are typically those that would be held out under #[cfg(test)] declarations. | Label | optional | None | | crate_features | List of features to enable for this crate.

Features are defined in the code using the #[cfg(feature = "foo")] configuration option. The features listed here will be passed to rustc with --cfg feature="${feature_name}" flags. | List of strings | optional | [] |