Commit graph

927 commits

Author SHA1 Message Date
Vinh Tran
0c4b9ec5e0 Implement bp2build converter for rust_protobuf_host
Test: go test
Bug: 295925256
Change-Id: I43b7359da8fc19f4338e2583448b7617194df5e6
2023-08-25 18:00:33 -04:00
Vinh Tran
093a57edb2 Implement bp2build converter for rust_binary
Test: go test
Bug: 295910295
Change-Id: Ieb18d9071f28e53a0463614594cee0fd755b7b3c
2023-08-25 17:58:53 -04:00
Vinh Tran
9b84678faf Convert libprotobuf to Bazel
Since this is a one-off just for building libprotobuf that will be removed when we handle cargo output more generically (b/297364081), I didn't write a unit test for this CL.

Test: b build //external/rust/crates/protobuf:libprotobuf
Bug: 295925256
Change-Id: I00cf44d54be27a09c184a96c13b250a2e54e2d10
2023-08-25 17:53:37 -04:00
Vinh Tran
c1a6ceefd3 Allowlist all aconfig deps modulo libprotobuf and libaconfig_protos
Test: b build //external/rust/crates:all
Bug: 295903972
Change-Id: Ieb29516722155ef8921e454eaa1ea51fad99ec08
2023-08-25 17:51:54 -04:00
Vinh Tran
b4bb20f583 Implement bp2build converter for rust_proc_macro
Test: WIP
Bug: 297356482
Change-Id: I17d1a0a95d4a67ccbc9b2d74e49bcacd6ff4d26b
2023-08-25 17:50:48 -04:00
Vinh Tran
bcb5f57eed Implement bp2build converter for rust_library
Test: go test
Bug: 297294749
Change-Id: I5400fe2c0fe2097b7a5810c736fbd1de4f35c6f7
2023-08-25 17:42:13 -04:00
Vinh Tran
80f6b2147f Export RustDefaultVersion to Bazel
The config constant is consumed by rust toolchain implemented in aosp/2709668.

Bug: 295918553
Test: go test
Change-Id: I0a28a802ad28f6ee24dfb1b5bdab72094534ae04
2023-08-23 22:55:40 -04:00
Cole Faust
1311c1af27 Merge "Add transitive shared libs to LOCAL_SHARED_LIBRARIES for rust modules" into main 2023-08-22 19:26:14 +00:00
Vinh Tran
497a6df359 Merge "Add test to confirm -L flag for cc deps in rust" into main 2023-08-21 15:01:02 +00:00
Treehugger Robot
d62482345d Merge "Require safety comments for unsafe blocks." into main 2023-08-18 16:25:43 +00:00
Cole Faust
b6e6f99521 Add transitive shared libs to LOCAL_SHARED_LIBRARIES for rust modules
Rust modules are different from C++ modules in that they will install
their transitive shared libs alongside a binary. C++ modules don't
do this, you have to install the transitive shared lib manually. (but
they do install direct shared libs)

It does this by using InstallDepNeeded, a mechanism that adds
dependencies from installed files to the installed copies of
dependencies if InstallDepNeeded() returns true. This mechanism does
not end up tracking the installed files all the way to
FULL_SYSTEMIMAGE_DEPS.

We're attempting to make FULL_SYSTEMIMAGE_DEPS more accurate so that
we can track the files that should be installed properly, and remove
the need for `m installclean`.

Listing the libraries a binary uses in LOCAL_SHARED_LIBRARIES does
properly track them and end up listing them in FULL_SYSTEMIMAGE_DEPS.

Bug: 205632228
Test: Building the systemimage with a change to delete anything not in FULL_SYSTEMIMAGE_DEPS
Change-Id: I4ba75b40b3ac77250297209a851bc9ba377782f5
2023-08-17 17:42:26 -07:00
Pawan Wagh
4266814527 Merge "Adding fuzz_config in rust_defaults" into main 2023-08-17 21:47:44 +00:00
Vinh Tran
156ea44375 Add test to confirm -L flag for cc deps in rust
Test: go test
Change-Id: Ib9c7e109a0bd9f54dfdbdf5b3764e2d3e8272b1b
2023-08-17 16:54:48 -04:00
Pawan Wagh
ccb7558563 Adding fuzz_config in rust_defaults
rust_defaults doesn't recognize fuzz_config properties unlike
cc_defaults. Adding fuzz_config properties to rust defaults.

Test: m parcel_fuzzer_rs && adb shell data/fuzz/x86_64/parcel_fuzzer_rs/parcel_fuzzer_rs
Bug: 296305888
Change-Id: I4ae4f9d3776e3a6340fce6e3095a00931677cbe7
2023-08-17 00:08:55 +00:00
Cody Schuffelen
d89ee08bbf Merge "Rust library linking fixes" into main 2023-08-16 19:51:02 +00:00
Ivan Lozano
b0e1035417 Merge "rust: Add support for host fuzzers." into main 2023-08-16 14:07:19 +00:00
Vinh Tran
e6adc83c6c Merge "Remove dylibs prop from rust module types" into main 2023-08-15 13:45:10 +00:00
A. Cody Schuffelen
c183e3a473 Rust library linking fixes
- Hide universal binary dependency for rust

