diff options
author | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2021-06-26 03:09:31 +0000 |
---|---|---|
committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2021-06-26 03:09:31 +0000 |
commit | 744500ad95952cb8ed30c16b3d73764f49569274 (patch) | |
tree | e4e192a00cdd1a33815a765f6b212069222e9d84 /toolchain-extras/profile-clang-extras.cpp | |
parent | c9897186b9437bc8d236e85b47df20a73b621cde (diff) | |
parent | b98bc39d9f3d44fc2910c0bdd16ba1933cab282d (diff) | |
download | extras-744500ad95952cb8ed30c16b3d73764f49569274.tar.gz |
Snap for 7495277 from b98bc39d9f3d44fc2910c0bdd16ba1933cab282d to sc-release
Change-Id: I166bfcbfff0153aa8b8da0d7d4747125b78f493c
Diffstat (limited to 'toolchain-extras/profile-clang-extras.cpp')
-rw-r--r-- | toolchain-extras/profile-clang-extras.cpp | 21 |
1 files changed, 6 insertions, 15 deletions
diff --git a/toolchain-extras/profile-clang-extras.cpp b/toolchain-extras/profile-clang-extras.cpp index 89c18b2a..bb713e18 100644 --- a/toolchain-extras/profile-clang-extras.cpp +++ b/toolchain-extras/profile-clang-extras.cpp @@ -36,24 +36,15 @@ static void llvm_signal_handler(__unused int signum) { } } -__attribute__((weak)) int init_profile_extras_once = 0; - // Initialize libprofile-extras: -// - Install a signal handler that triggers __llvm_profile_write_file on <COVERAGE_FLUSH_SIGNAL>. -// -// We want this initializer to run during load time. // -// Just marking init_profile_extras() with __attribute__((constructor)) isn't -// enough since the linker drops it from its output since no other symbol from -// this static library is referenced. +// - Install a signal handler that triggers __llvm_profile_write_file on +// <COVERAGE_FLUSH_SIGNAL>. // -// We force the linker to include init_profile_extras() by passing -// '-uinit_profile_extras' to the linker (in build/soong). -__attribute__((constructor)) int init_profile_extras(void) { - if (init_profile_extras_once) - return 0; - init_profile_extras_once = 1; - +// We want this initializer to run during load time. In addition to marking +// this function as a constructor, we link this library with `--whole-archive` +// to force this function to be included in the output. +static __attribute__((constructor)) int init_profile_extras(void) { if (chained_signal_handler != SIG_ERR) { return -1; } |