Commit graph

8400 commits

Author SHA1 Message Date
Spandan Das
af72583468 Generate a ndk_sysroot target in bp2build
This target will have a dependency edge to every bp2build equivalent of
Soong's ndk_headers. In b builds, sdk variants will compile against this
aggregated CcInfo providing target

A non monolithic alternative was discarded after conversations in
b/300504837#comment1-5

Contents of bp2build generated target: https://paste.googleplex.com/6643820291686400

Implementation details
- Since there is no equivalent Soong module for ndk_sysroot, hardcode
  bp2build/build_conversion.go to collect all ndk_headers soong modules.
  Add them to `deps` of a ndk_sysroot target
- Create `ndk_sysroot` in build/bazel/rules/cc/BUILD.bazel. This is
  expected to be a temporary location. This will use the
  cc_library_headers macro
- Update SetStubsForDynamicDeps so that sdk variant of rdeps depends on
  //build/bazel/rules/cc:ndk_sysroot. This will provide a CcInfo during
  compilation. Since ndk_sysroot is of type cc_library_headers, it will
  not get packaged into the apk.
- Refactor `goBazelTarget` to a generic `bTarget` so that it is
  representative of the expanded usage by ndk_sysroot

Test: b build //build/bazel/examples/android_app/java/com/app:app_with_sdk_variant_of_jni_deps --config=android (with aosp/2755284)

Bug: 300504837

Change-Id: Ifa427dd78115703ab251b0e1a0b71d3f19e91008
2023-09-25 21:27:19 +00:00
Colin Cross
40c7bae1df Merge changes from topics "revert-2629131-sandbox-rust-inputs-JRFPQTIPEY", "revert-2758566-WBNIADIEXA" into main
* changes:
  Revert^3 "add rust_toolchain_rustc_prebuilt module type"
  Revert^3 "add crate_root property to rust modules"
  Revert^3 "allow Ninja variables in RuleBuilder API"
  Revert "conditionally escape rule builder command"
  Revert "support sandboxed rust rules"
  Revert "fix failing rust_aconfig_library test"
  Revert "rustSetToolchainSource to use linux-x86 srcs"
  Revert "remove rust deps on clang prebuilts"
2023-09-23 05:19:13 +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
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
Chris Parsons
6666d0f6b1 Switch bp2build mutator to bottom up
This should be no-op, as the underlying mutator has not changed yet.

Some other refactoring is required and done in this CL:

- Delete some old, dead ApiBp2build code
- Fix casting to TopDownMutator when it's not necessary

This change is required to prepare for allowlist v2 work, as only
BottomUp mutators can AddDependency.

Bug: 285631638
Test: m nothing
Test: presubmits
Change-Id: I5212a5f5634cc13056195783e6df37ff8eb000da
2023-09-22 19:19:22 +00:00
Liz Kammer
596ee5c82d Merge "Do not convert non-unit tests." into main 2023-09-22 14:08:53 +00:00
Spandan Das
7ba007a3c6 Merge "Create a bp2build converter for ndk_headers" into main 2023-09-21 23:11:33 +00:00
Liz Kammer
80b54d2502 Do not convert non-unit tests.
Test: CI
Change-Id: Iab9c134718351187859f34a26bd3a2aa66e009d5
2023-09-21 14:27:42 -04:00
Trevor Radcliffe
44e4102362 Merge "Revert "Block CFI on static libraries"" into main 2023-09-21 18:15:25 +00:00
Yu Liu
62f7302701 Merge "Convert cc_aconfig_library to bazel." into main 2023-09-21 17:43:07 +00:00
Trevor Radcliffe
85d55c2847 Revert "Block CFI on static libraries"
This reverts commit f9abec0987.

Reason for revert:
https://b.corp.google.com/issues/301444094
https://b.corp.google.com/issues/301443813
https://b.corp.google.com/issues/301437374

Change-Id: I6fd03e4d3c0930005178ad347f53156be8f15efc
2023-09-21 17:04:43 +00:00
Trevor Radcliffe
9483e4873c Merge "Block CFI on static libraries" into main 2023-09-21 13:05:21 +00:00
Yu Liu
855cfc2fac Convert cc_aconfig_library to bazel.
Bug: 297358249
Test: Unit test and CI
Change-Id: Ic84128b0df16efe4255b52b83670ec9902c09383
2023-09-20 17:46:46 -07:00
Spandan Das
319711b0bc Create a bp2build converter for ndk_headers
And add this module type to alwaysConvertList

Test: go test ./bp2build
Bug: 300504837
Change-Id: Ic09738ab47e7c497287b73de0f952d52aa78dd17
2023-09-20 23:04:02 +00:00
Spandan Das
9d47a82e27 Add version to stub label
This is a followup fix for aosp/2753352 that added the name of the
`cc_stub_suite` as deps of `unbundled_app` config setting. However,
cc_stub_suite is really a macro that expands to <name>-<ver>.

Add the version explicitly to rdeps

