Skip to content

docs: Add an experiment record for incremental builds of vendored extensions - #849

Open
krlmlr wants to merge 4 commits into
mainfrom
claude/experiments-reproducers
Open

krlmlr wants to merge 4 commits into
mainfrom
claude/experiments-reproducers

Conversation

@krlmlr

@krlmlr krlmlr commented Nov 11, 2026 •

Copy link
Copy Markdown
Member

The reproducer for #836, as an experiment record: an incremental build is not something a reprex can host. It follows the experiment convention of cynkra/handbook-tools: experiments/README.md is the registry and names every record, and each record is a directory named for its date and topic, whose README.md says what it measures, when and on what, and what it supports, followed by the method, the findings and how to replicate them, with the driver and its output beside it. RSQLite has no handbook, so a record supports an issue instead of a handbook page. Nothing under experiments/ runs on its own or gates a merge, and .Rbuildignore leaves the directory out of the package; R CMD build gives a tarball without it.

The record, experiments/2026-11-11-incremental-build-vendor/, measures at 3b7bea3 that an edit to src/vendor/extensions/http.c leaves src/ext-http.o as it was, with R CMD INSTALL and with pkgbuild::compile_dll(), which devtools::load_all() calls. Listing the vendored file in src/ext-http.dd by hand makes the next build recompile it, but the next regeneration of src/ext-http.dd drops it again. It also finds that the filter in src/Makevars.deps expects the two-space indentation of clang's dependency output, while GCC indents by one space, so with GCC a regenerated .dd file keeps absolute and vendored paths, and pkgbuild::compile_dll() rewrites src/cpp11.dd to 721 lines, leaving the working tree dirty. That second finding matters for the "regenerate" step of #836.

Three clean reviews (first, second, third) confirmed the findings by running the driver; their fixes make a failed build print its error lines before the driver restores the files, and the README now says what the driver needs, what it leaves in src/, and which step-1 lines depend on the state of the checkout. What remains is under Accepted limitations.


Generated by Claude Code

…ensions

The record measures, at 3b7bea3, that an edit to `src/vendor/extensions/http.c` leaves `ext-http.o` as it was, with `R CMD INSTALL` and with `pkgbuild::compile_dll()`.
Listing the vendored file in `src/ext-http.dd` makes the build recompile it, and the next regeneration of that file drops it again.
With GCC, the filter in `src/Makevars.deps` also lets absolute and vendored paths through, because GCC indents continuation lines by one space where the filter expects two.
`experiments/README.md` is the registry, following the convention of cynkra/handbook-tools.
`.Rbuildignore` leaves the directory out of the package, which `R CMD build` confirms.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Hr1rd3gjmufoKCWVDBPCgE

krlmlr commented Nov 11, 2026

Copy link
Copy Markdown
Member Author

