[coverage] Wrap calls to open
Bug: http://b/173448692
The coverage runtime creates files with uga+rw permissions but an
earlier umask call can restrict these and cause problems with profile
merging ('%Nm' in LLVM_PROFILE_FILE). This change passes `--wrap,open`
to coverage builds. The other change in this topic adds the wrapper
function to set the permissions again using `fchmod` (only for files
opened under /data/misc/trace).
Test: Manually validate permissions of files under /data/misc/trace.
Test: libprofile-clang-extras-test
Change-Id: I881474ab184d03d14c5637951aac027a363739b6
diff --git a/cc/coverage.go b/cc/coverage.go
index aa1fdf6..acf98dd 100644
--- a/cc/coverage.go
+++ b/cc/coverage.go
@@ -149,6 +149,7 @@
coverage := ctx.GetDirectDepWithTag(getClangProfileLibraryName(ctx), CoverageDepTag).(*Module)
deps.WholeStaticLibs = append(deps.WholeStaticLibs, coverage.OutputFile().Path())
+ flags.Local.LdFlags = append(flags.Local.LdFlags, "-Wl,--wrap,open")
}
}