Without a darwin_arm64 libstd prebuilt, many rust binaries are not
possible to build as a universal binary anyway. This fixes an
intermediate error with compiling rust FFI targets, where C++ shared
library dependencies for both architectures were combined into the same
linker command.

There is still an outstanding problem with C++ executable targets that
include rust FFI library targets, as the rust FFI library targets
fail to find a proper libstd to build the arm64 side of the universal
executable.

- Use dynamic_lib instead of soname

This matches similar logic in cc/library.go : linkerFlags for including
shared libraries.

Bug: 291830024
Test: m libkmr_cf_ffi (when enabled for darwin)
Change-Id: I1d6b6a7855c6649b93ab6592ea43b17c6e37b3a3
2023-08-14 21:27:41 -07:00
Vinh Tran
5ce68092d3 Merge "Add unit test to verify default linkage for rust binaries" into main 2023-08-14 18:13:04 +00:00
Vinh Tran
4eeb2a9514 Remove dylibs prop from rust module types
For device build, rust defaults to dylib linkage for rustlibs deps. `dylibs` prop was provided for flexibility.

By removing it, we're enforcing users to either use the default linkage (dylibs for device and rlibs for host) or rlibs prop explicitly. This means no dylibs for host modules. This makes sense because host modules always uses rlib linkage against libstd. The flexibility with dylibs prop opened room for linkage collisions because the dependencies don't link against libstd the same way.

Test: go test
Change-Id: I2fc221daa8a9bb42bdcf6d9823c723a4ddabe7b5
2023-08-14 14:03:28 -04:00
Vinh Tran
05b3410290 Add unit test to verify default linkage for rust binaries
Test: go test
Change-Id: I16eed90dffc8f98a880aa801e96601227dcc37be
2023-08-14 11:26:18 -04:00
Ivan Lozano
2fcbffa4a1 rust: Add support for host fuzzers.
Adds support for host-based Rust fuzzers.

Bug: 282897366
Test: SANITZE_HOST="address" m <host_fuzzer>
Test: run fuzzer
Change-Id: Ibb951f651ef12e763778ebbf12e66769a7113920
2023-08-10 09:48:13 -04:00
A. Cody Schuffelen
f29ca58e88 Darwin/Mac OS host rust compilation fixes
- Don't pass `--as-needed` to the linker on Mac OS which is unsupported
  there
- Use `--force_load` rather than `--Wl,--whole-archive` on Mac OS
- Scan `rustc`'s linker arguments for `-dylib` and `-dynamiclib`, which
  it can use instead of `-shared` on Mac OS:
  7bd81ee190/compiler/rustc_codegen_ssa/src/back/linker.rs (L319)

Test: m libhalf serde_derive
Bug: 291164566
Change-Id: Iecd6c2532fa31c9476834f49b109de98cbd2dccf
2023-08-03 16:26:44 -07:00
Colin Cross
0a10dfd6dc Merge "Fix missing rust dependencies when ALLOW_MISSING_DEPENDENCIES=true" into main 2023-08-01 20:07:53 +00:00
Colin Cross
a86ea0e0eb Fix missing rust dependencies when ALLOW_MISSING_DEPENDENCIES=true
Register a missing dependency when a dependency returns an invalid
OptionalPath.

Fixes: 294070048
Test: rust_test.go
Change-Id: Ibccfc30d59c706308e99f11e372f7c9b60d9dc74
2023-08-01 10:19:53 -07:00
Treehugger Robot
d97daa5a39 Merge "rust: Add Bindgen_flag_files property" into main 2023-07-31 22:38:31 +00:00
Ivan Lozano
17ac9fa93e Merge "Revert "rust: Add SCS sanitizer option for AArch64"" into main 2023-07-31 18:13:40 +00:00
Ivan Lozano
22823eed4b Revert "rust: Add SCS sanitizer option for AArch64"
This reverts commit 8827113577.

Reason for revert: hwasan builds breaking

Change-Id: I28094e27d5935c6f371fddddf4b6b0334de9b12c
2023-07-31 18:01:26 +00:00
Ivan Lozano
0e403456b0 Merge "rust: Add SCS sanitizer option for AArch64" into main 2023-07-31 17:27:01 +00:00
Ivan Lozano
f74612e346 Merge "rust: Add support for more cargo pkg version vars" into main 2023-07-31 16:31:14 +00:00
Ivan Lozano
f445562840 rust: Add support for more cargo pkg version vars
Add support for CARGO_PKG_VERSION_{MAJOR,MINOR,PATCH}.

Bug: 293602526
Test: m
Test: check build flags for cargo_env_compat module
Change-Id: I6b2796656e3a489cd077c2f42b0bbd04de610ba4
2023-07-31 09:25:18 -04:00
Ivan Lozano
7113df6c8f Merge "rust: Pass ASAN/HWASAN flags alongside fuzzers" into main 2023-07-31 12:42:46 +00:00
Ivan Lozano
8827113577 rust: Add SCS sanitizer option for AArch64
SCS has been supported in Rust since 1.64.0.

