diff --git a/R/install.R b/R/install.R index 692eddbd..4bea2dd0 100644 --- a/R/install.R +++ b/R/install.R @@ -846,8 +846,12 @@ toolchain_PATH_env_var <- function() { } rtools4x_toolchain_path <- function() { - c_runtime <- ifelse(is_ucrt_toolchain(), "ucrt64", "mingw64") - repair_path(file.path(rtools4x_home_path(), c_runtime, "bin")) + if (rtools4x_version() == "40") { + toolchain_folder <- "mingw64" + } else { + toolchain_folder <- "x86_64-w64-mingw32.static.posix" + } + repair_path(file.path(rtools4x_home_path(), toolchain_folder, "bin")) } rtools4x_version <- function() { diff --git a/R/model.R b/R/model.R index da746b4a..a9b43203 100644 --- a/R/model.R +++ b/R/model.R @@ -662,6 +662,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"), echo = !quiet || is_verbose_mode(), echo_cmd = is_verbose_mode(), spinner = quiet && rlang::is_interactive() && !identical(Sys.getenv("IN_PKGDOWN"), "true"), diff --git a/R/utils.R b/R/utils.R index 99e8af4a..3314e8a9 100644 --- a/R/utils.R +++ b/R/utils.R @@ -86,7 +86,14 @@ is_rosetta2 <- function() { # Returns the type of make command to use to compile depending on the OS make_cmd <- function() { if (os_is_windows() && !os_is_wsl()) { - "mingw32-make.exe" + if (R.version$major == "3") { + make_folder <- file.path(Sys.getenv("RTOOLS35_HOME"), "mingw_64", "bin") + } else if (rtools4x_version() == "40") { + make_folder <- file.path(rtools4x_home_path(), "mingw64", "bin") + } else { + make_folder <- file.path(rtools4x_home_path(), "ucrt64", "bin") + } + repair_path(file.path(make_folder, "mingw32-make.exe")) } else { "make" }