Skip to content

Commit 7c28d7e

Browse files
committed
Update windows compiler usage
1 parent 91583e3 commit 7c28d7e

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed

R/install.R

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -846,8 +846,12 @@ toolchain_PATH_env_var <- function() {
846846
}
847847

848848
rtools4x_toolchain_path <- function() {
849-
c_runtime <- ifelse(is_ucrt_toolchain(), "ucrt64", "mingw64")
850-
repair_path(file.path(rtools4x_home_path(), c_runtime, "bin"))
849+
if (rtools4x_version() == "40") {
850+
toolchain_folder <- "mingw64"
851+
} else {
852+
toolchain_folder <- "x86_64-w64-mingw32.static.posix"
853+
}
854+
repair_path(file.path(rtools4x_home_path(), toolchain_folder, "bin"))
851855
}
852856

853857
rtools4x_version <- function() {

R/model.R

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -662,6 +662,7 @@ compile <- function(quiet = TRUE,
662662
cpp_options_to_compile_flags(c(cpp_options, list("KEEP_OBJECT"="true"))),
663663
stancflags_val),
664664
wd = cmdstan_path(),
665+
env = c("current", "CXXFLAGS"="-fPIC"),
665666
echo = !quiet || is_verbose_mode(),
666667
echo_cmd = is_verbose_mode(),
667668
spinner = quiet && rlang::is_interactive() && !identical(Sys.getenv("IN_PKGDOWN"), "true"),

R/utils.R

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,14 @@ is_rosetta2 <- function() {
8686
# Returns the type of make command to use to compile depending on the OS
8787
make_cmd <- function() {
8888
if (os_is_windows() && !os_is_wsl()) {
89-
"mingw32-make.exe"
89+
if (R.version$major == "3") {
90+
make_folder <- file.path(Sys.getenv("RTOOLS35_HOME"), "mingw_64", "bin")
91+
} else if (rtools4x_version() == "40") {
92+
make_folder <- file.path(rtools4x_home_path(), "mingw64", "bin")
93+
} else {
94+
make_folder <- file.path(rtools4x_home_path(), "ucrt64", "bin")
95+
}
96+
repair_path(file.path(make_folder, "mingw32-make.exe"))
9097
} else {
9198
"make"
9299
}

0 commit comments

Comments
 (0)