Skip to content

Commit

Permalink
Update windows compiler usage
Browse files Browse the repository at this point in the history
  • Loading branch information
andrjohns committed Jan 23, 2024
1 parent 91583e3 commit 7c28d7e
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
8 changes: 6 additions & 2 deletions R/install.R
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
1 change: 1 addition & 0 deletions R/model.R
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down
9 changes: 8 additions & 1 deletion R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Expand Down

0 comments on commit 7c28d7e

Please sign in to comment.