This adds SCS as a sanitizer option in Rust.

Bug: 168914033
Test: Built module with sanitize: { scs: true }
Change-Id: Ie54ac4693286878b98704cf052649a267777d764
2023-07-28 14:34:28 -04:00
Ivan Lozano
408d37319a rust: Pass ASAN/HWASAN flags alongside fuzzers
'-Z sanitizer={hw}address' was not being passed if the fuzzer sanitizer
property was also set. Additionally, trying to use the fuzzer sanitizer
with the address sanitizer incorrectly linked in the hwasan runtime.

Bug: 293466009
Test: SANITIZE_TARGET="fuzzer address" m android_logger_fuzzer
Test: SANITIZE_TARGET="fuzzer hwaddress" m android_logger_fuzzer
Test: ldd <fuzzer_on_device> # ensure correct libraries linked
Test: Check build flags
Change-Id: I6b01c8808af07c642217b642af128ebf934f4bc6
2023-07-27 14:00:07 -04:00
Ivan Lozano
7e377d045e Merge "Revert "rust: Add SCS sanitizer option."" into main 2023-07-27 15:08:50 +00:00
Ivan Lozano
f9780422b3 Revert "rust: Add SCS sanitizer option."
This reverts commit 447f5b1ea9.

Reason for revert: b/293445283

Change-Id: Iadc6c7ed196be2a65329f86423730ba7f851002c
2023-07-27 14:52:20 +00:00
Ivan Lozano
c7c29b9b8e Merge "rust: Add SCS sanitizer option." into main 2023-07-27 14:23:33 +00:00
Andrei Homescu
78a1f8dfb8 rust: Add Bindgen_flag_files property
Add a new Bindgen_flag_files property to bindgen modules
that let users specify files that contain extra flags for
bindgen.

Bug: 242243245
Test: presubmit
Change-Id: I21d987c08ac417c04aaa3bfb3b75d563fc662d5b
2023-07-27 07:03:14 +00:00
Ivan Lozano
447f5b1ea9 rust: Add SCS sanitizer option.
SCS has been supported in Rust since 1.64.0.

This adds SCS as a sanitizer option in Rust.

Bug: 168914033
Test: Built module with sanitize: { scs: true }
Change-Id: Ibdc116a335339af6d0b0d6dd0bb82c0358fa9087
2023-07-26 13:34:55 -04:00
Ivan Lozano
2797e876f1 rust: Add BTI/PAC for supported targets.
This mirrors the support provided for cc modules.

Bug: 181027427
Test: m rust
Change-Id: I1354b37ec8c47132f143400adba6d42cf2081df5
2023-07-25 14:25:43 -04:00
Chris Wailes
9081d142cb Merge "rustc-1.71.0 Build 10534657" into main 2023-07-24 19:21:11 +00:00
Ivan Lozano
5b55c2f366 rust: Enable Product support for dylibs.
There is no longer a reason to restrict dylibs on product, make them
available.

Bug: 204303985
Test: m
Change-Id: I315d22307f64d02633940f30ae600c63f16f0e7a
2023-07-21 14:02:21 -04:00
Chris Wailes
2e23a3d140 rustc-1.71.0 Build 10534657
Bug: https://issuetracker.google.com/issues/288268986
Test: m rust
Change-Id: If1db6f9e866eeda121f757159a02cfb9018ab270
2023-07-20 14:52:57 -07:00
Yabin Cui
2850da608e Update rust bindgen to clang-r498229
Bug: 280683256
Test: presubmit
Change-Id: I30c57035eaba408cdbaa4f1151ea2605fdd9d32b
2023-07-18 13:41:21 -07:00
Treehugger Robot
8edcba4c2f Merge "Create one rule per one corpus/data files" into main 2023-07-18 15:37:25 +00:00
Inseob Kim
3b24406dda Create one rule per one corpus/data files
To avoid MAX_ARG_STRLEN hardlimit.

Test: build and check intermediate directory
Change-Id: I44db1ed14cae4de6ace5b25a392d394d0f9f617a
2023-07-18 12:38:08 +00:00
Ivan Lozano
add122a828 rust: Add vendor and recovery dylib support.
Adds dylib support for vendor and recovery images.

This changes the default linkage for vendor and recovery images to
dylib, which matches the platform default linkage. This also means that
by default, dylib-std variants are used for rlib dependencies.

Bug: 204303985
Test: Soong tests.
Test: m dist vendor-snapshot
Test: RECOVERY_SNAPSHOT_VERSION=current m dist recovery-snapshot
Change-Id: If84074b8615a70c45e7e162abeb853dc8c34d49a
2023-07-14 12:43:09 -04:00
Andrei Homescu
4494685aec rust: Allow any host tool for custom_bindgen
Switch custom_bindgen to use any HostToolProvider
instead of just Rust modules, so any host binary can
be used as the bindgen wrapper.

Bug: 242243245
Test: presubmit
Change-Id: I9ba189b2857b3049dcf14842c178ce5846bab2f7
2023-07-07 04:59:07 +00:00
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