Commit graph

980 commits

Author SHA1 Message Date
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
Justin Yun
af1fde43f9 Generate product variants by default
PRODUCT_PRODUCT_VNDK_VERSION is set to 'current' by default. Now, we
can generate product variants without checking the
PRODUCT_PRODUCT_VNDK_VERSION build variable. Remove reading the
PRODUCT_PRODUCT_VNDK_VERSION variable from soong and generate product
variants by default.

Bug: 302255959
Test: m
Change-Id: I9a9b2076f4367c5ce9a393bbb206f8dee3884bd8
2023-09-27 16:36:40 +09: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
Sam Delmerico
63ca14e9b7 Revert^4 "add crate_root property to rust modules"
9c64274b27

Change-Id: I1c4dad76842cebf18cd82e04e435910f09038d07
2023-09-25 12:13:17 +00:00
Sam Delmerico
f2b16069bb Revert^4 "add rust_toolchain_rustc_prebuilt module type"
930fd8bfb1

Change-Id: Id3f3a66022a496aab7db93670a7bdf8507384875
2023-09-25 12:13:17 +00:00
Wen-yi Chu
930fd8bfb1 Revert^3 "add rust_toolchain_rustc_prebuilt module type"
9333ac1249

Change-Id: Ic7f064806553a0cfbc286136a764b5ea3898d06c
2023-09-22 22:05:54 +00:00
Wen-yi Chu
9c64274b27 Revert^3 "add crate_root property to rust modules"
60375c4adf

Change-Id: I356e936139592893a47d4c6b9e747f24470b11f9
2023-09-22 22:05:54 +00: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
7ba7e8232b Revert "rustSetToolchainSource to use linux-x86 srcs"
Revert submission 2758566

Reason for revert: b/301463284

Reverted changes: /q/submissionid:2758566

Change-Id: Ia4966732e9bec105c854f09aa0523329ef4d8fd0
2023-09-22 22:02:28 +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
fbec3a5f5c rustSetToolchainSource to use linux-x86 srcs
This was hardcoded in previously, and aosp/2746467 changed this to use
the HostPrebuiltTag instead which caused errors. Reverting back to
original implementation.

Change-Id: I8ed1919aa2ea737f7836fab39f9ee0663fb455d2
2023-09-21 05:25:56 +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
Sam Delmerico
60375c4adf Revert^2 "add crate_root property to rust modules"
5162ff14fc

Change-Id: I9a76df938639676ee4aa7bdd2b2902e0e6df08d5
2023-09-15 22:41:51 +00:00
Sam Delmerico
9333ac1249 Revert^2 "add rust_toolchain_rustc_prebuilt module type"
400749d1f0

Change-Id: I63f04e13605c43f800f01f45345e4b3dc61aefb7
2023-09-15 22:40:16 +00:00
Treehugger Robot
2e3f8e6b35 Merge "Enable target features for riscv64 Rust builds" into main 2023-09-15 18:42:40 +00:00
Chris Wailes
820ec84427 Enable target features for riscv64 Rust builds
This CL enables the following features for riscv64 Rust builds in
Android: V, Zba, Zbb, and Zbs

Test: m rust
Bug: 300313717
Bug: 300312461
Change-Id: I8712b1850a60a05e99a3e89e602bb56d2ccf2563
2023-09-13 16:39:17 -07:00
James Farrell
732b37f7bf rustc-1.72.0 Build 10803849
Bug: https://issuetracker.google.com/issues/295883071
Test: m rust
Change-Id: I5bd81a4ceecf21aa2984c07186b2713159501273
2023-09-13 23:34:18 +00:00
Ivan Lozano
085efff213 rust: Emit frame pointers on 64-bit device targets.
Frame pointers can aid in unwinding and reading stack traces.

Bug: 298267402
Test: m rust
Change-Id: I48bf5ef9ffa9912d6af5fc2b7297f250d15718ea
2023-09-12 13:28:37 -04:00
Treehugger Robot
e79010c7ca Merge "Revert "rustc-1.72.0 Build 10752340"" into main 2023-09-11 22:29:04 +00:00
James Farrell
5d4be57cac Revert "rustc-1.72.0 Build 10752340"
Revert submission 2736851-rust-1.72

Reason for revert: Breaks Mac builds

Change-Id: I94a30e61f9f717ad135fbef7ec7241730f583110
2023-09-11 20:01:49 +00:00
Treehugger Robot
d15dcb7158 Merge "rustc-1.72.0 Build 10752340" into main 2023-09-11 18:20:20 +00:00
Sam Delmerico
1d3740a274 Merge changes from topic "revert-2605644-rulebuilder-ninja-vars-OAAWYCDDLT" into main
* changes:
  Revert "add rust_toolchain_rustc_prebuilt module type"
  Revert "add crate_root property to rust modules"
  Revert "allow Ninja variables in RuleBuilder API"
2023-09-08 20:46:55 +00:00
Sam Delmerico
400749d1f0 Revert "add rust_toolchain_rustc_prebuilt module type"
Revert submission 2605644-rulebuilder-ninja-vars

Reason for revert: b/299568218

Reverted changes: /q/submissionid:2605644-rulebuilder-ninja-vars

Change-Id: Ic3d1ba7e8a61427b52f31cc3f187c9d5a7d9a7bb
2023-09-08 16:10:47 +00:00
Sam Delmerico
5162ff14fc Revert "add crate_root property to rust modules"
Revert submission 2605644-rulebuilder-ninja-vars

Reason for revert: b/299568218

Reverted changes: /q/submissionid:2605644-rulebuilder-ninja-vars

Change-Id: I17645fcff117909c09a016157235805f0974340b
2023-09-08 16:10:47 +00:00
Treehugger Robot
9abcf649a7 Merge changes from topics "rulebuilder-ninja-vars", "rustc_prebuilt_build_tool" into main
* changes:
  allow Ninja variables in RuleBuilder API
  add crate_root property to rust modules
  add rust_toolchain_rustc_prebuilt module type
2023-09-08 00:10:18 +00:00
Yi Kong
06521c4f46 Update rust bindgen to clang-r498229b
Bug: 293616148
Change-Id: I5102c5834a4f2f74242d57c9ec946d0b9381e893
Test: presubmit
2023-09-07 07:18:50 +00:00
James Farrell
26b90d5474 rustc-1.72.0 Build 10752340
Bug: https://issuetracker.google.com/issues/295883071
Test: m rust
Change-Id: Ie37d902ae16d8471785cc54beaea5a2c82f063b1
2023-09-07 01:08:02 +00:00
Colin Cross
3ef9285ed2 Disable rust sanitizers for linux_musl_x86
rustc 1.71.0 doesn't support any sanitizers for linux_musl_x86, disable
sanitizing for now.

Bug: 257334542
Test: m USE_HOST_MUSL=true host-native
Change-Id: I70819d2175c59bca1ff385d4aee48518d6b702e7
2023-09-05 12:10:54 -07:00
Sam Delmerico
553edff9dd add crate_root property to rust modules
The crate_root property will be used to specify the entry point for a
rustc compilation. This will allow the srcs property to be used to
collect all src inputs to rustc rather than just the entry point.

Bug: 286077158
Test: m libnum_traits
Change-Id: I1a167182305dcc11cc927d562ceed622153111d3
2023-08-31 18:03:33 +00:00