Skip to content

[link] libs key parsing (§16.8) #548

Closed

Description

@ehartford

Summary

Parse and honor [link].libs from with.toml. §16.8 already documents both libs and search_paths; the current parser only handles search paths.

Spec

§16.8 says libraries can be specified in with.toml with [link] libs = ["sqlite3", "ssl", "crypto"] and search_paths = ["/usr/local/lib"], or inline through c_import(..., link: ...) (docs/with-specification.md:8589). with build passes these to the linker (docs/with-specification.md:8606).

Current state

ProjectConfig has link_search_paths and dep_link_libs fields, but no direct link_libs field for [link].libs (src/compiler/ProjectConfig.w:5). project_config_apply_entry parses [link].search_paths only (src/compiler/ProjectConfig.w:148). project_config_wants_key likewise recognizes only search_paths under [link] (src/compiler/ProjectConfig.w:249). Compilation passes dependency link libs and link search paths into link planning (src/compiler/Compilation.w:859), so direct libs have no route to the linker.

Implementation plan

  1. Add link_libs: Vec[str] to ProjectConfig, initialized in project_config_default.
  2. Add project_config_parse_str_array or reuse a generalized array parser to parse [link].libs = ["sqlite3"] without resolving entries as paths.
  3. Update project_config_apply_entry and project_config_wants_key to accept section == "link" and key == "libs".
  4. Combine direct link_libs with package-derived dep_link_libs when constructing link plans in src/compiler/Compilation.w, preserving deterministic order: direct manifest libs first, then dependency libs, or document the chosen order.
  5. Include direct link libs in any project info dump so tests can assert parsing without requiring the host to have a specific library.
  6. Add diagnostics for malformed libs values instead of silently parsing an empty list.

Test plan

Add a config parsing behavior test with a fixture with.toml containing [link] libs = ["sqlite3", "m"] and search_paths = ["vendor/lib"], then assert dump/project info includes both libs and paths. Add a build-plan/link-plan test if available that proves -lsqlite3 or the platform equivalent reaches Link.w. Add a malformed TOML array test that fails loudly.

Acceptance criteria

  • [link].libs is parsed and stored.
  • Direct link libs reach the linker in deterministic order.
  • Existing [link].search_paths behavior is unchanged.
  • Tests cover parsing and link-plan propagation.
  • with build && with build :fixpoint && with build :test pass.

Dependencies

Overlaps #450, which tracks the broader §18.5a with.toml surface.

Traceability

From the requirements campaign (docs/requirements.md, spec v7.1). Affected requirement IDs: 16.8.1.1.

Activity

  1. ehartford commented on Jun 11, 2026

    @ehartford
    ContributorAuthor

    Implemented in 4a69507 and completed in the follow-up validator commit. [link].libs is now stored separately from dependency link libraries, included in project info dumps, threaded into binary link plans before dependency libs, and malformed non-array values fail loudly with a with.toml diagnostic. Added project self-host tests for parsing, link-plan propagation via a missing-library negative case, and malformed libs diagnostics. 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