# Errors during compile

**URL:** <https://discourse.mc-stan.org/t/errors-during-compile/20663>\
**Category:** CmdStan\
**Created:** [February 7, 2021, 8:38am UTC](https://discourse.mc-stan.org/t/errors-during-compile/20663 "2021-02-07T08:38:56Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![maydin](https://avatars.discourse-cdn.com/v4/letter/m/49beb7/32.png) [@maydin](https://discourse.mc-stan.org/u/maydin)\
**Post date:** [February 7, 2021, 8:38am UTC](https://discourse.mc-stan.org/t/errors-during-compile/20663/1 "2021-02-07T08:38:56Z")

</div>

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](http://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!

---

<div class="post-metadata">

**Author:** ![rok\_cesnovar](https://avatars.discourse-cdn.com/v4/letter/r/7bcc69/32.png) [@rok\_cesnovar](https://discourse.mc-stan.org/u/rok_cesnovar)\
**Post date:** [February 7, 2021, 9:00am UTC](https://discourse.mc-stan.org/t/errors-during-compile/20663/2 "2021-02-07T09:00:41Z")

</div>

Hi,

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

```
make clean-all
make build -j4
```

---

<div class="post-metadata">

**Author:** ![maydin](https://avatars.discourse-cdn.com/v4/letter/m/49beb7/32.png) [@maydin](https://discourse.mc-stan.org/u/maydin)\
**Post date:** [February 7, 2021, 10:43pm UTC](https://discourse.mc-stan.org/t/errors-during-compile/20663/3 "2021-02-07T22:43:26Z")

</div>

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 %

---

<div class="post-metadata">

**Author:** ![maydin](https://avatars.discourse-cdn.com/v4/letter/m/49beb7/32.png) [@maydin](https://discourse.mc-stan.org/u/maydin)\
**Post date:** [February 7, 2021, 10:50pm UTC](https://discourse.mc-stan.org/t/errors-during-compile/20663/4 "2021-02-07T22:50:13Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![mitzimorris](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/mitzimorris/32/29_2.png) [@mitzimorris](https://discourse.mc-stan.org/u/mitzimorris)\
**Post date:** [February 8, 2021, 2:05am UTC](https://discourse.mc-stan.org/t/errors-during-compile/20663/5 "2021-02-08T02:05:08Z")

</div>

discussion here: [Anyone planning on getting an M1 machine to benchmark? - #5 by rok\_cesnovar](https://discourse.mc-stan.org/t/anyone-planning-on-getting-an-m1-machine-to-benchmark/19344/5)

---

<div class="post-metadata">

**Author:** ![maydin](https://avatars.discourse-cdn.com/v4/letter/m/49beb7/32.png) [@maydin](https://discourse.mc-stan.org/u/maydin)\
**Post date:** [February 8, 2021, 7:39pm UTC](https://discourse.mc-stan.org/t/errors-during-compile/20663/6 "2021-02-08T19:39:47Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![rok\_cesnovar](https://avatars.discourse-cdn.com/v4/letter/r/7bcc69/32.png) [@rok\_cesnovar](https://discourse.mc-stan.org/u/rok_cesnovar)\
**Post date:** [February 8, 2021, 7:49pm UTC](https://discourse.mc-stan.org/t/errors-during-compile/20663/7 "2021-02-08T19:49:50Z")

</div>

> [@maydin](#):
>
> I now suspect I’m running into issues because Matlab is x86 and goes through rosetta, but Xcode c++ is arm64.

That seems plausible yes.

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

---

<div class="post-metadata">

**Author:** ![maydin](https://avatars.discourse-cdn.com/v4/letter/m/49beb7/32.png) [@maydin](https://discourse.mc-stan.org/u/maydin)\
**Post date:** [February 8, 2021, 8:05pm UTC](https://discourse.mc-stan.org/t/errors-during-compile/20663/8 "2021-02-08T20:05:20Z")

</div>

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

I will try the command line approach first.

---

<div class="post-metadata">

**Author:** ![rok\_cesnovar](https://avatars.discourse-cdn.com/v4/letter/r/7bcc69/32.png) [@rok\_cesnovar](https://discourse.mc-stan.org/u/rok_cesnovar)\
**Post date:** [February 8, 2021, 8:07pm UTC](https://discourse.mc-stan.org/t/errors-during-compile/20663/9 "2021-02-08T20:07:16Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![maydin](https://avatars.discourse-cdn.com/v4/letter/m/49beb7/32.png) [@maydin](https://discourse.mc-stan.org/u/maydin)\
**Post date:** [February 8, 2021, 8:18pm UTC](https://discourse.mc-stan.org/t/errors-during-compile/20663/10 "2021-02-08T20:18:59Z")

</div>

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).

---

<div class="post-metadata">

**Author:** ![maydin](https://avatars.discourse-cdn.com/v4/letter/m/49beb7/32.png) [@maydin](https://discourse.mc-stan.org/u/maydin)\
**Post date:** [February 8, 2021, 11:08pm UTC](https://discourse.mc-stan.org/t/errors-during-compile/20663/11 "2021-02-08T23:08:45Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![dstauffer11](https://avatars.discourse-cdn.com/v4/letter/d/76d3ee/32.png) [@dstauffer11](https://discourse.mc-stan.org/u/dstauffer11)\
**Post date:** [November 21, 2021, 10:30pm UTC](https://discourse.mc-stan.org/t/errors-during-compile/20663/12 "2021-11-21T22:30:25Z")

</div>

@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.

---

<div class="post-metadata">

**Author:** ![dstauffer11](https://avatars.discourse-cdn.com/v4/letter/d/76d3ee/32.png) [@dstauffer11](https://discourse.mc-stan.org/u/dstauffer11)\
**Post date:** [November 23, 2021, 2:12am UTC](https://discourse.mc-stan.org/t/errors-during-compile/20663/13 "2021-11-23T02:12:07Z")

</div>

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](https://stackoverflow.com/questions/5942059/creating-an-xcode-project-with-existing-code)

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

---

<div class="post-metadata">

**Author:** ![Rob\_J\_Goedman](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/rob_j_goedman/32/110_2.png) [@Rob\_J\_Goedman](https://discourse.mc-stan.org/u/Rob_J_Goedman)\
**Post date:** [November 25, 2021, 3:20pm UTC](https://discourse.mc-stan.org/t/errors-during-compile/20663/14 "2021-11-25T15:20:17Z")

</div>

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!
````

---

<div class="post-metadata">

**Author:** ![Rob\_J\_Goedman](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/rob_j_goedman/32/110_2.png) [@Rob\_J\_Goedman](https://discourse.mc-stan.org/u/Rob_J_Goedman)\
**Post date:** [November 25, 2021, 7:36pm UTC](https://discourse.mc-stan.org/t/errors-during-compile/20663/15 "2021-11-25T19:36:30Z")

</div>

A few more observations, also in response to above [link](https://discourse.mc-stan.org/t/errors-during-compile/20663/7). 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.

---

<div class="post-metadata">

**Author:** ![dstauffer11](https://avatars.discourse-cdn.com/v4/letter/d/76d3ee/32.png) [@dstauffer11](https://discourse.mc-stan.org/u/dstauffer11)\
**Post date:** [November 29, 2021, 3:04pm UTC](https://discourse.mc-stan.org/t/errors-during-compile/20663/16 "2021-11-29T15:04:15Z")

</div>

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.
