I’m being forced to work on a new MacBook for a project I’ve just started and it came with Mac OS Big Sur, which I have heard has some problems (as these things always do when they first come out). I’ve tried following the standard procedure to install CmdStan:
xcode-select --install
cd ~
git clone https://github.com/stan-dev/cmdstan.git --recursive
cd cmdstan
make build -j6
I’ve tried reinstalling xcode CLT etc. the usual fixes, but no matter what I do I get the following error:
Failed to build Boost.Build build engine
Consult 'bootstrap.log' for more details
I’m noting that this seems to specify its using clang++ from my conda environment, not sure how to revert to xcode’s clt here? Regardless of the environment I try, I can’t seem to get this to work.
Operating System: Mac OS Big Sur
CmdStan Version: 2.25.0
Compiler/Toolkit: Xcode, Apple clang version 12.0.0 (clang-1200.0.32.27) and GNU Make 3.81
I spoke too soon potentially as I might need a bit more help. This has allowed cmdstan to build successfully, but when I go to use it via cmdstanr I get the following error, is there a way to specify this CXX flag globally?
Compiling Stan program...
error: stack protector mode differs in PCH file vs. current file
error: PCH file was compiled for the target 'x86_64-apple-macosx10.9.0' but the current translation unit is being compiled for target 'x86_64-apple-macosx11.0.0'
2 errors generated.
make: *** [/var/folders/rc/_df5n5md3vg8qs3wl_5lk0f80000gn/T/Rtmp6PbS5L/model-3822ebf8022] Error 1
Error: An error occured during compilation! See the message above for more information.
The problem there is that Cmdstan uses a precompiled header (PCH) that speeds up compilation for up to a factor of 2. And when the PCH is compiled using some other compiler or an earlier version of the same compiler you need to rebuild cmdstan.
So far we have not found a way to automatically detect that in cmdstan so you need to run rebuild cmdstan manually whenever that occurs. This seems to come up on MacOS sometime when the xcode toolchain updates.
There is one possible solution to this, which is disabling precompiled headers, but that will slow down compilation for a factor of 2.