Stan precompiled headers not picking up changes to stan/math?

in cmdstan, failing to do a make stan-update whenever the math lib changes causes problems with the precompiled headers file - see error message below.

I think I’ve also hit similar error when developing/testing stuff in core Stan - there the problem is that cmdstan creates the file stan/src/stan/model/model_header.hpp.gch and there’s nothing in the core Stan makefile that gets rid of it.

@seantalts - why precompiled headers? how will this change when we go to monorepo?

--- Compiling pre-compiled header ---	
clang++ -std=c++1y -Wno-unknown-warning-option -Wno-tautological-compare -Wno-sign-compare      -O3 -I src -I stan/src -I stan/lib/stan_math/ -I stan/lib/stan_math/lib/eigen_3.3.3 -I stan/lib/stan_math/lib/boost_1.66.0 -I stan/lib/stan_math/lib/sundials_3.1.0/include    -DBOOST_RESULT_OF_USE_TR1 -DBOOST_NO_DECLTYPE -DBOOST_DISABLE_ASSERTS -DBOOST_PHOENIX_NO_VARIADIC_EXPRESSION     -c stan/src/stan/model/model_header.hpp -o stan/src/stan/model/model_header.hpp.gch
In file included from stan/src/stan/model/model_header.hpp:8:
stan/src/stan/io/reader.hpp:709:16: error: no member named 'locscale_constrain' in namespace 'stan::math'; did you mean
      'scalar_constrain'?
        return stan::math::locscale_constrain(scalar(), loc, scale);
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
               scalar_constrain
stan/src/stan/io/reader.hpp:180:9: note: 'scalar_constrain' declared here
      T scalar_constrain(T& /*log_prob*/) {
        ^
stan/src/stan/io/reader.hpp:727:16: error: no member named 'locscale_constrain' in namespace 'stan::math'; did you mean
      'scalar_constrain'?
        return stan::math::locscale_constrain(scalar(), loc, scale, lp);
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
               scalar_constrain
stan/src/stan/io/reader.hpp:180:9: note: 'scalar_constrain' declared here
      T scalar_constrain(T& /*log_prob*/) {
        ^
In file included from stan/src/stan/model/model_header.hpp:9:
stan/src/stan/io/writer.hpp:179:39: error: no member named 'locscale_free' in namespace 'stan::math'
        data_r_.push_back(stan::math::locscale_free(y, loc, scale));
                          ~~~~~~~~~~~~^
3 errors generated.
make: *** [stan/src/stan/model/model_header.hpp.gch] Error 1
~/github/stan-dev/cmdstan (develop)> 

They speed up builds and testing and will still be in monorepo. They do need to be cleaned appropriately - probably just need to generate the right .d file for them in the new makefiles.

@seantalts, is there any doc that describes under what conditions precompiled headers need to be rebuilt? I think your assessment is right… one way to do it is to include it in the right .d file. But I’m not clear when the rebuild is supposed to happen.

The precompiled header is just a precompiled version of the header, so it has to be rebuilt whenever anything that header includes changes. I think I had a line in the makefiles before that added it to the .d files manually, that was a pain.