Skip to content

Commit e56ca89

Browse files
authored
Dont recomment rust_library as a CcInfo target
Previous work has made `rust_library` operate as a `CcInfo` provider. As far as I can tell this lets the compiler directly consume an rlib rather than a formal static or shared library crate type. This is a fine experiment but is a poor recommendation in the documentation, I would suggest that until rust-lang/rust#73632 is in a better place we dont recommend people use a `rust_library` target directly where `CcInfo` is expected. I found that this failed for me in ways similar to bazelbuild#1238 even without stating a custom allocator. After fixing this for Linux + GCC this then failed in macos *and* windows. It seems that we are jumping the gun slightly and encouraging a behavior that only works with a specific configuration as the default, rather than as something to trial.
1 parent 3be056a commit e56ca89

File tree

1 file changed

+2
-18
lines changed

1 file changed

+2
-18
lines changed

docs/defs.md

+2-18
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,8 @@ INFO: Elapsed time: 1.245s, Critical Path: 1.01s
303303
| <a id="rust_library-stamp"></a>stamp | Whether to encode build information into the <code>Rustc</code> action. Possible values:<br><br>- <code>stamp = 1</code>: Always stamp the build information into the <code>Rustc</code> action, even in [--nostamp](https://docs.bazel.build/versions/main/user-manual.html#flag--stamp) builds. This setting should be avoided, since it potentially kills remote caching for the target and any downstream actions that depend on it.<br><br>- <code>stamp = 0</code>: Always replace build information by constant values. This gives good build result caching.<br><br>- <code>stamp = -1</code>: Embedding of build information is controlled by the [--[no]stamp](https://docs.bazel.build/versions/main/user-manual.html#flag--stamp) flag.<br><br>Stamped targets are not rebuilt unless their dependencies change.<br><br>For example if a <code>rust_library</code> is stamped, and a <code>rust_binary</code> depends on that library, the stamped library won't be rebuilt when we change sources of the <code>rust_binary</code>. This is different from how [<code>cc_library.linkstamps</code>](https://docs.bazel.build/versions/main/be/c-cpp.html#cc_library.linkstamp) behaves. | Integer | optional | 0 |
304304
| <a id="rust_library-version"></a>version | A version to inject in the cargo environment variable. | String | optional | "0.0.0" |
305305

306+
This rule provides CcInfo, so it can be used everywhere Bazel expects `rules_cc`. Right now this is somewhat experimental and can cause
307+
failures on Windows, macos and with GCC. It is hoped that https://github.com/rust-lang/rust/issues/73632 will make this work more seemlessly.
306308

307309
<a id="rust_proc_macro"></a>
308310

@@ -352,15 +354,6 @@ rust_shared_library(<a href="#rust_shared_library-name">name</a>, <a href="#rust
352354

353355
Builds a Rust shared library.
354356

355-
This shared library will contain all transitively reachable crates and native objects.
356-
It is meant to be used when producing an artifact that is then consumed by some other build system
357-
(for example to produce a shared library that Python program links against).
358-
359-
This rule provides CcInfo, so it can be used everywhere Bazel expects `rules_cc`.
360-
361-
When building the whole binary in Bazel, use `rust_library` instead.
362-
363-
364357
**ATTRIBUTES**
365358

366359

@@ -396,15 +389,6 @@ rust_static_library(<a href="#rust_static_library-name">name</a>, <a href="#rust
396389

397390
Builds a Rust static library.
398391

399-
This static library will contain all transitively reachable crates and native objects.
400-
It is meant to be used when producing an artifact that is then consumed by some other build system
401-
(for example to produce an archive that Python program links against).
402-
403-
This rule provides CcInfo, so it can be used everywhere Bazel expects `rules_cc`.
404-
405-
When building the whole binary in Bazel, use `rust_library` instead.
406-
407-
408392
**ATTRIBUTES**
409393

410394

0 commit comments

Comments
 (0)