diff --git a/compiler-rt/lib/profile/InstrProfilingUtil.c b/compiler-rt/lib/profile/InstrProfilingUtil.c --- a/compiler-rt/lib/profile/InstrProfilingUtil.c +++ b/compiler-rt/lib/profile/InstrProfilingUtil.c @@ -44,6 +44,17 @@ char save = path[i]; if (!IS_DIR_SEPARATOR(path[i])) continue; + +#if defined(__ANDROID__) && defined(__ANDROID_API__) && \ + defined(__ANDROID_API_FUTURE__) && __ANDROID_API__==__ANDROID_API_FUTURE__ + // Avoid spammy selinux denial messages in Android by not attempting to + // create directories in GCOV_PREFIX. These denials occur when creating (or + // even attempting to stat()) top-level directories like "/data". + const char *gcov_prefix = getenv("GCOV_PREFIX"); + if (gcov_prefix != NULL && strncmp(path, gcov_prefix, i) == 0) + continue; +#endif + path[i] = '\0'; #ifdef _WIN32 _mkdir(path);