stan-dev / rstan

RStan, the R interface to Stan
https://mc-stan.org
1.04k stars 265 forks source link

rstan reverts to Apple clang #1104

Closed joshua-zh closed 10 months ago

joshua-zh commented 10 months ago

Summary:

Please provide a short summary (no more than a sentence or two). rstan reverts to Apple clang, but I have setup llvm clang as the default compiler.

Description:

Describe the issue as clearly as possible.

The terminal: % which clang /opt/homebrew/opt/llvm/bin/clang % which clang++ /opt/homebrew/opt/llvm/bin/clang++

R: library(rstan) Loading required package: StanHeaders

rstan version 2.33.1.9000 (Stan version 2.33.0)

For execution on a local, multicore CPU with excess RAM we recommend calling options(mc.cores = parallel::detectCores()). To avoid recompilation of unchanged Stan programs, we recommend calling rstan_options(auto_write = TRUE) For within-chain threading using reduce_sum() or map_rect() Stan functions, change threads_per_chain option: rstan_options(threads_per_chain = 1)

y <- as.matrix(read.table('/Users/zhang/Documents/R/rats.txt', header = TRUE)) x <- c(8, 15, 22, 29, 36) xbar <- mean(x) N <- nrow(y) T <- ncol(y) rats_fit <- stan(file='/Users/zhang/Documents/R/rats.stan', data = list(N=N, T=T, y=y, x=x, xbar=xbar)) Trying to compile a simple C file make cmd is make -f '/Library/Frameworks/R.framework/Resources/etc/Makeconf' -f '/Library/Frameworks/R.framework/Resources/share/make/shlib.mk' CXX='$(CXX17) $(CXX17STD)' CXXFLAGS='$(CXX17FLAGS)' CXXPICFLAGS='$(CXX17PICFLAGS)' SHLIB_LDFLAGS='$(SHLIB_CXX17LDFLAGS)' SHLIB_LD='$(SHLIB_CXX17LD)' SHLIB='filed77394f4ab9.so' OBJECTS='filed77394f4ab9.o'

make would use clang++ -arch arm64 -fopenmp -std=gnu++17 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I"/Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/library/Rcpp/include/" -I"/Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/library/RcppEigen/include/" -I"/Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/library/RcppEigen/include/unsupported" -I"/Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/library/BH/include" -I"/Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/library/StanHeaders/include/src/" -I"/Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/library/StanHeaders/include/" -I"/Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/library/RcppParallel/include/" -I"/Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/library/rstan/include" -DEIGEN_NO_DEBUG -DBOOST_DISABLE_ASSERTS -DBOOST_PENDING_INTEGER_LOG2_HPP -DSTAN_THREADS -DUSE_STANC3 -DSTRICT_R_HEADERS -DBOOST_PHOENIX_NO_VARIADIC_EXPRESSION -D_HAS_AUTO_PTR_ETC=0 -include '/Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/library/StanHeaders/include/stan/math/prim/fun/Eigen.hpp' -D_REENTRANT -DRCPP_PARALLEL_USE_TBB=1 -I/opt/R/arm64/include -I/opt/homebrew/opt/libomp/include -fopenmp -fPIC -falign-functions=64 -Wall -g -O2 -c filed77394f4ab9.cpp -o filed77394f4ab9.o if test "zfiled77394f4ab9.o" != "z"; then \ echo clang++ -arch arm64 -fopenmp -std=gnu++17 -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L"/Library/Frameworks/R.framework/Resources/lib" -L/opt/R/arm64/lib -o filed77394f4ab9.so filed77394f4ab9.o '/Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/library/rstan/lib//libStanServices.a' -L'/Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/library/StanHeaders/lib/' -lStanHeaders -L'/Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/library/RcppParallel/lib/' -ltbb -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation; \ clang++ -arch arm64 -fopenmp -std=gnu++17 -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L"/Library/Frameworks/R.framework/Resources/lib" -L/opt/R/arm64/lib -o filed77394f4ab9.so filed77394f4ab9.o '/Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/library/rstan/lib//libStanServices.a' -L'/Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/library/StanHeaders/lib/' -lStanHeaders -L'/Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/library/RcppParallel/lib/' -ltbb -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation; \ fi Error in compileCode(f, code, language = language, verbose = verbose) : using C++ compiler: ‘Apple clang version 15.0.0 (clang-1500.0.40.1)’using C++17using SDK: ‘MacOSX14.0.sdk’clang: error: unsupported option '-fopenmp'make: *** [filed77394f4ab9.o] Error 1 Error in sink(type = "output") : invalid connection ake cmd is

packageVersion("rstan") [1] ‘2.33.1.9000’

[1] "R version 4.3.1 (2023-06-16)"

Operating System:

Mac OS 14

joshua-zh commented 10 months ago

This is not rstan specific issue. I closed it.