Stan in R on PowerPC G5 (10.6 PPC): Help needed

I would be okay with 64 bit (PowerPC G5), but Linux or rather BSD is a step I can take if everything fails on MacOS.
For one thing, it will be inconvenient for practical reasons (rebooting into other OS just for the sake of running R). From another side, making it work on MacOS will probably benefit someone else who faces a similar issue. It is sad that many developers give up on PowerPC, since G5 ones are pretty capable even nowadays.

(I have a backup route with Julia instead of R, but perhaps all the same issues with Stan will arise in that case too.)

Yes, Julia will have all the same issues as it just calls cmdstan.

The errors above are due to TBB, both because it’s looking for clang and because it’s assuming that you’re using 64bit powerpc. You can use Stan to force the choice of c compiler with the TBB by creating a make/local file and adding: TBB_CC = /opt/local/bin/gcc-mp-7

However there’s no easy resolution for the error:

/usr/include/mach/task.h:35:10: fatal error: mach/ppc64/task.h: No such file or directory
 #include <mach/ppc64/task.h>
          ^~~~~~~~~~~~~~~~~~~

As that is caused by some part of the TBB’s build/config process that Stan doesn’t interact with.

I have some success in proceeding toward building rstan, though V8 failed at the moment: Override dependency on V8 or make V8 build on PowerPC Mac? (R 4.1.2)

If that is sorted and I am ready to build rstan itself, all the same issues as with CmdStan will arise, right? I am thinking how to minimize “dependency hell”, since fixing every failing component is usually a non-trivial task in its own right.

If you have an option to work with a more recent CPU & operating system than powerpc G5 & Mac OS X 10.6 , I suspect things will become much easier. It looks like many open source tools and libraries no longer maintain support for that platform, so it might be simpler to switch to a different platform that is supported.

@andrjohns I have made through building all required libraries with Macports:

36-9:~ svacchanda$ port installed tbb
The following ports are currently installed:
  tbb @2020.3_0 (active)
36-9:~ svacchanda$ port installed eigen
The following ports are currently installed:
  eigen @2.0.17_0 (active)
36-9:~ svacchanda$ port installed boost
The following ports are currently installed:
  boost @1.76_0 (active)
36-9:~ svacchanda$ port installed sundials
The following ports are currently installed:
  sundials @5.7.0_0+accelerate+gcc7+mpich (active)

How do I use these for CmdStan in place of its own attached libs?

There are make variables you should be able to set to point cmdstan to them, but they’re sadly not that documented anywhere. @rok_cesnovar has been able to help me with some in the past, I know for TBB you need to set TBB_INC and TBB_LIB to point to the path with the headers and library respectively, and I suspect there are the same for other libraries

It looks like the macports Eigen is very out of date (we’re currently on 3.3.9), and won’t be compatible with Stan. If the TBB is the only library you can’t build locally, then you should use the TBB_INC and TBB_LIB flags that @WardBrian mentioned. There’s some more guidance on those in this section of the Github readme.

Unfortunately we don’t have equivalent functionality for the other libraries, only the TBB

1 Like

I have finally built gcc10 and gcc11 natively on PowerPC, however CmdStan still fails with the same lgamma error when I tried to build using gcc10. This looks like a problem on CmdStan side.

For the Boost lgamma fix to work, you need to use the github version of cmdstan (the changes aren’t in a release yet).

Then, in your make/local file, add:

CXXFLAGS += -D_BOOST_LGAMMA
1 Like

Thank you! I will try and update you.

I wanna rebuild R using gcc11 outside of Macports also. At the moment there is some issue with building 64-bit on 10.5.8, but 32-bit works both on 10.5.8 and 10.6 PPC.