summaryrefslogtreecommitdiff
path: root/gcc/coverage.c
diff options
context:
space:
mode:
authorJan Hubicka <jh@suse.cz>2020-04-16 14:25:51 +0200
committerJan Hubicka <jh@suse.cz>2020-04-16 14:27:20 +0200
commit44b326839d864fc10c459916abcc97f35a9ac3de (patch)
treedcee354ce5653457b3fe7d38b2667e36ebb22e76 /gcc/coverage.c
parent3c3f12e2a7625c9a2f5d74a47dbacb2fd1ae5643 (diff)
Make it possible to have different instrumented and feedback builds without copying gcda files around [pr93401]
Hi, in GCC 8 we changed -fprofile-generate=<path> to use mangled absolute paths in the <path> directory. This was necessary to avoid clashes of files when gcc is executed from different directories to build different sources of same filename. However this made it difficult to build projects on setups where instrumented build is done in one directory, feedback build in different and possibly training happens in yet another directory structure. This happens i.e. for Firefox builds for month or two. This patch adds -fprofile-prefix-path that can be used to inform gcc where the root of build directory is and strip it form the gcda filenames. This is similar to exisitng debug-prefix-map but without the map feature since it seems useless for profile data. We spent quite some time with Maritn Liska discussing options and found no better solution. I was looking how this work on LLVM and they produce single profdata file which is then transformed into kind of simple database by llvmprofdata tool. This database keys functions by filename and symbol name. If you arrane two files with same name define static variable with same symbol name this gets messedup and result in wrong info. So I think this is not very good solution and preffer the extra option. Bootstrapped/regtested x86_64-linux. I plan to commit it later today if there are no complains. I suppose our manual could have some central section on profile feedback explaining the whole setup at one place. Honza PR gcov-profile/93401 * common.opt (profile-prefix-path): New option. * coverae.c: Include diagnostics.h. (coverage_init): Strip profile prefix path. * doc/invoke.texi (-fprofile-prefix-path): Document.
Diffstat (limited to 'gcc/coverage.c')
-rw-r--r--gcc/coverage.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/gcc/coverage.c b/gcc/coverage.c
index 30ae84df90f..45c0278f44f 100644
--- a/gcc/coverage.c
+++ b/gcc/coverage.c
@@ -49,6 +49,7 @@ along with GCC; see the file COPYING3. If not see
#include "intl.h"
#include "auto-profile.h"
#include "profile.h"
+#include "diagnostic.h"
#include "gcov-io.c"
@@ -1221,6 +1222,19 @@ coverage_init (const char *filename)
const char *separator = "/";
#endif
filename = concat (getpwd (), separator, filename, NULL);
+ if (profile_prefix_path)
+ {
+ if (!strncmp (filename, profile_prefix_path,
+ strlen (profile_prefix_path)))
+ {
+ filename += strlen (profile_prefix_path);
+ while (*filename == *separator)
+ filename++;
+ }
+ else
+ warning (0, "filename %qs does not start with profile "
+ "prefix %qs", filename, profile_prefix_path);
+ }
filename = mangle_path (filename);
len = strlen (filename);
}