On Sun, Jun 22, 2014 at 08:54:24AM -0700, Sylvestre Ledru wrote: > On 20/05/2014 09:58, Aurelien Jacobs wrote: > > Package: clang-3.4 > > Version: 1:3.4.1-3 > > > > Dear Maintainer, > > > > scan-build stopped working for me since you added the following patch in > > version 1:3.4.1-1: > > scan-build-fix-clang-detection.diff > > > > I use scan-build in a cross-compilation environement so I call it > > with --use-cc: > > scan-build --use-cc=arm-none-eabi-gcc -o out make -e > > > The attached patch seems to fix it. > > If you are happy about it, let me know and I will push that upstream too.
Great ! Well, it works for me (not using c++), but I think there is a small mistake in the CXX compiler check, where you used a || instead of a &&. It also seems more logical to me with parenthesis around the && part of the check. I'm not sure I'm really clear, so attached is a very slightly modified version of your patch, which I tested as well and which works fine for me. > Thanks for this interesting bug report Thanks for taking care of it ! Aurel
Index: llvm-toolchain-3.4-3.4.2/clang/tools/scan-build/ccc-analyzer =================================================================== --- llvm-toolchain-3.4-3.4.2.orig/clang/tools/scan-build/ccc-analyzer 2014-06-22 08:51:25.452950214 -0700 +++ llvm-toolchain-3.4-3.4.2/clang/tools/scan-build/ccc-analyzer 2014-06-22 08:52:17.602331808 -0700 @@ -25,6 +25,17 @@ # Compiler command setup. ##===----------------------------------------------------------------------===## +# 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; +} + my $Compiler; my $Clang; my $DefaultCCompiler; @@ -40,14 +51,14 @@ if ($FindBin::Script =~ /c\+\+-analyzer/) { $Compiler = $ENV{'CCC_CXX'}; - if (!defined $Compiler || ! -x $Compiler) { $Compiler = $DefaultCXXCompiler; } + if (!defined $Compiler || (! -x $Compiler && ! SearchInPath($Compiler))) { $Compiler = $DefaultCXXCompiler; } $Clang = $ENV{'CLANG_CXX'}; if (!defined $Clang || ! -x $Clang) { $Clang = 'clang++'; } } else { $Compiler = $ENV{'CCC_CC'}; - if (!defined $Compiler || ! -x $Compiler) { $Compiler = $DefaultCCompiler; } + if (!defined $Compiler || (! -x $Compiler && ! SearchInPath($Compiler))) { $Compiler = $DefaultCCompiler; } $Clang = $ENV{'CLANG'}; if (!defined $Clang || ! -x $Clang) { $Clang = 'clang'; }