[build] Support for setting -fprofile-list flag

This flag can be used to specify a file describing files and functions
to instrument (or exclude from instrumentation).

Bug: 68426
Change-Id: I5abfb34e41fc9bcb5cf8bb632e01c92f2b6b33aa
Reviewed-on: https://fuchsia-review.googlesource.com/c/fuchsia/+/475757
Reviewed-by: Roland McGrath <mcgrathr@google.com>
Commit-Queue: Auto-Submit <auto-submit@fuchsia-infra.iam.gserviceaccount.com>
Fuchsia-Auto-Submit: Petr Hosek <phosek@google.com>
diff --git a/build/config/profile/BUILD.gn b/build/config/profile/BUILD.gn
index 7600738..61a223e 100644
--- a/build/config/profile/BUILD.gn
+++ b/build/config/profile/BUILD.gn
@@ -2,6 +2,7 @@
 # Use of this source code is governed by a BSD-style license that can be
 # found in the LICENSE file.
 
+import("//build/config/profile/config.gni")
 import("//build/toolchain/variant.gni")
 
 variant("profile") {
@@ -10,6 +11,11 @@
     "-fcoverage-mapping",
   ]
 
+  if (profile_list != "") {
+    common_flags +=
+        [ "-fprofile-list=" + rebase_path(profile_list, "", root_build_dir) ]
+  }
+
   is_kernel = toolchain_variant.tags + [ "kernel" ] - [ "kernel" ] !=
               toolchain_variant.tags
 
diff --git a/build/config/profile/config.gni b/build/config/profile/config.gni
new file mode 100644
index 0000000..eb6c722
--- /dev/null
+++ b/build/config/profile/config.gni
@@ -0,0 +1,8 @@
+# Copyright 2020 The Fuchsia Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+declare_args() {
+  # Path to profile list file describing files and functions to instrument.
+  profile_list = ""
+}