You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We're using ccache to speed up compilation, so in our system, CC is set to "ccache gcc-4.9" (basically). We want and need to run scan-build with the same underlying compiler, so we run it with the CCC_CC="$(CC)" environment variable.
However, ccc-analyzer doesn't accept this, but falls back to the default compiler instead. An easy way to reproduce this is to do
$ touch /tmp/a.c # Empty C source
$ CCC_CC=ls ccc-analyzer /tmp/a.c
/tmp/a.c
$ CCC_CC="true ; ls" ccc-analyzer /tmp/a.c
/usr/bin/ld: [...]: relocation 0 has invalid symbol index 11
so in the second case, ccc-analyzer ignores CCC_CC and falls back to gcc. My Perl-knowledge is extremely limited, but I believe this is caused by ccc-analyzer verifying that the compiler exists in the path:
Search in the PATH if the compiler exists
sub SearchInPath {
my $file = shift;
foreach my $dir (split (':', $ENV{PATH})) {
if (-x "$dir/$file") {
return 1;
}
}
return 0;
}
[...]
Extended Description
We're using ccache to speed up compilation, so in our system, CC is set to "ccache gcc-4.9" (basically). We want and need to run scan-build with the same underlying compiler, so we run it with the CCC_CC="$(CC)" environment variable.
However, ccc-analyzer doesn't accept this, but falls back to the default compiler instead. An easy way to reproduce this is to do
$ touch /tmp/a.c # Empty C source
$ CCC_CC=ls ccc-analyzer /tmp/a.c
/tmp/a.c
$ CCC_CC="true ; ls" ccc-analyzer /tmp/a.c
/usr/bin/ld: [...]: relocation 0 has invalid symbol index 11
so in the second case, ccc-analyzer ignores CCC_CC and falls back to gcc. My Perl-knowledge is extremely limited, but I believe this is caused by ccc-analyzer verifying that the compiler exists in the path:
Search in the PATH if the compiler exists
sub SearchInPath {
my $file = shift;
foreach my $dir (split (':', $ENV{PATH})) {
if (-x "$dir/$file") {
return 1;
}
}
return 0;
}
[...]
$Compiler = $ENV{'CCC_CC'};
if (!defined $Compiler || (! -x $Compiler && ! SearchInPath($Compiler))) { $Compiler = $DefaultCCompiler; }
I tested this with clang-3.7, but the latest ccc-analyzer seems to have the same construct. Obviously, the same is true for the handling of CCC_CXX.
The text was updated successfully, but these errors were encountered: