Bug 10912 - Ignore -Wl,... linker flag for calculating hash
Summary: Ignore -Wl,... linker flag for calculating hash
Status: CLOSED FIXED
Alias: None
Product: ccache
Classification: Unclassified
Component: ccache (show other bugs)
Version: unspecified
Hardware: All All
: P5 enhancement
Target Milestone: 3.2
Assignee: Joel Rosdahl
QA Contact: Joel Rosdahl
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-11-02 03:07 UTC by ishikawa
Modified: 2014-11-17 19:24 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description ishikawa 2014-11-02 03:07:44 UTC
Hi,

During testing and using a locally modified version of ccache to
support "-gsplit-dwarf" (see bug 10005 )
I noticed that the popular compiler flag to pass parameters to linker
-Wl,... (... is a string that denotes the parameters to the linker)
is not ignored for computing hash and thus
the sequence of commands,

ccache gcc -c /tmp/t.c
ccache gcc -c /tmp/t.c -Wl,...

does not cause a cache hit when the second command is issued.
It should.

A simple change like the following would suffice:
(Sorry this is not in a diff form.)
Simply process "-Wl,..." like -Lpath.

static struct file_hash *
calculate_object_hash(struct args *args, struct mdfour *hash, int direct_mode)
{
	int i;
	char *manifest_name;
	struct stat st;
	int result;
	struct file_hash *object_hash = NULL;
	char *p;

	if (direct_mode) {
		hash_delimiter(hash, "manifest version");
		hash_int(hash, MANIFEST_VERSION);
	}

	/* first the arguments */
	for (i = 1; i < args->argc; i++) {
		/* -L doesn't affect compilation. */
		if (i < args->argc-1 && str_eq(args->argv[i], "-L")) {
			i++;
			continue;
		}
		if (str_startswith(args->argv[i], "-L")) {
			continue;
		}

		/* for gcc, -Wl,... is for linker options and so does not affect
		   compilation */
		if (str_startswith(args->argv[i], "-Wl,")) {
			cc_log("(debug) -Wl,... is ignored from hashing.");
			continue;
		}



I have tested this and it works. make test pass, so I have not incorporated a new bug (maybe I need more test cases, etc.)

Thank you in advance for your attention.
Comment 1 Joel Rosdahl 2014-11-15 15:04:12 UTC
Thanks, added in 47f5e8c77d3138beb1087fccb0f76ab76273e4cb on master.
Comment 2 ishikawa 2014-11-15 16:24:50 UTC
(In reply to Joel Rosdahl from comment #1)

Dear Joel,

In,
https://git.samba.org/?p=ccache.git;a=commit;h=47f5e8c77d3138beb1087fccb0f76ab76273e4cb

I noticed that you put a commit message to this patch as follows

>Don't include -Wl,... in hash since it doesn't affect compilation
>
> As suggested by Mutsumi Ishikawa.

I am not Mutsumi Ishikawa (of Debian fame?).
"Ishikawa" is a rather common name in Japan.

Anyway, thank you for incorporating this feature.

TIA
Comment 3 Joel Rosdahl 2014-11-15 21:45:35 UTC
Oh, drats. Terribly sorry about the name confusion.
Comment 4 ishikawa 2014-11-16 03:21:32 UTC
(In reply to Joel Rosdahl from comment #3)

No problem.

I am working on creating a patch set for "-gsplit-dwarf".
I just noticed yesterday that a few changes were made to git repository
and so manually updating my source tree.

Due to my day job, this patch set has to wait for a few weeks :-(

But in the meantime, the clean up continues a little by little incorporating the changes made to the ccache git repository, and |make test| passes, 
and I am using it for mozilla thunderbird local build, and so
should be in a good shape once the patch set is ready so that
I can upload it here.

TIA
Comment 5 Joel Rosdahl 2014-11-17 19:24:53 UTC
Included in v3.2.