Skip to content

Evaluate Kbuild with the selected toolchain - #88

Open
tamird wants to merge 89 commits into
hermeticbuild:mainfrom
tamird:codex/older-kernel-dynamic-graph
Open

tamird wants to merge 89 commits into
hermeticbuild:mainfrom
tamird:codex/older-kernel-dynamic-graph

Conversation

@tamird

@tamird tamird commented Sep 25, 2026

Copy link
Copy Markdown

Kernel configuration and build planning need to use the compiler Bazel actually selects. This moves them into declared actions, uses the selected kernel's native Kconfig implementation, and expands source-selected Kbuild through map_directory into individual build actions.

Includes Tim's work from #83 and the work needed for Aya's source-built kernel matrix: older Kbuild evaluation, declared LLVM tool paths, Linux 5.10 example coverage, and native configuration artifacts shared with kernel and module builds.

The combined change requires Bazel 9 and the linux-kbuild-* C/C++ toolchain action contract. The README documents the linux_images API, fixed outputs, toolchain patch, and limits on cross-configuration reuse. Linux 5.10 remains example coverage outside the maintained 6.12/6.18 catalog.

Prepared with assistance from Codex.

@tamird
tamird force-pushed the codex/older-kernel-dynamic-graph branch from 2850402 to cb77f3e Compare September 27, 2026 11:50
Carry source-selected compiler queries through bounded guard discovery and
fresh replay; derive content-addressed config capsules and retain conservative
inputs whenever complete source/compiler dependency coverage is unavailable.

Add real GCC/Clang family, intrinsic, macro-diagnostic and module metadata
coverage, plus SONiC and QEMU matrix wiring and unchanged reuse regression gates.
Include the optional-definedness BUILD formatting correction.

This is an incomplete draft checkpoint: actual four-kernel and SONiC builds
pass, but base/LZ4 sharing is only 5/1240 compiler nodes and the reuse gate fails.
Planning latency and the remaining full CI matrix still need work. No release
or merge is intended.
Pin twelve pre-refactor request and ordered-dependency identities across literal, symbolic and source-shell inputs. Preserve the single-use construction path without an extra deep copy; reusable contexts own their mutable request data.

This is groundwork for discovery context transport, not a serialized handoff or a performance completion claim. Both Bazel root suites pass with the local nested-output-base test excluded.
Reproduced the ARM64 nVHE CI failure with the exact KVM allnoconfig: the literal ../fpsimd.S operand did not match its canonical source edge. Normalize only literal positional path identities before optional probe construction, preserve option/placeholder ownership, and keep the runner's exact occurrence check unchanged.

Both Bazel root suites pass locally (177 tests each, nested-output-base test excluded). The real Clang KVM build now passes the initial probe stage; full kernel/matrix and performance validation remain pending. Temporary example reproduction edits are excluded.
Keep one copy of the LLVM, GCC, and libbpf patches and symlink each
consumer's patch files to it. Bazel requires these override labels to
belong to the root module [1].

Use the canonical patch files in CI repository-cache keys.

[1]: https://bazel.build/rules/lib/globals/module#single_version_override
4d4621b made the mapped-kernel source fixture a root-only development
dependency, so selecting its internal test from the e2e module cannot
resolve that repository. Keep the test in the existing root //... suite
and remove the invalid e2e invocation.
055d9da limits the initial guard pass to root Make continuations. Rust
can encounter a compiler-dependent DTB include only after entering a
selected child, where ordinary discovery rejected it. Measure these later
guards in the existing paired source/feature rounds and replay their
authenticated results before final lowering, retaining final rejection
for unmeasured guards.
055d9da tracked source recipe lines in a parallel command-index slice.
Removing directory setup or stale-output cleanup changed the command
count, so the identity check rejected otherwise valid recipes. Carry
each immutable recipe snapshot with its command through normalization.
055d9da only lowers a local PHONY check after its recursive children.
Linux 6.12 checks Rust availability before entering rust/, so retain a
private completion for that source line and order later children after
it. Keep the enclosing target completion after all children, and bind the
check to its frozen source frontier without publishing a synthetic file.

Distinguish direct recipe calls from recursive prerequisite completions
when matching children, retaining both as ordering dependencies. Isolated
checks may retain exported MAKE through a deny-all proxy but cannot replay
the enclosing target's children. Checkpoint the resulting actions and
sequence edges, not the temporary selection keys used during lowering.
The bounded source-word matcher from b3a1300 handles whole-group
strip but not filter-out. ARM compiler requests filter out -pg, so
requests exceeding the exhaustive-rendering budget retain unrelated
scripts/recordmcount.c and fail the exact source-operand check.

