Commit graph

264 commits

Author SHA1 Message Date
Ivan Lozano
2aee601e95 Merge "rust: Fix handling of bindgen header libs" into main 2024-04-11 13:20:46 +00:00
Kiyoung Kim
37693d0a27 Deprecate Snapshot build
Existing snapshot code will no longer work from VNDK deprecation, but it
can give confusion to users if we keep code for the snapshot - and it
adds complexity on existing code while it is not in use. This change
removes all snapshot definition except host snapshot and its usage.

Bug: 330100430
Bug: 332986564
Test: AOSP CF build succeeded
Change-Id: Ieb6fa43d5e38315c662ce997bc305b744b367c24
2024-04-05 01:56:56 +00:00
Ivan Lozano
1dbfa144f9 rust: Fix handling of bindgen header libs
Static libraries were being appended to the list of header library
dependencies. They should not be. This also makes sure we track them
appropriately in Make.

Test: m blueprint_tests
Change-Id: Ifa664f09fe2102aea57d22cbaaeba71f0c26074d
2024-03-29 16:30:30 +00:00
Andrew Walbran
52533237ef Add aliases property for renaming Rust dependencies.
This is equivalent to specifying a dependency name different to the
package name in cargo, which some external crates do.

Bug: 308790322
Test: Built libgrpcio with aliases for protobuf
Change-Id: I2801222051fdd962460cc7f4900cec357f63b974
2024-03-19 17:27:46 +00:00
Yu Liu
c888460e5d Support rust in aconfig mode validation.
Bug: 323071835
Test: Unit tests
Change-Id: I6de2a6fe1618e21c9aab728e6d77c6b0c6ce33df
2024-03-15 18:48:38 +00:00
Colin Cross
f5f4ad3db6 Convert coverageMutator to a TransitionMutator
Convert coverageMutator to a TransitionMutator as a step towards
variants-on-demand.

Bug: 319288033
Test: coverage_test.go
Test: treehugger coverage builds
Change-Id: Ic50c0040dea8b42c36b5d784221daa00b7b0d379
2024-01-24 10:17:10 -08:00
Kiyoung Kim
b5fdb2e966 Generate image variation without version
Current CC/Rust Image variations are generated with target VNDK version.
However, this is no longer valid if VNDK is deprecated. This change
generates image variation without version ("vendor", "product") if VNDK
is deprecated.

Bug: 316829758
Test: m nothing --no-skip-soong-tests passed
Test: aosp_cf_x86_64_phone build succeeded
Change-Id: I2387ed8a2632bfd9462621f882a947695ae1653d
2024-01-05 11:15:23 +09:00
LaMont Jones
aa005ae080 move CollectDependencyAconfigFiles to android
This needs to be called by some modules in android.

Bug: 308625757
Test: manual
Change-Id: I389fcfd88a3f4bd85a9218fdd4dd66d8a239bb67
2023-12-19 19:34:00 +00:00
Colin Cross
313aa5475f Convert OtherModuleProvider to generic providers API
Convert all of the callers of OtherModuleProvider/OtherModuleHasProvider
to use the type-safe android.OtherModuleProvider API.

Bug: 316410648
Test: builds
Change-Id: Id77f514d68761a262d9ea830a601dbed804bbbe5
2023-12-14 16:12:22 -08:00
Colin Cross
ff694a8c88 Convert Provider to generic providers API
Convert all of the callers of Provider/HasProvider to use the type-safe
android.ModuleProvider API.

Bug: 316410648
Test: builds

Change-Id: I73479de1625fa2865b6c73444cd477e50d56dc5a
2023-12-14 16:12:21 -08:00
Colin Cross
402130276c Convert SetProvider to generic providers API
Convert all of the callers of SetProvider to use the type-safe
android.SetProvider API.

Bug: 316410648
Test: builds
Change-Id: If58f4b5355264ddab2045bc3591a4eac19cd58fc
2023-12-14 16:12:20 -08:00
Colin Cross
bc7d76cca2 Convert NewProvider/NewMutatorProvider to generic providers API
Convert all of the callers to NewProvider and NewMutatorProvider
to use a generic type parameter instead of an example object.

Bug: 316410648
Test: builds
Change-Id: Ic9cdafc87336e26730d3fd596df05de0e7267542
2023-12-14 16:12:20 -08:00
Colin Cross
8ff105860d Remove ConvertWithBp2build implementations
Remove the ConvertWithBp2build implementations from all the module
types, along with the related code.

Bug: 315353489
Test: m blueprint_tests
Change-Id: I212672286686a318893bc7348ddd5a5ec51e77a7
2023-12-08 13:51:05 -08:00
LaMont Jones
0c97185450 rust: add aconfig_flag support
Bug: b/308625757
Test: manual
Change-Id: Ifd98cd0ad4e2525b08f5766e9332991c049162ea
2023-12-07 21:56:59 +00:00
Aditya Choudhary
26df39fe44 Add source file provider for genrule/srcs, python libraries and rust libraries.
Change-Id: I2d7d4684a10c15aeecc27b8db800ab27a807d2e2
2023-12-05 19:56:26 +00:00
Matthew Maurer
b103659c0b Merge changes I0caddbf6,Iee20b060,I6c92580b,I45028945,Ia7dd5220, ... into main
* changes:
  rust: Resolve crate roots outside rust-project
  rust: Cache crateRootPath to avoid ctx
  rust: internalize srcPathFromModuleSrcs
  rust: move crateRootPath to compiler
  rust: Privatize Cargo* methods on compiler
  rust: Move compiler interface to compiler.go
2023-11-22 20:37:27 +00:00
Aditya Choudhary
87b2ab28a8 Add test spec provider to test modules.
Provider added for the following test modules in this change: art_cc_test, cc_benchmark, cc_fuzz, cc_test, cc_test_host, rust_test,and rust_test_host.

