cmd: build local package graphs

This commit is contained in:
2026-08-11 22:26:07 +09:00
parent db96422f74
commit 52f6d6f0d4
6 changed files with 1316 additions and 510 deletions

View File

@@ -2770,6 +2770,59 @@ The replacement deletes these concepts rather than emulating them indefinitely:
There will be no compatibility alias that silently translates an old import,
interface, workdir, or link search into the new model.
### 11.6 Implemented local package slice
The first executable package slice is intentionally smaller than the final
module design above. It is local, offline, and manifest-free. The supported
form is:
```sh
out/bin/ww build -I /work/acme -o app /work/acme/cmd/app
```
Every selected source uses the existing syntax:
```ww
package main;
import lib.math;
```
An import is translated from dots to path separators and resolved, with
directory packages preferred, through the entry package's directory, explicit
`-I` roots in command order, and the toolchain source-library root. There is no
network or manifest fallback. The loader uses the compiler frontend's
imports-only parser, unions duplicate imports, byte-sorts direct edges, interns
resolved directories by filesystem identity, and reports self-imports and
stable cycle chains before compilation.
A directory package consists of its immediate regular non-symlink `.ww` files,
excluding `*_test.ww`, in byte-sorted filename order. Every selected file must
declare the same package. An imported directory's declared package must equal
the final component of its import path; two logical identities for one physical
directory are rejected rather than compiled twice.
Packages compile serially in dependency-first postorder. The compiler emits the
existing deterministic `.wwi` interface for every importable package and only
exported declarations enter that interface. A source qualifier is visible only
when its owning package directly imports it; private members and transitive-only
qualifiers are compiler errors. For compatibility with public signatures that
name deeper types, composed compiler units still carry transitive interface type
facts for internal resolution, but those facts do not create source-visible
bare names, package qualifiers, or value bindings. Replacing that
source-like closure with a self-contained typed export encoding remains part of
the later export-format work, not package-loader semantics.
An ordinary root is linked with the full reachable object closure into the
requested executable (legacy WW programs may use a package name other than
`main`). `ww build -p -o lib.a DIR` explicitly requests a non-main package
product: it emits a deterministic archive at `lib.a` and its compiler interface
at `lib.a.wwi`, without invoking the linker. A logical target retains its full
identity (`ww build -p -I ROOT -o bar.a foo.bar` emits `foo.bar.*` symbols),
while a literal directory uses its declared leaf package. Package output
requires a directory and `-p` cannot be combined with assembly-only `-S`. Two
cold builds with identical inputs are required to produce byte-identical
requested products.
## 12. Candidate architectures and hard-gate decision
Five candidates were developed as coherent systems, not as feature bins.