From c4d2461d08a5477191d032d72839b4d0c9c3f10b Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Mon, 22 Jan 2024 19:42:07 +0200 Subject: [PATCH] Test diff winflags --- R/model.R | 5 ----- R/utils.R | 18 ++++++++++++------ 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/R/model.R b/R/model.R index 07664201..80ecc1f7 100644 --- a/R/model.R +++ b/R/model.R @@ -655,11 +655,6 @@ compile <- function(quiet = TRUE, 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( diff --git a/R/utils.R b/R/utils.R index 8d427aaa..f274ccb7 100644 --- a/R/utils.R +++ b/R/utils.R @@ -745,18 +745,24 @@ with_cmdstan_flags <- function(expr) { } lib_paths <- c("/stan/lib/stan_math/lib/tbb/", "/stan/lib/stan_math/lib/sundials_6.1.1/lib/") + new_makevars <- c( + USE_CXX14 = 1, + PKG_CPPFLAGS = ifelse(cmdstan_version() <= "2.30.1", "-DCMDSTAN_JSON", ""), + PKG_CXXFLAGS = paste(cxxflags, cmdstanr_includes, r_includes, collapse = " "), + PKG_LIBS = libs + ) + if (os_is_windows() && is_ucrt_toolchain()) { + cxx <- "x86_64-w64-mingw32-g++" + cc <- "x86_64-w64-mingw32-gcc" + new_makevars <- c(new_makevars, "CXX" = cxx, "CC" = cc) + } withr::with_path( c( paste0(cmdstan_path(), lib_paths), toolchain_PATH_env_var() ), withr::with_makevars( - c( - USE_CXX14 = 1, - PKG_CPPFLAGS = ifelse(cmdstan_version() <= "2.30.1", "-DCMDSTAN_JSON", ""), - PKG_CXXFLAGS = paste(cxxflags, cmdstanr_includes, r_includes, collapse = " "), - PKG_LIBS = libs - ), + new_makevars, expr ) )