Support coverage instrumentation for Linux host

Bug: http://b/77792074

- Add the libclang_rt.profile runtime libraries directly to the compile
command (for both host and target) instead of relying on the Clang
driver.
- Move the coverage mutator to PreDepsMutators so the mutation has
already happened when runtime libraries are added during dependence
computation.
- Factor out cc/config/toolchain to identify libclang_rt.profile modules
for the x86 and x86_64 host.

Test: make NATIVE_COVERAGE=true produces coverage-enabled host binaries.
Change-Id: I1ebc8cffdf11622bfc18199a57674672888b3a5f
diff --git a/cc/config/toolchain.go b/cc/config/toolchain.go
index ca863a7..19d2828 100644
--- a/cc/config/toolchain.go
+++ b/cc/config/toolchain.go
@@ -85,6 +85,8 @@
 	AvailableLibraries() []string
 
 	Bionic() bool
+
+	profileRuntimeLibrary() string
 }
 
 type toolchainBase struct {
@@ -169,6 +171,10 @@
 	return true
 }
 
+func (t toolchainBase) profileRuntimeLibrary() string {
+	return ""
+}
+
 func (t toolchainBase) ToolPath() string {
 	return ""
 }
@@ -240,6 +246,12 @@
 }
 
 func ProfileRuntimeLibrary(t Toolchain) string {
+	lib := t.profileRuntimeLibrary()
+	if lib != "" {
+		// Return the directly exported profile library
+		return lib
+	}
+	// Return the Android-specific library
 	return SanitizerRuntimeLibrary(t, "profile")
 }
 
diff --git a/cc/config/x86_linux_bionic_host.go b/cc/config/x86_linux_bionic_host.go
index a9fb1f6..290793e 100644
--- a/cc/config/x86_linux_bionic_host.go
+++ b/cc/config/x86_linux_bionic_host.go
@@ -151,6 +151,10 @@
 	return true
 }
 
+func (t *toolchainLinuxBionic) profileRuntimeLibrary() string {
+	return "libclang_rt.profile-x86_64"
+}
+
 var toolchainLinuxBionicSingleton Toolchain = &toolchainLinuxBionic{}
 
 func linuxBionicToolchainFactory(arch android.Arch) Toolchain {
diff --git a/cc/config/x86_linux_host.go b/cc/config/x86_linux_host.go
index 354500e..653f819 100644
--- a/cc/config/x86_linux_host.go
+++ b/cc/config/x86_linux_host.go
@@ -270,6 +270,14 @@
 	return "${config.LinuxX8664YasmFlags}"
 }
 
+func (t *toolchainLinuxX86) profileRuntimeLibrary() string {
+	return "libclang_rt.profile-i386"
+}
+
+func (t *toolchainLinuxX8664) profileRuntimeLibrary() string {
+	return "libclang_rt.profile-x86_64"
+}
+
 func (t *toolchainLinux) AvailableLibraries() []string {
 	return linuxAvailableLibraries
 }