Commit graph

1011 commits

Author SHA1 Message Date
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
Treehugger Robot
e0a5c5ae1d Merge "Define __ANDROID_VENDOR_API__" into main 2023-12-05 03:48:26 +00:00
Colin Cross
0d5dd390c6 Merge "Move test data installation to Soong" into main 2023-12-01 18:56:01 +00:00
Matthew Maurer
15675d5936 rust: Enable ELF TLS by default in platform Rust
Upstream currently uses pthread keys to emulate TLS on Android because
it historically did not have it, and is going to move to LLVM emulated
TLS, which is needed to target L. Since we know the platform is Q+, we
can just use the new features.

Test: Treehugger
Change-Id: I7c7747d89cba736377cfeb4080573a89b801e8fe
2023-11-30 23:12:55 +00:00
Colin Cross
5c1d5fb21b Move test data installation to Soong
To generate module-info.json in Soong for b/309006256 Soong needs to
know the test data paths. Moving test data installation into Soong will
also help later for test suite packaging.

Add ModuleContext.InstallTestData that installs the files listed in a
[]DataPath alongside the test.  The files will also be passed to Make
to allow it to continue packaging them into the test suites for now.

Update the module types that are producing LOCAL_TEST_DATA entries
in their Android.mk files to go through InstallTestData instead.

Bug: 311428265
Test: atest --host toybox-gtests --test-timeout=120000
Change-Id: Ia8b964f86e584ea464667fd86a48d754d118bead
2023-11-30 13:38:49 -08:00
Justin Yun
41cbb5e9b5 Define __ANDROID_VENDOR_API__
cc modules can use __ANDROID_VENDOR_API__ to read BOARD_API_LEVEL
that is the API level of the vendor surface.

Bug: 313822931
Test: check ninja commands to have -D__ANDROID_VENDOR_API__=<version>
Change-Id: Iceb5918cbfce0f24929d02d7e3caf1e9942b88e8
2023-11-30 05:26:12 +00:00
Charisee
67b2923cd0 rustc-1.73.0 Build 11110309
bug: http://b/303252546
Test: m rust
Change-Id: Ic8f99af411665b7eaef81d9ca15342e1ea396fc3
2023-11-27 22:30:13 +00:00
Treehugger Robot
359611c1df Merge "rust: rust-project.json: Skip disabled modules" into main 2023-11-27 21:12:11 +00:00
Matthew Maurer
5a3c71c1aa rust: rust-project.json: Skip disabled modules
Disabled modules may not have a valid root path.

Bug: 313410568
Test: SOONG_GEN_RUST_PROJECT=1 m nothing
Change-Id: I253cca18493193245aa198adfce5fd75cf27cefb
2023-11-27 17:54:03 +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
Matthew Maurer
db72f7ed80 rust: Resolve crate roots outside rust-project
Previously, we manually re-computed crate roots inside project_json for
rendering rust-project.json. In addition to added complexity, this meant
that generated sources and glob sources would not render correctly - it
would select e.g. `src/**.rs` or `:foo` as a crate root.

Use a centralized computation of crate roots instead.

Bug: 309943184
Test: SOONG_GEN_RUST_PROJECT=1 m nothing, compare rust-project.json
Change-Id: I0caddbf600d025a0041f45e69812cdd6f1761234
2023-11-22 00:52:34 +00:00
Matthew Maurer
a28404a7b0 rust: Cache crateRootPath to avoid ctx
This makes it possible to call crateRootPath in situations where a
ModuleContext is unavailable.

Test: m nothing
Bug: 309943184
Change-Id: Iee20b0606954a18ca516cdac40917d0016f94a05
2023-11-22 00:52:14 +00:00
Matthew Maurer
1d8e20d744 rust: internalize srcPathFromModuleSrcs
This was frequently misused (for example, in the prebuilts module, it
was used as a complex "assert(len(srcs))==1"), and can be superceded by
getCrateRoot anywhere it was used. It's now only called from
compiler.go, and can drop the second return parameter, as it was only
actually used by the prebuilt assert misuse.

Bug: 309943184
Test: m nothing
Change-Id: I6c92580bc8f0ecb7586c544056b5409e6dd280e7
2023-11-22 00:52:10 +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
d221d31534 rust: move crateRootPath to compiler
Test: m nothing
Bug: 309943184
Change-Id: I45028945357c394301d93ca7995a4f9adf281931
2023-11-20 21:02:40 +00:00
Matthew Maurer
cd41653b96 rust: Privatize Cargo* methods on compiler
These methods aren't used outside, and probably shouldn't be.

