Errors during compile

Changed computers and getting two errors during compile to cmdStan from Matlab:
Error using StanModel/compile (line 908)
error: half args and returns was enabled in PCH file but is currently disabled
error: PCH file was compiled for the target ‘arm64-apple-macosx11.0.0’ but the current translation
unit is being compiled for target ‘x86_64-apple-macosx11.0.0’

I’m guessing the second error is due to trying to migrate the Matlab version to the new computer and hope I’ll be able to solve it with a fresh install.

I’m puzzled by the first one. I don’t know what half args and returns are in this context and not sure how to enable them. I presume this error is related Xcode, but not sure.

If you are reporting a bug (thank you!) please use the issue tracker (github.com/stan-dev/cmdstan/issues) instead of the forums.

code_to_run_your_model(if_applicable)

If possible, add also code to simulate data or attach a (subset of) the dataset you work with.

Please provide this additional information in addition to your question:

  • Operating System:
  • CmdStan Version:
  • Compiler/Toolkit:

Don’t forget to add relevant tags to your topic (top right of this form) especially for application area. Delete this text before posting your topic. Thx!

Looking forward to your topic!

Hi,

you need to rebuild cmdstan when you get an error mentioning PCH.

make clean-all
make build -j4

Looks like I’m running into a serious issues here. Reinstalling Matlab files did not fix anything. In fact, since there is practically no installation (just a download of scripts), I realize now it was silly to expect it would fix anything.

I tried rebuilding the CmdStan (both 2.24.1 and 2.26.0 versions), but to no avail.

The build seems to work, but generates 10 warnings:
ld: warning: cannot export hidden symbol typeinfo for tbb::tbb_exception from task_group_context.o

ld: warning: cannot export hidden symbol typeinfo name for tbb::tbb_exception from task_group_context.o

ld: warning: cannot export hidden symbol typeinfo name for tbb::empty_task from arena.o

ld: warning: cannot export hidden symbol typeinfo for tbb::empty_task from arena.o

ld: warning: cannot export hidden symbol typeinfo name for tbb::empty_task from scheduler.o

ld: warning: cannot export hidden symbol typeinfo name for tbb::tbb_exception from scheduler.o

ld: warning: cannot export hidden symbol typeinfo for tbb::empty_task from scheduler.o

ld: warning: cannot export hidden symbol typeinfo for tbb::tbb_exception from scheduler.o

10 warnings generated.

— CmdStan v2.26.0 built —

murataydin@Murats-MBP3 cmdstan-2.26.0 %

I wonder if the CmdStan has been tested on the Apple M1 chip. I’m getting a sense that this problem might be related to the new laptop not having an Intel chip anymore.

discussion here: Anyone planning on getting an M1 machine to benchmark? - #5 by rok_cesnovar

I made a post under that topic. Perhaps other M1 users encountered similar errors.

I now suspect I’m running into issues because Matlab is x86 and goes through rosetta, but Xcode c++ is arm64.

Perhaps, I can bypass by using an x86 c++. Any suggestions?

That seems plausible yes.

You can use cmdstan directly in the command line or the cmdstanr wrapper for R or cmdstanpy wrapper for python.

2 Likes

CmdStanR will still need Xcode c++ right, R wrapper is arm64 then?

I will try the command line approach first.

We know the CmdStanR approach does work on M1, but the command line approach will be cleanest to start.

There is another twist.

It looks like I did not install the command line tools when I installed Xcode.

My clang++ version is Apple clang-1200.0.32.29.

But I was using GNU make 3.81 to build CmdStan, which may be x86 (I see a note that says built for i386-apple-darwin11.3.0).

The problem had nothing to do with Matlab wrapper in the end. I was able to solve it by building CmdStan from within Xcode.

1 Like

@maydin could you be a bit more specific about how you built CmdStan in Xcode? I’m running into the same errors you’ve posted here but I don’t understand what that means.

I think I got this to work. For anyone who stumbles on this, I mostly used the instructions from the accepted answer here: creating an XCode project with existing code - Stack Overflow

Only differences were hitting return wasn’t relevant and to build the project I did Product > Build.

Hi @dstauffer11 I’ve also been hitting the issue for CmdStan 2-28-2:

Error when compiling SampleModel m1.2s:
error: half args and returns was enabled in PCH file but is currently disabled
error: PCH file was compiled for the target 'arm64-apple-macosx12.0.0' but the current translation unit is being compiled for target 'x86_64-apple-macosx12.0.0'
2 errors generated.
make: *** [/var/folders/l7/pr04h0650q5dvqttnvs8s2c00000gn/T/jl_6nsXSj/m1.2s] Error 1
``` compiling CmdStan "as usual" and then calling it from a Rosetta based application.

When you say "I think I got this to work", you mean the Xcode project solves the problem just for Rosetta apps or for both cases (arm-based apps as well)?

Thanks for your help!
1 Like

A few more observations, also in response to above link. Building and compiling cmdstan “as usual” works fine on M1. The problem occurs if you call it from an app running under Rosetta.

Note for JuliaStan users: Choose the arm version of Julia-1.7-rc3 and it all works fine. Julia-1.6.4 has no arm version, that’s where the problem will show up. To build cmdstan-2.28.2 I use:

CXX=clang++
STAN_THREADS=true

and export to my (zsh) shell :

export STAN_NUM_THREADS=-1

which gives me 10 threads on my 16" M1.

1 Like

I was getting this error when calling from JuliaStan, that’s what building from Xcode fixed. It sounds like there’s an easier way using the arm version of Julia, thanks for posting.

1 Like