Skip to content

Ali merge upstream 0.8.1#1

Merged
Ali-Piccioni merged 46 commits intomainfrom
ali-merge-upstream-0.8.1
Aug 4, 2022
Merged

Ali merge upstream 0.8.1#1
Ali-Piccioni merged 46 commits intomainfrom
ali-merge-upstream-0.8.1

Conversation

@Ali-Piccioni
Copy link
Copy Markdown

No description provided.

Kohei Watanabe and others added 30 commits June 24, 2022 18:30
To use config.string with allow_multiple
* WIP coverage support

* Make it work

* Regenerate documentation

* Gate env vars on coverage being enabled

* Add coverage targets

* Allow 2 actions when generating coverage

Co-authored-by: Krasimir Georgiev <krasimir@google.com>
…d#1426)

* crate_universe support for individually updating packages.

* Regenerated crate_universe outputs

* Regenerate documentation
* Added Rust 1.62.0

* Regenerate documentation

* Updated crate_universe examples

* Addressed new clippy warnings
….llvm-cov is None (bazelbuild#1432)

Do not attempt to instrument rust code for coverage if toolchain.llvm-cov is None.
…ld#1433)

* update crate_universe `--repin` args to not require values.

* Regenerate documentation
* Updated crate_universe version to `0.4.0`.

* Regenerated crate_universe outputs

* Regenerated crate_universe example outputs
…ild#1434)

This is supposed to fix the long standing Windows flakiness as described in bazelbuild#1427 (comment)

Initially I thought it's an issue with `rustdoc_test`, however the actual issue is that `rust_binary` and its `rust_test` have the same crate name and generate the same intermediary `.o` files. For sandboxed builds this is not an issue, as the actions are isolated, however, we have a race condition in non-sandboxed builds (Windows):

Let's consider the following build:
```
bazel build --spawn_strategy=standalone \
    //test/unit/rustdoc:bin_with_transitive_proc_macro \
    //test/unit/rustdoc:bin_with_transitive_proc_macro_test
```

The `bin_with_transitive_proc_macro` compile action will create the following intermediate file: `bazel-out/k8-fastbuild/bin/test/unit/rustdoc/bin_with_transitive_proc_macro.bin_with_transitive_proc_macro.573369dc-cgu.2.rcgu.o`, as will the `bin_with_transitive_proc_macro_test` action. These two files differ slightly (as the second action is for a test), namely the `bin_with_transitive_proc_macro` output has the following symbols:

```
0000000000000000 T main
0000000000000000 t _ZN30bin_with_transitive_proc_macro4main17hfc292cc42314e131E
                 U _ZN3std2rt10lang_start17h1dbc829c47cd61d9E
```

while the `bin_with_transitive_proc_macro_test` `.o` output looks like this:
```
0000000000000000 T main
0000000000000000 t _ZN30bin_with_transitive_proc_macro4main17h28726504dc060f8dE
                 U _ZN3std2rt10lang_start17h1dbc829c47cd61d9E
                 U _ZN4test16test_main_static17h37e3d88407f5b40fE
```

Now, when the two actions run in parallel, it can happen that `bin_with_transitive_proc_macro` creates the output, and `bin_with_transitive_proc_macro_test` overwrites it. Then, at linking time for `bin_with_transitive_proc_macro`, `rustc` will complain:
```
note: ld.lld: error: undefined symbol: test::test_main_static::h37e3d88407f5b40f
```
This is because `bin_with_transitive_proc_macro` is not a test and as such is not linked against `libtest`.

This PR fixes the issue by directing the compilation outputs of `rust_test` to be under a `test-{hash}` directory.
…argets (bazelbuild#1437)

* exclude `BUILD` and `WORKSPACE` files from generated crate_universe targets

* Regenerated crate_universe outputs
v0.2.0 does not have `rust_bindgen_dependencies`
bazelbuild#1442)

* Updated toolchain repository rules to represent one toolchain per repo

* Regenerate documentation
* Upgrade stardoc

I am eagerly awaiting bazelbuild/stardoc#124 so
the anchor links work.

* Regenerate documentation

Co-authored-by: UebelAndre <github@uebelandre.com>
…uild#1454)

* shorten `crate_universe_crate_index` to `cui`

* refresh crate_universe/3rdparty

* Update crate_universe/repositories.bzl

Co-authored-by: UebelAndre <github@uebelandre.com>

Co-authored-by: UebelAndre <github@uebelandre.com>
* Add extra_rustc_flag and extra_exec_rustc_flag

* Restore Label wrappers

* Update docs/BUILD.bazel and docs/symbols.bzl

* Regenerate documentation

* Revert "Regenerate documentation"

This reverts commit 37a39e1.

* Regenerate documentation
The include prefix for "src/" was not stripped correctly.
**Context**
When building [rustdocs](https://doc.rust-lang.org/rustdoc/what-is-rustdoc.html) it is very useful to pass `-Dwarnings`. This allows you to easily assert things like [intra-doc-links](https://doc.rust-lang.org/rustdoc/write-documentation/linking-to-items-by-name.html) aren't broken. As far as I can tell, passing flags to `rustdoc` isn't possible today. 

**Solution**
Add the `rustc_flags` attr to the `rust_doc` rule. `rustc_flags` is already parsed in [`construct_arguments(...)`](https://github.com/bazelbuild/rules_rust/blob/main/rust/private/rustc.bzl#L601) which `rust_doc` calls into.
…ommand (bazelbuild#1461)

* Updated header of crate_universe generated files to include a regen command

* Regenerate documentation

* Regenerated crate_universe outputs
Currently we pass `bazel-out/volatile-status.txt` to all the `Rustc` actions, which is bad for remote caching with `--stamp`enabled.

This PR makes only `rust_binary` be affected by the `--stamp` flag by default. The rest of the rust rules have `stamp = 0` as a default. Should you want to force stamp you can set `stamp = 1`. If you want to make your target stamp behavior depend on the `--stamp` command line flag, use `stamp = -1`.

Additionally, this PR makes `rules_rust` also use the stable keys for stamping, by passing `bazel-out/stable-status.txt` to the relevant `Rustc` actions when stamping is enabled. This makes `rules_rust` adhere to the contract described here: https://docs.bazel.build/versions/main/user-manual.html#flag--workspace_status_command
Bazel provides COVERAGE_MANIFEST which is a file we can pass through to
llvm-cov to limit the files that we produce coverage for. Using this
revealed the path-equivalence was backwards because we're using the
coverage prefix map to disable absolute paths in code coverage info,
but llvm-cov operates on absolute paths, so we have to remap the `.` in
the coverage data to the full path so that llvm-cov understands the
relative paths (which it absolutizes internal) from the manifest file.
This feels a bit weird and ideally it could operate entirely on these
relative paths instead.

This has the side effect of excluding files that aren't part of bazel
sources, which fixes bazelbuild#1466

This should also improve interaction with `--instrumentation_filter`.

Co-authored-by: UebelAndre <github@uebelandre.com>
UebelAndre and others added 16 commits July 18, 2022 14:52
* Updated `wasm_bindgen` rules dependencies.

* Regenerated crate_universe outputs.
* Updated `tools/rust_analyzer` to use `crate_universe`.

* Regenerate documentation

* Updated generated files.

* Deleted tools/rust_analyzer/raze

* Add missing bzl_lib target
* Update `//bindgen` to use crate_universe

* Updated generated files.

* Deleted bindgen/raze
…build#1473)

bazelbuild#1452 set `rust_*.stamp=0` as a default for all rules except `rust_binary`, which has -1 as a default.

The `rust_binary_without_process_wrapper` rule is used to build the process wrapper itself. It needs to override the `stamp` attribute back to 0, as we do not support stamping without the process wrapper. bazelbuild#1452 introduced a bug where the default value for this rule became `-1`, thus building `//util/process_wrapper` with `--stamp` is now broken.

This PR fixes the issue by routing all the attributes through the [_common_attrs_for_binary_without_process_wrapper](https://source.corp.google.com/piper///depot/google3/third_party/bazel_rules/rules_rust/rust/private/rust.bzl;rcl=461281665;l=1069?q=rust_binary_without_process_wrapper&ct=os&sq=package:piper%20file:%2F%2Fdepot%2Fgoogle3%20-file:google3%2Fexperimental) function, thus ensuring that the `stamp` attribute is once again set to 0.
* Fixed fetch_shas.sh

* Added Rust version 1.62.1

* Regenerate documentation

* Updated crate_universe examples
…bazelbuild#1455)

* Added `rust_analyzer_toolchain` and repository rules for creating one

* Regenerate documentation

* Update rust/repositories.bzl

Co-authored-by: Daniel Wagner-Hall <dawagner@gmail.com>

* Updated rust_analyzer_toolchain export

* Fixed rust_analyzer_toolchain_repository rule

Co-authored-by: Daniel Wagner-Hall <dawagner@gmail.com>
Previously if the workspace root manifest was missing, a panic would be
triggered due to unwrapping a `None` option.

Now, we suggest the missing manifest if possible, or direct you to work
it out yourself if we can't.
…ild#1483)

* Fix rust-analyzer being unable to find rust sysroot sources.

* Update tools/rust_analyzer/main.rs

Co-authored-by: Daniel Wagner-Hall <dawagner@gmail.com>

Co-authored-by: Daniel Wagner-Hall <dawagner@gmail.com>
@Ali-Piccioni Ali-Piccioni merged commit 496ce1a into main Aug 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.