Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmdstan fails to build #770

Closed
idontgetoutmuch opened this issue Nov 21, 2019 · 13 comments
Closed

cmdstan fails to build #770

idontgetoutmuch opened this issue Nov 21, 2019 · 13 comments

Comments

@idontgetoutmuch
Copy link

Summary:

clang++ -std=c++1y -Wno-unknown-warning-option -Wno-tautological-compare -Wno-sign-compare -D_REENTRANT -I stan/lib/stan_math/lib/tbb_2019_U8/include -O3 -I src -I stan/src -I lib/rapidjson_1.1.0/ -I stan/lib/stan_math/ -I stan/lib/stan_math/lib/eigen_3.3.3 -I stan/lib/stan_math/lib/boost_1.69.0 -I stan/lib/stan_math/lib/sundials_4.1.0/include -DBOOST_DISABLE_ASSERTS -c -o bin/cmdstan/stansummary.o src/cmdstan/stansummary.cpp
In file included from src/cmdstan/stansummary.cpp:5:
In file included from stan/src/stan/mcmc/chains.hpp:5:
In file included from stan/lib/stan_math/stan/math/prim/mat.hpp:142:
In file included from stan/lib/stan_math/stan/math/prim/mat/fun/lgamma.hpp:5:
stan/lib/stan_math/stan/math/prim/scal/fun/lgamma.hpp:65:12: error: no member named 'lgamma_r' in the global namespace
return ::lgamma_r(x, &sign);
~~^
stan/lib/stan_math/stan/math/prim/scal/fun/lgamma.hpp:84:12: error: no member named 'lgamma_r' in the global namespace
return ::lgamma_r(x, &sign);
~~^
2 errors generated.
make: *** [make/command:3: bin/cmdstan/stansummary.o] Error 1

Description:

Describe the issue as clearly as possible.

Reproducible Steps:

nix-shell -I nixpkgs=~/nixpkgs -p cmdstan

but I'll need to create a public branch for the modified nixpkgs.

Current Output:

See above

Expected Output:

I'd expect it to install.

Additional Information:

Current Version:

v2.21.0

@seantalts
Copy link
Member

Just to double check, is this on 2.21.0 or develop branch?

@idontgetoutmuch
Copy link
Author

idontgetoutmuch commented Nov 21, 2019

https://github.com/stan-dev/cmdstan/releases/download/v2.21.0/cmdstan-2.21.0.tar.gz

but there's no urgency - the problem I am investigating is why pystan and rstan give different results for the same .stan file with the same seed - they both seem to be using 2.19.1 and I have just built cmdstan 2.19.1 successfully and will continue my investigations with that. I am assuming that cmdstan gives the "ground truth" - we shall see

[nix-shell:~/Dropbox/Tidy/labeling-experiment]$ stanc --version
stanc version 2.19.1

@wds15
Copy link
Contributor

wds15 commented Nov 21, 2019

What OS is this?

You have issues with _REENTRANT which is odd as we tested this on all of our platforms we support.

You could start to define __MINGW32__ manually which tells the code to use code which is always available on all platforms.

@idontgetoutmuch
Copy link
Author

Darwin 17.7.0 Darwin Kernel Version 17.7.0: Thu Jun 21 22:53:14 PDT 2018; root:xnu-4570.71.2~1/RELEASE_X86_64 x86_64

@idontgetoutmuch
Copy link
Author

This may be an extra data point

[nix-shell:~/Dropbox/Tidy/labeling-experiment-alt]$ gcc -I/Users/dom/cmdstan/stan/src -I/Users/dom/cmdstan/stan/lib/stan_math -I/Users/dom/cmdstan/stan/lib/stan_math/lib/eigen_3.3.3 -I/Users/dom/cmdstan/stan/lib/stan_math/lib/boost_1.69.0 -I/Users/dom/cmdstan/stan/lib/stan_math/lib/tbb_2019_U8/include -I/Users/dom/cmdstan/stan/lib/stan_math/lib/sundials_4.1.0/include FromPymc_model.cpp
In file included from /Users/dom/cmdstan/stan/lib/stan_math/stan/math/prim/mat/fun/lgamma.hpp:5,
                 from /Users/dom/cmdstan/stan/lib/stan_math/stan/math/prim/mat.hpp:142,
                 from /Users/dom/cmdstan/stan/lib/stan_math/stan/math/rev/mat.hpp:12,
                 from /Users/dom/cmdstan/stan/lib/stan_math/stan/math.hpp:4,
                 from /Users/dom/cmdstan/stan/src/stan/model/model_header.hpp:4,
                 from FromPymc_model.cpp:3:
