Skip to content

with.toml: feature flags, target defaults, defines/link-libs, version constraints (§18.5a) #450

Closed

Description

@ehartford

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

  1. Extend ProjectConfig in src/compiler/ProjectConfig.w with fields for direct link libs, direct C defines, feature flags, and target defaults. Prefer typed storage rather than raw TOML snippets.
  2. Add parsers for [c_import].defines, [link].libs, target defaults, and feature flag tables to project_config_apply_entry; update project_config_wants_key so recognized allowed keys are parsed rather than ignored.
  3. 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.
  4. Thread direct link libs into Compilation.emit_* and Link.w beside dependency link libs. Compilation.compile_file_to_object already consumes project_config for build settings; keep direct TOML link libs separate from package-derived libs so diagnostics can name the source.
  5. Preserve the existing forbidden-key policy. If a key looks like imperative build behavior, project_config_forbidden_entry should still produce a manifest error instead of ignoring it.
  6. 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 ProjectConfig or fail loudly with an explicit unsupported-key diagnostic if the implementation intentionally defers a sub-surface.
  • [link].libs contributes linker libraries; direct [c_import].defines contributes 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 :test pass.

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

  1. ehartford commented on Jun 11, 2026

    @ehartford
    ContributorAuthor

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions