Skip to content

Commit d7a63bc

Browse files
committed
Fix -j flag earlier
1 parent ae00aea commit d7a63bc

2 files changed

Lines changed: 8 additions & 1 deletion

File tree

r/inst/build_arrow_static.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ ${CMAKE_WRAPPER} ${CMAKE} -DARROW_BOOST_USE_SHARED=OFF \
114114
-G "${CMAKE_GENERATOR:-Unix Makefiles}" \
115115
${SOURCE_DIR}
116116

117-
${CMAKE} --build . --target install --parallel $N_JOBS
117+
${CMAKE} --build . --target install -- -j"${N_JOBS}"
118118

119119
if command -v sccache &> /dev/null; then
120120
echo "=== sccache stats after the build ==="

r/tools/nixlibs.R

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -539,6 +539,13 @@ build_libarrow <- function(src_dir, dst_dir) {
539539
j_match <- regmatches(makeflags, regexpr("-j\\s*([0-9]+)", makeflags, perl = TRUE))
540540
if (length(j_match) > 0) {
541541
ncores <- as.integer(sub("-j\\s*", "", j_match, perl = TRUE))
542+
# Keep GNU make's optional -j argument in one token for nested gmake
543+
makeflags <- sub("(^|\\s)-j\\s+([0-9]+)(?=\\s|$)", "\\1-j\\2", makeflags, perl = TRUE)
544+
Sys.setenv(MAKEFLAGS = makeflags)
545+
} else if (grepl("(^|\\s)-j(\\s|$)", makeflags, perl = TRUE)) {
546+
# Give a bare `-j` (e.g. from a parent make's jobserver) an explicit count
547+
makeflags <- sub("(^|\\s)-j(\\s|$)", sprintf("\\1-j%s\\2", ncores), makeflags, perl = TRUE)
548+
Sys.setenv(MAKEFLAGS = makeflags)
542549
}
543550
}
544551
if (!quietly) {

0 commit comments

Comments
 (0)