Bug: 296873595
Test: Manual test
Change-Id: I815680529bcbecacb3a2bdb8f3746053afdee48c
2023-11-20 21:52:56 +00:00
Matthew Maurer
689d6f63e4 rust: Move compiler interface to compiler.go
Refactor cleanup

Bug: 309943184
Test: m nothing
Change-Id: I7dcb0af64a4db71fdc46c0876b22e5015c02438e
2023-11-20 17:49:25 +00:00
Vinh Tran
7515994523 Add bp2build converter for rust_ffi_static
Test: go test
Change-Id: Ibf0bb2687073f8650da4ca27c1f57e68a93025d4
2023-10-19 11:22:51 -04:00
Colin Cross
004bd3f526 Revert "Split Rust crate builds into compile and link phases."
This reverts commit e7c71c344d.
The intermediates created by the separated rust compile steps are very
large, on the order of 60GB.  This is more than CI can support for now,
revert the split into compile and link phases.  This comes at the expense
of incremental build time, especially when modifying C/C++ sources that
are dependencies of rust modules.

Bug: 293349612
Test: builds
Change-Id: I81169e7d0727330c8de5e7688dcdc87fe7b8d3b5
2023-10-02 22:15:55 -07:00
Ivan Lozano
d106efe76d rust: Import protos from dependent rust_protobuf
rust_protobuf were unable to import protos from other rust_protobuf
modules. This CL adds support for that. rust_protobuf modules which are
listed in rustlibs will have their modules imported into the generated
protobuf stub. Additionally, rust_protobuf modules which define
"exported_include_dirs" will export those include paths to dependent
rust_protobuf modules.

Bug: 301266700
Test: m rust
Change-Id: I132edffa4d77e0ac80a7ac934f873374c8e94c1b
2023-09-27 20:53:54 -04:00
Vinh Tran
47faaad254 Add bp2build for rust_protobuf module
We only supported bp2build for rust_protobuf_host because the non-host toolchain for rust is not checked in yet. aosp/2759750 changed a converted module from rust_protobuf_host to rust_protobuf and broke CI.

This CL adds bp2build support for rust_protobuf but makes the target incompatible with android os for now untilnon-host rust toolchain is checked in.

Bug: 301956497
Test: b build //build/make/tools/aconfig:all --config=android
Change-Id: I739896c79f32674000c2603e394f16860a6fc57d
2023-09-25 17:37:59 -04:00
Wen-yi Chu
41326c1f41 Revert "support sandboxed rust rules"
Revert submission 2629131-sandbox-rust-inputs

Reason for revert: Fail on android build.

Reverted changes: /q/submissionid:2629131-sandbox-rust-inputs

Change-Id: Ifd9aa46e80a12d8f4ffa0a2daa74b96727cbb7e6
2023-09-22 22:05:54 +00:00
Colin Cross
05cbcb3539 Revert "remove rust deps on clang prebuilts"
Revert submission 2758566

Reason for revert: b/301463284

Reverted changes: /q/submissionid:2758566

Change-Id: I54f0ecbbd922deb23009ca89ff79689e128f4f31
2023-09-22 22:02:28 +00:00
Sam Delmerico
476e876119 remove rust deps on clang prebuilts
Prebuilt modules for some clang tools were created in aosp/2746469, but they do not exist for darwin builds. Adding the same modules in prebuilts/clang/host/darwin-x86/Android.bp results in duplicate module names. Instead we can just get a path to these files directly in Soong.

Test: CI
Test: https://android-build.googleplex.com/builds/abtd/run/L90700000963131594
Change-Id: I620cfd7b1ab34bd0959feea562d599b963717198
2023-09-21 08:15:36 +00:00
Sam Delmerico
52d1cc334b Merge changes from topics "revert-2746976-revert-2605644-rulebuilder-ninja-vars-OAAWYCDDLT-KMAGKVIXAT", "sandbox-rust-inputs" into main
* changes:
  support sandboxed rust rules
  conditionally escape rule builder command
  Revert^2 "allow Ninja variables in RuleBuilder API"
  Revert^2 "add crate_root property to rust modules"
  Revert^2 "add rust_toolchain_rustc_prebuilt module type"
2023-09-20 18:48:21 +00:00
Chris Parsons
637458d326 Have ConvertWBp2build use Bp2buildMutatorContext
This no-op refactoring facilitates some upcoming functional changes for
"bp2build allowlist v2". The work requires that the bp2build conversion
mutator be changed from a TopDown mutator to a BottomUp mutator.
Refactoring all bp2build-related methods so that they use Bp2buildMutatorContext
makes it easier to make this functional change without touching tens of
files and multiple projects.

Bug: 285631638
Test: m bp2build
Change-Id: I3d1ef3064146e959c6f0dc315350fc9764bf2bd2
2023-09-20 14:49:35 +00:00
Sam Delmerico
a588d153c8 support sandboxed rust rules
This commit adds support for compiling rust rules inside the sbox
sandbox. To compile a rust module with sandboxing enabled, the entry
point to the crate must be specified via the `crate_root` property, and
all input sources and compile-time data must be specified via the `srcs`
and `compile_data` properties.

Bug: 286077158
Change-Id: I8c9dc5cf7578037a583b4be2e2f73cf20ffd4408
2023-09-15 22:46:56 +00:00
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
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
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
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
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
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
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
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
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
LaMont Jones
0c10e4dcc0 Parallelize singleton execution
Bug: 281536768
Test: manual, presubmits
Change-Id: I57fdc76ba6b277e88e196b506af87127a530fd37
2023-05-19 20:31:32 +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
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
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
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
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