Treat whole-group filter-out as deletion-only when each Make word is
shell-complete. Retaining the unfiltered words is conservative; quoted
or escaped whitespace still makes the result unknown. Exercise the
filtered captured request and preserve both present and absent words
in the existing bounded matcher regression.
Rust filename and option probes can inherit srctree from the selected
Make environment. Their requests name the Linux source root but omit
its declared Kconfig anchor, so action construction rejects the Rust
filename probes reached by Linux 6.18.

Return the anchor with the environment that requires it and carry it
into both request kinds. Their existing environment regressions now
check the root and its declared source together.
The causal traversal in 055d9da captures native prerequisites only
for a grouped recipe's triggering target. Its peers may declare other
prerequisites, and comparing this target-local provenance as shared
recipe context rejects the Linux dm-verity grouped outputs.

Capture each peer's declared prerequisites against the completed
prerequisite frontier. Validate and bind them through the logical peer
while retaining the triggering target's recipe and automatic variables.
Exclude only this target-local field from the shared context comparison;
the grouped action still depends on every peer's selected producers.
Extend the existing goal-order regression through action planning with
a prerequisite declared only by the second peer.
The causal planner in 055d9da infers parent PHONY prerequisites only
during final lowering. Early input selection can therefore bind an
external module's future modules.order to the earlier outputmakefile
cleanliness check and create a cycle.

Capture completed control targets in the source traversal and carry
them into recursive invocation identity. Use the same provenance for
early input selection and final sequence edges; a parent target enters
this set only after its own children finish. Keep Makefile identities
source-relative so these checks authenticate under Bazel's relative
external source roots. Exercise the producer through action planning,
including the completed check's edge to the module build.
With a relative source root named kernel, the root replacement helper
from a398822 matches the name inside ${tree:kernel}. Normalizing a
selected recursive command repeatedly then nests tree markers and breaks
its source-authenticated replay identity.

Skip existing action placeholders and protected source literals when
replacing physical roots. Extend the relative-root regression to cover
short root names, already canonical paths, and literal tree spellings.
Large directory copies need a parameter file without losing Bazel's
path mapping for typed File operands. Accept explicitly selected
multiline @files alongside the existing strict JSON transport, sharing
its bounded regular-file reader. Preserve each argument verbatim,
including spaces in source paths.
Native extraction overwrites Linux files whose names differ only by
case, including netfilter headers and C sources. Preserve both members
of the verified archive pairs before extraction, and carry one logical
to physical mapping into source runfiles, planners, probes, and module
SDKs. The existing tools/Build relocation uses that mapping too, so its
Makefile no longer needs rewriting.

Translate patch filename metadata while leaving hunk bytes and patch
application to Bazel's native patcher. Keep original file labels through
aliases and directory labels through lazy Linux directory views. Document
the runfiles-link and remote-download requirements for clients that
cannot materialize the logical tree themselves.
Rust proc-macro output names come from compiler probes. Their symbolic
paths made command selection retain bookkeeping references as execution
occurrences and drop surrounding wrapper effects.

Record whether a symbolic branch or transformation actually hides a
command selection. Keep exact wrapper replay when only its data remains
symbolic, while preserving discovery of unresolved command branches.
a398822 lowered scalar deferred queries directly to argv without the
root conversion used by compound queries. Linux 6.12's bindgen parameter
queries therefore passed a literal source-tree marker to grep, even
though the source file was declared as an input.

Convert the captured command before either lowering path and finalize
typed roots after protecting literal dollars. The argv path can then bind
source operands to their declared files while preserving query-time
exports and literal shell data.
Linux 6.12's Rust availability check runs in a private working directory,
but its library source export remains execroot-relative and its opaque
reads do not declare the Rust source closure.

Project observed independent source exports through their declared
namespace into immutable input trees. Bind those roots with typed File
anchors and carry their source closure in family and ordinary mapped
actions, including external modules. Leave unused global exports out of
that closure and reject ambiguous namespace bindings.

Extend source-check coverage to retain the declared tree during planning
and read its bytes after the runner changes working directories.
a398822 treated source-root operands as script invocations, routing
Linux 6.12's bindgen-parameter grep through a scalar substitution that
rejects its argument list. Recognize script positions with the existing
command and shell parsers so data operands reach the immutable-source
query grammar, preserving conservative ownership when parsing fails. The
existing query test omitted the production source-root alias.
055d9da proved outputmakefile's private effects only for the kernel
source root, so Linux 6.18 external module planning fell through to the
single-effect PHONY path and failed. Share frozen recipe expansion
between selection and lowering, retaining the invocation directory and
exact source subtree in the effect receipt.

