stan-dev / stan-dev/rstan

Running legacy R 3.5.2 code (ISO C++ 2011 standard support)

Open
#1,118 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
R
Stars
1.1k
Forks
266
Avg merge
2h 56m
Merged PRs (30d)
1

Description

Summary:

Legacy code returns This file requires compiler and library support for the ISO C++ 2011 standard. This support is currently experimental, and must be enabled with the -std=c++11 or -std=gnu++11 compiler options. for rstan v2.18.2 and R 3.5.2

Description:

First of all, I'm sorry for asking a question regarding such an archaic version of the rstan and R. Unfortunately, I have to reproduce a few years old environment in a docker image and I struggle to set rstan to work properly. In the original system, the snippet I'll paste below works just fine, however, when moving the docker, having exactly the same gcc compiler and Makeconf I'm getting the error mentioned above.

Reproducible Steps:
library(rstan)

set.seed(12345)

mu <- 0
tau2 <- 0.5
sigma2 <- 1

n <- 20
theta <- rnorm(n, mu, sqrt(tau2))
y <- rnorm(n, theta, sqrt(sigma2))

### set prior parameters ###
mu0 <- 0
tau20 <- 1
alpha <- 1
beta <- 1

# models
stancodeH0 <- 'data {
    int<lower=1> n; // number of observations
    vector[n] y; // observations
    real<lower=0> alpha;
    real<lower=0> beta;
    real<lower=0> sigma2;
    }
    parameters {
    real<lower=0> tau2; // group-level variance
    vector[n] theta; // participant effects
    }
    model {
    target += inv_gamma_lpdf(tau2 | alpha, beta);
    target += normal_lpdf(theta | 0, sqrt(tau2));
    target += normal_lpdf(y | theta, sqrt(sigma2));
    }
    '

# compile models
tmp <- capture.output(suppressMessages(
  stanmodelH0 <- stan_model(model_code = stancodeH0, model_name="stanmodel")
))

Makeconf used in both environments:

CC = gcc -m64 -std=gnu99
CFLAGS = -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches   -m64 -mtune=generic $(LTO)
CPICFLAGS = -fpic
CPPFLAGS = -I/usr/local/include
CXX = g++ -m64 
CXXCPP = $(CXX) -E
CXXFLAGS = -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches   -m64 -mtune=generic $(LTO)
CXXPICFLAGS = -fpic
CXX98 = g++ -m64
CXX98FLAGS = -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches   -m64 -mtune=generic
CXX98PICFLAGS = -fpic
CXX98STD = -std=gnu++98
CXX11 = g++ -m64
CXX11FLAGS = -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches   -m64 -mtune=generic
CXX11PICFLAGS = -fpic
CXX11STD = -std=gnu++11
CXX14 = g++ -std=c++1y -Wno-unused-variable -Wno-unused-function -fPIC
CXX14FLAGS = 
CXX14PICFLAGS = 
CXX14STD = 

Both systems are running RedHat 7.9

I know it's hard to help with such an old code and without access to the system, however, maybe you have some guesses where I could look for differences and why the same code, in seemingly the same environments, works only in one of them.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the provided R and rstan model compilation with the listed R 3.5.2, rstan v2.18.2, RedHat 7.9, GCC, and Makeconf details. Compare the compiler invocation and generated build configuration between the working and failing environments; done means identifying a reproducible configuration difference or confirming that the legacy environment is unsupported.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, r
Domain
build-system
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.