Skip to content

build: Vendor the nanoarrow C library - #953

Draft
krlmlr wants to merge 4 commits into
claude/rb-split-parsersfrom
claude/rb-vendor-nanoarrow
Draft

krlmlr wants to merge 4 commits into
claude/rb-split-parsersfrom
claude/rb-vendor-nanoarrow

Conversation

@krlmlr

@krlmlr krlmlr commented Dec 1, 2026

Copy link
Copy Markdown
Member

No change of behavior: this vendors the nanoarrow C library and compiles it into the package, with nothing calling it yet, so that the Arrow layers further up the chain can build Arrow arrays. Landing the build change alone shows that the C sources compile and link everywhere before any code depends on them.

What changes:

  • src/vendor/nanoarrow/ holds nanoarrow.c, nanoarrow.h and nanoarrow.hpp of nanoarrow 0.9.0, the current CRAN release and the version build: Vendor the nanoarrow C library #857 used, plus LICENSE.txt, NOTICE.txt and a README.md that records the origin, the delta and how to update. The sources are byte-identical to src/ of nanoarrow_0.9.0.tar.gz except for line 30 of nanoarrow.h, #define NANOARROW_NAMESPACE RSQLite (upstream RPkg, marked with a comment), which prefixes every symbol so that it cannot collide with the copies in the nanoarrow or arrow packages. LICENSE.txt and NOTICE.txt are byte-identical to the release tag apache-arrow-nanoarrow-0.9.0. When later layers add the nanoarrow R package to LinkingTo/Suggests, its version can follow this one; nothing ties them together, since the prefixed symbols never meet.
  • src/Makevars links vendor/nanoarrow/nanoarrow.o next to the SQLite object, defines NANOARROW_DLL empty so that no nanoarrow symbol is exported, and makes the object depend on nanoarrow.h. There is no Makevars.win, so Windows uses the same file. cleanup, cleanup.ucrt, cleanup.win and .Rbuildignore keep the object out of the tarball.
  • inst/COPYRIGHTS and inst/licenses/ install the Apache License 2.0 and nanoarrow's NOTICE with the package, so that binaries carry them, and list the terms of the other bundled code as far as the sources state them. DESCRIPTION gains Copyright: See file COPYRIGHTS. and the Apache Software Foundation as cph for the included nanoarrow sources. License: LGPL (>= 2.1) is unchanged, so there is no NEWS bullet. UPDATE.md lists nanoarrow as a third updatable component.
  • A new .covrignore keeps the unused library out of the coverage report.

The clang-format exclusions of #920 (src/vendor/** in .clang-format-ignore) cover the new directory as they are, and the style action only formats top-level src/* anyway, so nothing is added here for it.