/Users/dom/cmdstan/stan/lib/stan_math/stan/math/prim/scal/fun/lgamma.hpp:19:2: error: #error "stan-math requires _REENTRANT being defined during compilation" "to make lgamma_r available."
 #error \
  ^~~~~
In file included from /Users/dom/cmdstan/stan/lib/stan_math/stan/math/prim/mat/fun/lgamma.hpp:5,
                 from /Users/dom/cmdstan/stan/lib/stan_math/stan/math/prim/mat.hpp:142,
                 from /Users/dom/cmdstan/stan/lib/stan_math/stan/math/rev/mat.hpp:12,
                 from /Users/dom/cmdstan/stan/lib/stan_math/stan/math.hpp:4,
                 from /Users/dom/cmdstan/stan/src/stan/model/model_header.hpp:4,
                 from FromPymc_model.cpp:3:
/Users/dom/cmdstan/stan/lib/stan_math/stan/math/prim/scal/fun/lgamma.hpp: In function ‘double stan::math::lgamma(double)’:
/Users/dom/cmdstan/stan/lib/stan_math/stan/math/prim/scal/fun/lgamma.hpp:65:12: error: ‘::lgamma_r’ has not been declared
   return ::lgamma_r(x, &sign);
            ^~~~~~~~
/Users/dom/cmdstan/stan/lib/stan_math/stan/math/prim/scal/fun/lgamma.hpp:65:12: note: suggested alternative: ‘lgamma’
   return ::lgamma_r(x, &sign);
            ^~~~~~~~
            lgamma
/Users/dom/cmdstan/stan/lib/stan_math/stan/math/prim/scal/fun/lgamma.hpp: In function ‘double stan::math::lgamma(int)’:
/Users/dom/cmdstan/stan/lib/stan_math/stan/math/prim/scal/fun/lgamma.hpp:84:12: error: ‘::lgamma_r’ has not been declared
   return ::lgamma_r(x, &sign);
            ^~~~~~~~
/Users/dom/cmdstan/stan/lib/stan_math/stan/math/prim/scal/fun/lgamma.hpp:84:12: note: suggested alternative: ‘lgamma’
   return ::lgamma_r(x, &sign);
            ^~~~~~~~
            lgamma

@mitzimorris
Copy link
Member

was this addressed by updating the submodules?

@wds15
Copy link
Contributor

wds15 commented Nov 23, 2019

if you put into your make/local

CXXFLAGS+=-D__MINGW32__

then it should work. Can you please try?

What is nixpkg? Darwin 17 is Mojave or Catalina?

@rok-cesnovar
Copy link
Member

I am going to close this stale issue. Do reopen if it was not resolved.

@idontgetoutmuch
Copy link
Author

It is not resolved.

@barracuda156
Copy link

I am going to close this stale issue. Do reopen if it was not resolved.

@rok-cesnovar It is not resolved. Just got this on stanmath test-suite:

In file included from ./stan/math/prim/fun/beta.hpp:6,
                 from ./stan/math/prim/fun.hpp:31,
                 from ./stan/math/prim.hpp:14,
                 from test/unit/math/fwd/core/std_numeric_limits_test.cpp:2:
./stan/math/prim/fun/lgamma.hpp: In function 'double stan::math::lgamma(double)':
./stan/math/prim/fun/lgamma.hpp:66:12: error: '::lgamma_r' has not been declared; did you mean 'lgamma'?
   66 |   return ::lgamma_r(x, &sign);
      |            ^~~~~~~~
      |            lgamma
./stan/math/prim/fun/lgamma.hpp: In function 'double stan::math::lgamma(int)':
./stan/math/prim/fun/lgamma.hpp:85:12: error: '::lgamma_r' has not been declared; did you mean 'lgamma'?
   85 |   return ::lgamma_r(x, &sign);
      |            ^~~~~~~~
      |            lgamma
In file included from ./stan/math/prim/fun/beta.hpp:6,
                 from ./stan/math/fwd/fun/beta.hpp:6,
                 from ./stan/math/fwd/fun.hpp:19,
                 from ./stan/math/fwd.hpp:12,
                 from test/unit/math/fwd/fun/accumulator_test.cpp:1:
