Commit graph

66380 commits

Author SHA1 Message Date
Spandan Das
1181ca2be3 Merge "Cleanup an unused variable in rule_builder" into main 2023-07-14 16:19:27 +00:00
Colin Cross
0a30ce7c4b Merge "Revert "Use depsets for transitive manifests and assets"" into main 2023-07-14 16:10:31 +00:00
Colin Cross
d8c711f884 Revert "Use depsets for transitive manifests and assets"
This reverts commit 4c90f99cb3.

Reason for revert: b/291252863

Change-Id: I646b039a305a1297167e0c56b0bce0f541da260d
2023-07-14 15:52:41 +00:00
Treehugger Robot
59276876cd Merge "Fix a typo. NFC." into main 2023-07-14 15:19:33 +00:00
Jiakai Zhang
a1140990a1 Merge changes from topics "art-boot-image-jars", "configured-jar-location-overrides" into main
* changes:
  Add a Make variable to determine ART boot image jars for testing.
  Add a Make variable that overrides configured jar locations.
  Refactor dexpreopt for boot jars to make it flexible to config changes.
2023-07-14 11:47:59 +00:00
Jiakai Zhang
556bdf8e96 Add a Make variable to determine ART boot image jars for testing.
Bug: 290583827
Test: m nothing
Change-Id: I6eb0c83dd14682905ebaf3af55171856300eb2e3
2023-07-14 12:13:30 +01:00
Jiakai Zhang
4d90da29a8 Add a Make variable that overrides configured jar locations.
We had hardcoded logic to override "framework-minus-apex", but we need
to override more jars, so this CL adds a general solution for this.

Bug: 290583827
Test: m nothing
Change-Id: I211ebda7aa2803886ab6e6d081d26327665e49a6
2023-07-14 12:13:30 +01:00
Jiakai Zhang
cb13b5d1bd Refactor dexpreopt for boot jars to make it flexible to config changes.
In the past, dexpreopt for boot jars was very inflexible, and it was
incredibly hard to make a change that is as simple as adding a jar to a
boot image. Boot image generation was handled by
"platform_bootclasspath" and "bootclasspath_fragment" separately. This
caused not only code duplication but also the inflexiblity as such a
design did not fit today's use cases, where a boot image may take jars
from multiple mainline modules and the platform, and a mainline module
can contribute to multiple boot images. The design casued a huge
maintenance burden as any change to the boot image cost multi-week
efforts.

In recent years, efforts have been made to improve this a bit by a bit.
This change is another step towards making dexpreopt reasonable.

After this change, all boot images are generated by "dex_bootjars",
which is in build/soong and is therefore available on both the full
source tree and the thin manifest (master-art). The change decouples
profile generation/extraction from boot image generation. Profiles for
mainline modules are still handled by "bootclasspath_fragment"
because they need to be packed into APEXes when building mainline
modules and extracted from APEXes whem building the system image from
prebuilt modules. Boot images are not handled by
"bootclasspath_fragment" anymore.

Bug: 290583827
Test: m (all existing tests are still passing)
Test: Manually checked that the boot images are exactly the same as
  before.
Change-Id: Ib5a5f401bee334ffcab5c26618e0c8888b84575a
2023-07-14 12:13:28 +01:00
Yi Kong
8f9ca23c1e Fix a typo. NFC.
Test upload from Cog...

Change-Id: I68964d14d0a01be2bdc0ad276bdfde9f879795f2
Test: N/A
2023-07-14 06:18:38 +00:00
Spandan Das
2a55cea4a0 Delete aliases to prebuilts
These tools will now be built from source using rules_go

Test: TH
Bug: 284483729
Change-Id: I6dde9f1418aaa516c4c6f8c8897dd20f4becfb51
2023-07-14 00:43:57 +00:00
Spandan Das
af4ccaaf41 Add functionality to sandbox mixed build actions
The use case for this is for building rules_go's root builder which runs
into issues when built in a directory that contains a symlink to
prebuilts/go