Bug: 298085502
Test: b build //build/bazel/examples/android_app/java/com/app:app_with_sdk_variant_of_jni_deps --config=android (with aosp/2755284)

Change-Id: I8cf2804141bb14589e11b03a138b715538a3f1ee
2023-09-20 23:04:02 +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
Christopher Parsons
c331812a59 Merge "Have ConvertWBp2build use Bp2buildMutatorContext" into main 2023-09-20 17:56:24 +00:00
Trevor Radcliffe
f9abec0987 Block CFI on static libraries
Bug: 295805467
Test: Unit tests and inspecting generated BUILD files
Change-Id: I1bbd2f48ad384e0b5b6f7cc1458b12ded2748e8f
2023-09-20 16:01:20 +00:00
Liz Kammer
8e9ccda5d8 Merge "Don't panic for unhandled product vars" into main 2023-09-20 15:10:18 +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
Liz Kammer
9e12c78637 Merge changes from topic "prebuilt-cc-shared-always" into main
* changes:
  Implement bp2build for java_sdk_library_import
  Always convert prebuilt libraries
  Always convert prebuilt cc library headers
2023-09-20 13:13:51 +00:00
Aleksei Vetrov
ed8fb7a6a6 Merge "NDK library: use prebuilts to check next level ABI" into main 2023-09-20 11:16:59 +00:00
Liz Kammer
9e2a5a7d6d Don't panic for unhandled product vars
Instead, we return an error. This allows us to access some product
variable information earlier when it will not be used as an attribute
without panicing

Test: m nothing
Change-Id: Id094b2b9e1364a8d174d99b3824fa149fb235b3e
2023-09-19 15:58:22 -04:00
Liz Kammer
86a407f284 Always convert prebuilt cc library headers
Test: go tests
Test: CI
Test: patch in CL using prebuilts for mainline modules and build
Bug: 300640274
Change-Id: I73f70dac679e341670e1484ce57bc984f413d409
2023-09-19 15:58:20 -04:00
Aditya Kumar
a1a29b75db Merge "Revert "Revert "riscv64: enable V.""" into main 2023-09-19 16:52:31 +00:00
Aleksei Vetrov
8c02bbc533 NDK library: use prebuilts to check next level ABI
NDK has two ABI checks:

1. Check that prebuilt ABI exactly matches compiled binaries.

2. Check that ABI of level X compatible with level X+1.

The second check used compiled binaries for level X and prebuilts for
level X+1. But this approach may confuse people, because ABI change will
be shown "reversed". For example, adding new field to ABI monitored
binary of level X would be shown as "removed" when compared to level X+1
prebuilt.

This change uses prebuilts for both level X and level X+1. Given, that
prebuilts are checked to match compiled binaries, this should be enough.

Change-Id: If942e4319744bc5a2674cdd65f6a6f664fdfaa7e
Signed-off-by: Aleksei Vetrov <vvvvvv@google.com>
2023-09-19 15:50:47 +00:00
Sami Tolvanen
ed78fc8553 Reapply "Enable CFI for riscv64"
This reverts commit 49dcf79550.

The previous init crash was caused by the kernel defaulting to Sv57 and
the CFI shadow implementation in bionic assuming a 48-bit virtual
address space. With 5-level paging disabled in cuttlefish, we can again
enable CFI.

Bug: 293884796
Link: https://github.com/google/android-riscv64/issues/45
Test: cuttlefish boots
Change-Id: Ibcc02cf7ca6e396fd58674c648abf9f84daa260e
2023-09-18 13:41:29 -07:00
Spandan Das
1f65f9e9bd Stub/Impl selection for sdk variants
If a dependency has ndk stubs, then the sdk variant of the library
should link against the ndk stub variant and not the impl/apex_stubs variant

Unlike module-libapi, the depdendency does not go through an
@api_surfaces external repo indirection. This indirection was created to
support Multi-tree, and will likely  be removed in the future

Test: Added a unit test
Bug: 298085502
Change-Id: Ie081e153fa586b6c22db0b8e42f91149fd8e5d9b
2023-09-16 02:57:29 +00:00
Spandan Das
63acae9af1 bp2build converter for ndk_library
ndk_libary will be converted to a cc_stub_suite target. Its api_surface
attribute will be publicapi

The headers corresponding to this stub target will be added in a followup bug
(tracked in b/300504837)

Bug: 298085502
Test: Added a unit test
Change-Id: If9745083b18e0bcf5ecb89229a0f709b949d401c
2023-09-16 02:57:26 +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
9333ac1249 Revert^2 "add rust_toolchain_rustc_prebuilt module type"
400749d1f0

Change-Id: I63f04e13605c43f800f01f45345e4b3dc61aefb7
2023-09-15 22:40:16 +00:00
Elliott Hughes
726b001ae1 Revert "Revert "riscv64: enable V.""
This reverts commit 2583523144.

