Commit graph

5063 commits

Author SHA1 Message Date
Christopher Parsons
bc39e17a1d Merge "Support cc_object modules in mixed builds" 2021-03-02 16:44:56 +00:00
Paul Duffin
4b786d2da1 Merge "Remove deapexer and prebuilt apex select mutators" 2021-03-02 10:48:29 +00:00
Treehugger Robot
ce80f18749 Merge "APEX uses the latest version of the stub" 2021-03-02 01:02:18 +00:00
Chris Parsons
8d6e433c1e Support cc_object modules in mixed builds
Test: With a handwritten conversion of crtbegin_so1, USE_BAZEL_ANALYSIS=1 m crtbegin_so1
Change-Id: I7c777d7f46b37aa1827cc04205e2014f9293bf35
2021-03-01 18:22:34 -05:00
Paul Duffin
c04fb9e6a2 Remove deapexer and prebuilt apex select mutators
Originally, when the prebuilt_apex was first created, it selected the
source to use in its DepsMutator. It did that because that was a
convenient place for it to perform that work which had to be:
* After the arch mutator had run so MultiTargets() was available.
* Before the prebuilt_select mutator runs as that relied on the Source
  property to have been set.

Change 064b70c9 then duplicated the call from the DepsMutator of the
deapexer module type that was added as part of the work to make dex
files available for hiddenapi processing.

Change 356f7d45 moved it out of the the DepsMutator methods into its
their own mutators, presumably because it interfered with the
Soong -> Bazel conversion work.

This change improves the existing PrebuiltSrcsSupplier mechanism to
support reporting errors so that the logic for selecting the source can
be done on demand rather than in separate mutators.

The main complication was that PrebuiltSrcsSupplier is called with a
BaseModuleContext for both source and prebuilt modules so it cannot use
any methods on it that are related to the current module. That
necessitated adding MultiTargets() to android.Module.

Bug: 181267622
Test: m droid
Change-Id: I106c78fd21016f051a315b82b470d8f12b1f820b
2021-03-01 17:11:25 +00:00
Jingwen Chen
37bd24a1db Merge "bp2build: add configurable attribute (select) support." 2021-03-01 13:43:55 +00:00
Jiyong Park
55549df051 APEX uses the latest version of the stub
Previously when an APEX whose min_sdk_version is set is linked to an
external library providing multiple versions of stubs, the
maximum version that is less than or equal to the min_sdk_version was
chosen. For example, if the versions of a library stubs are 28, 29, 30,
and 31, then APEX with min_sdk_version: 29 linked to the version 29 of
the stub.

This was to ensure that the APEX doesn't use any new APIs whose
existence can't be guaranteed.

This however imposes a severe restriction that the APEX can never use
new APIs even when the APIs are actually available: i.e. when the
APEX is running on a newer platform.

With the recent work about unguarded availability, using the future APIs
became much safer. When you use an API that is newer than your
min_sdk_version, the API is automatically declared as a weak symbol
(thus no link error at runtime), while the call to API is guaranteed to
be guarded with the `__builtin_available(...)` macro.

So, there really is no reason to use the old version of the stub. We can
always use the latest version of stub safely.

Bug: N/A
Test: m
Change-Id: Iaac0d8761d8929154527dc2e861a51ae31e23d49
2021-03-01 09:12:32 +00:00
Chih-hung Hsieh
7e52be849e Merge "Forbit extra quotes in tidy flag lists" 2021-02-27 08:45:47 +00:00
Jingwen Chen
5d8644990b bp2build: add configurable attribute (select) support.
This CL adds a basic framework to support configurable string_list
attributes, selecting on the Arch variant (x86, x86_64, arm, arm64).

It offers fine-grained controls to map individual configurable
properties (arch_variant) to configurable Bazel attributes, starting
with the string_list type for the copts property for cc_object.

This design is primarily motivated to have minimal boilerplate in
bp2build mutators, allowing anyone to opt-in configurable attributes,
and modify intermediate states before passing them on into the
CreateBazelTargetModule instantiator.

Fixes: 178130668

Test: go tests
Test: build/bazel/scripts/milestone-2/demo.sh

Change-Id: Id6f04d7c560312a93e193d7ca4e1b7ceb6062260
2021-02-26 05:17:54 -05:00
Justin Yun
07b9f86f0c Define getSnapshotNameSuffix()
By sharing a single function for generating snapshot name suffix,
make sure both the DepsMutator and the snapshot modules use the same
names.

Bug: 179666286
Test: m nothing
Change-Id: I9efa94f2981a6bd1b4128bf0e84ca44873ebf3b7
2021-02-26 14:00:03 +09:00
Chih-Hung Hsieh
217e09a784 Forbit extra quotes in tidy flag lists
* Start with clang-tidy flags;
  maybe other flags should be checked too.

