Commit graph

879 commits

Author SHA1 Message Date
Andrew Walbran
7d61fae91d Require safety comments for unsafe blocks.
Also require unsafe blocks even within unsafe functions.

Bug: 290018030
Test: m pvmfw_bin
Change-Id: I6ffce7b59a9b2f22572a88e0ba55aaf01576273c
2023-07-06 17:30:47 +01:00
Matthew Maurer
34609faea3 rust: Set env variables consistently for build/doc
Test: m rustdoc
Bug: 288151817
Bug: 288129815
Change-Id: I7fbf9eaea243fa2832f3dff717deb7889e0ed17c
2023-06-26 21:10:13 +00:00
Ivan Lozano
184893a851 Merge "rust: Enable stack-protector for Rust modules" 2023-06-23 13:08:37 +00:00
Colin Cross
313d32f730 Merge "Use generics for DepSets" 2023-06-22 20:57:01 +00:00
Ivan Lozano
464f3b381e rust: Enable stack-protector for Rust modules
Bug: 288407220
Test: m
Change-Id: Ifea0d4e3be715d9cef74ddfc6e64447a006fe0ed
2023-06-22 18:03:16 +00:00
Colin Cross
c85750bfe3 Use generics for DepSets
Use Go's generics for DepSets so they don't require a type-specific
wrapper and reflection.

Test: depsets_test.go
Change-Id: I22ba0b7d680d37d2cd05230b0f560d166c4dd20b
2023-06-22 08:18:33 -07:00
Ivan Lozano
85cc859d73 Merge "rust: Make dylib-std the canonical rlib form" 2023-06-16 00:39:55 +00:00
Ivan Lozano
4df0257fe5 rust: Make dylib-std the canonical rlib form
This removes the dylib-std suffix from rlib variants which link against
libstd dynamically. This is by far the common case.

This fixes an issue where 'm <rust_library_rlib>' would fail since Make
would expect the suffix to be included (e.g. 'm libfoo.dylib-std').

Bug: 173312517
Bug: 268086496
Test: m <rust_library_rlib> # without a suffix
Change-Id: I1e5778c57468302a8d672d5eb540047d8bb79314
2023-06-15 18:29:22 +00:00
Charisee
4fa57fbadb rustc-1.70.0 Build 10322039
bug: 285036397
Test: m rust
Change-Id: I44fc85e53d23c834007cbd1922376a7a64af2bb4
2023-06-14 22:30:12 +00:00
Matthew Maurer
9c8c9ff82a rust: Add support for CARGO_PKG_NAME
Technically cargo package names and crate names can be different, but
this is rare and usually only a matter of presentation. Adding basic
support in this fashion lets several crates build without adding
significant machinery.

Bug: 276464273
Test: Build a crate which uses this environment variable
Change-Id: I4f4c8c9e277789de7a63be2457f00090e8c3e973
2023-06-14 00:25:33 +00:00
Ivan Lozano
b10aabae61 Merge "rust: Fix flags for Rust libfuzzer fuzzers" 2023-06-13 20:27:21 +00:00
Ivan Lozano
1247b3c8a0 rust: Fix flags for Rust libfuzzer fuzzers
Rust libfuzzer flags have changed upstream, so update our set of flags.

This fixes the following fuzzer error:

  ERROR: The size of coverage PC tables does not match the
  number of instrumented PCs. This might be a compiler bug,
  please contact the libFuzzer developers.

Bug: 249551848
Test: SANITIZE_TARGET="hwaddress fuzzer" m <fuzz_target>
Test: Test running the fuzzer.
Change-Id: I4f7df1fbe636133c646dfb0bd12757c947995ffe
2023-06-12 15:08:45 -04:00
Ivan Lozano
61c02cc537 rust: Bundle Rust shared dependencies in fuzzers
Rust shared library dependencies are not always bundled in cc_fuzz or
rust_fuzz modules, which can lead to difficult to debug runtime errors
when running these fuzzers. It can also be hard to determine which
dependencies need to be explicitly declared.

This CL makes sure that we bundle the appropriate transitive
dependencies for our fuzzers.

Bug: 249551848
Test: Soong tests
Test: m <fuzzer> # check data/fuzz/<arch>/lib dir contents
Change-Id: I957ca8898079b61e2ff20d750f8c92bf61ac394f
2023-06-09 14:17:49 -04:00
Chris Wailes
547bfdd1d1 Remove the last allow-listed unstable features
This CL removes the custom_inner_attributes and mixed_integer_ops
features from the allow-list.  This also allows us to remove the `-A
stable-features` flag.

