aboutsummaryrefslogtreecommitdiffstats
path: root/package/valgrind/valgrind-fix-ccache-support.patch
blob: 40ada8d81b56e8285f0ab2c05ecd3e4de409de6f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
Fix link_tool_exe_linux.in to work with ccache

The link_tool_exe_linux.in Perl script makes the assumption that the
compilation command line is always:

  gcc -o foobar foobar.c -someflags

I.e, it assumes that the compiler is the first word of the command
line. However, this is not true with ccache, where the command line
is:

  /path/to/ccache /path/to/crossgcc -o foobar foobar.c -someflags

Therefore, we tune the script to take into account the case where
ccache is used.

Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>

Index: b/coregrind/link_tool_exe_linux.in
===================================================================
--- a/coregrind/link_tool_exe_linux.in
+++ b/coregrind/link_tool_exe_linux.in
@@ -60,8 +60,16 @@
 die "Bogus alt-load address"
     if (length($ala) < 3 || index($ala, "0x") != 0);
 
+shift(@ARGV);
+
+if ($ARGV[0] =~ /.*ccache/) {
+    shift(@ARGV);
+}
+
 # The cc invokation to do the final link
-my $cc = $ARGV[1];
+my $cc = $ARGV[0];
+
+shift(@ARGV);
 
 # and the 'restargs' are argv[2 ..]
 
@@ -82,7 +90,7 @@
 }
 
 # Add the rest of the parameters
-foreach my $n (2 .. $#ARGV) {
+foreach my $n (0 .. $#ARGV) {
    $cmd = "$cmd $ARGV[$n]";
 }