Search code examples
scons

How to clear scons cache? CheckLibWithHeader returns "no" first time called, "yes" second time


I have a SConstruct file that is checking for the Google protobuf library, like so:

main['HAVE_PROTOBUF'] = main['PROTOC'] and \
conf.CheckLibWithHeader('protobuf', 'google/protobuf/message.h',
                        'C++', 'GOOGLE_PROTOBUF_VERIFY_VERSION;')

I noticed that this call to CheckLibWithHeader was returning "no". I was doing some debugging of the script, and it became apparent to me that subsequent identical calls to CheckLibWithHeader returned "yes". When I put an identical line in the SConstruct file immediately following the one above, the output was as follows:

.
.
.
Checking for accept(0,0,0) in C++ library None... (cached) yes
Checking for zlibVersion() in C++ library z... (cached) yes
Checking for GOOGLE_PROTOBUF_VERIFY_VERSION in C++ library protobuf... (cached) no
Checking for GOOGLE_PROTOBUF_VERIFY_VERSION in C++ library protobuf... (cached) yes
Checking for clock_nanosleep(0,0,NULL,NULL) in C library None... no
Checking for clock_nanosleep(0,0,NULL,NULL) in C library rt... yes
.
.
.

I do have the protobuf libraries. Does anyone know why the first call to CheckLibWithHeader is returning "no"?

This problem for me occurs in CentOS, but not in Ubuntu.

Update: I am no longer able to reproduce the above problem. However, I have found that when I run into a problem with scons using a value marked as "(cached)" that appears to be incorrect, I can do two things to help get to a solution. I'll put these in an answer below.


Solution

  • The --config=force command line option should re-run all configuration tests without looking at the cached results. According to the man page for SCons:

    --config=force
    
    If this option is specified, all configuration tests will be re-run
    regardless of whether the cached results are out of date. This can 
    be used to explicitly force the configuration tests to be updated in
    response to an otherwise unconfigured change in a system header file 
    or compiler.