Keep srcroot immutable before expanding the cleanliness guard and
Makefile writer: generated modules.order in the writable overlay is not
source dirt. Allow the symlink effect to name a validated source subtree
and check that exact destination in the runner. Existing setup coverage
exercised only the kernel root; extend it through checkpoint restoration
and execution in a module directory.
055d9da made object-tree reads follow the causal frontier but omitted
preconfigured SDK inputs. Linux external modpost consequently treated
Module.symvers as absent and dropped its kernel symbol imports. Include
the declared object tree's frozen file index in every evaluation view,
loading bytes on demand while retaining selected-writer and config
precedence. Bind recipe reads through the existing exact SDK source
resolver so their bytes also reach the action's working tree. Native
Kconfig tool compilation starts with a fresh object tree; stop marking
its physical source-root stand-in as preconfigured. The external-module
fixture omitted upstream's wildcard check; cover it through action
lowering and keep native bootstrap source files out of the object view.
055d9da excluded bare operands from deferred-query input discovery.
ARM's KBSS_SZ query ran nm without vmlinux; its pipeline masked the
failure and returned zero for the decompressor's BSS size. Resolve
basenames only when present in the query's frozen object-file view,
retaining exact producer and working-path binding. The compression
regression previously covered only rooted and directory-qualified
inputs; it now checks a bare generated input through action lowering.
a398822 chose an ISO timestamp rejected by the hermetic BusyBox date
command. Linux catches that conversion failure and creates initramfs
entries with the current time. Use an epoch spelling accepted by the
selected runtime; explicit caller timestamps remain unchanged. Exercise
the default through the actual date tool in the existing execution test.
a398822 masked arithmetic expressions without visiting their nested
command substitutions. ARM's KBSS_SZ query therefore lost its nm input
and returned zero for the decompressor's BSS size. Discover those commands
while keeping arithmetic itself as argument data and preserving source
positions. The compression regression now covers arithmetic wrapping and
the transitive Image-to-vmlinux prerequisite path.
Native Kconfig omits disabled symbols that have no prompt. The switch
to native configuration in 4d4621b exposed this in the compiler
identity test, which required every unselected identity to be written
as n. Treat absent boolean identities as n while still rejecting an
absent selected identity or an explicitly empty value.
Linux 6.18 follows C compilation with force_checksrc, which expands to
@: when source checking is disabled. Command selection drops that
line, but target-wide lowering still compares its empty read set with
the compiler recipe and rejects modversions module builds.

Extend the existing single-line projection to omit inactive commands
only after proving that their complete Make expansion is pure. Retain
the active recipe’s own inputs and environment, and continue rejecting
incompatible executable lines or hidden Make effects.
Family actions repeat source IDs and execution-root paths for every
binding. In a Linux 6.18 CI sample, these bindings accounted for 259 KB
of a 268 KB argument vector, requiring six argument-chunk actions.

Use the input-set closure for source IDs and send bounded relative-path
packs anchored by typed source leaves. Factor out common directories,
retain explicit bindings for renamed files, and preserve the original
inputs and path mapping. The sample shrinks to 45 KB, below the existing
direct-argument budget.
Source-output probes stage and validate generated files. A Linux 6.18
probe copies 868 files, and this setup hit the 20-second process limit
in CI. Remove that limit and let build execution govern process lifetime.
Keep the ten-second limit on the measured recipe and the output-size cap.
@tamird
tamird force-pushed the codex/older-kernel-dynamic-graph branch from a4f6045 to 4c4e3aa Compare September 29, 2026 21:37
The Windows job reaches final family replay 99 minutes into a cold
build, then hits its two-hour limit before producing the kernels [1].
Allow three hours for Windows while retaining the macOS budget.

[1]: https://github.com/hermeticbuild/linux.bzl/actions/runs/36634471075/job/109632157898
23c3ff5 carries PHONY prerequisite completions into recursive
children. Keeping those ordering edges after their checks have run
in the execution cut makes config-independent actions inherit the
checks' full configuration.

Discharge unused ordering inputs from precise compilers and explicit
file actions after verifying the exact completed check and its absent
status receipt. Keep executed producers pinned and verify the final
cut; data uses and unexecuted checks retain their dependencies.
The measurements in 2a2ec3f came from a case-insensitive filesystem.
Extraction changed Perl pathname casing and omitted eight GCC headers
whose names differ only by case, so the resulting toolset identities
do not match Linux CI.

Record the Clang and GCC identities measured in CI on both supported
Bazel versions [1]. Keep the work counts and compiler-sharing floors.

[1]: https://github.com/hermeticbuild/linux.bzl/actions/runs/36634471078
@tamird
tamird force-pushed the codex/older-kernel-dynamic-graph branch from ebd5b31 to 104b965 Compare September 30, 2026 01:11
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