Respect -fprofile-prefix-map for getcwd in .gcno files

so that
`gcc -c a.cc --coverage -fprofile-prefix-map=$PWD=.`
does not emit $PWD in the generated a.gcno file.

gcc/ChangeLog:

	PR gcov-profile/96092
	* coverage.cc (coverage_init): Remap getpwd().
This commit is contained in:
Fangrui Song 2024-12-31 16:32:07 -08:00
parent f9c99d403c
commit fa778ba7d0

View file

@ -1341,7 +1341,7 @@ coverage_init (const char *filename)
gcov_write_unsigned (bbg_file_stamp);
/* Use an arbitrary checksum */
gcov_write_unsigned (0);
gcov_write_string (getpwd ());
gcov_write_string (remap_profile_filename (getpwd ()));
/* Do not support has_unexecuted_blocks for Ada. */
gcov_write_unsigned (strcmp (lang_hooks.name, "GNU Ada") != 0);