Skip to content

toolchain: the target's convention pin silently overrides an explicitly-set default toolchain, and toolchain list still reports the ignored one #283

Done

Description

@Sunrisepeak

Setting a default and then building disagree about which toolchain is in effect, with nothing said either way.

$ mcpp toolchain default gcc 15 --target x86_64-linux-musl
     Default set to [email protected] → x86_64-linux-musl (was: [email protected])

$ mcpp toolchain list
  *  gcc 15.1.0              (default)
  *  x86_64-linux-musl       static      gcc 15.1.0    installed

$ mcpp build
    Resolved [email protected] → x86_64-linux-musl → .../xim-x-musl-gcc/16.1.0/bin/x86_64-linux-musl-g++

Reproduced on 0.0.107 with ~/.mcpp/config.toml holding [toolchain] default = "[email protected]", default_target = "x86_64-linux-musl", and both musl-gcc 15.1.0 and 16.1.0 installed.

Cause

Once the target triple is known, the vocabulary tables convention pin replaces whatever tcSpec held — src/build/prepare.cppm:894:

if (known && !hasToolchainOverride && !known->pin.empty())
    tcSpec = std::string(known->pin);

x86_64-linux-musl is pinned to [email protected] (src/toolchain/triple.cppm:104), and hasToolchainOverride (prepare.cppm:854) is true only for a [target.X] toolchain = ... section in the projects mcpp.toml:

bool hasToolchainOverride = hasExplicitSection && !it->second.toolchain.empty();

The global config is not consulted — and the global config is exactly what mcpp toolchain default writes (lifecycle.cppm:690). So a users explicit choice never counts as an override and the pin always wins.

mcpp toolchain list reads the config directly instead (effective_default_toolchain, lifecycle.cppm:198/223), which is why it shows the value the build just discarded. Two code paths, two different notions of "the default".

Why it matters

The pin itself is well-founded — the comment in triple.cppm records that GCC 15 drops module template instantiations at link under musl — so silently preferring 16 is defensible. What is not defensible is doing it without a word while toolchain list presents the ignored setting as the default. A user has no way to tell the setting did not take, and --print-fingerprint / mcpp explain toolchain are not where they would look after running an explicit toolchain default.

Note the pins own comment (triple.cppm:93-95) scopes it to "--target <canonical> with no explicit ... override". Someone who ran mcpp toolchain default gcc 15 --target x86_64-linux-musl has made an explicit choice; the code just does not recognise that spelling of it.

Workaround

A per-project override does take effect:

[target.x86_64-linux-musl]
toolchain = "[email protected]"

→ Resolved [email protected] → x86_64-linux-musl → .../xim-x-musl-gcc/15.1.0/bin/x86_64-linux-musl-g++ (verified).

Directions

  1. Let an explicitly-set global default carry the same weight as [target.X] toolchain — the user asked for it by name, including the target.
  2. If the pin must still win (module-linking correctness is a real constraint), say so at resolve time: note: x86_64-linux-musl pins [email protected]; your default [email protected] was not used — and have toolchain list mark the pinned value as what will actually run.
  3. Either way the two paths should share one resolution function, so list and build cannot drift again.

Activity

  1. speak-agent commented on Nov 26, 2026

    @speak-agent
    Member

    Closing: the row's toolchain stays the choice, and it is no longer silent.

    • A global default does not outrank a row's pin. The reason is recorded in the source as a measured regression: the pin names the payload that supplies the target's C library.
    • The Resolved line says so: target default for <triple>, replacing your <default> — override with [target.<triple>] toolchain.
    • mcpp toolchain list lists each target with the toolchain it builds with.

    Read from source at 2026.11.26.1 (src/build/prepare/toolchain_resolver.cpp); the home of the report was not rebuilt.

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