Skip to content

fix(toolchain): list '*' reflects effective project-aware toolchain#140

Merged
Sunrisepeak merged 1 commit into
mainfrom
fix/toolchain-effective-resolution
Jun 21, 2026
Merged

fix(toolchain): list '*' reflects effective project-aware toolchain#140
Sunrisepeak merged 1 commit into
mainfrom
fix/toolchain-effective-resolution

Conversation

@Sunrisepeak

Copy link
Copy Markdown
Member

Problem

A user saw mcpp toolchain default / mcpp toolchain list report gcc@16.1.0
as the default (the *), yet mcpp run resolved and used gcc@15.1.0-musl.
Three views of "the toolchain" disagreed.

Root cause

mcpp toolchain default <spec> writes, and mcpp toolchain list's * reads,
only the global config.toml [toolchain] default. But the build-time
resolver (src/build/prepare.cppm) reads the project mcpp.toml [toolchain] first — it shadows the global default entirely (and [target.*]
overrides shadow it further). So inside a project that declares [toolchain],
list's * (global) and what mcpp run resolves (project) can point at
different toolchains. They are genuinely different sources of truth.

Fix

Add effective_default_toolchain(cfg) — resolves the toolchain the same way a
build in the current directory does (project mcpp.toml [toolchain] for the
current platform, else global config default). mcpp toolchain list now marks
* on the effective toolchain and prints a one-line note when it comes
from the project, e.g.:

  *  gcc 16.1.0   ...
  (* = effective toolchain from project mcpp.toml [toolchain]; global default is 'gcc@15.1.0-musl')

--target overrides are intentionally not folded in (they only apply with an
explicit --target).

Test

  • mcpp build + mcpp test green (22 passed).
  • Live: in this repo (which has [toolchain] default = "gcc@16.1.0"), list
    now stars gcc 16.1.0 with the explanatory note — matching what mcpp build
    resolves.

Part of the 5-PR follow-up batch (.agents/docs/2026-06-22-mcpp-followups-design.md).
Note: the ABI-mismatch error already suggests both mcpp toolchain default and
[toolchain] in mcpp.toml, so no change needed there.

`mcpp toolchain default` and `mcpp toolchain list`'s `*` marker read only
the global config.toml [toolchain] default, but the build resolver
(prepare.cppm) reads the project mcpp.toml [toolchain] FIRST — it shadows
the global default. So in a project with a [toolchain] section, `list`
could mark `*` on a different toolchain than `mcpp run` actually resolves
(the reported gcc@16.1.0-vs-gcc@15.1.0-musl divergence).

Compute the effective default the same way a build does (project
mcpp.toml [toolchain] for the current platform, else global config), mark
`*` on it, and print a note when it comes from the project so it never
silently disagrees with the build. --target overrides are not folded in
(they only apply with an explicit --target).
@Sunrisepeak Sunrisepeak merged commit 48cec33 into main Jun 21, 2026
3 checks passed
@Sunrisepeak Sunrisepeak deleted the fix/toolchain-effective-resolution branch June 21, 2026 20:04
Sunrisepeak added a commit that referenced this pull request Jun 21, 2026
* fix(build): self-heal stale build.ninja on 'missing and no known rule'

When a dependency package under the registry is reinstalled/moved but keeps
the same version string, the build fingerprint (which does not yet cover
registry dep state) is unchanged, so the cached build.ninja is reused.
Ninja then aborts with 'missing and no known rule to make it' and the build
hard-fails, forcing the user to run `mcpp clean` by hand.

Add that signature to is_stale_ninja_failure so try_fast_build drops to a
full graph regeneration (same invocation) instead of failing — the stale
graph is rewritten against the current dep state and the build proceeds.

(Folding registry dep state into the fingerprint to avoid the regen entirely
is a larger follow-up; see .agents/docs/2026-06-22 §T-j.)

* chore: bump version 0.0.57 -> 0.0.58

Release carrying the follow-up batch: scanner raw-string fix (#138),
first-run progress (#139), toolchain effective-resolution (#140),
doctor runtime-dep check (#141), and the build.ninja self-heal above.
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.

1 participant