Bug: 180862582
Test: make
Change-Id: I82f86a911733693a14fe56a35e28590b065e3ae7
2021-02-25 20:46:15 -08:00
Treehugger Robot
a777d960ab Merge "Remove dependency from vendor_snapshot to each module" 2021-02-26 03:57:42 +00:00
Jingwen Chen
1251bb5775 Merge "bp2build: add support for cc_object's objs and exclude_srcs properties." 2021-02-25 14:09:08 +00:00
Justin Yun
4813867ec3 Remove dependency from vendor_snapshot to each module
The 'vendor_snapshot' module is required to every cc_library to check
if the dependencies need to be rewritten to the snapshot modules or
not. However, as the 'vendor_snapshot' module has dependencies to the
snapshot modules, the dependency to the 'vendor_snapshot' module
creates circular dependencies.
The dependency from the 'vendor_snapshot' to the snapshot modules is
required only to read the module names of the snapshot modules. We
may remove the dependency by setting the name of the snapshot modules
directly.

Bug: 179666286
Test: m nothing
Change-Id: I14abcb06c5c81ef7f8535103578747385c89ae0f
2021-02-25 09:31:12 +00:00
Christopher Di Bella
c28f5d97a6 reverses common and external Clang flags
Flags for external projects are specialisations of the common flags, and
need to follow the common flags, not precede them.

Bug: 181177782
Test: None

Change-Id: I19c8c2a3539573e9b2f2d9e3e1c898fa09570663
2021-02-25 01:34:08 +00:00
Paul Duffin
b2773e116f Merge "Generated headers may not be arch specific" 2021-02-24 10:10:23 +00:00
Paul Duffin
efa0f00706 Merge "Fix the snapshot handling of generated headers" 2021-02-24 10:08:34 +00:00
Jingwen Chen
db12024524 bp2build: add support for cc_object's objs and exclude_srcs properties.
objs contains module references to other cc_objects that will be used
for linking later. This maps to cc_library deps.

Also support exclude_srcs, and added tests.

Test: bp2build generate, sync, bazel build //bionic/...

Change-Id: I21200ff73f24bcf5357d9df8dcb5519cde532a77
2021-02-24 01:08:57 -05:00
Treehugger Robot
bbfd5ab606 Merge "Move bazel.Properties to a BazelModuleBase" 2021-02-24 05:53:25 +00:00
Treehugger Robot
30899caf1f Merge "Refactor BazelTargetModule" 2021-02-23 20:40:23 +00:00
Liz Kammer
ea6666fba9 Move bazel.Properties to a BazelModuleBase
This allows more direct access to the bazel label and whether the module
is bp2build available.

Test: go test *
Change-Id: I23375835d20fa53d7d94127b2dc2d5bb20487bfb
2021-02-23 10:58:57 -05:00
Paul Duffin
1dd5764a4e Merge "Only export sysprop headers in exported sysprop include directory" 2021-02-23 15:28:26 +00:00
Treehugger Robot
2b22365c8c Merge "Export aidl, proto and sysprop generated headers separately" 2021-02-23 14:11:24 +00:00
Liz Kammer
fc46bc1ee4 Refactor BazelTargetModule
This eliminates the need to remove quotes, delete attributes, and
re-checking that name has correct prefix. Additionally, this allows
assignment directly to the BazelTargetModuleProperties struct, which
allows defaulting unused fields and clarity of which field is being set.

Test: go test soong tests
Test: ran ./build/bazel/scripts/milestone-2/demo.sh
Change-Id: Ia9bfcce76234c793a4ddd5f29a661150f83341c9
2021-02-23 08:29:40 -05:00
Treehugger Robot
277303f042 Merge "Add ctx to AndroidMkExtraEntriesFunc" 2021-02-22 22:40:31 +00:00
Paul Duffin
7a7d067c74 Generated headers may not be arch specific
Previously, it was assumed that generated headers must be arch specific
and so prevented the fields referencing the paths to those headers from
being automatically optimized by the sdk generation code. That is not
always the case, e.g. with headers generated from protos so this change
allows those fields to be optimized.

Bug: 180427921
Test: m nothing
Change-Id: Id2af419d58ae3c30ea6d9e87f71e33a9ff6ba13b
2021-02-22 18:23:22 +00:00
Paul Duffin
42dd4e6cd6 Fix the snapshot handling of generated headers
Previously, the snapshot handling code did not preserve the directory
structure of generated include directories and instead just copied the
headers into the same module specific directory and added that single
directory to the export_include_dirs (or similar) property.

That had a couple of issues:
* The include directory was repeated in the ..._include_dirs property.
* It did not work when the include directories overlapped.

