[cfe-dev] using scan-build on osx 10.9 command line

James Burgess jamesrburgess at mac.com
Tue Dec 30 12:41:10 PST 2014


Hi Ted,
 Thanks for the reply

(1) Yes, I can compile normally with gcc/g++. I use the command line tools for building a pretty sizable code base that is mostly c++. This is a very stock Mac, it had 10.9 when I tried this the first time but I’ve now updated to 10.10.1 and I get the same error. After upgrading to 10.10 I ran Xcode to see if it wanted to update, it did install something but it looks like the gcc/g++ report the same versions with a slight bump in the build number (clang-600.0.56)

2) using -isysroot fixes the problem, success!

Now I’d like to integrate this into my own build system. I read that if I was using make/autoconf (which I am not) I could just set CC and CXX and the right thing would happen?

 I can see scan-build doing the same but most of the script seems to be about building the report html, I’m guessing I’m going to need some of that script after my build is done. Does anyone know what would be the recipe if for doing that if I had a large pile of makefiles and I’d set CC and CXX before building?

Cheers,
 - James


> On Dec 29, 2014, at 10:37 PM, Ted Kremenek <kremenek at apple.com> wrote:
> 
> Hi James,
> 
> I just tried replicating your problem and was unable to do so.
> 
> A couple questions:
> 
> (1) If you just run "gcc -g main.c" can the compiler successfully compiler main.c?  I'm assuming the answer is "yes", but it is a good sanity check.
> 
> (2) Does it work if you pass an explicit SDK path?
> 
> For example:
> 
> scan-build gcc -g main.c -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk
> 
> Cheers,
> Ted
> 
> 
>> On Dec 20, 2014, at 10:35 PM, James Burgess <jamesrburgess at me.com> wrote:
>> 
>> Hi, 
>> I’m having trouble getting going with scan-build. I downloaded checker-276 from the link on http://clang-analyzer.llvm.org and I can’t get the simplest example to run. The first error is the clang in checker-276 is that it can’t find a system header (stdio.h in my case). I have Xcode 6.0.1 installed and gcc and g++ work fine from the command line:
>> 
>> jrb$ gcc --version
>> Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/c++/4.2.1
>> Apple LLVM version 6.0 (clang-600.0.51) (based on LLVM 3.5svn)
>> Target: x86_64-apple-darwin13.4.0
>> Thread model: posix
>> 
>> If I use a very simple example:
>> jrb$ cat main.c
>> #include <stdio.h>
>> int
>> main(int argc, char** argv)
>> {
>>  printf("hello world\n");
>>  return 0;
>> }
>> 
>> When I run scan-build I get this:
>> 
>> jrb$ ~/Downloads/checker-276/scan-build gcc -g main.c
>> scan-build: Using '/Users/jrb/Downloads/checker-276/bin/clang' for static analysis
>> main.c:1:10: fatal error: 'stdio.h' file not found
>> #include <stdio.h>
>>       ^
>> 1 error generated.
>> main.c:1:10: fatal error: 'stdio.h' file not found
>> #include <stdio.h>
>>       ^
>> 1 error generated.
>> scan-build: 0 bugs found.
>> scan-build: The analyzer encountered problems on some source files.
>> scan-build: Preprocessed versions of these sources were deposited in '/var/folders/cd/pbxz31kj4bl_x_t1dzxnqxhm0000gn/T/scan-build-2014-12-20-221956-7628-1/failures'.
>> scan-build: Please consider submitting a bug report using these files:
>> scan-build:   http://clang-analyzer.llvm.org/filing_bugs.html
>> 
>> 
>> - James
>> 
>> 
>> _______________________________________________
>> cfe-dev mailing list
>> cfe-dev at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
> 





More information about the cfe-dev mailing list