Conversation
CmdStan bundles TBB 2020.3 and RcppParallel ships oneTBB under the same library file name on every platform. Once one copy is in the R process, code linked against the other fails to load, so the model methods failed after rstan or brms had loaded RcppParallel's copy, and RcppParallel failed to load after the methods had brought in CmdStan's. rcpp_source_stan() now asks make for its flags with TBB_INC, TBB_LIB and TBB_INTERFACE_NEW pointing at RcppParallel's install whenever RcppParallel is there with its oneTBB. Stan Math supports oneTBB through TBB_INTERFACE_NEW and CmdStan's makefiles already handle the substitution. RcppParallel goes in Suggests for the new test, which also gets CI to install it on every platform. Closes #1270.
Member
Author
|
@andrjohns Could you take a quick look at this since it touches your model methods and expose functions code? Previously we couldn't use rstan, rstanarm, etc. in the same session as compiling cmdstanr model methods or exposing functions. I ran the idea by @WardBrian and @SteveBronder but hopefully you can take a peek at the code changes (it's a small diff) |
Make's print rule echoes through the shell, which drops quotes, so an R library path with a space came back as two arguments and the build failed. Quote the two paths after they come back, the way get_cmdstan_flags() already quotes CmdStan's own. The roxygen for rcpp_source_stan() now says the flags come from the selected installation rather than the one that built the executable. Part of #1270.
rcppparallel_tbb() returns NULL for such a build, and lapply() turned that into an empty list that sent the mocked helper down the RcppParallel branch without paths. Part of #1270.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## v1.0 #1286 +/- ##
=======================================
Coverage ? 93.11%
=======================================
Files ? 19
Lines ? 7337
Branches ? 0
=======================================
Hits ? 6832
Misses ? 505
Partials ? 0 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
In R CMD check's temporary library system.file() returns the RcppParallel paths with backslashes. The flags make prints go through sh in the Makevars, which strips the backslashes, so the compiler saw -isystem C:UsersRUNNER~1... and every model-method build failed on the Windows CI jobs. repair_path() replaces them with forward slashes. Part of #1270.
stanc3 changed its error reports on 2026-09-23 (stanc3 PR #1724): the "Semantic error in '<file>', line N" heading is gone and the location is now a "<file>:N:M" frame under the message. The CmdStan 2.40.0 tarball ships a placeholder for the macOS stanc binary, so its makefile downloads the nightly and every macOS CI job started seeing the new format. The two tests that pin the location now match either format. Part of #1270.
When TBB_LIB is set CmdStan's make adds -Wl,--disable-new-dtags on every OS except macOS. The flag only exists for ELF binaries, so Rtools' ld and lld both refuse it and every model-methods build on Windows failed at link time. Passing LDFLAGS_TBB_DTAGS= on the make command line leaves the flag out; CmdStan's own Windows builds never set TBB_LIB, which is why nobody hit this before. The test that builds against a library path with a space handed the mocked rcppparallel_tbb() a backslash path from tempdir(), which make's print rule mangled so the quoting in rcpp_source_stan() no longer matched. The real function repairs its paths, so the mock now does too. Part of #1270.
jgabry
marked this pull request as ready for review
September 24, 2026 13:37
This was referenced Sep 24, 2026
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Submission Checklist
Summary
I had Claude help implement these changes. I have reviewed all code and doc.
CmdStan bundles TBB 2020.3 and RcppParallel ships oneTBB under the same library file name on every platform (
libtbb.dylib,tbb.dll,libtbb.so.2). Once one copy is in the R process, code linked against the other fails to load, which prevents using e.g. rstan, rstanarm, brms in the same session as exposing functions or model methods via cmdstanr.Both
$init_model_methods()and$expose_functions()build throughrcpp_source_stan(). When RcppParallel is installed with its oneTBB, that function now passesTBB_INC,TBB_LIBandTBB_INTERFACE_NEW=1to CmdStan's make, so the flags it gets back point at RcppParallel's TBB instead of the bundled one. It also puts RcppParallel's lib directory on the PATH so the built object findstbb.dllon Windows.I verified it locally on macOS with identical
log_proband gradient values. CI will test on Linux and Windows too.Closes #1270.
Copyright and Licensing
Please list the copyright holder for the work you are submitting
(this will be you or your assignee, such as a university or company):
Jonah Gabry
By submitting this pull request, the copyright holder is agreeing to
license the submitted work under the following licenses: