Commit graph

1107 commits

Author SHA1 Message Date
Ivan Lozano
ab58647b2e rust: Add an option to disable LTO for Rust
This adds an option to disable LTO when building a Rust module. This is
mostly intended to speedu p local prototyping, and LTO should not
normally be disabled for production builds.

Bug: 339628497
Test: m blueprint_tests && m rust
Change-Id: I21d5d4513a259a56f101ce8906e2bef7404e4efb
2024-05-17 10:11:57 -04:00
Ivan Lozano
e8fcd37775 Merge changes from topic "rust-made-to-order-staticlibs" into main
* changes:
  rust: made-to-order rust staticlibs
  rust: refactored transformSrctoCrate
2024-05-17 12:40:36 +00:00
Ivan Lozano
0a468a4f3b rust: made-to-order rust staticlibs
Whenever any two Rust static libraries are included
as static libraries anywhere in a CC dependency tree, we sometimes
get duplicate symbol errors. To avoid this, we no longer
directly link multiple rust static libs to CC modules.

Instead, we build rust_ffi_rlib modules and produce the actual
static library that gets linked against the CC module based on
that CC module's full list of Rust rlib dependencies.

This introduces a new static_rlibs property for cc modules to
define the rust_ffi_rlib dependencies, which are then used to
generate the module above.

This CL is intended to deprecate rust_ffi_static. It leaves
rust_ffi_static and rust_ffi static variants in place until
the remaining rust_ffi_static declarations and uses can be
removed. In the meantime, rust_ffi_static produces
rust_ffi_rlib variants as well to make the transition easier.

Bug: 254469782
Test: m # with no changes
Test: m libapexsupport # with static_rlibs
Test: m libunwindstack # with static_rlibs
Test: m netsimd # with static_rlibs, no duplicate symbols
Test: m blueprint_tests # New Soong tests

Change-Id: I47e27ac967ef0cad46d398ebf59d8275929ae28a
2024-05-16 13:00:43 -04:00
Ivan Lozano
28ed8f4f83 rust: refactored transformSrctoCrate
Refactor transformSrctoCrate and the functions it calls to not rely
on rust.ModuleContext, preparing it to be callable from soong-cc
context to build a Rust staticlib.

This also refactors out common default flags used when building
libraries, again to prepare for building a Rust staticlib from
a soong-cc context.

Bug: 254469782
Test: m blueprint_tests && m
Change-Id: I678f6fee989c61bb15c340b9887e4d1934991907
2024-05-16 10:32:08 -04:00
Justin Yun
40182b6ff3 Remove duplicated CollectDependencyAconfigFiles()
android.ModuleBase already calls aconfigUpdateAndroidBuildActions()
that is the same with CollectDependencyAconfigFiles(). Remove the
CollectDependencyAconfigFiles() to avoid duplication with
aconfigUpdateAndroidBuildActions().

To make the aconfig information available in
GenerateAndroidBuildActions() of all modules, call
aconfigUpdateAndroidBuildActions() before calling
GenerateAndroidBuildActions() of each module.

Also, we don't need SetAconfigFileMkEntries(), which is a duplicate
of aconfigUpdateAndroidMkData()

Bug: 335363964
Test: diff `adb shell printflags` before and after the change.
Change-Id: I52808e442e9fed7db1eae7b7c5ed0b1c5ba74f5d
2024-05-10 10:00:14 +09:00
Cole Faust
3f01580c04 Merge "Make the enabled property configurable" into main 2024-05-07 17:49:10 +00:00
Charisee
cd3ac91bdc rustc-1.77.1.p1 Build 11801116
Bug: http://b/331848727
Test: m rust
Change-Id: I68cb748f0de97cc92dbfbfff79d641a64dd51d8e
2024-05-06 21:30:12 +00:00
Ivan Lozano
3b591c771a rust: Support for generated c files from bindgen
To handle static inline functions, bindgen generates a C file which is
expected to be compiled and linked into dependents on the generated
bindgen source.

This CL adds support for cc modules ingesting this output and for
bindgen to produce it (and link it against the bindgen rust_library
variant as well).