The implementation will involve two changes of working dir
- `sbox` to change the working directory to
__SBOX_SANDBOX_DIR__
- the generated manifest will change the working
directory to mixed build execution root relative to that

Implemenation details
1. Create a unique intermediate path by hashing the outputs of a buildAction.
   "out/bazel/output/execroot/__main__/" was deliberately not chosen as
   the outpuDir for the sandbox because ruleBuilder would wipe it.
   `sbox` will generate the files in __SBOX_SANDBOX_DIR__ and then place
   the files in this intermediate directory.
2. After the files have been generated in (1), copy them to
   out/bazel/output/execroot/__main__/...
3. For bazel depsets that are inputs of an action, copy the direct
   artifacts into the sandbox instead of the phony target
4. Make sandboxing an opt-in. Currently we will only use it for
   `GoToolchainBinaryBuild`

In the current implementation, (3) will increase the size of the ninja
file. With sboxing turned on for only GoToolchainBinaryBuild, this will
increase the size of the ninja file by around 1.3% on aosp's cf

Test: m com.android.neuralnetworks (will build soong_zip from source
using rules_go)
Test: OUT_DIR=out.other m com.android.neuralnetworks
Bug: 289102849

Change-Id: I7addda9af583ba0ff306e50c1dfa16ed16c29799
2023-07-14 00:43:52 +00:00
Spandan Das
33e309746e Cleanup an unused variable in rule_builder
Test: In build/soong, go build ./android
Change-Id: Ic8fad64a95fd2d27c639b0b60c95db47d22bb45b
2023-07-14 00:34:07 +00:00
Prashanth Swaminathan
0498912c9f Revert "Enable sext.w removal for riscv targets"
This reverts commit bce5507c02.

The update of LLVM to clang-r498229 resolved the error with sext.w as
resolved in D143594.

Bug: 275574215
Test: Verified boot of riscv64 phone target.
Change-Id: Ie31b7db03004c5aafb6067713ef5f819e0706b64
2023-07-13 17:33:12 -07:00
Spandan Das
5b18c0ca27 Add missing formatting directive
Fixes the error
```
fmt.Errorf call has arguments but no formatting directives
```

Test: go test ./android
Change-Id: Ic589d6133ccdc88e77dedd4b8a5a56166f62efa9
2023-07-14 00:25:02 +00:00
Treehugger Robot
c38523cd33 Merge "Add flag to skip writing output from soong_zip." into main 2023-07-13 23:32:26 +00:00
Treehugger Robot
4d9dbdab7a Merge "Add unconverted_reasons_from_heuristics fields to the Module message" into main 2023-07-13 22:45:17 +00:00
Dan Albert
1cec6d5000 Add flag to skip writing output from soong_zip.
We want to measure how much of build time is spent on writing large
zips to disk. We can do this by doing the rest of the work but
skipping the write itself.

Some local and trivial testing shows this is probably a lot of the
cost of these rules:

    $ python -m timeit -s "import os" -r 10 "os.system('soong_zip -write_if_changed -o foo.zip -D prebuilts/sdk')"
    1 loop, best of 10: 8.37 sec per loop
    $ python -m timeit -s "import os" -r 10 "os.system('soong_zip -o foo.zip -D prebuilts/sdk')"
    1 loop, best of 10: 5.39 sec per loop
    $ python -m timeit -s "import os" -r 10 "os.system('soong_zip -n -o foo.zip -D prebuilts/sdk')"
    1 loop, best of 10: 3.66 sec per loop

Bug: None
Test: treehugger
Change-Id: I43acdb08d0e00efaba9e5d7add972a7ec41646d2
2023-07-13 18:45:32 +00:00
Wei Li
9a8df6669b Some new libraries are added to system partition and are not captured in
product SBOM of cuttlefish devices, ignore these diffs for now in the
SBOM integration test to fix the CI breakage.