CI note: the smoke test failed before any R code ran, because the runners could not resolve the Ubuntu package mirrors while installing aspell (Temporary failure resolving 'security.ubuntu.com'), as on every pull request of this repository since about 14:00 UTC (see #832). That is the runners' network, not this change, and there is no fix to port. The job will be re-run once the mirrors resolve again.


Generated by Claude Code

krlmlr commented Nov 11, 2026

Copy link
Copy Markdown
Member Author

Review of this pull request at 66591de, by a Claude Code reviewer with clean context that read the description, #836, the experiments convention page and stub in cynkra/handbook-tools, all five changed files (.Rbuildignore, the registry, the record's README, run.sh, output.txt), and src/Makevars, src/Makevars.deps and R's Makeconf rules; ran run.sh in a fresh worktree at 3b7bea3 and from this branch; built and checked the package from this branch; and posted nothing itself. "Confirmed" means reproduced by running code.

What was run

  • run.sh in a fresh worktree at 3b7bea3, with experiments/ copied in (GCC 13.3.0, clang 18.1.3, R 4.5.3, make 4.3, pkgbuild 1.4.8, ccache 4.9.1, Ubuntu 24.04.5): 3m22 cold, 45 s warm. Both runs were diffed against output.txt with time stamps masked: the second matched exactly, the first differed in one line (Low 2). git status was clean afterwards.
  • run.sh from this branch, interrupted with SIGINT during step 1 and between steps 3 and 4, while src/ext-http.dd and src/vendor/extensions/http.c were edited: each time the checksums and mtimes of those files and of src/ext-http.c matched the values before the run, git status was clean, src/ext-http.o was deleted, and the temporary directory was gone.
  • R CMD build of this branch gives a tarball with no experiments/ entry. R CMD check --no-manual --no-tests gives 1 NOTE, "hidden files and directories: .git", which comes from the worktree's .git file, not from this change; no other NOTE or WARNING. Nothing in run.sh runs during build, install or check (by reading).

What holds

  • Confirmed: an edit to src/vendor/extensions/http.c is missed by R CMD INSTALL (step 2 compiles nothing) and by pkgbuild::compile_dll() (step 7 compiles only cpp11.cpp).
  • Confirmed: listing the file in src/ext-http.dd by hand makes the next build recompile it (step 3), the regeneration in step 4 drops it again, and step 5 compiles nothing.
  • Confirmed: GCC indents -MM continuation lines by one space and clang by two (step 8); under GCC the filter in src/Makevars.deps keeps /opt/R/.../Rconfig.h and the vendored sqlite3.h paths, under clang everything but ext-http.c is dropped, which is the committed .dd. By reading, the first sed breaks mid-line paths onto two-space lines but leaves a leading one-space indent alone, and the second deletes only lines starting with exactly two spaces.
  • Confirmed: src/cpp11.dd grows from 11 to 721 lines after compile_dll(), as the README says, and run.sh restores it.
  • Confirmed: run.sh restores the files it edits, with their mtimes, under interruption and on normal exit.
  • By reading: the record follows the convention: the YYYY-MM-DD-topic name, three italic-labelled opening paragraphs whose last links Incremental builds miss changes to bundled extensions under src/vendor/extensions/ #836, method and findings with quoted excerpts, output.txt beside the driver without replacing the excerpts, a registry line with the name, one clause and the issue, and the adaptation from a handbook leaf to an issue stated in the registry. The record argues for no change, which fits "evidence, not a check". The "about a minute with a warm ccache" claim holds (45 s).

High

None.

Medium

1. A failed build leaves no trace of why. By reading: run.sh#L71, and the same at L77. Each build's output goes only to $work/<n>.log. Under set -e a failing R CMD INSTALL, or a missing pkgbuild or compiler, exits the script before report runs, and the EXIT trap then deletes $work with the logs, so the caller sees the files restored and exit status 1 with nothing printed. The header says "The full log of each build stays in the temporary directory, which is deleted on exit", the opposite of what someone debugging a failed replication needs. Suggested fix: in install() and compile_dll(), test the command's status and on failure print the tail of the log to stderr before exiting, and say in the README that pkgbuild and a compiler are required.

Low

1. The driver's requirements are unstated. By reading: run.sh#L54, L60, L101, L130. It needs bash (pipefail), GNU make and GNU userland (stat -c %y, sed -i without a suffix and with \n in the replacement, and sed -r in Makevars.deps itself). It detects a link by -shared in the log, which is -dynamiclib on macOS, so there it would report "linked: nothing". It calls bare gcc and clang with hand-picked flags (-DNDEBUG -Ivendor) instead of R's CC and ALL_CPPFLAGS, and bare gcc is clang on macOS. Suggested fix: one sentence under "Replicating" saying it needs bash, GNU coreutils, sed and make on Linux, and that step 8 uses gcc and clang as found on the PATH.

2. The committed output is not reproducible from a truly fresh checkout. Confirmed: output.txt#L8-L13. In a first run from a fresh worktree, step 1 printed no "regenerated: cpp11.dd" line, because whether the build remakes cpp11.dd depends on the checkout's file mtimes; after one run, restore() puts the old mtimes back with cp -p, so every later run matches the committed output exactly. Everything the findings rest on is identical. Suggested fix: drop the "regenerated:" report from step 1, or say in the README that step 1's list of regenerated files depends on the time stamps of the checkout.

3. The README understates the side effects on a developer's checkout. Confirmed: README.md#L119-L120. Step 1 uses --preclean; step 6 leaves .Rconfig and the objects built with pkgbuild's flags, so the next normal build recompiles all 28 files; src/ext-http.o is deleted on exit. The git tree stays clean, since those files are ignored. Suggested fix: say that it overwrites any existing in-place build of src/ and that the next build compiles everything, or advise running it in a throwaway worktree, as the record itself did.

4. The record is stamped "at commit 3b7bea3", but run from this branch the script prints "commit 66591de". Confirmed: README.md#L8. The two commits differ only in experiments/ and the .Rbuildignore line, so the findings are unaffected. Suggested fix: say that the registry commit changes nothing under src/, or print git describe with a note on dirty state.

5. #836 links the record by the branch URL, blob/claude/experiments-reproducers/..., which stops resolving once the branch is deleted after merge (by reading). Suggested fix: link a commit-pinned URL, or blob/main/... after merging.


Generated by Claude Code

The driver wrote each build's output only to a log in a temporary directory,
and the exit trap deleted that directory before anyone could read it.
A failed build now prints the step and the last 30 lines of its log to stderr before the driver restores its files and exits.

The README now says what the driver needs and that it is Linux only as written.
It also says that the driver overwrites an in-place build of `src/`,
that the record was measured at 3b7bea3 and a run from this branch prints a later commit,
and that step 1 may not list `cpp11.dd` in a fresh checkout.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Hr1rd3gjmufoKCWVDBPCgE

krlmlr commented Nov 11, 2026

Copy link
Copy Markdown
Member Author

Review of the fixes at a483418 (the commit after 66591de), by a Claude Code reviewer with clean context that read the first review, the diff 66591de5..a4834183 and the whole of run.sh as it now stands; ran the real run.sh with a deliberate syntax error appended to src/vendor/extensions/http.c (default, MAKEFLAGS=-j8, and CCACHE_DISABLE=1 MAKEFLAGS=-j4), a copy of the script that injects the same error just before step 6 (the pkgbuild::compile_dll() build), as is and with a candidate fix, and an unmodified run.sh on a clean tree; and posted nothing itself. After every failing run the vendored file was back to what it was before, with a clean git status. Environment: GCC 13.3, R 4.5.3, pkgbuild, ccache. "Confirmed" means reproduced by running code.

What holds

  • Confirmed: a failure in step 1 with the error in http.c exits with status 1 and prints Step 1 failed: R CMD INSTALL ... and the last 30 log lines to stderr. The three compiler errors and the make: *** ... ext-http.o Error 1 line are in that tail, with or without ccache and -j, because ext-http.o is the last compile before the link and make stops at the first error.
  • Confirmed: the files are restored on failure: http.c is back to its content before the run, src/ext-http.o is gone, and the temporary directory is deleted.
  • Confirmed: a normal run still works (1m32 with a mostly warm ccache, exit status 0, nothing on stderr, git status clean), and its output matches the committed output.txt once time stamps and the commit id are masked.
  • Confirmed and by reading: the README's new sentences are accurate; Low 1, 3 and 4 of the first review are resolved in the README, and Low 2 by the sentence on time stamps. Low 5, the link in Incremental builds miss changes to bundled extensions under src/vendor/extensions/ #836, is outside this branch.

High

None.

Medium

1. The failure report can still miss the compiler error when the failing step is the pkgbuild build (steps 6 and 7). Confirmed: run.sh#L71-L80 prints tail -n 30 of the log. Step 6 runs Rscript -e 'pkgbuild::compile_dll(...)'; when that build fails, the log ends with the compiler output, ERROR: compilation failed, the removal message, R's error message and a 26-line Backtrace: from callr and processx. With a syntax error put into http.c just before step 6, the 30 printed lines were Step 6 failed: ..., stdout & stderr: <printed>, --- and the backtrace frames, with no error: line and no make: ***; the compiler error was in the log just above the printed tail, which is deleted a moment later. Suggested fix, tested: before the tail, print the log lines that carry the cause, and keep the tail as context:

    echo "Step $step failed: $*" >&2
    grep -E -A3 ': (fatal )?error|make: \*\*\*|^ERROR' "$work/$step.log" | head -n 30 >&2 || true
    echo "--- last 30 lines of the log:" >&2
    tail -n 30 "$work/$step.log" >&2

With this, the same step 6 failure printed http.c:580:1: error: unknown type name 'this', the two further error: lines, make: *** ... ext-http.o Error 1 and ERROR: compilation failed for package 'RSQLite', then the tail. A bare grep error would match the backtrace's error_on_status line, and \*\*\* alone matches the ************ of boost's static-assert warnings. The || true is needed because set -e -o pipefail is active and a log without a match would otherwise end the script inside the failure handler. An alternative that needs no pattern is to copy the log out before the trap removes it and print its path.

Low

1. The README says the driver "prints the step and the tail of its log", which stops being accurate with the Medium's fix. By reading: README.md#L128 and the comment at run.sh#L13-L14. Suggested fix: "the step, the log lines that report an error, and the tail of its log".

2. The README sentence on the commit stamp is slightly off. By reading: README.md#L126-L128 says that "the branch commit that adds the record changes nothing under src/, so running it from this branch prints that commit", but a run prints the current HEAD (here a483418), a later commit than the one that adds the record. The claim still holds, since the later commits touch only experiments/. Suggested fix: "so running it from a later commit on this branch prints that commit, with the same findings".


Generated by Claude Code

When the pkgbuild build of step 6 or 7 fails, the last 30 lines of its log are R's backtrace,
and the compiler error is just above them, in a log that is deleted on exit.
The failure handler of `run.sh` now prints the log lines that report an error before the tail,
separated from it by a line of its own.
The README and the header comment of `run.sh` say so.

The README also says that running the driver from a later commit on this branch prints that commit, with the same findings,
since those commits change nothing under `src/`.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Hr1rd3gjmufoKCWVDBPCgE

krlmlr commented Nov 11, 2026

Copy link
Copy Markdown
Member Author

Review of the fixes at c26fdef (the diff a4834183..c26fdefe, README.md and run.sh under experiments/2026-11-11-incremental-build-vendor/), by a Claude Code reviewer with clean context that read the second review, the full diff and all of run.sh, src/Makevars.deps and the README's replication section; ran run.sh unchanged in a fresh throwaway worktree at c26fdef (3m29 cold, then warm), and three modified copies of the script: A (a syntax error injected into src/vendor/extensions/http.c before step 1), B (the same before step 6) and C (a step 1 build that fails with a log without any error line); after each compared checksums and mtimes of http.c, ext-http.dd, ext-http.c and cpp11.dd with their values before the run, checked that src/ext-http.o and src/ext-http.d were gone, and ran git status; and posted nothing itself. "Confirmed" means reproduced by running code.

What holds

  • Confirmed: the second review's Medium is fixed for step 1. In run A the handler prints Step 1 failed: ..., then vendor/extensions/http.c:578:9: error: expected expression before ';' token with the source line and caret, then make: *** ... ext-http.o Error 1 and ERROR: compilation failed for package 'RSQLite', then --- last 30 lines of the log: and the tail; exit status 1.
  • Confirmed: the same holds for step 6 (run B): the error: line, the make: *** line and ERROR: appear above the pkgbuild backtrace.
  • Confirmed: set -euo pipefail does not end the script inside the handler when the log has no matching line (run C): the header, the separator, the log and exit 1 all came out. By reading, || true also covers grep being killed by SIGPIPE when head -n 30 closes the pipe.
  • Confirmed: after A, B and C the files had identical checksums and mtimes, the object files were deleted, the temporary directory was removed after the log was printed, and git status was clean.
  • Confirmed: in a fresh worktree, where the gitignored src/.Rconfig does not exist, a first run matches output.txt apart from time stamps and the commit id, except that regenerated: cpp11.dd under step 1 is missing; a second run in the same worktree matches output.txt completely, including the .Rconfig: changed line.
  • By reading: the header comment, the comment above build() and the README sentence on failures agree with the code, and the README sentence on running from a later commit on this branch is true for the commits up to c26fdef.

High

None.

Medium

None.

Low

1. The README explains why the line regenerated: cpp11.dd can be missing, but not why the line .Rconfig: changed, ... can be. Confirmed: README.md#L131 is the only sentence about step-1 lines that vary, and it names only the .dd list. The .Rconfig: changed line comes from the rule in src/Makevars.deps#L15-L18, which compares R CMD config --all with the untracked src/.Rconfig and reports a change when that file is missing or differs; it does not depend on time stamps. In a fresh worktree there is no src/.Rconfig, so step 1 prints the line, and step 6 leaves an .Rconfig written with pkgbuild's debug flags, so a later run prints it again. The line is absent only when src/.Rconfig already matches plain R CMD config --all, for example after an earlier normal in-place build with the same R in a checkout that was not cleaned (by reading). The findings are not affected. Suggested fix: one sentence after L131 saying that whether step 1 prints the .Rconfig: changed line depends on whether src/.Rconfig exists and matches R CMD config --all, which it does not in a fresh checkout or after an earlier run of this driver, and that --preclean rebuilds every object either way.

2. In step 1 the "last 30 lines" block still shows mostly noise. Confirmed: run.sh#L77-L78. In run A the 30 lines are g++ template instantiation notes and -c command lines below the error. It does no harm, since the error is above it; the tail is the right fallback for an unrecognised failure such as the pkgbuild backtrace, so leaving it is reasonable.


Generated by Claude Code

The line depends on whether the untracked `src/.Rconfig` exists and matches `R CMD config --all`.
`--preclean` rebuilds every object either way, so the findings are unaffected.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Hr1rd3gjmufoKCWVDBPCgE

krlmlr commented Nov 11, 2026

Copy link
Copy Markdown
Member Author

Accepted limitations

The first clean review found one Medium and five Low issues, the second one Medium and two Low ones about those fixes, and the third nothing above Low. All are fixed up to 444b6b7, except the one below; the link in #836 now points at the record as of that commit. This remains:

  • run.sh#L74-L80: when a build fails, the driver prints the log lines that report an error and then the last 30 lines of the log, which in step 1 are mostly compiler notes below the error; the tail is kept as the fallback for a failure without a recognizable error line, such as R's backtrace from pkgbuild. Relevance: low; reviewer's confidence: high.
  • README.md#L111-L136: the driver needs bash and GNU tools on Linux, overwrites any in-place build of src/, and prints a few step-1 lines that depend on the state of the checkout (the regenerated .dd files and the .Rconfig line); the README says all of this, and none of it affects the findings. Relevance: low; reviewer's confidence: high. (recorded)

Generated by Claude Code

@krlmlr

krlmlr commented Nov 13, 2026

Copy link
Copy Markdown
Member Author

Fix in an idiomatic way. Either a minimal change in the generation of the .dd files or perhaps by changing upgrade.R to touch the relevant src/*.c .

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants