CmdStan on Linux server - Chain finished unexpectedly with schools example (but not with bernoulli example)

I tried compiling my model from the command line using the following command:

make CXXFLAGS=‘-ggdb3’ /PATH/TO/MODEL

But I got the following error:

— Translating Stan model to C++ code —
bin/stanc --warn-pedantic --o=/modeling/ib700/CalCAST_code/schools.hpp /modeling/ib700/CalCAST_code/schools.stan

— Compiling, linking C++ code —
/modeling/spack/opt/spack/linux-centos7-haswell/gcc-4.8.5/gcc-12.2.0-jvrrfd27hm6g6x5lksmvapqw3dnkce3p/bin/g++ -ggdb3 -DBOOST_DISABLE_ASSERTS -c -Wno-ignored-attributes -x c++ -o /path/to/model/schools.o /path/to/model/schools.hpp
/path/to/model/schools.hpp:3:10: fatal error: stan/model/model_header.hpp: No such file or directory
3 | #include <stan/model/model_header.hpp>
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.

However, looking around the forum I found this post and decided to try the following:

make STAN_THREADS=TRUE STANCFLAGS=–O1 /PATH/TO/MODEL

This makes my model complete succesfully! Any idea why?