Tested: R CMD INSTALL of this branch and its base; the shared object exports the same 131 dynamic symbols as the base, none containing "arrow", and grows by about 215 KB. nanoarrow.o defines only RSQLiteArrow* symbols and calls only memory and string functions from libc (no abort, printf, stderr or exit). nanoarrow.c compiles without a warning with gcc and clang under -Wall -Wextra -pedantic -Wstrict-prototypes for C99, gnu99 and gnu2x, and nanoarrow.hpp with g++ and clang++ for C++11 and C++17. Touching nanoarrow.h recompiles only that object. The package loads and works with the nanoarrow package in the same session, in either load order. R CMD build puts the six vendored files and the two licence files into the tarball and no object file; R CMD check --no-manual (run before rebasing onto the base's latest commit, which touches no build file) reports Status: OK, with "compilation flags in Makevars", "GNU extensions in Makefiles" and "compiled code" OK (tests without NOT_CRAN: FAIL 0, WARN 3, SKIP 30, PASS 1589). The full suite with NOT_CRAN=true on the head gives FAIL 0, WARN 4, SKIP 63, PASS 11457; three warnings are the known locale ones in test-encoding.R, and the fourth ("Unknown string format, NA is returned.") comes from test-out-of-memory.R:38 as changed in the base (cfb7c5c), not from this pull request.

Open questions carried over from #857, unanswered there, so their defaults apply here: whether to keep both copies of nanoarrow's LICENSE.txt and NOTICE.txt (next to the sources and under inst/licenses/; default: keep both, the update steps refresh both; #857 (comment)), and whether inst/COPYRIGHTS or License: should say that a build with nanoarrow is distributed under the LGPL 3 (default: leave both as they are; #857 (comment)). The question on extension-functions.c was resolved in #880 (the note in inst/COPYRIGHTS stays).

Layer R6 of the rebuilt chain, planned in #880; based on #952. Ported from #857 (draft).

Coordinating session: https://claude.ai/code/session_01Hr1rd7QnTD4acgzTUihnF4



Generated by Claude Code

Bundle nanoarrow 0.9.0 under src/vendor/nanoarrow/ and link it into the shared object, so that later changes can build Arrow arrays.
Nothing calls it yet.
The sources are those of the nanoarrow 0.9.0 CRAN package,
with NANOARROW_NAMESPACE set to RSQLite so that its symbols cannot collide with the copies in nanoarrow or arrow,
and -DNANOARROW_DLL= keeps them out of the exports.
The object depends on nanoarrow.h, the one edited file,
and cleanup and .Rbuildignore keep it out of the tarball.

The Apache License 2.0 and nanoarrow's NOTICE are installed under licenses/,
inst/COPYRIGHTS lists the terms of all bundled code,
and DESCRIPTION names the Apache Software Foundation as copyright holder and points to COPYRIGHTS.
src/vendor/nanoarrow/README.md records the origin, the delta and the update steps.

Ported from #857.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Hr1rd7QnTD4acgzTUihnF4
Nothing calls the library yet, so its lines would only lower the coverage figure.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Hr1rd7QnTD4acgzTUihnF4
@krlmlr
krlmlr added this pull request to stack #928 December 1, 2026 04:21

krlmlr commented Dec 1, 2026

Copy link
Copy Markdown
Member Author

Question: keep a single copy of nanoarrow's licence and NOTICE?

Carried over from #857's question, which nobody answered; this pull request ports #857 unchanged, so the default described below stands here too. The links below point at #857's lines.

nanoarrow's LICENSE.txt and NOTICE.txt exist twice: next to the sources in src/vendor/nanoarrow/, and under inst/licenses/, so that the installed package and binaries carry them. Step 3 of the update steps says to refresh both (src/vendor/nanoarrow/README.md#L17-L18). A copy forgotten in an update would go stale without notice.

  • Keep both copies, with the update step that refreshes both (recommended)
  • Keep only the copies under inst/licenses/ and point src/vendor/nanoarrow/README.md to them, or check in CI that the two copies are identical

Kirill decides. If nobody decides, both copies stay, and the limitation stays checked in the "Accepted limitations".


Generated by Claude Code

krlmlr commented Dec 1, 2026

Copy link
Copy Markdown
Member Author

Question: should inst/COPYRIGHTS or License: say that a build with nanoarrow is distributed under the LGPL 3?

Carried over from #857's question, which nobody answered; this pull request ports #857 unchanged, so the default described below stands here too. The links below point at #857's lines.

The clean review of 2026-11-29 raised this as a Low, for the maintainer to judge; it fails no CRAN check. RSQLite is License: LGPL (>= 2.1) (DESCRIPTION#L35), and this pull request bundles nanoarrow under the Apache License 2.0 (inst/COPYRIGHTS#L4-L16). The FSF considers the Apache License 2.0 incompatible with the GPL and LGPL version 2.x but compatible with version 3, so a binary that links both can be passed on under the LGPL 3 only, which (>= 2.1) permits. Neither file says so today. This session cannot give legal advice; the options only differ in what the package states.

A sentence in inst/COPYRIGHTS that a build including nanoarrow is distributed under the LGPL 3 or later, as the "or later" clause allows, costs one line and changes nothing for users of the source package. Changing License: to LGPL (>= 3) states it for the package as a whole, also for code that never touches nanoarrow, and shows in CRAN's metadata. Leaving it relies on recipients reading the two licences together.

  • Add one sentence to inst/COPYRIGHTS that a build including nanoarrow is distributed under the LGPL 3 or later (recommended: states the effect where the licences are listed, and nothing else changes)
  • Change License: to LGPL (>= 3)
  • Leave both files as they are

Kirill decides, as the maintainer and licensor. If nobody decides, both files stay as they are.


Generated by Claude Code

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