Repository navigation
Description
Summary
Bring with.toml parsing up to the declarative project-build surface in §18.5a. The goal is not to move build logic into TOML; it is to support the spec's allowed declarative keys while continuing to reject imperative build behavior loudly.
Spec
§18.5a says with.toml is declarative package configuration and imperative build concerns belong in build.w (docs/with-specification.md:9638). Allowed entries include package identity, dependencies and version constraints, target defaults and feature flags, C include paths/defines/link libraries/search paths, and publishing/lint/runtime policy (docs/with-specification.md:9642). Conditionals, generated-file steps, custom shell commands, target graph construction, and multi-binary behavior are not allowed in TOML (docs/with-specification.md:9650). Build targets must honor per-target link_system_lib, include_path, and define settings (docs/with-specification.md:9692).
Current state
ProjectConfig stores package identity, C include paths, defines from dependency metadata, link search paths, dependency link libs, no_std/alloc/runtime, and overflow mode (src/compiler/ProjectConfig.w:5). Direct parsing handles project/package name and version, std, alloc, runtime, [build].overflow, [c_import].include_paths, [link].search_paths, and [deps].c.* (src/compiler/ProjectConfig.w:114). project_config_wants_key does not recognize feature flags, target defaults, direct [c_import].defines, direct [link].libs, or dependency version-constraint forms beyond a string value (src/compiler/ProjectConfig.w:249). Forbidden imperative sections are already rejected (src/compiler/ProjectConfig.w:264). The gap is missing allowed declarative keys, not missing rejection of imperative build scripts.
Implementation plan
- Extend
ProjectConfiginsrc/compiler/ProjectConfig.wwith fields for direct link libs, direct C defines, feature flags, and target defaults. Prefer typed storage rather than raw TOML snippets. - Add parsers for
[c_import].defines,[link].libs, target defaults, and feature flag tables toproject_config_apply_entry; updateproject_config_wants_keyso recognized allowed keys are parsed rather than ignored. - Decide and document the exact TOML shapes in tests and comments. For example:
[features] default = ["x"],[target] default = "native"or equivalent, and[link] libs = ["sqlite3"]matching §16.8. - Thread direct link libs into
Compilation.emit_*andLink.wbeside dependency link libs.Compilation.compile_file_to_objectalready consumesproject_configfor build settings; keep direct TOML link libs separate from package-derived libs so diagnostics can name the source. - Preserve the existing forbidden-key policy. If a key looks like imperative build behavior,
project_config_forbidden_entryshould still produce a manifest error instead of ignoring it. - Add
--dump-project-info/check coverage for every parsed field so tests can assert the resolved config without invoking a full build.
Test plan
Add behavior tests for config parsing, likely test/behavior/behav_with_toml_declarative_keys.w or a CLI harness fixture, covering direct [link].libs, [link].search_paths, [c_import].include_paths, [c_import].defines, package identity, feature flags, target defaults, and version constraints. Add negative fixtures for [scripts], command, generated-file steps, and target graph behavior still failing with the current manifest-error wording.
Acceptance criteria
- All §18.5a allowed declarative keys parse into
ProjectConfigor fail loudly with an explicit unsupported-key diagnostic if the implementation intentionally defers a sub-surface. [link].libscontributes linker libraries; direct[c_import].definescontributes c_import cache/input configuration.- Imperative TOML remains rejected.
- Config behavior is covered without relying on a full build as a probe.
with build && with build :fixpoint && with build :testpass.
Dependencies
Overlaps #548 for [link].libs specifically and #403 for [runtime] keys.
Traceability
From the requirements campaign (docs/requirements.md, spec v7.1). Affected requirement IDs: 18.5.2.6, 18.5.2.7, 18.5.2.8.
Activity
ehartford commentedon Jun 11, 2026
Implemented in 4a69507. with.toml now parses the declarative Phase 1 configuration surface for direct c_import defines, direct link libs, feature declarations/defaults, dependency version constraints, and target defaults. Direct [link].libs are threaded into binary link plans, c_import defines feed header processing, target defaults are applied before loud non-host rejection, and imperative target/build behavior remains rejected. Added project self-host coverage for positive parsing, c_import define propagation, link-lib propagation, target defaults, invalid targets, and imperative TOML rejection. Verification passed: build, fixpoint, full test suite, and test-green.