Bug: 291073898
Test: build/soong/tests/sbom_test.sh
Change-Id: Idf5569f67642784ee422847301c59dddc8ff0907
2023-07-13 10:29:55 -07:00
Spandan Das
06f3c9bb42 Merge changes from topic "go_bp2build" into main
* changes:
  Respect package boundaries in bp2build conversion of go modules
  Create a temporary denylist for go binaries used in mixed builds
  Partial bp2build conversion of blueprint_go_binary
  Partial bp2build conversion of bootstratp_go_package
2023-07-13 16:16:00 +00:00
Alix
b1e5c6a69a Bp2build for errorprone modules that manually enabled/disabled it
Test: go test ./bp2build
Change-Id: Ie60c0959ee9ae8ce86c11a8e85a0bc7592f63df8
2023-07-13 15:50:18 +00:00
Ayush Budhwani
62efa1d650 Add unconverted_reasons_from_heuristics fields to the Module message
A heuristics is implemented in the build/bazel/scripts/bp2build_progress/bp2build_progress.py script to determine the reason for why a module is not converted.

Test: b build //build/bazel/scripts/bp2build_progress:bp2build_progress

Change-Id: I9d4eaf309dbf26bbb6de18e1af0d9cdc8fe09e94
2023-07-13 13:31:09 +00:00
Igor Foox
ae2e23a4ba Merge "Remove openwrt modules from genrule denylist." into main 2023-07-13 13:29:13 +00:00
Cole Faust
bbe2cc6191 Cleanup genrule_sandbox_test.py
In preparation for adding the ability to check all genrules in the tree.

Bug: 290816499
Test: ./build/soong/tests/genrule_sandbox_test.py extensions_db.pb
Change-Id: I6454be7e88a876a2ab1105c04f5ecda03ecd7771
2023-07-12 18:01:32 -07:00
Spandan Das
0a8a27500e Respect package boundaries in bp2build conversion of go modules
bp2build's codegen context does not implement
BazelPathConversionContext. To reuse the utility function
transformPackagePaths, update its signature

(Also make deps of go_library unique to make the conversion resilient)

Test: go test ./bp2build
Change-Id: I126b1057d2b26bc6c7d3be2780f1b62d28323cf0
2023-07-13 00:22:26 +00:00
Spandan Das
69afa98fbd Create a temporary denylist for go binaries used in mixed builds
This allows us to rollout building _some_ go targets using rules_go
without affecting mixed builds.

Test: Presubmit
Bug: 284483729
Change-Id: I0ccb4c9b90614369147a380f44f7ae372ef9396e
2023-07-13 00:22:26 +00:00
Colin Cross
654f176379 Merge "Use depsets for transitive manifests and assets" into main 2023-07-12 21:49:13 +00:00
Vadim Spivak
7a2e48bd36 Merge "AIDEGen: Collect apt generated sources" into main 2023-07-12 21:33:59 +00:00
Alix
c0dac52975 Make errorprone a configurable attribute for bazel conversion
Change-Id: Icf2265e9f712c3255321456e977928163696dc22
Test: ./bp22build tests in child commit
2023-07-12 18:18:15 +00:00
Fabián Cañas
3875e1c582 Merge "Make clang debug level configurable" into main 2023-07-12 17:58:33 +00:00
Vadim Spivak
3c496f00fa AIDEGen: Collect apt generated sources
The Java compiler may generate sources when processing annotations.
These sources are currently not included in the IDE project model, which
results in unresolved symbols when using Hilt and other annotation
processors. These sources are not passed to the Java compiler for
compilation, so they cannot be handled like other Java module sources.

This change archives the generated sources and appends them to the
existing srcjar list in module_bp_java_deps.json.

Test: go test .
Test: Verified that module_bp_java_deps.json contained srcjar entry
Test:   with path/to/android_common/javac/anno.srcjar.
Test: Verified that IntelliJ can resolve generated symbols after
Test:   invoking aidegen.
Change-Id: I6a3011f9140fd25f785178baee0cd6074ad94600
2023-07-12 17:34:39 +00:00
Treehugger Robot
105005bfd4 Merge "Remove metalava --no-banner argument" into main 2023-07-12 17:08:42 +00:00
Trevor Radcliffe
d71487173e Update name of blocklist feature in bp2build
Bug: 290908194
Test: Forrest
Change-Id: I0576fb644edb6b6043df9cf01b508ee887f946f1
2023-07-12 13:45:10 +00:00
Mårten Kongstad
bd2624442b Remove metalava --no-banner argument
metalava no longer prints an ASCII banner, and has removed its
--no-banner argument. Update all call sites accordingly.

