Skip to content

Commit

Permalink
Test alt config
Browse files Browse the repository at this point in the history
  • Loading branch information
andrjohns committed Jan 22, 2024
1 parent 67c637b commit b5736f7
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
12 changes: 11 additions & 1 deletion R/model.R
Original file line number Diff line number Diff line change
Expand Up @@ -651,6 +651,16 @@ compile <- function(quiet = TRUE,
expose_stan_functions(self$functions, !quiet)
}

env_vars <- "current"
if (os_is_linux()) {
env_vars <- c(env_vars, "CXXFLAGS"="-fPIC")
}
if (os_is_windows() && is_ucrt_toolchain()) {
cxx <- "x86_64-w64-mingw32.static.posix-g++"
cc <- "x86_64-w64-mingw32.static.posix-gcc"
env_vars <- c(env_vars, "CXX"=cxx, "CC"=cc)
}

withr::with_path(
c(
toolchain_PATH_env_var(),
Expand All @@ -662,7 +672,7 @@ compile <- function(quiet = TRUE,
cpp_options_to_compile_flags(c(cpp_options, list("KEEP_OBJECT"="true"))),
stancflags_val),
wd = cmdstan_path(),
env = c("current", "CXXFLAGS"="-fPIC"),
env = env_vars,
echo = !quiet || is_verbose_mode(),
echo_cmd = is_verbose_mode(),
spinner = quiet && rlang::is_interactive() && !identical(Sys.getenv("IN_PKGDOWN"), "true"),
Expand Down
10 changes: 9 additions & 1 deletion R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -741,7 +741,7 @@ with_cmdstan_flags <- function(expr) {
libs <- c("LDLIBS", "LIBSUNDIALS", "TBB_TARGETS", "LDFLAGS_TBB")
libs <- paste(sapply(libs, get_cmdstan_flags), collapse = " ")
if (.Platform$OS.type == "windows") {
libs <- paste(libs, "-fopenmp -lstdc++")
libs <- paste(libs, "-fopenmp")
}
lib_paths <- c("/stan/lib/stan_math/lib/tbb/",
"/stan/lib/stan_math/lib/sundials_6.1.1/lib/")
Expand Down Expand Up @@ -1061,3 +1061,11 @@ expose_stan_functions <- function(function_env, global = FALSE, verbose = FALSE)
}
invisible(NULL)
}

get_r_config <- function(config_name) {
system2(
command = file.path(R.home(component = "bin"), "R"),
args = c("CMD", "config", config_name),
stdout = TRUE
)
}

0 comments on commit b5736f7

Please sign in to comment.