Bug: 309943184
Test: m nothing
Change-Id: Ia7dd5220ccd10c0136aa16f5e21149eaf7a03ea1
2023-11-20 20:25:27 +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
Colin Cross
7e2e794333 Fix soong for go test ./...
Fix various issues that prevent building or running tests with the
Go tools:

Remove testing/test_spec_proto/go.mod.  There's already a go.mod at
the top level, and adding testing/test_spec_proto/go.mod breaks
compiling with the Go tools in IntelliJ or from the command line.

Fix go vet issues when trying to print []DataPath.

Fix aconfig_conversion_test.go and add it to Android.bp so it runs
in presubmit.

Test: go test ./...
Change-Id: I18af2f05631446fe507744a2951e4b02c7ab59be
2023-11-17 21:28:39 +00:00
Ivan Lozano
c518202e28 rust: Allow no_stdlibs per-target variants.
stdlibs can be set per-target, it makes to sense to allow no_stdlibs to
be set per-target as well.

Bug: 310924208
Test: Android.bp with per-target no_stdlibs builds.
Change-Id: I1c3a458a849367d2c363bd5f65af77b8cce8c0e0
2023-11-14 10:40:08 -05:00
Colin Cross
f96b001064 Don't call android.PathForModuleSrc(ctx).String() to get ModuleDir
ctx.ModuleDir is much cheaper than android.PathForModuleSrc(ctx).String().

Test: builds
Change-Id: I81819088d9564b06a0336a59a45f2b110b0bd9d6
2023-11-02 19:07:49 +00:00
Treehugger Robot
9301b11e06 Merge "fix some moved code from revert of aosp/2518976" into main 2023-10-31 23:25:01 +00:00
Chris Wailes
d6c5839be2 rustc-1.72.1 Build 11023353
Bug: https://issuetracker.google.com/issues/307308192
Test: m rust
Change-Id: Iadcb2d74b5e90d3488bdf6e156345d358d6c4a82
2023-10-30 14:15:31 -07:00
Sam Delmerico
c5cf990797 fix some moved code from revert of aosp/2518976
aosp/2768553 reverted aosp/2518976, but there was some code that was
moved in between these two commits. This commit removes a code block
for some envvars that were moved in aosp/2638675, and adds back the code
for the ANDROID_RUST_DARWIN envvar.

Change-Id: I9ac09c608fe64340535ac493ab7f07ecb9b9c335
2023-10-25 17:29:46 +00:00
Eric Rahm
25acde2f56 Reapply "Use zstd to compress debug info in rust libraries"
This reverts commit 99d682ad4a.

Test: m
Bug: 305277519
Change-Id: I33c951265229d9f65670760c2255625ef3226707
2023-10-20 16:01:14 +00:00
Matías Hernández
a76ea9ac49 Merge changes from topic "revert-2788316-JFVDBRFDKA" into main
* changes:
  Revert "Decompress debug sections when creating debug info"
  Revert "Compress debug info in clang builds with zstd"
  Revert "Use zstd to compress debug info in cc libraries"
  Revert "Use zstd to compress debug info in rust libraries"
2023-10-20 15:48:28 +00:00
Matías Hernández
99d682ad4a Revert "Use zstd to compress debug info in rust libraries"
Revert submission 2788316

Reason for revert: DroidMonitor-triggered revert due to breakage https://android-build.corp.google.com/builds/quarterdeck?branch=git_main&target=panther-next-userdebug&lkgb=10981485&lkbb=10981536&fkbb=10981536, bug b/306625613

Reverted changes: /q/submissionid:2788316

Change-Id: I78830209e04e5cd8872d75ec3a0faa46acd47ac6
BUG: 306625613
2023-10-20 13:07:14 +00:00
Eric Rahm
b60cd11bc7 Merge changes Ia85d8dc0,I4ab3d47f,Ieeaa6554,I0b3c1f08 into main
* changes:
  Use zstd to compress debug info in rust libraries
  Use zstd to compress debug info in cc libraries
  Compress debug info in clang builds with zstd
  Decompress debug sections when creating debug info
2023-10-20 10:32:13 +00:00
Eric Rahm
a806f9dc44 Use zstd to compress debug info in rust libraries
We can save a significant amount of disk space by compressing debug info
in rust builds. This adds a flag that configures compressing debug info
at the link stage for rust binaries.

Test: m
Bug: 305277519
Change-Id: Ia85d8dc0e7bea35d9f9abfeae27a4610b3113e78
2023-10-19 22:47:44 +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
Vinh Tran
59aa97a594 Merge "Remove restriction on android config in generated rust_library targets" into main 2023-10-16 19:08:35 +00:00
Chris Wailes
ed75eef953 Merge "Set incremental or codegen-units, not both" into main 2023-10-13 21:19:17 +00:00
Vinh Tran
fb8c5a54ea Remove restriction on android config in generated rust_library targets
Bug: b/290790800
Test: b build //external/rust/crates/... --config=android
Change-Id: Id06dc94f8bff519c09de7a0de0f1999cf310f599
2023-10-13 11:51:18 -04:00
Vinh Tran
308096475b Export rust flags for arm, x86, and x86_64 to Bazel
Test: b build //build/bazel/examples/rust:all --config=android
Bug: 295918553
Change-Id: I53d393f4cc5cd99ccd17d37e32211adaaba5bd0a
2023-10-12 14:59:50 -04:00
Chris Wailes
7c1b29c9a4 Set incremental or codegen-units, not both
This CL changes the handling of Rust flags to only pass one of either
incremental or codegen-units.  This is necessary because incremental
implies a codegen-units value of 128 and it may be overridden by the
separate codegen-units argument.

Test: TH
Change-Id: Ia474e4f9fc071d5054cb479ec9de550fa886677e
2023-10-12 10:56:34 -07:00
Ivan Lozano
839b5f9ac5 rust: Temporarily disable ASAN builds for Host
This is breaking sanitized host builds. Disable the sanitizer in Rust
for host targets until this can be resolved.

Bug: 304507701
Test: SANITIZE_HOST=address m rust
Change-Id: I12b0c3e217717de7a89b32198f4c4729709e99b3
2023-10-11 13:18:37 -04:00
Ivan Lozano
829e1e9378 rust: Emit -x c++ for bindgen modules with cpp_std
rust_bindgen modules which defined cpp_std with a .h file were not
correctly emitting the `-x c++` flag. This CL addresses that, and
ensures that if either cpp_std or c_std is set then the appropriate
behavior occurs no matter the file extension.

Bug: 304269101
Test: Soong tests
Change-Id: I71a8ae30ac0ed502d9d3fbf2f3039b0c56529d39
2023-10-09 11:52:18 -04:00
Vinh Tran
8321763764 Export device arm64 rust flags to Bazel
Test: b build //build/bazel/examples/rust:all --config=android
Change-Id: I2656dc963cc4fe0c42da52a0d2a235b5cd86fa13
2023-10-04 18:26:13 -04:00
Vinh Tran
50de8becd1 Export rust flags to bazel
Bug: 290790800
Test: Inspect out/soong/soong_inspection folder after running `m bp2build`
Change-Id: Iffc43a540f67e5f07d109a0a87f3248fae035267
2023-10-04 13:14:32 -04:00
Colin Cross
ff4d5b40ca Merge "Don't pass -lrt or -lgcc_s to darwin rust compiles" into main 2023-10-04 16:36:03 +00:00
Justin Yun
ce12ea8f95 Merge "Generate product variants by default" into main 2023-10-04 06:29:31 +00:00
Colin Cross
e18bd2097b Don't pass -lrt or -lgcc_s to darwin rust compiles
Fix mac builds by removing the -lrt and -lgcc_s flags from darwin
rust compiles.

Bug: 293349612
Test: builds
Change-Id: I99a9fea963761730efc4d3236135ee6d83dbca57
2023-10-03 21:45:33 -07: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
Sam Delmerico
1579a91352 Merge "add testcases for rust output file paths" into main 2023-09-29 08:35:28 +00:00
Sam Delmerico
079a97c778 add testcases for rust output file paths
Prepare for changing rust rules by testing that output file names will
match. A build failure in b/301463284 was partially caused by output paths changing and resulting in old files building up on buildbots which filled the disk. This unit test will ensure that the file paths of rust modules do not change and cause the same failure.

Bug: 301463284
Bug: 286077158
Change-Id: I1baba2c63ad29a2c98e378fce0a2ed32bc319c1e
2023-09-29 08:35:04 +00:00
Ivan Lozano
a0d741edef Merge "rust: Import protos from dependent rust_protobuf" into main 2023-09-28 15:58:48 +00: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
Sam Delmerico
7a346cdaa0 Revert^2 "rustSetToolchainSource to use linux-x86 srcs"
7ba7e8232b

Change-Id: Ia10aede6a8b7422848146500506458ae495f7b9a
2023-09-27 20:45:48 +00:00
Sam Delmerico
ec59517f6a Merge changes from topic "reland-rust-sbox-1" into main
* changes:
  Revert^2 "conditionally escape rule builder command"
  Revert^4 "allow Ninja variables in RuleBuilder API"
  Revert^4 "add crate_root property to rust modules"
  Revert^4 "add rust_toolchain_rustc_prebuilt module type"
2023-09-27 08:10:26 +00:00