In the latter case it had a couple of issues:
* Code which compiled fine against the source would not compile against
  the prebuilt.
* Header files were duplicated in the output.

e.g. assume the following generated header file structure:
  foo/
      foo.h
  bar/
      bar.h
      baz/
          baz.h

When the sdk snapshot was passed include directories of "foo", "bar" and
headers of "foo/foo.h", "bar/bar.h", "bar/baz/baz.h" it would generate a
snapshot with the structure:
  include_gen/
      foo.h
      bar.h
      baz/
         baz.h

And:
  export_include_dirs: ["include_gen", "include_gen"]

However, when the include directories overlapped and include directories
of "foo", "bar" and "bar/baz" were passed in the directory structure
would be the same and the export_include_dirs would contain 3 usages of
"include_gen".

That meant that source code which used the following would build
against the source (because it would find "baz.h" in the "bar/baz"
include directory) but would fail when built against the prebuilts
because the "include_gen" directory did not contain "baz.h":
    #include "baz.h"

This change preserves the input directory structure for generated files
in a similar way to how it does it for source files. So, the snapshot
structure looks something like this:

  include_gen/
      foo/
          foo.h
      bar/
          bar.h
          baz/
              baz.h

And:
  export_include_dirs: [
    "include_gen/foo",
    "include_gen/bar",
    "include_gen/bar/baz",
  ],

Bug: 180427921
Test: m nothing
Change-Id: Id69eef8cf5eecd033841d3b7cd0c044a697ce404
2021-02-22 18:23:22 +00:00
Paul Duffin
37e0de5004 Only export sysprop headers in exported sysprop include directory
Bug: 180712399
Test: m nothing
Change-Id: Ia93d20fe0fecf977773257fa43fe40e7fe9f024f
2021-02-22 18:05:18 +00:00
Paul Duffin
33056e8a9a Export aidl, proto and sysprop generated headers separately
Previously, a cc library that included .aidl, .proto and/or .sysprop
files and exported headers generated from at least one of those types
would actually export generated headers from all of them.

While headers generated from .sysprop files are always exported those
generated from .aidl or .proto should only be exported when explicitly
requested.

This change treats them separately as expected. It has the potential
to break the build as it could reduce the set of headers exported and
so a dependent module that needed those would break. The fix in that
case is to simply add one (or both) of the following to the module
that previously exported those headers:

  aidl: {
    export_aidl_headers: true,
  }

  proto: {
    export_proto_headers: true,
  }

Bug: 180712399
Test: m droid
Change-Id: I488182e27dd423d261443612f98d5c112dd3ef8f
2021-02-22 18:05:10 +00:00
Paul Duffin
bc179bc44f Merge "Add tests for exported generated headers" 2021-02-22 18:03:00 +00:00
Justin Yun
107a4cb56c Update test_min_api_level for cc_test
By replacing MinApiLevelModuleController with
ShippingApiLevelModuleController, we don't need to define
api-level-prop option. The property name must not be a parameter but
be defined in the module controller.

test_min_sdk_version is removed as it is not used.

Bug: 178990561
Test: atest vts_core_liblp_test
Change-Id: Ib4660b91c7adb2ec8b970197dc6f65b8e6952a66
2021-02-20 00:46:21 +00:00
Colin Cross
aa2555387d Add ctx to AndroidMkExtraEntriesFunc
Add a ctx parameter to AndroidMkExtraEntriesFunc to allow them to
access providers.

Test: m checkbuild
Change-Id: Id6becc1e425c3c3d8519248f8c0ce80777fac7cc
Merged-In: Id6becc1e425c3c3d8519248f8c0ce80777fac7cc
2021-02-19 23:05:40 +00:00
Elliott Hughes
272649ceb5 Merge "__ANDROID_UNGUARDED_AVAILABILITY__ is gone now." 2021-02-19 22:27:11 +00:00
Elliott Hughes
5a8c9531e4 __ANDROID_UNGUARDED_AVAILABILITY__ is gone now.
So no need to keep `-D`ing it.

Bug: http://b/179067538
Test: treehugger
Change-Id: If5bcead40d3bb355c241e363a8f1a956cb144438
2021-02-19 10:43:19 -08:00
Paul Duffin
3cb603eb51 Add tests for exported generated headers
Improves the test coverage for exporting of generated headers. These
tests highlight the bug described in b/180712399.

Follow up changes will refactor and fix bugs in this code. Adding the
tests separately help ensure that those changes do not inadvertantly
change the behavior.