Bug: 290347127
Test: m blueprint_tests
Test: Example module with static inline functions builds locally
Change-Id: I167a8356eb6e0059fc21169fd3bfc6bf4d9c812f
2024-05-03 14:01:09 -04:00
Cole Faust
a963b94cde Make the enabled property configurable
This allows using select statements with it.

Bug: 323382414
Test: m nothing --no-skip-soong-tests
Change-Id: I6f3efaaa3d82505e38a91ee4ba0e18e404360191
Merged-In: If355d24506e3f117d27b21442a6c02bca3402dc7
2024-05-02 15:41:24 -07:00
Ivan Lozano
ec6dc938c9 Merge "rust: Add a default cfg indicating an AOSP build" into main 2024-05-01 17:53:47 +00:00
Ivan Lozano
07fd7e32fd rust: Add a default cfg indicating an AOSP build
This adds a cfg flag `android_platform` which can be used
to indicate there's some conditional compilation need specific to
AOSP.

Test: New flag is emitted on builds
Change-Id: I833a7d68db2dad7ab2d32a5eb51d764f0d66b849
2024-05-01 10:41:35 -04:00
Matthew Maurer
c1e0cb695b rust: Don't suppress adding deps for rust-project.json device override
When switching from an initially found host module to a later found
device module, we passed `cInfo.Deps` through. This actually suppresses
addition of some modules, which was not the intention.

Bug: 336695421
Test: SOONG_GEN_RUST_PROJECT=1 m blueprint_tests
Test: check rust-projects.json manually afterwards for deps
Change-Id: Ib90f9c755e07f88e85a3b3cbd9bc698cce8af038
2024-04-30 23:26:29 +00:00
Yu Liu
24cd8c3756 Merge "Only link the profile extras lib for device variant for rust." into main 2024-04-25 22:45:57 +00:00
Treehugger Robot
c66702491f Merge "Shard rust protobuf sources" into main 2024-04-24 23:02:54 +00:00
Colin Cross
f526863a40 Shard rust protobuf sources
Shorten the command line for generating rust protobuf sources
by sharding the sources into groups of 50 source files.

Bug: 322564768
Bug: 336323108
Test: builds
Change-Id: Ia8069cdaf49f9a42d14a83139545ba61277418e0
2024-04-23 10:47:00 -07:00
Ellen Arteca
810c37ec1e Adds support to bindgen to handle static inline fcts
Adds support for bindgen to be able to handle `static inline`
functions. This is done by adding a new boolean field to the `BindgenProperties`
struct, `Handle_static_inline` (default to false).
If this field is true, then the flags to trigger bindgen support of
static inline functions are passed in.

The rust-bindgen documentation list two ways of handling `static inline`
functions, both specified with command line args.
1) --generate-inline-functions
2) --experimental --wrap-static-fns

Option 1 requires some extra effort on the part of the C library developer, in
that they have to expose the function symbols: the docs (linked below) explain
that this is often done by compiling the library with inlining disabled, which
can be detrimental to performance.

Option 2 requires no effort on the part of the C library developer, but it does
require the `--experimental` flag, since this feature is still under development.

This CL goes with option 2.

Relevant docs: https://github.com/rust-lang/rust-bindgen/discussions/2405

This CL also adds a new test: TestBindgenHandleStaticInlining in bindgen_test.go

Test: m blueprint_tests
Change-Id: If28000e3f3ccecc65c4cae1c62d7bf455454239a
2024-04-23 00:48:25 +00:00
Yu Liu
f0cf1cce98 Only link the profile extras lib for device variant for rust.
Bug: 297082598
Test: CI
Change-Id: Id66ce88d8c8a757c53ecb7ba0d101511d81eb911
2024-04-18 19:35:34 +00:00
Alex
91c74762f8
rust: Remove unnecessary escaping in grep call
Replicate cfeec1c2dd in the Clippy rule.