Change-Id: I5b05d546e17dee497dce1bfeb9290445e1c071c2
2023-09-15 16:36:59 +00:00
Vinh Tran
ce40b92c84 Implement bp2build converter for fdo_profile
Ignore-AOSP-First: ag/24746588, in the same topic, is in an internal repo. This CL will be cherry-picked to AOSP afterward.
Test: go test
Bug: 277091218
Change-Id: I389d9535ea176991a1faa9beb46352b93363acd2
Merged-In: I389d9535ea176991a1faa9beb46352b93363acd2
2023-09-15 10:45:17 -04:00
Spandan Das
0e76a723fc Merge "Parameterize cc_stub_suite for api surface" into main 2023-09-14 21:39:17 +00:00
Spandan Das
c77ca9af3a Merge changes Ib58cc7f6,I780e2564 into main
* changes:
  Create a bp2build converter for ndk_prebuilt_*_stl
  Make ndk_prebuilt_*_stl's libDir relative to module
2023-09-14 17:22:14 +00:00
Spandan Das
04f9f4cf71 Parameterize cc_stub_suite for api surface
cc_stub_suite now has an additional attribute correponding to the api
surface. This attribute will be used to pass additional args to the stub
generator.

Update bp2build to set the api_surface of the apex stubs. This ensures
that its stubs are generated with "--systemapi --apex"

Test: unit tests
Bug: 298085502
Change-Id: If4c479f85e6e485b5c795a565a0c559f1f013bf5
2023-09-14 17:07:24 +00:00
Aditya Kumar
928c0c436d Merge "Revert "riscv64: enable V."" into main 2023-09-14 16:53:59 +00:00
Aleksei Vetrov
7ab127f7c7 Merge "NDK library: collect NDK headers for ABI monitoring" into main 2023-09-14 12:05:46 +00:00
Jeremy DeHaan
2583523144 Revert "riscv64: enable V."
This reverts commit aa204ec49c.

Reason for revert: b/300158981

Change-Id: I4e969c7fccade0f8e1b29cb6267c27355ddca866
2023-09-14 00:46:21 +00:00
Spandan Das
e12d252e22 Create a bp2build converter for ndk_prebuilt_*_stl
This module type will be converted to a cc_prebuilt_* bazel target. It
will provide
1. a prebuilt (.a/.so) file
2. headers (as -isystem)

Test: added a bp2build unit test
Bug: 298088835
Change-Id: Ib58cc7f6fde8f4ca34516f6f18a4c048a02a049a
2023-09-13 18:08:55 +00:00
Spandan Das
6e332d2266 Make ndk_prebuilt_*_stl's libDir relative to module
Currently, we have ~4 of these modules which are all defined in
prebuilts/ndk. However, using ctx.ModuleDir() instead has the following
advantages
- makes bp2build simpler since we do not need to relativize this path
- prevents soong modules from reaching into another directory (as the
  test setups were doing).

Test: m nothing
Change-Id: I780e2564cb37ebf4b800f0cd184789f3fc6f2fc8
2023-09-13 18:05:13 +00:00
Zijun Zhao
748f8fb624 Merge "Handle Clang's change of defaults from -fcommon to -fno-common" into main 2023-09-13 17:34:47 +00:00
Aleksei Vetrov
262ed1a347 NDK library: collect NDK headers for ABI monitoring
Collect all NDK exported headers paths into a file that is used to
detect public types that should be ABI monitored.

Assume that we have the following code in exported header:

typedef struct Context Context;
typedef struct Output {
    ...
} Output;
void DoSomething(Context* ctx, Output* output);

If none of public headers exported to end-users contain definition of
"struct Context", then "struct Context" layout and members shouldn't be
monitored. However we use DWARF information from a real library, which
may have access to the definition of "string Context" from
implementation headers, and it will leak to ABI.

STG tool doesn't access source and header files, only DWARF information
from compiled library. And the DWARF contains file name where a type is
defined. So we need a rule to build a list of paths to public headers,
so STG can distinguish private types from public and do not monitor
private types that are not accessible to library users.

Bug: 156513478
Test: development/tools/ndk/update_ndk_abi.sh with enabled canDumpAbi
Change-Id: I9fa41e73450a41379638debb3dc56f421e0fb870
Signed-off-by: Aleksei Vetrov <vvvvvv@google.com>
2023-09-13 15:39:58 +00:00
zijunzhao
5bcebba331 Handle Clang's change of defaults from -fcommon to -fno-common
Remove fcommon and make fno-common by default.

Bug: b/151457797
Test: make checkbuild
Change-Id: Ieb4c1e1bfff05fd0db894e8eab263fb31b376da9
2023-09-13 05:09:11 +00:00
Treehugger Robot
83c0ea6e26 Merge "Use ndk_system STL header library" into main 2023-09-13 00:34:15 +00:00
Elliott Hughes
5c12fb922d Merge "riscv64: enable V." into main 2023-09-12 17:57:50 +00:00
Sam Delmerico
dd6caa739d export SetStubsForDynamicDeps for use in AIDL
Bug: 298249725
Change-Id: Ia93b320783eccf04fef167a26e2efb401c0e4236
2023-09-10 18:15:45 +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
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