From dcabea581cb855ee9a735781e25c3375862875ff Mon Sep 17 00:00:00 2001 From: Pirama Arumuga Nainar Date: Tue, 27 Apr 2021 15:47:43 -0700 Subject: [PATCH] [cc/coverage] Define a macro during coverage builds Bug: http://b/186576313 During a coverage build, pass the __ANDROID_CLANG_COVERAGE__ macro to native compilations. This allows tools like dalvikvm and dex2oat, which would otherwise call _exit(), to write profiles on coverage builds by calling exit() instead. Test: `m CLANG_COVERAGE=true NATIVE_COVERAGE_PATHS="art" nothing` and check compiler flags in out/soong/build.ninja. Change-Id: I18315b89170abdd650e4c6c55577688348c42225 (cherry picked from commit 551b06d9e69066baf1b621b20d4b838ac2f28902) --- cc/coverage.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cc/coverage.go b/cc/coverage.go index b2788ecc6..baf422637 100644 --- a/cc/coverage.go +++ b/cc/coverage.go @@ -96,7 +96,8 @@ func (cov *coverage) flags(ctx ModuleContext, flags Flags, deps PathDeps) (Flags // flags that the module may use. flags.Local.CFlags = append(flags.Local.CFlags, "-Wno-frame-larger-than=", "-O0") } else if clangCoverage { - flags.Local.CommonFlags = append(flags.Local.CommonFlags, profileInstrFlag, "-fcoverage-mapping", "-Wno-pass-failed") + flags.Local.CommonFlags = append(flags.Local.CommonFlags, profileInstrFlag, + "-fcoverage-mapping", "-Wno-pass-failed", "-D__ANDROID_CLANG_COVERAGE__") } }