Skip to content

toolchain, llvm: test that one package builds hello-world (#805's intent, per arch#183) - #1557

Open
bryan-minimal wants to merge 2 commits into
mainfrom
toolchain-hello-world-tests
Open

bryan-minimal wants to merge 2 commits into
mainfrom
toolchain-hello-world-tests

Conversation

@bryan-minimal

@bryan-minimal bryan-minimal commented Nov 18, 2026 •

Copy link
Copy Markdown
Member

Carries the intent of #805: one package should be enough to build hello-world. It doesn't take #805's approach, which the registry spec now rules against.

#805 added binutils and linux_headers to the gcc/llvm runtime_deps (and toolchain to rust's). gominimal/arch#183 (D-25, build §3) instead gives a compiler package only its own parts, and has the toolchain group supply the assembler, linker, libc and kernel headers. So the "one package" is toolchain, and this PR makes that a tested promise:

test what it proves #805 case
toolchain hello_c cc compiles, links (binutils) and runs C with only the group plus bash and coreutils gcc h.c: cannot execute 'as'
toolchain hello_cxx_linux_headers g++ with <linux/types.h> header not found
llvm hello_clang_toolchain plain clang h.c through the system ld, with toolchain as a test dep clang link failure
(already on main) rust default_linker_rustc / _cargo rustc and cargo with toolchain as a test dep linker 'cc' not found

I rendered the test sources locally from the Nickel strings, through the shell printf, to check the escaping. Nothing was compiled here; build-bot runs the tests.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Tests
    • Added standalone checks for compiling and running C programs with the toolchain, including programs that use Linux and standard I/O headers.
    • Added coverage confirming C++ programs can include Linux type definitions and produce the expected output.
    • Added a check that plain Clang can compile and run a C program using Linux and standard I/O headers.

… intent)