Bug: 333445551
Change-Id: I84134569af0f28730a483f091e6da4c78de83b9c
2024-04-12 11:04:22 +02:00
Ivan Lozano
2aee601e95 Merge "rust: Fix handling of bindgen header libs" into main 2024-04-11 13:20:46 +00:00
Charisee
92b7f386e0 rustc-1.77.1 Build 11685613
Test: m rust
Change-Id: I381106a54245b5d096dfcb0b3449f7ef440d067c
2024-04-09 19:39:01 +00:00
Cole Faust
8982b1c49e Remove "exported" ninja variables
There was infrastructure to export ninja variables to bazel. Now that
the bazel migration is cancelled, we don't need it anymore.

Bug: 315353489
Test: m nothing
Change-Id: I298cc2ac7ebd004557be3b30d75f7357cab0b7a0
2024-04-09 09:42:37 -07:00
Kiyoung Kim
4e765b1bfc Remove Device VNDK version usage from Soong
As of VNDK deprecation, Device VNDK version should no longer be used
from build. This change removes all references on Device VNDK version
and related logic with it.

Bug: 330100430
Test: AOSP CF build succeeded
Change-Id: Ibc290f0b41e8321f80c75c69f810223989af68dc
2024-04-05 01:57:32 +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
Kiyoung Kim
1db4a74a59 Remove VNDK information from Rust, etc, and sysprop tests
VNDK is deprecated in 24Q2, so soong should be tested with no device and
platform vndk versions. This change removes all VNDK related tests and
VNDK versions from soong-etc, soong-rust and soong-sysprop tests.

Bug: 330100430
Test: m nothing --no-skip-soong-tests passed
Change-Id: Ie34d23f0facab31078de54682f7cc78d37fcd4be
2024-04-01 15:53:58 +09:00
Ivan Lozano
e2524fb87e Merge "rust: Remove unnecessary escaping in grep call" into main 2024-03-29 16:31:44 +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
Ivan Lozano
cfeec1c2dd rust: Remove unnecessary escaping in grep call
Modules with special characters wouldn't build correctly because $out
was being double escaped -- once in the build command and once by Soong
itself.

Remove the escape in the build command and just let Soong escape as
necessary.

Bug: 320578837
Test: Module with @ in name builds
Change-Id: Ic2554b9c07f37783287e1ebdeb06ef8b7b66a296
2024-03-28 19:27:24 +00:00
Kiyoung Kim
0d1c1e6aef Remove VNDK information from CC and APEX tests
VNDK is deprecated in 24Q2, so soong should be tested with no device and
platform vndk versions. This change removes all VNDK related tests and
VNDK versions from soong-cc and soong-apex tests.

Bug: 330100430
Test: m nothing --no-skip-soong-tests passed
Change-Id: I45e6c13e6c0a6bc9710b120e8d5b167e2051631e
2024-03-28 15:15:01 +09:00
Kiyoung Kim
d8ec229bc0 Remove vendor_snapshot_test
Remove vendor_snapshot_test from cc and rust as they are no longer in
support.

Bug: 330100430
Test: m nothing --no-skip-soong-tests passed
Change-Id: Ia798bc1c87d3f1d73ea5866dc85ff4073f5f9c5b
2024-03-28 15:11:16 +09:00
Ivan Lozano
aad0b20d2b Merge "rust: Add export_include_dirs property to rust_ffi" into main 2024-03-22 12:59:06 +00:00
Ivan Lozano
f033ca61a2 rust: Add export_include_dirs property to rust_ffi
The cc property include_dirs is neverallowed in certain paths since it
has been deprecated. The property in rust_ffi modules with the same name  functionally works the same way as the CC property export_include_dirs.

To reduce confusion, and avoid triggering the neverallow rule, deprecate
include_dirs and create an export_include_dirs property which does the
same thing. This brings rust module properties into better alignment
with cc module property as well, reducing confusion.

Bug: 330736943
Test: New Soong test
Change-Id: Ib2020a22e6747ac690c46dbff84e38744f93ed15
2024-03-21 17:53:19 +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
73cf0e87b4 Merge "Support rust in aconfig mode validation." into main 2024-03-18 20:49:35 +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
James Farrell
e288cdeda1 rustc-1.76.0 Build 11569723
Bug: https://issuetracker.google.com/issues/327204642
Test: m rust
Change-Id: I3b39a12d1379a9193d348b364897d7df9de16330
2024-03-13 19:47:51 +00:00
Stephen Hines
5f8dae514b Allow clippy::disallowed_names since it can be used for debugging
https://rust-lang.github.io/rust-clippy/master/index.html#/disallowed_names