Test: m nothing
Bug: 180712399
Change-Id: I0225b0cf53259071edb99a94be5014ed0e019bde
2021-02-19 17:12:01 +00:00
Julien Desprez
251261d01b Merge "Switch cc_test host_supported: true to unit tests" 2021-02-19 16:55:04 +00:00
Jingwen Chen
4e86b6ae43 Merge "bp2build: cc_object converter." 2021-02-19 03:54:43 +00:00
vichang
cd821d8283 Merge "Non-installable module should not be installed into a fuzzer .zip package" 2021-02-18 09:59:06 +00:00
Jingwen Chen
8c1b97e01b bp2build: cc_object converter.
This CL introduces a basic bp2build converter for cc_object modules.
cc_objects maps cleanly to cc_library targets, but with -fnoaddrsig.

This CL also demonstrates generating include deps within a macro to
allow the cc_object compilation to depend on a relative-include header
within an include dir.

e.g. if "foo.cc" includes "android/log.h" and the latter is located at
"include/android/log.h", the autogenerated header deps would export
"android/log.h" correctly to the foo.cc upstream target.

Test: GENERATE_BAZEL_FILES=true m nothing && bp2build-sync write && bazel build //bionic/libc:crtbegin_so1

Change-Id: Ifd9e097051ec184ab0a1929d07918f0ff4f24d98
2021-02-18 03:27:28 -05:00
Dan Albert
a175126009 Merge "[arm64] Build NDK with PAuth and BTI" 2021-02-17 21:37:41 +00:00
Chih-hung Hsieh
6e304f5a88 Merge "Change default DEFAULT_TIDY_HEADER_DIRS to empty" 2021-02-17 18:34:48 +00:00
Victor Chang
00c144f930 Non-installable module should not be installed into a fuzzer .zip package
libicu_* fuzzer depends on installable cc modules and non-installable
cc modules with the same name, because the non-installable modules are
stubs used in the compile-time, and shouldn't be used in runtime.

Bug: 175583039
Test: make haiku dist
Test: Run 2 arbitrary binaries from out/dist/fuzz-target-x86_64.zip on device
Test: Run 2 arbitrary binaries from out/dist/fuzz-host-x86_64.zip on host
Change-Id: I0ecf24bb83e3985da3b8f393adab8c87ab7400c6
2021-02-17 16:40:25 +00:00
Rupert Shuttleworth
a0516f76ab Merge "Add cc_library_headers support to bp2build." 2021-02-17 08:57:19 +00:00
Chih-hung Hsieh
296b7b8440 Merge "Switch to clang-r412851 (build 7141649)" 2021-02-17 00:17:14 +00:00
Rupert Shuttleworth
54e7841b90 Add cc_library_headers support to bp2build.
Test: Added cc_conversion_test.go.
Change-Id: Id4459d2c2fa02687a374cd9fb25d687e9678218c
2021-02-16 23:07:01 +00:00
Chih-Hung Hsieh
6338deba1d Switch to clang-r412851 (build 7141649)
Bug: 179065588
Test: presubmit
Change-Id: Ifb9399e9f4ec0968b174b90c1a1f4f78f903d39d
2021-02-12 13:53:10 -08:00
Chih-Hung Hsieh
9f94c362ea Change default DEFAULT_TIDY_HEADER_DIRS to empty
* Default -header-filter will now contain only module directory.
  * In a clean build of aosp_x86_64-eng, this change can reduce
    the number of (duplicated) clang-tidy warnings by 77% or more.
* When compiled with WITH_TIDY=1, if DEFAULT_TIDY_HEADER_DIRS is
  not set, warnings from a header file will be shown only if
  the file is in a module's (sub)directory.
* Set DEFAULT_TIDY_HEADER_DIRS="bionic/|bootable/|build/|cts/|\
  dalvik/|developers/|development/|frameworks/|\
  libcore/|libnativehelper/|system/"
  will get before this change's -header-filter.
* Fix a bug: Default header-filter was not added when
  tidy_flags was defined in a module.
  With this fix, some incorrectly hidden header file tidy warnings
  will now show up.

Bug: 179530304
Test: make with WITH_TIDY=1 and various setting of DEFAULT_TIDY_HEADER_DIRS
Change-Id: Ia0c05349908a730862dae36be9a2dbe4f44fb6da
2021-02-12 13:50:38 -08:00
Elliott Hughes
5add0c61d6 Rename __ANDROID_UNGUARDED_AVAILABILITY__ -> __ANDROID_UNAVAILABLE_SYMBOLS_ARE_WEAK__.
Bug: http://b/179067538
Test: treehugger
Change-Id: I5945ca6e767212280a1981e6f78ec3c50acfb3f3
2021-02-11 14:21:59 -08:00
Treehugger Robot
b68036f44b Merge "Add LOCAL_LICENSE_KINDS to build/soong" 2021-02-10 07:18:29 +00:00
Treehugger Robot
509ab03f12 Merge "Ensure that stubs.symbol_file has ".map.txt" suffix" 2021-02-10 01:07:30 +00:00