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

[BUG] stanc.js persisting model name & namespace between calls #1491

Closed
andrjohns opened this issue Jan 20, 2025 · 1 comment · Fixed by #1492
Closed

[BUG] stanc.js persisting model name & namespace between calls #1491

andrjohns opened this issue Jan 20, 2025 · 1 comment · Fixed by #1492

Comments

@andrjohns
Copy link
Contributor

Current Behavior:

After calling stanc.js once with a model name, all future calls will reuse the same initial model name:

stanc_js <- tempfile(fileext = ".js")
download.file("https://github.com/stan-dev/stanc3/releases/download/nightly/stanc.js",
              destfile = stanc_js)

qjs_ctx <- QuickJSR::JSContext$new()
qjs_ctx$source(stanc_js)

mod1 <- "data { real y_mean; } parameters { real y; } model { y ~ normal(y_mean, 1); }"
> qjs_res_1 <- qjs_ctx$call("stanc", "model_one", mod1)
> cat(qjs_res_1$result, sep = "\n")
# // Code generated by stanc v2.36.0-28-gd13e71e
# #include <stan/model/model_header.hpp>
# namespace model_one_model_namespace {
# ...
> qjs_res_2 <- qjs_ctx$call("stanc", "model_two", mod1)
> cat(qjs_res_2$result, sep = "\n")
# // Code generated by stanc v2.36.0-28-gd13e71e
# #include <stan/model/model_header.hpp>
# namespace model_one_model_namespace {
# ...

(happens with both V8 & QuickJS)

This is an issue for R packages since it leads to duplicate symbols, so I'm seeing failures like this for rstanarm:

C:\rtools44\x86_64-w64-mingw32.static.posix\bin/ld.exe: stanExports_binomial.o:C:\Users\Andrew\Git\rstanarm\src/stanExports_binomial.h:29: multiple definition of `model_bernoulli_model_namespace::profiles__[abi:cxx11]'; stanExports_bernoulli.o:C:\Users\Andrew\Git\rstanarm\src/stanExports_bernoulli.h:29: first defined here
C:\rtools44\x86_64-w64-mingw32.static.posix\bin/ld.exe: stanExports_continuous.o:C:\Users\Andrew\Git\rstanarm\src/stanExports_continuous.h:29: multiple definition of `model_bernoulli_model_namespace::profiles__[abi:cxx11]'; stanExports_bernoulli.o:C:\Users\Andrew\Git\rstanarm\src/stanExports_bernoulli.h:29: first defined here
C:\rtools44\x86_64-w64-mingw32.static.posix\bin/ld.exe: stanExports_count.o:C:\Users\Andrew\Git\rstanarm\src/stanExports_count.h:29: multiple definition of `model_bernoulli_model_namespace::profiles__[abi:cxx11]'; stanExports_bernoulli.o:C:\Users\Andrew\Git\rstanarm\src/stanExports_bernoulli.h:29: first defined here
C:\rtools44\x86_64-w64-mingw32.static.posix\bin/ld.exe: stanExports_jm.o:C:\Users\Andrew\Git\rstanarm\src/stanExports_jm.h:29: multiple definition of `model_bernoulli_model_namespace::profiles__[abi:cxx11]'; stanExports_bernoulli.o:C:\Users\Andrew\Git\rstanarm\src/stanExports_bernoulli.h:29: first defined here
C:\rtools44\x86_64-w64-mingw32.static.posix\bin/ld.exe: stanExports_lm.o:C:\Users\Andrew\Git\rstanarm\src/stanExports_lm.h:29: multiple definition of `model_bernoulli_model_namespace::profiles__[abi:cxx11]'; stanExports_bernoulli.o:C:\Users\Andrew\Git\rstanarm\src/stanExports_bernoulli.h:29: first defined here
C:\rtools44\x86_64-w64-mingw32.static.posix\bin/ld.exe: stanExports_mvmer.o:C:\Users\Andrew\Git\rstanarm\src/stanExports_mvmer.h:29: multiple definition of `model_bernoulli_model_namespace::profiles__[abi:cxx11]'; stanExports_bernoulli.o:C:\Users\Andrew\Git\rstanarm\src/stanExports_bernoulli.h:29: first defined here
@WardBrian
Copy link
Member

This was introduced in #1477 and should be an easy fix

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

Successfully merging a pull request may close this issue.

2 participants