build-cran-binaries/local/list-unsafe-flat-objects.R
pat-s 35b80da540
feat(abi): repair from the recorded verdicts rather than an ad-hoc scan
The earlier repair worked from package lists produced by a one-off local symbol
scan. Those lists were derived from a candidate set seeded on one slot, so they
were a lower bound by construction, and they do not survive the machine that
made them.

abi_flat_safety now holds the authoritative answer for every slot: the
flat-safety backfill inspected all 95418 objects and recorded which cannot load
under which minor. 4077 are unsafe, against the 93% of compiled packages the
source classifier suspects.

Each object is rebuilt under every installed R minor with no --sensitive-only
gate. Since bincraft v5.3.0 the destination is decided by the built binary's
symbols, so a package needing a per-minor slot lands there and a portable one
lands in the flat slot. Gating on the source classifier is what let Rcpp slip
through and break every R 4.4 client on the slot.

This change will:

- add local/list-unsafe-flat-objects.R, printing the recorded unsafe objects
- fail loudly when a slot has no verdicts at all, since an empty repair list
  would otherwise read as "nothing to do"
- add a manual workflow rebuilding them under every installed minor
2026-09-07 18:39:38 +00:00

80 lines
2.3 KiB
R

### Print the flat-slot objects recorded as unable to load under some R minor.
#
# Usage: Rscript local/list-unsafe-flat-objects.R <arch> <codename>
#
# Prints one `<package> <version>` per line, for a caller that rebuilds each
# under every installed R minor.
#
# The verdicts come from `abi_flat_safety`, written by the flat-safety backfill
# from the binaries themselves: an object is unsafe when it references a symbol
# some supported minor does not export. That is the authoritative list of what
# needs a per-minor build, and it replaces the ad-hoc symbol scans that produced
# earlier repair lists.
options(error = function() {
cat("ERROR:", geterrmessage(), "\n", file = stdout())
q(status = 1)
})
args <- commandArgs(trailingOnly = TRUE)
if (length(args) < 2L) {
stop("usage: list-unsafe-flat-objects.R <arch> <codename>", call. = FALSE)
}
arch <- args[[1L]]
codename <- args[[2L]]
con <- DBI::dbConnect(
RPostgres::Postgres(),
dbname = "build_metadata",
host = "r-binaries.devxy.io",
port = 15432L,
user = "rpkgs",
password = Sys.getenv("PGPASS"),
sslmode = "require"
)
on.exit(try(DBI::dbDisconnect(con), silent = TRUE), add = TRUE)
rows <- DBI::dbGetQuery(
con,
paste0(
"SELECT package, version FROM abi_flat_safety ",
"WHERE NOT safe AND codename = $1 AND arch = $2 ",
"ORDER BY package, version"
),
params = list(codename, arch)
)
# An empty result is ambiguous: either nothing is unsafe, or the backfill never
# ran for this slot. Say which, rather than let the caller read silence as done.
if (nrow(rows) == 0L) {
total <- DBI::dbGetQuery(
con,
"SELECT count(*) AS n FROM abi_flat_safety WHERE codename = $1 AND arch = $2",
params = list(codename, arch)
)$n[[1L]]
if (total == 0L) {
stop(
sprintf(
"No verdicts recorded for %s/%s at all. Run the flat-safety backfill first; an empty repair list here would look like success.", # nolint
arch,
codename
),
call. = FALSE
)
}
message(sprintf(
"%s/%s: %d objects recorded, none unsafe. Nothing to repair.",
arch,
codename,
total
))
quit(status = 0)
}
message(sprintf(
"%s/%s: %d objects need a per-minor build",
arch,
codename,
nrow(rows)
))
cat(sprintf("%s %s", rows$package, rows$version), sep = "\n")