I've added everything to my $PATH
and I've tweaked my SConstruct
to set the appropriate environment variables, as per these answers [ 1, 2, 3 ]. Now when I run
scan-build --use-c++=`which clang++` scons
the build begins, and I can see the process forked by scons
is
/path/to/c++-analyzer ... -std=c++11 ...
The object file successfully builds, but then I get an error:
could not find clang line
This error occurs in c++-analyzer
when the forked process does not contain the string -cc1
. But if I check ps aux
, I clearly see
/path/to/clang -cc1 ...
How could the program build properly but the static analyzer fail like this?
For reference, if I manually run
scan-build clang++ <parameters from scons>
then the build succeeds and the report is generated!
I can also "cheat" by adding
env["ENV"]["PATH"] = os.environ["PATH"]
and then running
CXX="scan-build clang++" scons
I just can't run scan-build
on scons
itself with an unmodified SConstruct
.
The problem is that clang is not on the search path in the execution environment (Wayback Machine). This explains why adding the line env["ENV"]["PATH"] = os.environ["PATH"]
solves the issue.
To run scan-build
on an unmodified SConstruct
you can put the clang executable (clang++
and possibly clang
) on the search path used by the execution environment, e.g. by creating a symbolic link from /usr/bin/clang++
to your /path/to/clang++
on Linux.