From ef59f03b588f89e6482c709aab5249b470a4523d Mon Sep 17 00:00:00 2001 From: Rok Mihevc Date: Wed, 1 Jul 2026 14:33:46 +0200 Subject: [PATCH 01/12] gmake parsing issue --- r/inst/build_arrow_static.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/r/inst/build_arrow_static.sh b/r/inst/build_arrow_static.sh index 349531b75fd..4c451c0f11e 100755 --- a/r/inst/build_arrow_static.sh +++ b/r/inst/build_arrow_static.sh @@ -114,7 +114,7 @@ ${CMAKE_WRAPPER} ${CMAKE} -DARROW_BOOST_USE_SHARED=OFF \ -G "${CMAKE_GENERATOR:-Unix Makefiles}" \ ${SOURCE_DIR} -${CMAKE} --build . --target install -- -j $N_JOBS +(unset MAKEFLAGS MFLAGS; ${CMAKE} --build . --target install -- -j "${N_JOBS}") if command -v sccache &> /dev/null; then echo "=== sccache stats after the build ===" From 4f135a144ce0aa05948bbcfba63a2b6061e7c409 Mon Sep 17 00:00:00 2001 From: Rok Mihevc Date: Wed, 1 Jul 2026 15:59:54 +0200 Subject: [PATCH 02/12] Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --- r/inst/build_arrow_static.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/r/inst/build_arrow_static.sh b/r/inst/build_arrow_static.sh index 4c451c0f11e..16f8c1d5a6e 100755 --- a/r/inst/build_arrow_static.sh +++ b/r/inst/build_arrow_static.sh @@ -114,7 +114,7 @@ ${CMAKE_WRAPPER} ${CMAKE} -DARROW_BOOST_USE_SHARED=OFF \ -G "${CMAKE_GENERATOR:-Unix Makefiles}" \ ${SOURCE_DIR} -(unset MAKEFLAGS MFLAGS; ${CMAKE} --build . --target install -- -j "${N_JOBS}") +(unset MAKEFLAGS MFLAGS; ${CMAKE} --build . --target install --parallel "${N_JOBS}") if command -v sccache &> /dev/null; then echo "=== sccache stats after the build ===" From ae00aea046b3c4f4c3c13e84509e66fde51a9081 Mon Sep 17 00:00:00 2001 From: Rok Mihevc Date: Thu, 2 Jul 2026 14:20:26 +0200 Subject: [PATCH 03/12] review feedback --- r/inst/build_arrow_static.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/r/inst/build_arrow_static.sh b/r/inst/build_arrow_static.sh index 16f8c1d5a6e..0df5240888a 100755 --- a/r/inst/build_arrow_static.sh +++ b/r/inst/build_arrow_static.sh @@ -114,7 +114,7 @@ ${CMAKE_WRAPPER} ${CMAKE} -DARROW_BOOST_USE_SHARED=OFF \ -G "${CMAKE_GENERATOR:-Unix Makefiles}" \ ${SOURCE_DIR} -(unset MAKEFLAGS MFLAGS; ${CMAKE} --build . --target install --parallel "${N_JOBS}") +${CMAKE} --build . --target install --parallel $N_JOBS if command -v sccache &> /dev/null; then echo "=== sccache stats after the build ===" From f217bd2f05c0a98ddccfbf37f1c85d170d1588d1 Mon Sep 17 00:00:00 2001 From: Rok Mihevc Date: Thu, 2 Jul 2026 19:22:45 +0200 Subject: [PATCH 04/12] Fix -j flag earlier --- r/inst/build_arrow_static.sh | 2 +- r/tools/nixlibs.R | 21 ++++++++++++++++++--- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/r/inst/build_arrow_static.sh b/r/inst/build_arrow_static.sh index 0df5240888a..349531b75fd 100755 --- a/r/inst/build_arrow_static.sh +++ b/r/inst/build_arrow_static.sh @@ -114,7 +114,7 @@ ${CMAKE_WRAPPER} ${CMAKE} -DARROW_BOOST_USE_SHARED=OFF \ -G "${CMAKE_GENERATOR:-Unix Makefiles}" \ ${SOURCE_DIR} -${CMAKE} --build . --target install --parallel $N_JOBS +${CMAKE} --build . --target install -- -j $N_JOBS if command -v sccache &> /dev/null; then echo "=== sccache stats after the build ===" diff --git a/r/tools/nixlibs.R b/r/tools/nixlibs.R index ba705e03ad7..5bf2d59779c 100644 --- a/r/tools/nixlibs.R +++ b/r/tools/nixlibs.R @@ -535,11 +535,26 @@ build_libarrow <- function(src_dir, dst_dir) { makeflags <- sprintf("-j%s", ncores) Sys.setenv(MAKEFLAGS = makeflags) } else { - # Extract -j value from existing MAKEFLAGS if present - j_match <- regmatches(makeflags, regexpr("-j\\s*([0-9]+)", makeflags, perl = TRUE)) + # Extract -j/--jobs value from existing MAKEFLAGS if present + j_match <- regmatches(makeflags, regexpr("(^|\\s)(-j\\s*|--jobs(=|\\s)+)([0-9]+)(?=\\s|$)", makeflags, perl = TRUE)) if (length(j_match) > 0) { - ncores <- as.integer(sub("-j\\s*", "", j_match, perl = TRUE)) + ncores <- as.integer(sub(".*?([0-9]+)$", "\\1", j_match, perl = TRUE)) } + # Keep GNU make's optional -j/--jobs argument in one token for nested gmake + makeflags <- gsub("(^|\\s)-j\\s+([0-9]+)(?=\\s|$)", "\\1-j\\2", makeflags, perl = TRUE) + makeflags <- gsub("(^|\\s)--jobs\\s+([0-9]+)(?=\\s|$)", "\\1--jobs=\\2", makeflags, perl = TRUE) + # Give any remaining bare `-j`/`--jobs` an explicit count + makeflags <- gsub("(^|\\s)-j(?=\\s|$)", sprintf("\\1-j%s", ncores), makeflags, perl = TRUE) + makeflags <- gsub("(^|\\s)--jobs(?=\\s|$)", sprintf("\\1--jobs=%s", ncores), makeflags, perl = TRUE) + Sys.setenv(MAKEFLAGS = makeflags) + } + gnumakeflags <- Sys.getenv("GNUMAKEFLAGS") + if (nzchar(gnumakeflags)) { + gnumakeflags <- gsub("(^|\\s)-j\\s+([0-9]+)(?=\\s|$)", "\\1-j\\2", gnumakeflags, perl = TRUE) + gnumakeflags <- gsub("(^|\\s)--jobs\\s+([0-9]+)(?=\\s|$)", "\\1--jobs=\\2", gnumakeflags, perl = TRUE) + gnumakeflags <- gsub("(^|\\s)-j(?=\\s|$)", sprintf("\\1-j%s", ncores), gnumakeflags, perl = TRUE) + gnumakeflags <- gsub("(^|\\s)--jobs(?=\\s|$)", sprintf("\\1--jobs=%s", ncores), gnumakeflags, perl = TRUE) + Sys.setenv(GNUMAKEFLAGS = gnumakeflags) } if (!quietly) { lg("Building with MAKEFLAGS=%s", makeflags) From 7999054c5d7f0b3a152f01d752ed4c570a483375 Mon Sep 17 00:00:00 2001 From: Rok Mihevc Date: Thu, 2 Jul 2026 21:52:22 +0200 Subject: [PATCH 05/12] another attempt --- r/inst/build_arrow_static.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/r/inst/build_arrow_static.sh b/r/inst/build_arrow_static.sh index 349531b75fd..11d7e14b3e7 100755 --- a/r/inst/build_arrow_static.sh +++ b/r/inst/build_arrow_static.sh @@ -114,7 +114,7 @@ ${CMAKE_WRAPPER} ${CMAKE} -DARROW_BOOST_USE_SHARED=OFF \ -G "${CMAKE_GENERATOR:-Unix Makefiles}" \ ${SOURCE_DIR} -${CMAKE} --build . --target install -- -j $N_JOBS +${CMAKE} --build . --target install -- -j"${N_JOBS}" if command -v sccache &> /dev/null; then echo "=== sccache stats after the build ===" From a623cf54234b50eff1319446c1121dbe523e1253 Mon Sep 17 00:00:00 2001 From: Rok Mihevc Date: Fri, 3 Jul 2026 00:09:17 +0200 Subject: [PATCH 06/12] another attempt --- r/tools/nixlibs.R | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/r/tools/nixlibs.R b/r/tools/nixlibs.R index 5bf2d59779c..6501213a782 100644 --- a/r/tools/nixlibs.R +++ b/r/tools/nixlibs.R @@ -516,6 +516,14 @@ env_vars_as_string <- function(env_var_list) { env_var_string } +strip_make_job_flags <- function(makeflags) { + makeflags <- gsub("(^|\\s)--jobserver-[^[:space:]]+", " ", makeflags, perl = TRUE) + makeflags <- gsub("(^|\\s)--jobs(=|\\s+)?[0-9]*(?=\\s|$)", " ", makeflags, perl = TRUE) + makeflags <- gsub("(^|\\s)-j\\s*[0-9]*(?=\\s|$)", " ", makeflags, perl = TRUE) + makeflags <- gsub("(^|\\s)([[:alpha:]]*)j[0-9]*([[:alpha:]]*)(?=\\s|$)", "\\1\\2\\3", makeflags, perl = TRUE) + trimws(gsub("\\s+", " ", makeflags, perl = TRUE)) +} + R_CMD_config <- function(var) { tools::Rcmd(paste("config", var), stdout = TRUE) } @@ -536,7 +544,10 @@ build_libarrow <- function(src_dir, dst_dir) { Sys.setenv(MAKEFLAGS = makeflags) } else { # Extract -j/--jobs value from existing MAKEFLAGS if present - j_match <- regmatches(makeflags, regexpr("(^|\\s)(-j\\s*|--jobs(=|\\s)+)([0-9]+)(?=\\s|$)", makeflags, perl = TRUE)) + j_match <- regmatches( + makeflags, + regexpr("(^|\\s)(-j\\s*|--jobs(=|\\s)+|[[:alpha:]]*j)([0-9]+)(?=\\s|$)", makeflags, perl = TRUE) + ) if (length(j_match) > 0) { ncores <- as.integer(sub(".*?([0-9]+)$", "\\1", j_match, perl = TRUE)) } @@ -556,6 +567,9 @@ build_libarrow <- function(src_dir, dst_dir) { gnumakeflags <- gsub("(^|\\s)--jobs(?=\\s|$)", sprintf("\\1--jobs=%s", ncores), gnumakeflags, perl = TRUE) Sys.setenv(GNUMAKEFLAGS = gnumakeflags) } + makeflags <- strip_make_job_flags(makeflags) + gnumakeflags <- strip_make_job_flags(Sys.getenv("GNUMAKEFLAGS")) + Sys.setenv(MAKEFLAGS = makeflags, GNUMAKEFLAGS = gnumakeflags) if (!quietly) { lg("Building with MAKEFLAGS=%s", makeflags) } @@ -594,6 +608,8 @@ build_libarrow <- function(src_dir, dst_dir) { ), # CXXFLAGS = R_CMD_config("CXX20FLAGS"), # We don't want the same debug symbols LDFLAGS = R_CMD_config("LDFLAGS"), + MAKEFLAGS = makeflags, + GNUMAKEFLAGS = gnumakeflags, N_JOBS = ncores ) From ca8919f554606ebb778f7d09cd38fa61986af437 Mon Sep 17 00:00:00 2001 From: Rok Mihevc Date: Fri, 3 Jul 2026 13:24:04 +0200 Subject: [PATCH 07/12] unset + env --- r/inst/build_arrow_static.sh | 3 ++- r/tools/nixlibs.R | 37 +++--------------------------------- 2 files changed, 5 insertions(+), 35 deletions(-) diff --git a/r/inst/build_arrow_static.sh b/r/inst/build_arrow_static.sh index 11d7e14b3e7..cdc59b42d99 100755 --- a/r/inst/build_arrow_static.sh +++ b/r/inst/build_arrow_static.sh @@ -114,7 +114,8 @@ ${CMAKE_WRAPPER} ${CMAKE} -DARROW_BOOST_USE_SHARED=OFF \ -G "${CMAKE_GENERATOR:-Unix Makefiles}" \ ${SOURCE_DIR} -${CMAKE} --build . --target install -- -j"${N_JOBS}" +env | sort +(unset MAKEFLAGS MFLAGS GNUMAKEFLAGS; ${CMAKE} --build . --target install -- -j"${N_JOBS}") if command -v sccache &> /dev/null; then echo "=== sccache stats after the build ===" diff --git a/r/tools/nixlibs.R b/r/tools/nixlibs.R index 6501213a782..ba705e03ad7 100644 --- a/r/tools/nixlibs.R +++ b/r/tools/nixlibs.R @@ -516,14 +516,6 @@ env_vars_as_string <- function(env_var_list) { env_var_string } -strip_make_job_flags <- function(makeflags) { - makeflags <- gsub("(^|\\s)--jobserver-[^[:space:]]+", " ", makeflags, perl = TRUE) - makeflags <- gsub("(^|\\s)--jobs(=|\\s+)?[0-9]*(?=\\s|$)", " ", makeflags, perl = TRUE) - makeflags <- gsub("(^|\\s)-j\\s*[0-9]*(?=\\s|$)", " ", makeflags, perl = TRUE) - makeflags <- gsub("(^|\\s)([[:alpha:]]*)j[0-9]*([[:alpha:]]*)(?=\\s|$)", "\\1\\2\\3", makeflags, perl = TRUE) - trimws(gsub("\\s+", " ", makeflags, perl = TRUE)) -} - R_CMD_config <- function(var) { tools::Rcmd(paste("config", var), stdout = TRUE) } @@ -543,33 +535,12 @@ build_libarrow <- function(src_dir, dst_dir) { makeflags <- sprintf("-j%s", ncores) Sys.setenv(MAKEFLAGS = makeflags) } else { - # Extract -j/--jobs value from existing MAKEFLAGS if present - j_match <- regmatches( - makeflags, - regexpr("(^|\\s)(-j\\s*|--jobs(=|\\s)+|[[:alpha:]]*j)([0-9]+)(?=\\s|$)", makeflags, perl = TRUE) - ) + # Extract -j value from existing MAKEFLAGS if present + j_match <- regmatches(makeflags, regexpr("-j\\s*([0-9]+)", makeflags, perl = TRUE)) if (length(j_match) > 0) { - ncores <- as.integer(sub(".*?([0-9]+)$", "\\1", j_match, perl = TRUE)) + ncores <- as.integer(sub("-j\\s*", "", j_match, perl = TRUE)) } - # Keep GNU make's optional -j/--jobs argument in one token for nested gmake - makeflags <- gsub("(^|\\s)-j\\s+([0-9]+)(?=\\s|$)", "\\1-j\\2", makeflags, perl = TRUE) - makeflags <- gsub("(^|\\s)--jobs\\s+([0-9]+)(?=\\s|$)", "\\1--jobs=\\2", makeflags, perl = TRUE) - # Give any remaining bare `-j`/`--jobs` an explicit count - makeflags <- gsub("(^|\\s)-j(?=\\s|$)", sprintf("\\1-j%s", ncores), makeflags, perl = TRUE) - makeflags <- gsub("(^|\\s)--jobs(?=\\s|$)", sprintf("\\1--jobs=%s", ncores), makeflags, perl = TRUE) - Sys.setenv(MAKEFLAGS = makeflags) - } - gnumakeflags <- Sys.getenv("GNUMAKEFLAGS") - if (nzchar(gnumakeflags)) { - gnumakeflags <- gsub("(^|\\s)-j\\s+([0-9]+)(?=\\s|$)", "\\1-j\\2", gnumakeflags, perl = TRUE) - gnumakeflags <- gsub("(^|\\s)--jobs\\s+([0-9]+)(?=\\s|$)", "\\1--jobs=\\2", gnumakeflags, perl = TRUE) - gnumakeflags <- gsub("(^|\\s)-j(?=\\s|$)", sprintf("\\1-j%s", ncores), gnumakeflags, perl = TRUE) - gnumakeflags <- gsub("(^|\\s)--jobs(?=\\s|$)", sprintf("\\1--jobs=%s", ncores), gnumakeflags, perl = TRUE) - Sys.setenv(GNUMAKEFLAGS = gnumakeflags) } - makeflags <- strip_make_job_flags(makeflags) - gnumakeflags <- strip_make_job_flags(Sys.getenv("GNUMAKEFLAGS")) - Sys.setenv(MAKEFLAGS = makeflags, GNUMAKEFLAGS = gnumakeflags) if (!quietly) { lg("Building with MAKEFLAGS=%s", makeflags) } @@ -608,8 +579,6 @@ build_libarrow <- function(src_dir, dst_dir) { ), # CXXFLAGS = R_CMD_config("CXX20FLAGS"), # We don't want the same debug symbols LDFLAGS = R_CMD_config("LDFLAGS"), - MAKEFLAGS = makeflags, - GNUMAKEFLAGS = gnumakeflags, N_JOBS = ncores ) From 4c7c074243f9bd83a913f34c95def7e556335487 Mon Sep 17 00:00:00 2001 From: Rok Mihevc Date: Fri, 3 Jul 2026 14:47:36 +0200 Subject: [PATCH 08/12] sanitize and print --- r/inst/build_arrow_static.sh | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/r/inst/build_arrow_static.sh b/r/inst/build_arrow_static.sh index cdc59b42d99..8341e8a0292 100755 --- a/r/inst/build_arrow_static.sh +++ b/r/inst/build_arrow_static.sh @@ -114,8 +114,29 @@ ${CMAKE_WRAPPER} ${CMAKE} -DARROW_BOOST_USE_SHARED=OFF \ -G "${CMAKE_GENERATOR:-Unix Makefiles}" \ ${SOURCE_DIR} +sanitize_makeflags() { + printf '%s\n' "$1" | + sed -E \ + -e 's/(^|[[:space:]])-j[[:space:]]*[0-9]*([[:space:]]|$)/ /g' \ + -e 's/(^|[[:space:]])([[:alpha:]]*)j[0-9]*([[:alpha:]]*)($|[[:space:]])/ \2\3 /g' \ + -e 's/[[:space:]]+/ /g' \ + -e 's/^ //; s/ $//' +} + env | sort -(unset MAKEFLAGS MFLAGS GNUMAKEFLAGS; ${CMAKE} --build . --target install -- -j"${N_JOBS}") +SANITIZED_MAKEFLAGS="$(sanitize_makeflags "${MAKEFLAGS:-}")" +SANITIZED_MFLAGS="$(sanitize_makeflags "${MFLAGS:-}")" +SANITIZED_GNUMAKEFLAGS="$(sanitize_makeflags "${GNUMAKEFLAGS:-}")" +printf 'MAKEFLAGS before sanitize: %s\n' "${MAKEFLAGS:-}" +printf 'MFLAGS before sanitize: %s\n' "${MFLAGS:-}" +printf 'GNUMAKEFLAGS before sanitize: %s\n' "${GNUMAKEFLAGS:-}" +printf 'MAKEFLAGS after sanitize: %s\n' "${SANITIZED_MAKEFLAGS}" +printf 'MFLAGS after sanitize: %s\n' "${SANITIZED_MFLAGS}" +printf 'GNUMAKEFLAGS after sanitize: %s\n' "${SANITIZED_GNUMAKEFLAGS}" +MAKEFLAGS="${SANITIZED_MAKEFLAGS}" \ +MFLAGS="${SANITIZED_MFLAGS}" \ +GNUMAKEFLAGS="${SANITIZED_GNUMAKEFLAGS}" \ + ${CMAKE} --build . --target install -- -j"${N_JOBS}" if command -v sccache &> /dev/null; then echo "=== sccache stats after the build ===" From cf523e8d43d9c5ca58fa70076028c6647b7bc5b2 Mon Sep 17 00:00:00 2001 From: Rok Mihevc Date: Fri, 3 Jul 2026 14:59:37 +0200 Subject: [PATCH 09/12] fix NA --- r/inst/build_arrow_static.sh | 5 +++-- r/tools/nixlibs.R | 3 +++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/r/inst/build_arrow_static.sh b/r/inst/build_arrow_static.sh index 8341e8a0292..2c4791cbb0c 100755 --- a/r/inst/build_arrow_static.sh +++ b/r/inst/build_arrow_static.sh @@ -117,8 +117,9 @@ ${CMAKE_WRAPPER} ${CMAKE} -DARROW_BOOST_USE_SHARED=OFF \ sanitize_makeflags() { printf '%s\n' "$1" | sed -E \ - -e 's/(^|[[:space:]])-j[[:space:]]*[0-9]*([[:space:]]|$)/ /g' \ - -e 's/(^|[[:space:]])([[:alpha:]]*)j[0-9]*([[:alpha:]]*)($|[[:space:]])/ \2\3 /g' \ + -e 's/(^|[[:space:]])-j[[:space:]]+[0-9]*([[:space:]]|$)/ /g' \ + -e 's/(^|[[:space:]])-j[^[:space:]]*([[:space:]]|$)/ /g' \ + -e 's/(^|[[:space:]])([[:alpha:]]*)j[[:alnum:]]*([[:alpha:]]*)($|[[:space:]])/ \2\3 /g' \ -e 's/[[:space:]]+/ /g' \ -e 's/^ //; s/ $//' } diff --git a/r/tools/nixlibs.R b/r/tools/nixlibs.R index ba705e03ad7..d40d8fe7134 100644 --- a/r/tools/nixlibs.R +++ b/r/tools/nixlibs.R @@ -527,6 +527,9 @@ build_libarrow <- function(src_dir, dst_dir) { # CRAN policy says not to use more than 2 cores during checks # If you have more and want to use more, set MAKEFLAGS or NOT_CRAN ncores <- parallel::detectCores() + if (is.na(ncores)) { + ncores <- 2 + } if (!not_cran) { ncores <- min(ncores, 2) } From 6aa0fe62030da4ec2fe554761005b651cdf07fdb Mon Sep 17 00:00:00 2001 From: Rok Mihevc Date: Fri, 3 Jul 2026 15:20:38 +0200 Subject: [PATCH 10/12] bash sanitize --- r/inst/build_arrow_static.sh | 24 ++---------------------- r/tools/nixlibs.R | 3 --- 2 files changed, 2 insertions(+), 25 deletions(-) diff --git a/r/inst/build_arrow_static.sh b/r/inst/build_arrow_static.sh index 2c4791cbb0c..a949165cb95 100755 --- a/r/inst/build_arrow_static.sh +++ b/r/inst/build_arrow_static.sh @@ -114,30 +114,10 @@ ${CMAKE_WRAPPER} ${CMAKE} -DARROW_BOOST_USE_SHARED=OFF \ -G "${CMAKE_GENERATOR:-Unix Makefiles}" \ ${SOURCE_DIR} -sanitize_makeflags() { - printf '%s\n' "$1" | - sed -E \ - -e 's/(^|[[:space:]])-j[[:space:]]+[0-9]*([[:space:]]|$)/ /g' \ - -e 's/(^|[[:space:]])-j[^[:space:]]*([[:space:]]|$)/ /g' \ - -e 's/(^|[[:space:]])([[:alpha:]]*)j[[:alnum:]]*([[:alpha:]]*)($|[[:space:]])/ \2\3 /g' \ - -e 's/[[:space:]]+/ /g' \ - -e 's/^ //; s/ $//' -} - -env | sort -SANITIZED_MAKEFLAGS="$(sanitize_makeflags "${MAKEFLAGS:-}")" -SANITIZED_MFLAGS="$(sanitize_makeflags "${MFLAGS:-}")" -SANITIZED_GNUMAKEFLAGS="$(sanitize_makeflags "${GNUMAKEFLAGS:-}")" +SANITIZED_MAKEFLAGS="${MAKEFLAGS/-jNA/}" printf 'MAKEFLAGS before sanitize: %s\n' "${MAKEFLAGS:-}" -printf 'MFLAGS before sanitize: %s\n' "${MFLAGS:-}" -printf 'GNUMAKEFLAGS before sanitize: %s\n' "${GNUMAKEFLAGS:-}" printf 'MAKEFLAGS after sanitize: %s\n' "${SANITIZED_MAKEFLAGS}" -printf 'MFLAGS after sanitize: %s\n' "${SANITIZED_MFLAGS}" -printf 'GNUMAKEFLAGS after sanitize: %s\n' "${SANITIZED_GNUMAKEFLAGS}" -MAKEFLAGS="${SANITIZED_MAKEFLAGS}" \ -MFLAGS="${SANITIZED_MFLAGS}" \ -GNUMAKEFLAGS="${SANITIZED_GNUMAKEFLAGS}" \ - ${CMAKE} --build . --target install -- -j"${N_JOBS}" +MAKEFLAGS="${SANITIZED_MAKEFLAGS}" ${CMAKE} --build . --target install -- -j"${N_JOBS}" if command -v sccache &> /dev/null; then echo "=== sccache stats after the build ===" diff --git a/r/tools/nixlibs.R b/r/tools/nixlibs.R index d40d8fe7134..ba705e03ad7 100644 --- a/r/tools/nixlibs.R +++ b/r/tools/nixlibs.R @@ -527,9 +527,6 @@ build_libarrow <- function(src_dir, dst_dir) { # CRAN policy says not to use more than 2 cores during checks # If you have more and want to use more, set MAKEFLAGS or NOT_CRAN ncores <- parallel::detectCores() - if (is.na(ncores)) { - ncores <- 2 - } if (!not_cran) { ncores <- min(ncores, 2) } From 5a5ea9368b2f41e9fa596d538bae411eb262a5b1 Mon Sep 17 00:00:00 2001 From: Rok Mihevc Date: Fri, 3 Jul 2026 15:46:36 +0200 Subject: [PATCH 11/12] minimal fix --- r/inst/build_arrow_static.sh | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/r/inst/build_arrow_static.sh b/r/inst/build_arrow_static.sh index a949165cb95..cd747baddbe 100755 --- a/r/inst/build_arrow_static.sh +++ b/r/inst/build_arrow_static.sh @@ -114,10 +114,7 @@ ${CMAKE_WRAPPER} ${CMAKE} -DARROW_BOOST_USE_SHARED=OFF \ -G "${CMAKE_GENERATOR:-Unix Makefiles}" \ ${SOURCE_DIR} -SANITIZED_MAKEFLAGS="${MAKEFLAGS/-jNA/}" -printf 'MAKEFLAGS before sanitize: %s\n' "${MAKEFLAGS:-}" -printf 'MAKEFLAGS after sanitize: %s\n' "${SANITIZED_MAKEFLAGS}" -MAKEFLAGS="${SANITIZED_MAKEFLAGS}" ${CMAKE} --build . --target install -- -j"${N_JOBS}" +MAKEFLAGS="${MAKEFLAGS/-jNA/}" ${CMAKE} --build . --target install -- -j $N_JOBS if command -v sccache &> /dev/null; then echo "=== sccache stats after the build ===" From 8f4ba3564a9c4ec723919ed088adce6c101471ee Mon Sep 17 00:00:00 2001 From: Rok Mihevc Date: Fri, 3 Jul 2026 16:48:38 +0200 Subject: [PATCH 12/12] minimal-er fix --- r/inst/build_arrow_static.sh | 2 +- r/tools/nixlibs.R | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/r/inst/build_arrow_static.sh b/r/inst/build_arrow_static.sh index cd747baddbe..349531b75fd 100755 --- a/r/inst/build_arrow_static.sh +++ b/r/inst/build_arrow_static.sh @@ -114,7 +114,7 @@ ${CMAKE_WRAPPER} ${CMAKE} -DARROW_BOOST_USE_SHARED=OFF \ -G "${CMAKE_GENERATOR:-Unix Makefiles}" \ ${SOURCE_DIR} -MAKEFLAGS="${MAKEFLAGS/-jNA/}" ${CMAKE} --build . --target install -- -j $N_JOBS +${CMAKE} --build . --target install -- -j $N_JOBS if command -v sccache &> /dev/null; then echo "=== sccache stats after the build ===" diff --git a/r/tools/nixlibs.R b/r/tools/nixlibs.R index ba705e03ad7..504caa42c00 100644 --- a/r/tools/nixlibs.R +++ b/r/tools/nixlibs.R @@ -526,7 +526,7 @@ build_libarrow <- function(src_dir, dst_dir) { # Set up make for parallel building # CRAN policy says not to use more than 2 cores during checks # If you have more and want to use more, set MAKEFLAGS or NOT_CRAN - ncores <- parallel::detectCores() + ncores <- max(1, parallel::detectCores(), na.rm = TRUE) if (!not_cran) { ncores <- min(ncores, 2) }