Test: presubmit
Bug: 286023667
Change-Id: I61cf5f1125dfbd93496e6a59eb1ea62886b32046
2023-07-12 14:07:01 +02:00
Spandan Das
de623294fe Partial bp2build conversion of blueprint_go_binary
This module type does not implement android.Module, and therefore we
cannot write a conventional bp2build converter for this module type.
Instead this has been special-cased inside bp2build/build_conversion.go.

There is one major deviation between Soong and Bazel's
go_binary/go_library. Soong
collects the deps in the transitve closure and puts them on compile/link
paths. Bazel OTOH, requires the direct imports to be listed in deps of the binary
explicitly (AFAIK). Since bp2build cannot determine the list of direct
imports from the list of transitive deps, put all the transitive deps in
`deps`

Test: unit tests
Test: TH
Bug: 284483729
Change-Id: I004aaf8607fef1697a0d9e7d018ad657b67778ac
2023-07-11 22:03:48 +00:00
Spandan Das
ea2abba3a9 Partial bp2build conversion of bootstratp_go_package
This module type does not implement android.Module, and therefore we
cannot write a conventional bp2build converter for this module type.
Instead this has been special-cased inside bp2build/build_conversion.go.

Because of the above, we also do not have access to useful functions
available in the ctx object of ConvertWithBp2build. This includes
1. Finding the package (directory) of a dep. This requires getting a
   handle of the underlying module from its name (string). To solve, we
   do a pre-visit to collect this information. This did not increase the
   wall time. On my machine, `m bp2build --skip-soong-tests` takes ~14s
   before and after this CL
2. Converting srcs to labels. This requires glob and package boundary
   resolution. This CL introduces a partial implementation for this
   function. (glob patterns are not used in go tools)

For (1), I considered creating a `ModuleFromName` on
`blueprint.Context` instead of a pre-run, but this increased the time to ~27s.

Test: unit tests
Test: TH
Bug: 284483729

Change-Id: Ifeb029103d14947352556dba295591dd7038b090
2023-07-11 22:03:26 +00:00
Liz Kammer
e3c11d0aad Merge "Ensure data is passed to all generation actions" into main 2023-07-11 21:05:32 +00:00
Jiakai Zhang
b898c112a2 Merge changes I0918f2fa,I3fc6ff91,I7adc97cb,I674a5fa1,I22c45cbf into main
* changes:
  Change the profile path on host.
  Extract duplicate code to common helper functions.
  Fix dumpOatRules.
  Remove Modules() from BootclasspathFragmentApexContentInfo.
  Fix some tests for dexpreopt and remove unnecessary tests.
2023-07-11 20:59:07 +00:00
Colin Cross
120b55a7ca Merge "Add tests for code that will be affected by resource processor feature" into main 2023-07-11 20:17:05 +00:00
Wei Li
1ab0564e65 Merge "Add integration test for m build SBOM of APEXs/APKs." into main 2023-07-11 18:25:39 +00:00
Treehugger Robot
71f5a63267 Merge "Turn on Global ThinLTO by default" into main 2023-07-11 17:42:12 +00:00
Treehugger Robot
da7973112a Merge "Experiment with not using ninja weights" into main 2023-07-11 17:42:06 +00:00
Jiakai Zhang
3444e561dc Change the profile path on host.
This is to decouple profile generation from image configs. A boot image
profile is either for a mainline module or for the platform, which is
orthogonal to boot images.

Bug: 290583827
Test: m nothing
Change-Id: I0918f2fa945a2af1839f1a08ecede331c64d0317
2023-07-11 17:59:24 +01:00
Jiakai Zhang
b1639db53f Extract duplicate code to common helper functions.
Also, fall back to using a default name for the dexpreopt directory if
we are not building for Android.