The current list is extremely short ("foo", "baz", "quux"), and thus
this really just prevents people from temporarily using `foo` to debug
code. In the spirit of improving productivity and reducing frustration,
it's easier to just allow this.

Bug: N/A
Test: TH
Change-Id: I50b65486ed2b58bfd2cf699ee3b43b936d25f2cb
2024-02-29 10:12:19 -08:00
Yi Kong
52e5e6b1a7 bindgen: set -Wno-unknown-warning-option flag by default
Test: presubmit
Change-Id: Id8547c0b3263f4e3b060f8b0fce2aef8a494b1b2
2024-02-25 12:49:41 +08:00
Stephen Hines
b0e708d03d Merge "rustc-1.75.0 Build 11471753" into main 2024-02-22 07:29:40 +00:00
Andrew Walbran
a5deb7307d Revert^4 "Integrate Rust-specific System Properties into rules generation."
This reverts commit 2766baa922.

Reason for revert: Relanding after fix in I3b190ebc1a1096972d0a1273e490972e04684dd2

Change-Id: Ie34301c506d3469ec3306f433631b0842b66d032
2024-02-21 11:53:18 +00:00
Stephen Hines
41f2ab846a rustc-1.75.0 Build 11471753
Bug: https://issuetracker.google.com/issues/321303117
Test: m rust
Change-Id: I90f0efb4eb3b6fcc41fbe256a9079e0e5647663c
2024-02-20 14:59:31 -08:00
Joonhun Shin
af9fc549ca Merge "Revert "Make building Rust targets faster in eng builds"" into main 2024-02-16 07:56:01 +00:00
Joonhun Shin
fad3e69d7f Revert "Make building Rust targets faster in eng builds"
This reverts commit 6146cf4b98.

Reason for revert: <b/325547632>

Change-Id: Ifd3619c5db5b989edb4aa2c37f85e5cd88d0c633
2024-02-16 07:26:14 +00:00
Chris Wailes
3fae67a32d Merge "Make building Rust targets faster in eng builds" into main 2024-02-15 23:12:27 +00:00
Paul Duffin
a0f0bdbced Merge "Revert^3 "Integrate Rust-specific System Properties into rules generation."" into main 2024-02-15 12:45:47 +00:00
Paul Duffin
2766baa922 Revert^3 "Integrate Rust-specific System Properties into rules generation."
This reverts commit ac0c87311d.

Reason for revert: breaking the same bug, b/323833345 as before

Change-Id: I474c032148f22c4b98f7adf23be61807fa0500a0
2024-02-15 11:54:17 +00:00
Andrew Walbran
e38e2c0071 Merge "Revert^2 "Integrate Rust-specific System Properties into rules generation."" into main 2024-02-15 10:31:49 +00:00
Andrew Walbran
ac0c87311d Revert^2 "Integrate Rust-specific System Properties into rules generation."
This reverts commit be3ea4f149.

Reason for revert: Reland

Change-Id: Ic003c52a1477da9a6a70b82e4d4ae4a55edc584f
2024-02-14 10:25:55 +00:00
Ivan Lozano
c2d4959bb4 Merge "rust: Re-enable host address sanitizer." into main 2024-02-13 16:34:42 +00:00
Colin Cross
a82de712b3 Merge changes from topic "revert-2952265-revert-2925209-KVPWEBRQHT-BBCOVJBOVF" into main
* changes:
  Remove fdoProfileMutator
  Convert AFDO mutators to TransitionMutator
2024-02-12 19:31:00 +00:00
Ivan Lozano
357433ae73 rust: Re-enable host address sanitizer.
Our toolchain supports a flag "-Z external-clangrt=true" which prevents
rustc from emitting a missing dependency to librust-dev_rt. Instead, we
link in libclang_rt.

Bug: 304507701
Bug: 324826914
Test: SANITIZE_HOST=address m aconfig
Change-Id: I8020c550b7a922c80620f61c22e01848a4f4a349
2024-02-12 14:16:26 -05:00