Bug: 267698452
Test: m rust
Change-Id: I4770c2e9477337f112732c354bf477a99d11a467
2023-05-31 11:53:44 -07:00
Ivan Lozano
7f9d7cbb75 rust: Support sanitizers in rust_ffi modules
Don't automatically assume that HWASAN or ASAN is enabled if Fuzzer is
enabled.

Bug: 178365482
Test: m bluetooth_stack_with_facade
Test: SANITIZE_TARGET=fuzzer m bluetooth_stack_with_facade
Test: SANITIZE_TARGET=address m bluetooth_stack_with_facade
Test: SANITIZE_TARGET=hwaddress m bluetooth_stack_with_facade
Test: SANITIZE_TARGET="fuzzer address" m bluetooth_stack_with_facade
Test: SANITIZE_TARGET="fuzzer hwaddress" m bluetooth_stack_with_facade
Change-Id: Ief8c0f899837c5889a8035782616025f1b0d54e7
2023-05-24 20:15:52 +00:00
LaMont Jones
0c10e4dcc0 Parallelize singleton execution
Bug: 281536768
Test: manual, presubmits
Change-Id: I57fdc76ba6b277e88e196b506af87127a530fd37
2023-05-19 20:31:32 +00:00
Treehugger Robot
ff007311e3 Merge "Update clang version for Rust bindgen to clang-r487747c" 2023-05-12 18:21:10 +00:00
Yi Kong
6974c7ec72 Update clang version for Rust bindgen to clang-r487747c
Test: presubmit
Bug: 279955553
Change-Id: I9092263024b5b8dc7a1538b00f318ef0d5c29bb7
2023-05-12 15:06:20 +01:00
Chris Wailes
6b82616c83 rustc-1.69.0 Build 10117114
Bug: https://issuetracker.google.com/issues/274972941
Test: m rust
Change-Id: If5570ba26080bdff38bdcbd65f6f1d7dc9f5bffc
2023-05-11 16:08:44 -07:00
Lei Ju
c38f1d5145 Merge "Revert "rustc-1.69.0 Build 10095304"" 2023-05-11 16:42:20 +00:00
Android Culprit Assistant
f36b2fae67 Revert "rustc-1.69.0 Build 10095304"
This revert was created by Android Culprit Assistant. The culprit was identified in the following culprit search session (http://go/aca-get/1fa75415-4722-46e3-b61b-7de26844a12d).

Change-Id: I7aabd3ff76c255ca13d594cc0f2f331ed8edc01b
2023-05-11 06:37:03 +00:00
Chris Wailes
a1909da281 Merge "rustc-1.69.0 Build 10095304" 2023-05-10 22:53:50 +00:00
Hamzeh Zawawy
38917496e5 Support removing suffix for device specific prebuilt during build
Some device specific prebuilts have a suffix that varies depending on the lunch target.
The resulting install dependency binary has the suffix.
The fuzzer build expects the presubmit binary without the suffix.
This change is to drop the suffix.

Test: make haiku
Change-Id: I8eadd84bf5797659b17bc428dca47b7c3f382aff
2023-05-09 23:11:42 +00:00
Chris Wailes
883507a7c9 rustc-1.69.0 Build 10095304
Bug: https://issuetracker.google.com/issues/274972941
Test: m rust
Change-Id: I5f376bd661eee014793aceeeb37a012dfad1fd80
2023-05-09 13:19:31 -07:00
Chris Wailes
34f2bc5693 Revert "rustc-1.69.0 Build 10027731"
Revert submission 2579357-rust-update-prebuilts-1.69.0

Reason for revert: Patch got dropped accidentally that broke a postsubmit test

Reverted changes: /q/submissionid:2579357-rust-update-prebuilts-1.69.0

Change-Id: I3fdd44a9df6c9c775c4f4157ea58df5e4215c47e
2023-05-05 18:19:32 +00:00
Chris Wailes
b5ae9bcf90 rustc-1.69.0 Build 10027731
Bug: https://issuetracker.google.com/issues/274972941
Test: m rust
Change-Id: I03ba07802c2d77d5e3776cc49abac8b98d6ebbfe
2023-04-28 01:15:55 -07:00
Jeff Vander Stoep
c1490ec25e Add option to use protobuf3
Users of the rust_protobuf module can use the 'use_protobuf3'
option to select version 3 of the protobuf crate instead of the
current default of version 2. This unblocks teams that would like
to use protobuf 3 immediately and provides a mechanism for us to
incrementally migrate users of protobuf 2 to protobuf 3.

Test: Adds tests that are executed during every build.
Bug: 270895633
Change-Id: Ib6a18b77cfa7dc3cc604cea05269004b3712bbb6
2023-04-24 11:33:50 +02:00
Peter Collingbourne
67237c82ed Merge "Pass -Wl,--as-needed when linking Rust binaries." 2023-04-18 19:17:41 +00:00
Peter Collingbourne
4629f7c886 Pass -Wl,--as-needed when linking Rust binaries.
aosp/2518976 revealed a pre-existing bug, which was that some Rust test
targets did not have all of their shared library dependencies packaged in
the host-unit-tests.zip file. Conveniently enough, these targets did not
actually depend on any of the symbols in the missing shared libraries, so
their DT_NEEDED entries were being removed by the --as-needed flag being
passed to the linker by rustc. This flag was dropped when we switched
to running the link command directly, causing the DT_NEEDED entries to
reappear and leading to runtime failures for these test binaries.

Although we could fix the issue that prevented these (unused) dependencies
from being packaged, there wouldn't be much point in doing so because
we already know that they aren't needed. So for now, let's return to
the status quo and keep passing --as-needed to the linker.

Bug: 278168700
Change-Id: Iae103803983240fa14cdbc2ff0d8ffb4329c6024
2023-04-14 17:36:57 -07:00
Peter Collingbourne
e7c71c344d Split Rust crate builds into compile and link phases.
Teach rustc to generate object files instead of a linked executable
for binary and shared library crates. This lets us skip the lengthy
Rust compilation phase when only the C++ dependencies of these crates
have changed.

This works using a Python script that replaces the linker invoked by
rustc and converts the linker command line into a rspfile that can be
used during the link phase. The script makes certain assumptions about
how rustc invokes the linker, but since we control the version of Rust
we use, we can update the script if those assumptions ever break. I've
asked the Rust developers about adding an official way to do this so
hopefully we won't need to rely on this hack in the future.

The rustc rule for Kythe has been altered to pass linker=true, somewhat
consistent with the main rustc rule, which now doesn't invoke the actual
linker either. `m xref_rust` still succeeds, but hopefully we can find
someone who knows more about the rest of the Kythe pipeline who can let
us know whether it should still work. Otherwise, let's use this CL as
an opportunity to find out whether the rest of the pipeline is happy
with linker=true, since otherwise we will find it hard to maintain the
Kythe rule in the future.

Change-Id: Ifb9c8689c1bd78c0afcf6fdfd111140d20377536
2023-04-12 15:51:41 -07:00
Treehugger Robot
43a2a9a5c6 Merge changes from topic "fdo_profile"
* changes:
  Reimplement afdo support for rust
  Implement fdo_profile module type
2023-04-03 22:35:25 +00:00
Treehugger Robot
d61ea3580d Merge "Set OUT_DIR=out with no src_deps." 2023-04-03 19:01:58 +00:00
Peter Collingbourne
0dcd62e8a0 Set OUT_DIR=out with no src_deps.
Some Rust crates with no src_deps have generated files checked in in an
"out" subdirectory and included via a reference to $OUT_DIR, such as
external/rust/crates/userfaultfd-sys.

Astonishingly, some people must be leaving $OUT_DIR set to the default
value of "out", because with $OUT_DIR set to this value, building these
crates would presumably succeed. For everyone else, the build fails
when building one of these crates because it will attempt to load from
the wrong directory. Presumably these crates should be using src_deps
instead (and once that's fixed, we should probably *unset* $OUT_DIR in
rustc invocations to prevent the same thing from happening again), but
for now, fix the build with non-default OUT_DIR by explicitly setting
OUT_DIR to "out" if there are no src_deps.

Change-Id: I09f99424fc01a1e42e910622c77ab8f7312819bd
2023-04-01 01:34:19 -07:00
Treehugger Robot
553d89a825 Merge "Fix rust snapshotInfo provider bug" 2023-04-01 06:41:25 +00:00
Vinh Tran
cde1016aff Reimplement afdo support for rust
Ignore-AOSP-First: The parent CL is internal
Bug: 267229065
Test: go test
Change-Id: Ia14679285b92f3f14ff269392a61f978c71311b2
Merged-In: Ia14679285b92f3f14ff269392a61f978c71311b2
2023-03-31 17:55:16 -04:00
Treehugger Robot
10361f5177 Merge "rust_proto: use protobuf crate version 2.x" 2023-03-31 10:37:24 +00:00
Inseob Kim
cd2b46aae3 Fix rust snapshotInfo provider bug
We must pass pointer of pointer to correctly cash snapshotInfo and
register provider only once.

Bug: 271215084
Test: build
Change-Id: Ia7b43c7b97a8fcabd3b4d6ac8b990c622b6ceb6e
2023-03-31 18:04:12 +09:00
Chris Wailes
fef4a02805 Remove stable feature from allowed features list
This CL removes the `default_alloc_error_handler` feature from the
allowed feature set passed to rustc.  This feature was stabilized in
Rust 1.68.0 and now that that has been deployed we can remove the
feature annotations from our codebase.

Bug: 267698452
Test: m rust
Change-Id: Ifc543ec83d3221cc8bcb6c83658abe09696b51ea
2023-03-29 16:18:04 -07:00
Treehugger Robot
0bdbc1c387 Merge "pass cc shared libs as order-only to rustc" 2023-03-29 18:25:50 +00:00
Sam Delmerico
51d6d1c585 pass cc shared libs as order-only to rustc
The library file for a cc_shared_library dependency is added to the linkFlags of the rustc compilation action, but no explicit dependency was made on it from a Ninja perspective if a TOC was also present. This change adds the explicit dependency on the library file whether or not a TOC is present.

Test: m crosvm
Bug: 275416061
Change-Id: I625b62762d9ba7b4fd2b8362285528e47f728dd4
2023-03-29 14:33:20 +00:00
Vinh Tran
2e7b0fd271 Add tests to verify more use cases of afdo in cc and rust
Test: go test
Bug: 267229065
Change-Id: I4aa9538e92aa27e0f842bdce3725bc82739196cb
2023-03-27 14:01:40 -04:00
Yi Kong
a137aa2e6e Merge "Revert^2 "Update clang version to clang-r487747"" 2023-03-24 13:19:52 +00:00
Jeff Vander Stoep
91c0466094 rust_proto: use protobuf crate version 2.x
Test: build
Bug: 270895633
Change-Id: I04e5e7fe70b8c509cd1b35852b75a0f24a633ce9
2023-03-24 09:32:36 +01:00
Yi Kong
fd07ed2c14 Revert^2 "Update clang version to clang-r487747"
9ede280375

Bug: 264965700
Change-Id: I4154c70c050a825525d5b591fa757104eb78c158
2023-03-23 14:14:31 +00:00
Treehugger Robot
ec68cf48e0 Merge "rustc-1.68.0 Build 9751466" 2023-03-21 17:51:27 +00:00
Spandan Das
0c7ea9582a Merge "Build rust libraries against C ModuleLib API surface." 2023-03-21 17:22:23 +00:00
Spandan Das
604f376dcf Build rust libraries against C ModuleLib API surface.
Previously, rust libs in platform would build against stubs even if the
dependency was part of platform. Port the correct logic from the
recently implemented aosp/2421967

Test: TH

Change-Id: I7f6a0ca24654b4424d2f4cfcef2d15e15b1298fc
2023-03-16 23:17:36 +00:00
Justin Yun
24b246a7a8 Fix the make name of rust snapshots
Rust snapshot must have proper suffix for androidmk to avoid conflict
with the existing modules.

Bug: 230780263
Bug: 235895567
Test: m nothing
Change-Id: I35794196553621cd722c067d7965b2a61aa351bd
2023-03-16 11:05:41 +09:00
Charisee
39f2d443ea rustc-1.68.0 Build 9751466
Bug: 270756468
Test: m rust
Change-Id: Ifa04d7fbbdc8ced9956aa50372df80ed6f481c02
2023-03-15 18:42:31 +00:00
Treehugger Robot
4b68649eb0 Merge "Remove slice_internals from features allow list" 2023-03-08 21:38:01 +00:00