Skip to content

Commit a54538d

Browse files
committed
locate objdump via the compiler R actually builds with
The previous attempt looked beside Sys.which("gcc"/"clang"), but on the aarch64 runner those resolve to C:/mingw64 -- the same x86_64 toolchain that leads the PATH -- so both candidates were the one objdump that cannot read an aarch64 PE, and the check still skipped there. They were also not deduplicated, differing only in slash direction. 'R CMD config CC' names the compiler that produced the library, so its objdump can read it by construction. Try that first, and normalize the candidates so one objdump is not tried under two spellings.
1 parent 5d1ca39 commit a54538d

1 file changed

Lines changed: 24 additions & 6 deletions

File tree

.github/scripts/tbb-downstream-check.R

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -106,16 +106,34 @@ dllName <- paste0("check", .Platform$dynlib.ext)
106106
# by the other -- so it is worth asserting rather than assuming.
107107

108108
# objdump has to match the target architecture, and the first one on the PATH
109-
# may well not: the aarch64 runner has an x86_64 objdump from C:/mingw64 ahead
110-
# of Rtools' own, and it exits non-zero having read nothing. Look beside the
111-
# compilers first, since those are necessarily right for the target
109+
# may well not: the aarch64 runner leads with an x86_64 objdump from C:/mingw64,
110+
# which exits non-zero having read nothing. Ask R which compiler it builds with
111+
# -- that is the one that produced the PE, so its objdump can always read it --
112+
# and only then fall back to whatever the PATH offers
112113
objdumpCandidates <- function() {
113114

114-
compilers <- Sys.which(c("gcc", "clang", "cc"))
115+
cc <- suppressWarnings(
116+
system2(
117+
file.path(R.home("bin"), "R"),
118+
c("CMD", "config", "CC"),
119+
stdout = TRUE,
120+
stderr = FALSE
121+
)
122+
)
123+
124+
# CC may carry arguments (e.g. 'gcc -std=gnu2x'), and may name the compiler
125+
# rather than spell out its path, in which case the PATH has to resolve it
126+
cc <- strsplit(trimws(paste(cc, collapse = " ")), "[[:space:]]+")[[1L]][[1L]]
127+
cc <- if (file.exists(cc)) cc else Sys.which(cc)
128+
129+
compilers <- c(cc, Sys.which(c("gcc", "clang", "cc")))
115130
beside <- file.path(dirname(compilers[nzchar(compilers)]), "objdump.exe")
116131

117-
candidates <- unique(c(beside, Sys.which("objdump")))
118-
candidates[nzchar(candidates) & file.exists(candidates)]
132+
candidates <- c(beside, Sys.which("objdump"))
133+
candidates <- candidates[nzchar(candidates) & file.exists(candidates)]
134+
135+
# '/' and '\\' spellings of one path are the same objdump; don't try twice
136+
unique(normalizePath(candidates, winslash = "/", mustWork = FALSE))
119137

120138
}
121139

0 commit comments

Comments
 (0)