summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWiwit Rifa'i <wiwitrifai@google.com>2023-11-08 20:10:00 +0800
committerWiwit Rifa'i <wiwitrifai@google.com>2023-11-17 18:02:11 +0800
commit181123b4b463fae4b768cc8cfe415bb403d56516 (patch)
tree98dc3551e30d77b6af7a5be325d4890f712494d7
parent14f7ffc4874ccf65ea999a9741a7ad9cbb8cac10 (diff)
downloadcommon-181123b4b463fae4b768cc8cfe415bb403d56516.tar.gz
hwc: add additional FLAGS from soong build when coverage enabled
Sometimes we still could not generate the coverage profraw files for some devices. By adding these additional flags, it could make the profraw files generation to be successful more often. These flags are copied from build/soong/cc/coverage.go which looks like for handling the android native code coverage on Android.bp modules. This will also make the default mode to regular mode. Continuous mode will only be enabled if CLANG_COVERAGE_CONTINUOUS_MODE=true is defined. If regular mode is used, we need to use `kill -37` to flush the coverage data to the profraw files. The signal handler to write the coverage data to disk is installed from static library libprofile-clang-extras_ndk. Bug: 295827160 Test: build with coverage enabled Change-Id: I543fac1c6d617ce8c2cdf78e3e35c83a4360e7cc
-rw-r--r--hwc3/Android.mk19
-rw-r--r--libacryl/Android.mk11
-rw-r--r--libhwc2.1/Android.mk44
3 files changed, 64 insertions, 10 deletions
diff --git a/hwc3/Android.mk b/hwc3/Android.mk
index ec860c8..fd3504b 100644
--- a/hwc3/Android.mk
+++ b/hwc3/Android.mk
@@ -31,11 +31,6 @@ LOCAL_CFLAGS += \
-DLOG_TAG=\"hwc-3\" \
-Wthread-safety
-ifeq ($(CLANG_COVERAGE),true)
-LOCAL_CFLAGS += -fprofile-instr-generate -fcoverage-mapping -mllvm -runtime-counter-relocation
-LOCAL_LDFLAGS += -fprofile-instr-generate
-endif
-
# hwc3 re-uses hwc2.2 ComposerResource and libexynosdisplay
LOCAL_SHARED_LIBRARIES := android.hardware.graphics.composer3-V3-ndk \
android.hardware.graphics.composer@2.1-resources \
@@ -91,6 +86,20 @@ LOCAL_SHARED_LIBRARIES += libExynosHWCService
LOCAL_HEADER_LIBRARIES += libbinder_headers
endif
+ifeq ($(CLANG_COVERAGE),true)
+# enable code coverage (these flags are copied from build/soong/cc/coverage.go)
+LOCAL_CFLAGS += -fprofile-instr-generate -fcoverage-mapping
+LOCAL_CFLAGS += -Wno-frame-larger-than=
+LOCAL_STATIC_LIBRARIES += libprofile-clang-extras_ndk
+LOCAL_LDFLAGS += -fprofile-instr-generate
+LOCAL_LDFLAGS += -Wl,--wrap,open
+
+ifeq ($(CLANG_COVERAGE_CONTINUOUS_MODE),true)
+LOCAL_CFLAGS += -mllvm -runtime-counter-relocation
+LOCAL_LDFLAGS += -Wl,-mllvm=-runtime-counter-relocation
+endif
+endif
+
LOCAL_VINTF_FRAGMENTS = hwc3-default.xml
LOCAL_INIT_RC := hwc3-pixel.rc
diff --git a/libacryl/Android.mk b/libacryl/Android.mk
index 14e6972..87144e6 100644
--- a/libacryl/Android.mk
+++ b/libacryl/Android.mk
@@ -43,8 +43,17 @@ ifdef BOARD_LIBACRYL_G2D_HDR_PLUGIN
endif
ifeq ($(CLANG_COVERAGE),true)
-LOCAL_CFLAGS += -fprofile-instr-generate -fcoverage-mapping -mllvm -runtime-counter-relocation
+# enable code coverage (these flags are copied from build/soong/cc/coverage.go)
+LOCAL_CFLAGS += -fprofile-instr-generate -fcoverage-mapping
+LOCAL_CFLAGS += -Wno-frame-larger-than=
+LOCAL_STATIC_LIBRARIES += libprofile-clang-extras_ndk
LOCAL_LDFLAGS += -fprofile-instr-generate
+LOCAL_LDFLAGS += -Wl,--wrap,open
+
+ifeq ($(CLANG_COVERAGE_CONTINUOUS_MODE),true)
+LOCAL_CFLAGS += -mllvm -runtime-counter-relocation
+LOCAL_LDFLAGS += -Wl,-mllvm=-runtime-counter-relocation
+endif
endif
LOCAL_HEADER_LIBRARIES += google_libacryl_hdrplugin_headers
diff --git a/libhwc2.1/Android.mk b/libhwc2.1/Android.mk
index 3c33fc1..24ec047 100644
--- a/libhwc2.1/Android.mk
+++ b/libhwc2.1/Android.mk
@@ -48,8 +48,17 @@ LOCAL_CFLAGS += -Wthread-safety
LOCAL_EXPORT_SHARED_LIBRARY_HEADERS := libdrm
ifeq ($(CLANG_COVERAGE),true)
-LOCAL_CFLAGS += -fprofile-instr-generate -fcoverage-mapping -mllvm -runtime-counter-relocation
+# enable code coverage (these flags are copied from build/soong/cc/coverage.go)
+LOCAL_CFLAGS += -fprofile-instr-generate -fcoverage-mapping
+LOCAL_CFLAGS += -Wno-frame-larger-than=
+LOCAL_STATIC_LIBRARIES += libprofile-clang-extras_ndk
LOCAL_LDFLAGS += -fprofile-instr-generate
+LOCAL_LDFLAGS += -Wl,--wrap,open
+
+ifeq ($(CLANG_COVERAGE_CONTINUOUS_MODE),true)
+LOCAL_CFLAGS += -mllvm -runtime-counter-relocation
+LOCAL_LDFLAGS += -Wl,-mllvm=-runtime-counter-relocation
+endif
endif
LOCAL_MODULE := libdrmresource
@@ -150,8 +159,17 @@ LOCAL_CFLAGS += -DSOC_VERSION=$(soc_ver)
LOCAL_CFLAGS += -Wthread-safety
ifeq ($(CLANG_COVERAGE),true)
-LOCAL_CFLAGS += -fprofile-instr-generate -fcoverage-mapping -mllvm -runtime-counter-relocation
+# enable code coverage (these flags are copied from build/soong/cc/coverage.go)
+LOCAL_CFLAGS += -fprofile-instr-generate -fcoverage-mapping
+LOCAL_CFLAGS += -Wno-frame-larger-than=
+LOCAL_STATIC_LIBRARIES += libprofile-clang-extras_ndk
LOCAL_LDFLAGS += -fprofile-instr-generate
+LOCAL_LDFLAGS += -Wl,--wrap,open
+
+ifeq ($(CLANG_COVERAGE_CONTINUOUS_MODE),true)
+LOCAL_CFLAGS += -mllvm -runtime-counter-relocation
+LOCAL_LDFLAGS += -Wl,-mllvm=-runtime-counter-relocation
+endif
endif
LOCAL_MODULE := libexynosdisplay
@@ -213,8 +231,17 @@ LOCAL_CFLAGS += -DSOC_VERSION=$(soc_ver)
LOCAL_CFLAGS += -Wthread-safety
ifeq ($(CLANG_COVERAGE),true)
-LOCAL_CFLAGS += -fprofile-instr-generate -fcoverage-mapping -mllvm -runtime-counter-relocation
+# enable code coverage (these flags are copied from build/soong/cc/coverage.go)
+LOCAL_CFLAGS += -fprofile-instr-generate -fcoverage-mapping
+LOCAL_CFLAGS += -Wno-frame-larger-than=
+LOCAL_STATIC_LIBRARIES += libprofile-clang-extras_ndk
LOCAL_LDFLAGS += -fprofile-instr-generate
+LOCAL_LDFLAGS += -Wl,--wrap,open
+
+ifeq ($(CLANG_COVERAGE_CONTINUOUS_MODE),true)
+LOCAL_CFLAGS += -mllvm -runtime-counter-relocation
+LOCAL_LDFLAGS += -Wl,-mllvm=-runtime-counter-relocation
+endif
endif
LOCAL_SRC_FILES := \
@@ -259,8 +286,17 @@ LOCAL_CFLAGS += -DSOC_VERSION=$(soc_ver)
LOCAL_CFLAGS += -Wthread-safety
ifeq ($(CLANG_COVERAGE),true)
-LOCAL_CFLAGS += -fprofile-instr-generate -fcoverage-mapping -mllvm -runtime-counter-relocation
+# enable code coverage (these flags are copied from build/soong/cc/coverage.go)
+LOCAL_CFLAGS += -fprofile-instr-generate -fcoverage-mapping
+LOCAL_CFLAGS += -Wno-frame-larger-than=
+LOCAL_STATIC_LIBRARIES += libprofile-clang-extras_ndk
LOCAL_LDFLAGS += -fprofile-instr-generate
+LOCAL_LDFLAGS += -Wl,--wrap,open
+
+ifeq ($(CLANG_COVERAGE_CONTINUOUS_MODE),true)
+LOCAL_CFLAGS += -mllvm -runtime-counter-relocation
+LOCAL_LDFLAGS += -Wl,-mllvm=-runtime-counter-relocation
+endif
endif
ifeq ($(BOARD_USES_HWC_SERVICES),true)