Bug: 290583827
Test: m nothing
Change-Id: I3fc6ff9142a2dcdf995796f75891b242fe2848d0
2023-07-11 17:59:05 +01:00
Colin Cross
4c90f99cb3 Use depsets for transitive manifests and assets
Instead of rolling assets and manifests up through each static lib,
provide them as a DepSet.  This will help with the next patch, which
needs to pass all the transitive manifests and R.txt files together.

Test: app_test.go
Change-Id: Id8b3aa2bed3771e82ab6bde192c9b43baa38b54c
2023-07-11 09:54:59 -07:00
Jiakai Zhang
da47d3c6f3 Fix dumpOatRules.
This method generates a build rule that runs oatdump for debugging
purposes.

- Pass "--runtime-arg -Xgc:CMC" to oatdump if UFFD GC is enabled.
- Build the phony name from the image name to avoid conflicts when using
  this method for multiple boot images.

Bug: 290583827
Test: m dump-oat-boot
Change-Id: I7adc97cb85b571486b78f173fb80ff7da2c4bfe4
2023-07-11 16:27:01 +01:00
Jiakai Zhang
f7f782c4f1 Remove Modules() from BootclasspathFragmentApexContentInfo.
The Modules() method was for the ART boot image in the ART APEX. It's no
longer needed because we don't install the ART boot image in the ART
APEX anymore.

Bug: 290583827
Test: m nothing
Change-Id: I674a5fa1ed18908413a64129df5947c7d26e638e
2023-07-11 15:29:17 +01:00
Jiakai Zhang
b69e89559f Fix some tests for dexpreopt and remove unnecessary tests.
This CL is to prepare for the changes in http://r.android.com/2652081.
See the description of that CL for the reasons.

Some tests were set up in a fragile way and were easy to be broken when
the implementation changes. This CL is a pure test change that fixes
them.

This CL also removes TestNoUpdatableJarsInBootImage. That test checks
what should go to the ART boot image and what should go to the
platform one, which does not apply today because boot images are not
associated with mainline modules anymore: a boot image may take jars
from multiple mainline modules and the platform, and a mainline module
can contribute to multiple boot images. In practice, we have ART jars in
the platform boot image, and we are going to add core-icu4j and
consrypt to the ART boot image, which is now for testing only.

Bug: 290583827
Test: m nothing
Change-Id: I22c45cbf6f853b030b68edb51197854e9c53a02e
2023-07-11 15:29:12 +01:00
Romain Jobredeaux
aa634fdbdb Merge "Support target and max sdk version in app bp2build." into main 2023-07-11 13:34:29 +00:00
Liz Kammer
796921d211 Ensure data is passed to all generation actions
Test: go test genrule tests
Test: build/soong/tests/genrule_sandbox_test.py \
      framework-cppstream-protos framework-javastream-protos
Change-Id: I16fa939280c7ff0f230a0a8cf18af5e55f16eb03
2023-07-11 08:27:51 -04:00
Yi Kong
add6375a10 Turn on Global ThinLTO by default
Build C/C++ targets with ThinLTO with "--lto-O0" by default. This takes
advantage of better dead code elimination and CFG simplification due to
ThinLTO's global view of the program, but do not enable the costly LTO
optimizations. This also makes builds faster because we can avoid doing
codegen for the dead code.

Code size for panther-userdebug:
                   /system/bin  /system/lib  /system/lib64
Original           57648        86264        181700
Global ThinLTO     55764        84916        175728
                   -3.27%       -1.56%       -3.29%

Build time for aosp_arm64-userdebug:
                   clang time   linker time
Original           56993.87s    1712.36s
Global ThinLTO     52839.18s    3114.93s

saving 4.68% build time in total.

Bug: 169004486
Test: presubmit
Change-Id: Idb0f4675ca4750b8b12b24f4679579419d3448c8
2023-07-11 21:26:52 +09:00