pkgs#805 wanted a box with one compiler package to build hello-world,
and did it by adding binutils and linux_headers to the compilers'
runtime_deps. The registry spec (gominimal/arch#183) rules the other
way: a compiler names only its own parts, and the `toolchain` group
supplies the assembler, linker, libc and kernel headers.

So the promise moves to `toolchain` and is now tested:
- toolchain hello_c: `cc` builds and runs a C program with only the
  group and a shell;
- toolchain hello_cxx_linux_headers: `g++` with <linux/types.h>, #805's
  missing-header case;
- llvm hello_clang_toolchain: plain `clang h.c` (the system ld,
  #805's clang case) with `toolchain` as a test dep, as rust's
  default_linker tests already do.

Tests are not in the spec hash, so nothing rebuilds. gcc already
installs `cc`. gcc's "TODO: Some of these need to be runtime_deps"
comments are left for after gcc 16 (#1545), which rewrites that recipe.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@bryan-minimal
bryan-minimal requested a review from a team as a code owner November 18, 2026 02:46
@coderabbitai

coderabbitai Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The toolchain package adds standalone C and C++ tests. The LLVM package adds a standalone Clang test that uses toolchain as a test dependency.

Changes: Compiler test coverage

Layer / File(s) Summary
Toolchain C and C++ tests
packages/toolchain/build.ncl
The module imports test utilities and adds comments describing the package. It adds standalone tests that compile and run C and C++ programs, then check their exact output.
Clang test with toolchain
packages/llvm/build.ncl
A standalone test uses plain Clang to compile a C program and check its output. The test depends on toolchain.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related issues

Possibly related PRs

  • gominimal/pkgs#805: Both PRs add compiler hello-world test coverage. PR #805 changes runtime dependencies, while this PR uses toolchain as a test dependency.

Suggested reviewers: norrietaylor, msample

Merge Risk: Minimal · up to 06c85

This change adds compile-and-run smoke tests for the toolchain and clang packages without altering shipped packages or their dependencies. No concrete merge-blocking risk was found; CI will confirm the tests pass on both architectures.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title names two packages (toolchain, llvm) and a test addition, which matches the changeset: new standalone C, C++, and clang smoke tests in packages/toolchain/build.ncl and packages/llvm/build.nc…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names two packages (toolchain, llvm) and a test addition, which matches the changeset: new standalone C, C++, and clang smoke tests in packages/toolchain/build.ncl and packages/llvm/build.ncl. The parenthetical references (#805, arch#183) add context but do not describe the change. The title is long (87 characters) and uses an internal issue reference, but it still identifies the primary change.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 6897a07 and 06c85c7.

Files selected for processing: 1

  • packages/toolchain/build.ncl

Included review availability: This review used your included allowance. 0 included reviews remain after this review. Your included PR review attempts over the past 7 days set your current allowance at 1 review per hour.

@norrietaylor norrietaylor left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Scope matches the title. The diff adds three tests and two comments, and it changes no runtime_deps. Clobber none: git log on both files shows no recent fix reverted. Correctness one defect: hello_c runs cc, and no package in this tree installs cc. The PR body says that gcc installs cc on main. packages/gcc/build.sh:80 still has that symlink commented out at this head. The printf escaping in all three tests renders to valid C and C++ when I trace it by hand. The clang test follows the existing hello_clang_lld test, which already finds the GCC installation. Not checked: no test ran, because that needs a build. The CLI version was not readable in this sandbox.

Comment thread packages/toolchain/build.ncl Outdated
class = 'Standalone,
test_deps = [bash-bootstrap, coreutils],
cmds = [
["/bin/bash", "-c", "printf '#include <stdio.h>\\nint main(void){puts(\"hello c\");return 0;}\\n' > h.c && cc h.c -o h && [ \"$(./h)\" = 'hello c' ]"],

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium · hello_c runs cc, and no package in this tree installs cc. The comment says "gcc installs it", and the PR body says the same about main. packages/gcc/build.sh:80 still has the symlink commented out under a # TODO, and rg finds no other usr/bin/cc in packages/. The test will fail with cc: command not found when build-bot runs it. The rust default_linker_* tests do not prove cc exists, because bootstrap.toml sets default-linker = "gcc". Add the cc symlink to gcc (this rebuilds gcc), or call gcc here and correct the comment. This is the only cc call in a test in the repo. Not checked by a build.

hello_c =
{
class = 'Standalone,
test_deps = [bash-bootstrap, coreutils],

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit · Both toolchain tests list coreutils in test_deps, and the commands use only bash builtins (printf, [) and the compiler. The comment above says "nothing beyond the group and a shell". The rust default_linker_rustc test at packages/rust/build.ncl:99 uses [bash-bootstrap, toolchain] with no coreutils. Drop coreutils from lines 32 and 42 and its import, so the test proves the one-package promise. If the compiler driver needs it, say so in the comment.

The standalone test failed on both arches: `cc` does not exist
(packages/gcc/build.sh leaves the link as a TODO).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@norrietaylor norrietaylor left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Scope matches the title. The diff adds three standalone tests and two comments. It changes no runtime_deps, build_deps, cmd or outputs, so no closure grows.

Clobber none. git log on both files shows no recent fix reverted.

Correctness I rendered the three test sources by hand through the Nickel and printf escaping. Each gives valid C or C++ and the expected output string. The second commit replaced cc with gcc in hello_c, and the comment now agrees with packages/gcc/build.sh:80. That answers the earlier cc thread. The bare gcc and g++ calls follow the lua tests, which do the same with toolchain as a test dep. packages/claude/build.ncl is a second cmd = "" package with tests. packages/llvm/build.sh sets no CLANG_DEFAULT_LINKER, so plain clang h.c links through ld from binutils, and hello_clang_toolchain fails without toolchain.

Two items are not findings here. The open thread on coreutils in the toolchain test_deps still applies at lines 32 and 42, and the comment at line 27 still says "nothing beyond the group and a shell". The PR body still says that gcc installs cc and that hello_c runs cc. Correct the body before the merge.

Not checked: the tests did not run, because that needs a build. The CLI version is not known, because the harness denied the command.

# linux_headers). A compiler package names only its own parts; a box that compiles
# lists `toolchain` (gominimal/arch#183: the group supplies binutils and the headers,
# not each compiler's runtime_deps). pkgs#805 asked for "add one package, build
# hello-world"; this is that package, and its tests are that promise.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit · The last sentence of the header comment tells the story of the issue, not what the package is. The sentences before it already say what toolchain supplies and why. Delete the sentence, or keep only a short pointer to the tests. The comment at line 37 has the same #805 narration in a smaller form. The llvm comment is acceptable, because it explains the test dep choice.

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