This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: gcc: -ftest-coverage and -auxbase
On 6/20/19 3:29 PM, David.Taylor@dell.com wrote:
>> From: Martin Liška <mliska@suse.cz>
>> Sent: Thursday, June 20, 2019 9:07 AM
>>
>> On 6/20/19 3:00 PM, David.Taylor@dell.com wrote:
>>>
>>>> From: Martin Liška <mliska@suse.cz>
>>>> Sent: Thursday, June 20, 2019 5:12 AM
>>>>
>>>> On 6/19/19 7:11 PM, David.Taylor@dell.com wrote:
>>>>> Thanks for the patch. Standalone it is not sufficient. Combined
>>>>> with the other two changes that have been discussed --
>>>>
>>>> Why is that not sufficient? If you build from top-level and you have
>>>> .o files that overwrite each other, then you can set
>>>> -fprofile-note-dir=/tmp/my- unique-folder
>>>>
>>>> And you'll not overwrite .gcno files.
>>>>
>>>> Martin
>>>
>>> Right now GCC names the GCNO files '-.gcno'.
>>>
>>> With your patch they get put into a specified directory. But, unless
>>> I am prepared to create over 16,000 directories each to hold just one
>>> file (I'm not), it is not sufficient.
>>>
>>> What I want to do -- unless it is going to create problems -- is to
>>> place the notes files alongside the object files. The files foo.o and
>>> foo.gcno would be in the same directory.
>
>> I would recommend that. You can achieve that with -fprofile-note-dir=.
>
> But unless some other change is also made, the '-o -' part of our
> compilation line results in all the notes files having names of
> '-.gcno'. While I have considered replacing the '-o -' with '-pipe'
> when doing instrumentation, I am loathe to make the dot c to
> dot o rule any more complicated -- it is already 30+ lines long.
>
> Your patch makes things much better. And for many it would be sufficient. For us, sadly, it is not enough.
>
I see. What about the following patch:
$ ./gcc/xgcc -Bgcc /tmp/main.c --coverage -fprofile-note=/tmp/main.gcno
$ ls -l /tmp/main.gcno
-rw-r--r-- 1 marxin users 428 Jun 20 15:48 /tmp/main.gcno
Martin
>From 30eb7f04c2ee84b5199ea908c8b72cec2163825f Mon Sep 17 00:00:00 2001
From: Martin Liska <mliska@suse.cz>
Date: Thu, 20 Jun 2019 15:47:18 +0200
Subject: [PATCH] Add -fprofile-note option.
---
gcc/common.opt | 4 ++++
gcc/coverage.c | 11 ++++++++---
2 files changed, 12 insertions(+), 3 deletions(-)
diff --git a/gcc/common.opt b/gcc/common.opt
index a1544d06824..c1b90562b9b 100644
--- a/gcc/common.opt
+++ b/gcc/common.opt
@@ -2096,6 +2096,10 @@ Common Joined RejectNegative Var(profile_data_prefix)
Set the top-level directory for storing the profile data.
The default is 'pwd'.
+fprofile-note=
+Common Joined RejectNegative Var(profile_note_location)
+Select the name for storing the profile note file.
+
fprofile-correction
Common Report Var(flag_profile_correction)
Enable correction of flow inconsistent profile data input.
diff --git a/gcc/coverage.c b/gcc/coverage.c
index 1ffefd5f482..960ff7ee86a 100644
--- a/gcc/coverage.c
+++ b/gcc/coverage.c
@@ -1255,9 +1255,14 @@ coverage_init (const char *filename)
/* Name of bbg file. */
if (flag_test_coverage && !flag_compare_debug)
{
- bbg_file_name = XNEWVEC (char, len + strlen (GCOV_NOTE_SUFFIX) + 1);
- memcpy (bbg_file_name, filename, len);
- strcpy (bbg_file_name + len, GCOV_NOTE_SUFFIX);
+ if (profile_note_location)
+ bbg_file_name = xstrdup (profile_note_location);
+ else
+ {
+ bbg_file_name = XNEWVEC (char, len + strlen (GCOV_NOTE_SUFFIX) + 1);
+ memcpy (bbg_file_name, filename, len);
+ strcpy (bbg_file_name + len, GCOV_NOTE_SUFFIX);
+ }
if (!gcov_open (bbg_file_name, -1))
{
--
2.21.0