Commit graph

21 commits

Author SHA1 Message Date
Oliver Nguyen
b6aeb14150 Merge "Add coverage flags for Clang coverage builds." 2020-01-22 22:34:35 +00:00
Jiyong Park
83dc74b770 Reland^2 "m <apex_name>-deps-info prints the internal/external deps of the APEX"
This reverts commit 7cb4d378e7.

Test: m
Test: ALLOW_MISSING_DEPENDENCIES=true DIST_DIR=out/dist ./art/tools/dist_linux_bionic.sh -j80 com.android.art.host
(in the master-art-host branch)

Change-Id: I9beca73aafdf42f03bfa19cf1634b2641dac417b
2020-01-14 18:40:56 +09:00
Jiyong Park
7cb4d378e7 Revert "Reland "m <apex_name>-deps-info prints the internal/external deps of the APEX"""
This reverts commit 956305c61c.

Reason for revert: broke master-art-host branch
Exempt-From-Owner-Approval: reverting a bad change

Change-Id: Id7faed4ee85328c7c65847a3543ea9e67a3d50b3
2020-01-14 08:58:02 +00:00
Jiyong Park
956305c61c Reland "m <apex_name>-deps-info prints the internal/external deps of the APEX""
This reverts commit 4513f703f9.

Bug: 1190898
Test: m
Test: EMMA_INSTRUMENT=true EMMA_INSTRUMENT_FRAMEWORK=true NATIVE_COVERAGE=true  m dist

Change-Id: I50fdccabb43e4751694db83ee451d388657257e0
2020-01-09 18:42:27 +09:00
Oliver Nguyen
1382ab6d31 Add coverage flags for Clang coverage builds.
Bug: 143977934
Test: m CLANG_COVERAGE=true
Test: m NATIVE_COVERAGE=true
Change-Id: I5d07d336e241856961eb0bc9678fdc9d5a076802
2019-12-09 16:35:15 -08:00
Colin Cross
4af21ed26f Split local and global cflags
Native compiler flags are currently applied in approximately:
global cflags
local cflags
local include dirs
global include dirs
global conlyflags
local conlyflags
global cppflags
local cppflags

This means that a flag that is enabled in the global cppflags
cannot be disabled in the local cflags, and an Android.bp author
must know to disable it in the local cppflags.  A better order
would be:
global cflags
global conlyflags
global cppflags
local cflags
local conlyflags
local cppflags
local include dirs
global include dirs

We are mixing both the global and local cflags into a single
variable, and similar for conlyflags and cppflags, which
prevents reordering them.  This CL prepares to reorder them
by splitting the global and local cflags into separate variables.

Bug: 143713277
Test: m native
Change-Id: Ic55a8c3516c331dc5f2af9d00e59ceca9d3e6c15
2019-11-07 15:27:58 -08:00
Jiyong Park
ee9a98d88e Build native coverage variant of APEXes when needed
When the native coverage is enabled, APEXes (and files there) are built
for native coverage as well.

Bug: 138952487
Test: make -j NATIVE_COVERAGE=true COVERAGE_PATHS='*' com.android.resolv
find out -name "*.gcno" | grep DnsResolver shows files

Test: libnetd_resolv.zip is found under
$(TARGET_OUT)/apex/com.android.resolv/lib directory

Change-Id: I97bcee9bf8ffc0dc71453abbdb613ed56ea2cdb4
2019-08-13 08:55:08 +09:00
Pirama Arumuga Nainar
100bbdc8f3 Wrap getenv when linking a coverage-enabled binary
The wrapper to getenv() appends the effective userid (euid) of the
current process to GCOV_PREFIX.  This avoids conflicts and permissions
issues when multiple processes try to create/access the same directories
and files under /data/misc/trace.

Test: Verify that coverage files are written to
/data/misc/trace/<euid>/proc/... instead of /data/misc/trace/proc/...

Change-Id: If58081a12b2b9bc40cfcbf64c99beafe198d07af
2019-07-03 15:28:54 -07:00
Pirama Arumuga Nainar
82fe59b656 Refactor libprofile-extras to be added as a whole static library
Bug: http://b/134177005
Bug: http://b/116873221

Previously, the libprofile-extras dependency was added as a
LateStaticLib and the constructor in this library was included during
linking with the '-uinit_profile_extras' linker flag.  This was done
because at the deps() stage, the exact binaries that need coverage are
not known (in fact the coverage-enabled variants are not created yet).

This meant that for a link command, if one of the shared libraries
already exported the constructor, the output of the link command did not
load/link libprofile-extras.

For other reasons, we now want to add more symbols to this library that
need to be linked into all libraries and executables.  To accomplish
that, refactor the dependency handling so libprofile-extras can be added
as a 'WholeStaticLib'.

This is done by creating a new dependency type (with a coverageDepTag
dependency tag) to add libprofile-extras as a dependency for all modules
that can potentially link with coverage.  During the flags() call, this
dependency is moved as a WholeStaticLib dependency iff coverage is
enabled in this link step.

There are a few NFC changes as well:
- deps() takes a DepsContext parameter.
- flags() has an extra PathDeps parameter and return value.
- add useSdk() helper to cc.Module.

Test: Build with coverage and check that we can generate coverage using
SIGUSR1 and the debug.coverage.flush sysprop.

Change-Id: I7e7d8201956a150febbda5bb1794f8ece016db8b
2019-07-03 15:28:50 -07:00
Pirama Arumuga Nainar
65c95ff1fb Include libprofile-extras to all coverage variants
Bug: http://b/128524141

Include libprofile-extras (defined in system/extras/toolchain-extras) to
all modules that need a coverage variant.  Also add
'-uinit_profile_extras' when linking with coverage.  This causes the
setup code in libprofile-extras to be linked into binaries/libraries
with coverage enabled.

We add the static library to the non-coverage variants as well but is a
no-op for them (since the '-u...' flag is not added for them).

Adding this dependency creates several circular dependencies since
coverage variants were being created for other module types that never
had any compilation or linking done during the build.  This change stops
creating coverage variants for toolchain_library, cc_prebuilt_library_*,
cc_library_headers module types (by adding a function to the linker
interface to specify whether native coverage is enabled).

Test: m NATIVE_COVERAGE=true COVERAGE_PATHS=*
Test: blueline_coverage target in internal branch (using forrest)
Change-Id: I5db876eb953639a55ba007248dd24e497f987730
2019-03-29 08:56:42 -07:00
Pirama Arumuga Nainar
ee30d5e132 Refactor coverage support
Bug: http://b/128524141

The goal is to add a static library (libprofile-extras) to modules that
require coverage.  Since the coverageMutator is a post-deps mutator, the
results of the coverageMutator are not available when the dependencies
get constructed in deps().  This change moves the detection from the
coverageMutator to begin().

Test: m NATIVE_COVERAGE=true COVERAGE_PATHS=*
Test: blueline_coverage target in internal branch (using forrest)

Change-Id: I4e7c8b31ed5060642c6218ea33c532a0f6619967
2019-03-29 08:56:42 -07:00
Pirama Arumuga Nainar
c7679de4ab Override module's C flags when coverage is enabled
Bug: http://b/116873221

Disable -Wframe-larger-than because building without optimization can
make frame larger.  Building dng_sdk with coverage results in a bigger
stack frame than the limit in C flags.

Get optimization level back to -O0 if module has a non-default
optimization level.  Not doing so causes link failures with
libneuralnetworks.so.

Test: Build with coverage.
Change-Id: I36b2979bb6a73023458c8de3241e975845bd36eb
2019-02-19 10:00:27 -08:00
Pirama Arumuga Nainar
2f289aca6e Enable coverage for vendor-related libraries
Bug: http://b/116873221

Enable coverage for libraries that use VNDK and those that have vendor
variants.  This previously caused a redefinition error in the
Android-<product>.mk but was indirectly fixed when
https://android-review.googlesource.com/c/platform/build/soong/+/906394
disabled coverage for LLNDK stub libraries.

Test: m NATIVE_COVERAGE=true COVERAGE_PATHS=frameworks nothing
Change-Id: Iccbc1c15c68562449ffffe7bbcc3d22419d84bfe
2019-02-15 15:24:47 -08:00
Pirama Arumuga Nainar
8113835940 Do not enable coverage for platform/llndk stub libraries
Bug: http://b/116873221

These are used only for linking, and secondly, don't link with libc or
other system libraries.

Test: Build system/core/libnativeloader with coverage
Change-Id: I37eae572a5eaa00f0e8c72bc1453e967b5bcb577
2019-02-14 15:39:31 -08:00
Pirama Arumuga Nainar
1acd4475f2 Extend coverage mutator to allow variants with coverage on and off
Bug: http://b/116873221

This allows us to enable coverage for a module (typically static
libraries) even if a dependent module cannot build with coverage.  In
this case, the dependent module can just pick the variant with coverage
off.

- Create the following variants from the coverage mutator:
  - "" (empty): Don't build  with coverage and always pick the
                non-coverage variants for dependents.  This variant is
                created for modules with 'native_coverage: false'.
  - "cov":      If this module's path is covered by the COVERAGE_PATHS
                option, build this module with coverage.  If not, build
                this module without coverage.  In either case, pick
                coverage variants ("cov") for dependencies if available.

- Do not enable coverage:
  - for NDK stub libraries
  - if sdk_version < 23 since libc doesn't export 'stderr' which is
    needed by the coverage/profile runtime library.
  - for VNDK libraries

Test: In AOSP: m COVERAGE_PATHS=system/security NATIVE_COVERAGE=true nothing

Change-Id: I4d08790d35cdeaf12fb3c4f999d69a870e65836a
2019-02-14 00:05:42 +00:00
Pirama Arumuga Nainar
0b882f0394 Revert "Support coverage instrumentation for Linux host"
This reverts commit 358056c058.

Reason for revert: Breaks build_test target in some branches.

Change-Id: I604561033038d4ff15b74caf7b81ff5c8dd9632f
2018-04-23 22:44:39 +00:00
Pirama Arumuga Nainar
358056c058 Support coverage instrumentation for Linux host
Bug: http://b/77792074

- Add the libclang_rt.profile runtime libraries directly to the compile
command (for both host and target) instead of relying on the Clang
driver.
- Move the coverage mutator to PreDepsMutators so the mutation has
already happened when runtime libraries are added during dependence
computation.
- Factor out cc/config/toolchain to identify libclang_rt.profile modules
for the x86 and x86_64 host.

Test: make NATIVE_COVERAGE=true produces coverage-enabled host binaries.
Change-Id: I1ebc8cffdf11622bfc18199a57674672888b3a5f
2018-04-23 10:34:37 -07:00
Colin Cross
ee6143cde2 Add VisitDirectDepsWithTag
Add a method on ModuleContext and TopDownMutatorContext to visit
direct dependencies that have a given dependency tag.

Test: m checkbuild
Change-Id: Ib875563091dcae6b7282b3e3427d0eb07d8c8af5
2018-01-02 18:23:43 -08:00
Colin Cross
d11fcda940 Convert Visit*Deps from blueprint.Module to android.Module
Also adds checks that the dependencies are android.Modules and
are not disabled.

Test: m checkbuild
Change-Id: I05e945f38915d49cd3c0ab72a86576949bc7eff2
2017-10-24 13:01:03 -07:00
Colin Cross
36242850fd Refactor factories
Change module factories from returning a blueprint.Module and a list
of property structs to returning an android.Module, which holds the
list of property structs.

Test: build.ninja identical except for Factory: comment lines
Change-Id: Ica1d823f009db812c518f271a386fbff39c9766f
2017-06-30 21:08:36 +00:00
Dan Willemsen
581341d4f2 Native Coverage support in Soong (gcov)
This is configured the same as make -- a global NATIVE_COVERAGE=true
flag to allow native coverage, then COVERAGE_PATHS=path1,path2,... to
turn it on for certain paths.

There are .gcnodir files exported to Make and saved in $OUT/coverage/...
files which are `ar` archives containing all of the compiler-produced
.gcno files for a particular executable / shared library.

Unlike the Make implementation, this only passes links the helper
library (automatically through --coverage) when one of the object files
or static libraries being used actually has coverage enabled.

Host support is currently disabled, since we set -nodefaultlibs, which
prevents libclang_rt.profile-*.a from being picked up automatically.

Bug: 32749731
Test: NATIVE_COVERAGE=true COVERAGE_PATHS=system/core/libcutils m -j libbacktrace libutils tombstoned
      $OUT/coverage/system/lib*/libcutils.gcnodir looks correct (self)
      $OUT/coverage/system/lib*/libbacktrace.gcnodir looks correct (static)
      $OUT/coverage/system/lib*/libutils.gcnodir doesn't exist (shared)
      $OUT/coverage/system/bin/tombstoned.gcnodir looks correct (executable)
Test: NATIVE_COVERAGE=true COVERAGE_PATHS=external/libcxxabi m -j libc++
      Confirm that $OUT/coverage/system/lib*/libc++.gcnodir looks correct (whole_static_libs)
Change-Id: I48aaa0ba8d76e50e9c2d1151421c0c6dc8ed79a9
2017-02-14 13:05:48 -08:00