Problems with migration from Intel to M1 Mac

I migrated my stuff on my old Intel Mac to a new M1 Mac instead of starting from scratch and I’m starting to think I should’ve just started from scratch. I git cloned a fresh version of cmdstanr, then did a make clean-all and a make build.

I get a few warnings about sprintf which I suspect are harmless but also the following warnings which seem less harmless

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
7 warnings generated.

There doesn’t seem to be any errors and I get the message that cmdstan 2.31 was successfully built, but when I go to compile a model I get the following error

% make examples/bernoulli/bernoulli
clang++ -std=c++1y -Wno-unknown-warning-option -Wno-tautological-compare -Wno-sign-compare -D_REENTRANT -Wno-ignored-attributes      -I stan/lib/stan_math/lib/tbb_2020.3/include    -O3 -I src -I stan/src -I stan/lib/rapidjson_1.1.0/ -I lib/CLI11-1.9.1/ -I stan/lib/stan_math/ -I stan/lib/stan_math/lib/eigen_3.3.9 -I stan/lib/stan_math/lib/boost_1.78.0 -I stan/lib/stan_math/lib/sundials_6.1.1/include -I stan/lib/stan_math/lib/sundials_6.1.1/src/sundials    -DBOOST_DISABLE_ASSERTS          -c -MT stan/src/stan/model/model_header.hpp.gch -MT stan/src/stan/model/model_header.d -MM -E -MG -MP -MF stan/src/stan/model/model_header.d stan/src/stan/model/model_header.hpp
clang++ -std=c++1y -Wno-unknown-warning-option -Wno-tautological-compare -Wno-sign-compare -D_REENTRANT -Wno-ignored-attributes      -I stan/lib/stan_math/lib/tbb_2020.3/include    -O3 -I src -I stan/src -I stan/lib/rapidjson_1.1.0/ -I lib/CLI11-1.9.1/ -I stan/lib/stan_math/ -I stan/lib/stan_math/lib/eigen_3.3.9 -I stan/lib/stan_math/lib/boost_1.78.0 -I stan/lib/stan_math/lib/sundials_6.1.1/include -I stan/lib/stan_math/lib/sundials_6.1.1/src/sundials    -DBOOST_DISABLE_ASSERTS          -c -MT src/cmdstan/main.o -MM -E -MG -MP -MF src/cmdstan/main.d src/cmdstan/main.cpp

--- Translating Stan model to C++ code ---
bin/stanc  --o=examples/bernoulli/bernoulli.hpp examples/bernoulli/bernoulli.stan
make: bin/stanc: Bad CPU type in executable
make: *** [examples/bernoulli/bernoulli.hpp] Error 1

I suspect that somewhere I still have some dynamic library or something that’s build for Intel even though I downloaded a fresh cmdstan and did a make clean. Maybe there are some dynamic libraries I need to rebuild?

Operating System: Monterey Version 12.5
Interface Version: cmdstan 2.31
Compiler/Toolkit:

% clang --version
Apple clang version 14.0.0 (clang-1400.0.29.202)
Target: arm64-apple-darwin21.6.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin

I realized my make version is built for the old architecture.

GNU Make 3.81
Copyright (C) 2006  Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.

This program built for i386-apple-darwin11.3.0

I tried reinstalling make via homebrew and it installs gmake. Homebrew then says

GNU "make" has been installed as "gmake".
If you need to use it as "make", you can add a "gnubin" directory
to your PATH from your bashrc like:

     PATH="$(brew --prefix)/opt/make/libexec/gnubin:$PATH"

I tried that and get that my make version is now the new one

GNU Make 4.4
Built for aarch64-apple-darwin21.6.0

but then still get the same error when trying to build bernoulli. Maybe because PATH isn’t being set permanently and only in this shell?

Ok I’m up and running now. The problem didn’t have to do with make. Turns out I just needed Rosetta 2 to run stanc which I added with

softwareupdate --install-rosetta

This thread pretty much led me to the fix: Link error on Apple M1 - #6 by rok_cesnovar

3 Likes

I assume it’s not crucial for the time being, but will stanc itself become an arm-native executable at some point?