./stan/math/prim/fun/lgamma.hpp: In function 'double stan::math::lgamma(double)':
./stan/math/prim/fun/lgamma.hpp:66:12: error: '::lgamma_r' has not been declared; did you mean 'lgamma'?
   66 |   return ::lgamma_r(x, &sign);
      |            ^~~~~~~~
      |            lgamma
./stan/math/prim/fun/lgamma.hpp: In function 'double stan::math::lgamma(int)':
./stan/math/prim/fun/lgamma.hpp:85:12: error: '::lgamma_r' has not been declared; did you mean 'lgamma'?
   85 |   return ::lgamma_r(x, &sign);
      |            ^~~~~~~~
      |            lgamma
In file included from ./stan/math/prim/fun/beta.hpp:6,
                 from ./stan/math/fwd/fun/beta.hpp:6,
                 from ./stan/math/fwd/fun.hpp:19,
                 from ./stan/math/fwd.hpp:12,
                 from test/unit/math/fwd/eigen_plugins_test.cpp:1:
./stan/math/prim/fun/lgamma.hpp: In function 'double stan::math::lgamma(double)':
./stan/math/prim/fun/lgamma.hpp:66:12: error: '::lgamma_r' has not been declared; did you mean 'lgamma'?
   66 |   return ::lgamma_r(x, &sign);
      |            ^~~~~~~~
      |            lgamma
./stan/math/prim/fun/lgamma.hpp: In function 'double stan::math::lgamma(int)':
./stan/math/prim/fun/lgamma.hpp:85:12: error: '::lgamma_r' has not been declared; did you mean 'lgamma'?
   85 |   return ::lgamma_r(x, &sign);
      |            ^~~~~~~~
      |            lgamma
In file included from ./stan/math/prim/fun/beta.hpp:6,
                 from ./stan/math/fwd/fun/beta.hpp:6,
                 from ./stan/math/fwd/fun.hpp:19,
                 from ./stan/math/fwd.hpp:12,
                 from test/unit/math/fwd/fun/array_builder_test.cpp:1:
./stan/math/prim/fun/lgamma.hpp: In function 'double stan::math::lgamma(double)':
./stan/math/prim/fun/lgamma.hpp:66:12: error: '::lgamma_r' has not been declared; did you mean 'lgamma'?
   66 |   return ::lgamma_r(x, &sign);
      |            ^~~~~~~~
      |            lgamma
./stan/math/prim/fun/lgamma.hpp: In function 'double stan::math::lgamma(int)':
./stan/math/prim/fun/lgamma.hpp:85:12: error: '::lgamma_r' has not been declared; did you mean 'lgamma'?
   85 |   return ::lgamma_r(x, &sign);
      |            ^~~~~~~~
      |            lgamma

@andrjohns
Copy link
Contributor

You have to update your makeflags, we covered this earlier: https://discourse.mc-stan.org/t/stan-in-r-on-powerpc-g5-10-6-ppc-help-needed/25176/29

@barracuda156
Copy link

You have to update your makeflags, we covered this earlier: https://discourse.mc-stan.org/t/stan-in-r-on-powerpc-g5-10-6-ppc-help-needed/25176/29

I will try passing it to tests now, thank you!

@barracuda156
Copy link

You have to update your makeflags, we covered this earlier: https://discourse.mc-stan.org/t/stan-in-r-on-powerpc-g5-10-6-ppc-help-needed/25176/29

@andrjohns By the way, lgamma_r in fact is available, but requires correct defines:

/*
 * Reentrant version of gamma & lgamma; passes signgam back by reference
 * as the second argument; user must allocate space for signgam.
 */
#ifdef _REENTRANT
extern double gamma_r ( double, int * );
extern double lgamma_r ( double, int * );
#endif /* _REENTRANT */
#endif /* (!_XOPEN_SOURCE || _DARWIN_C_SOURCE) */
#endif /* !_ANSI_SOURCE && (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */

I.e. it needs _DARWIN_C_SOURCE and _REENTRANT defined prior to including system math.h. Alternatively, passing -D_DARWIN_C_SOURCE and -D_REENTRANT as cppflags should work, though perhaps may not be the best way (-D_DARWIN_C_SOURCE on macOS should be safe, but I am not sure if -D_REENTRANT may have some adverse effects if passed in general).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants