Skip to content

Commit f481614

Browse files
2026.10.16.3: a configured toolchain for the host's own target is kept; gcc for a glibc target is the glibc payload on aarch64 (#813)
Co-authored-by: speak-agent <248744407+speak-agent@users.noreply.github.com>
1 parent 7b608ae commit f481614

8 files changed

Lines changed: 72 additions & 4 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,20 @@
44
> Each `## [<version>]` section is that release's notes. Entries are written in English
55
> from 2026.9.28.3 on; earlier entries remain as written.
66

7+
## [2026.10.16.3] - 2026-10-17
8+
9+
### Fixed
10+
11+
- Keep the toolchain the configuration names for this machine's own target.
12+
`[toolchain] default` with a `default_target` that is the host's triple (a
13+
Luban system's `/etc/mcpp/config.toml`: its gcc on `aarch64-linux-gnu`) was
14+
replaced by the target row's convention, and on aarch64 a first build
15+
downloaded llvm instead of using the system's gcc. A cross target and a
16+
capability pin are unchanged.
17+
- `gcc` for a target that names glibc (`aarch64-linux-gnu`) is the glibc
18+
payload, which `xim:gcc` publishes for aarch64 since 16.1.0; it was
19+
answered with `musl-gcc`. With no target, aarch64 still takes `musl-gcc`.
20+
721
## [2026.10.16.2] - 2026-10-17
822

923
### Changed

‎mcpp.toml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "mcpp"
3-
version = "2026.10.16.2"
3+
version = "2026.10.16.3"
44
description = "Modern C++ build & package management tool"
55
license = "Apache-2.0"
66
authors = ["mcpp-community"]

‎modules/versioning/src/version.cppm‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,6 @@ import std;
3131

3232
export namespace mcpp {
3333

34-
inline constexpr std::string_view MCPP_VERSION = "2026.10.16.2";
34+
inline constexpr std::string_view MCPP_VERSION = "2026.10.16.3";
3535

3636
} // namespace mcpp

‎src/build/prepare.cppm‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ import mcpp.toolchain.lifecycle;
8585
import mcpp.toolchain.stdmod;
8686
import mcpp.toolchain.post_install;
8787
import mcpp.toolchain.abi;
88+
import mcpp.toolchain.triple;
8889
import mcpp.build.plan;
8990
import mcpp.build.flags; // compute_flags — the per-role contracts (#418)
9091
import mcpp.build.graph_shape; // #407: the graph says which mode wrote it
@@ -279,6 +280,21 @@ export inline bool tc_origin_is_user_explicit(TcOrigin o) {
279280
|| o == TcOrigin::BuildProgram;
280281
}
281282

283+
// IS THIS A PAIR THE CONFIGURATION STATES FOR THE MACHINE'S OWN TARGET?
284+
//
285+
// `[toolchain] default` with a `default_target` that is the host's triple
286+
// names the compiler that serves this machine (a Luban system's
287+
// /etc/mcpp/config.toml: its own gcc on aarch64-linux-gnu). A row's
288+
// convention pin does not replace it: on aarch64 it replaced the system's gcc
289+
// with a download of llvm. A cross target keeps the rule above (the
290+
// windows-gnu regression), and a capability pin always applies.
291+
export inline bool configured_native_pair(bool targetFromGlobalDefault, TcOrigin origin,
292+
const mcpp::toolchain::triple::Triple& target,
293+
const mcpp::toolchain::triple::Triple& host) {
294+
return targetFromGlobalDefault && origin == TcOrigin::GlobalDefault
295+
&& !target.pin_is_capability() && target.str() == host.str();
296+
}
297+
282298
// MAY A BUILD THAT RESOLVED THIS WAY WRITE THE MACHINE'S DEFAULT?
283299
//
284300
// `GraphRequirement` is the one origin that must not: it is a property of a

‎src/build/prepare/toolchain.cpp‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -464,6 +464,9 @@ struct TargetOverrideCtx {
464464
const mcpp::manifest::TargetEntry* sectionEntry = nullptr;
465465
bool hasExplicitSection = false;
466466
bool hasToolchainOverride = false;
467+
// The target came from the configuration's `default_target`, beside its
468+
// `[toolchain] default`: a pair the configuration states.
469+
bool targetFromGlobalDefault = false;
467470
const mcpp::toolchain::triple::TargetInfo* known = nullptr;
468471
};
469472

@@ -869,8 +872,13 @@ step1_target_row_pin_and_capability_check(PrepareState& state, TargetOverrideCtx
869872
state.targetRowPin = std::string(ctx.known->pin);
870873
state.targetRowName = ctx.parsed->str();
871874
}
875+
// A pair the configuration states for this machine's own target is kept
876+
// (`configured_native_pair`).
877+
const bool configuredNativePair = ctx.parsed
878+
&& configured_native_pair(ctx.targetFromGlobalDefault, state.tcOrigin, *ctx.parsed,
879+
mcpp::toolchain::triple::host_triple());
872880
if (ctx.known && !ctx.hasToolchainOverride && !ctx.known->pin.empty()
873-
&& !tc_origin_is_user_explicit(state.tcOrigin)) {
881+
&& !tc_origin_is_user_explicit(state.tcOrigin) && !configuredNativePair) {
874882
state.targetPinCandidate = std::string(ctx.known->pin);
875883
state.targetPinIsCapability = ctx.parsed && ctx.parsed->pin_is_capability();
876884
}
@@ -1012,6 +1020,7 @@ static std::expected<void, std::string> step1_target_and_static_overrides(Prepar
10121020
// override and the vocabulary-table convention (pin + default linkage).
10131021
if (!state.overrides.target_triple.empty()) {
10141022
TargetOverrideCtx ctx;
1023+
ctx.targetFromGlobalDefault = targetFromGlobalDefault;
10151024
if (auto r = step1_resolve_target_triple_request(state, ctx); !r)
10161025
return std::unexpected(r.error());
10171026
if (auto r = step1_validate_target_tier(state, ctx); !r)

‎src/toolchain/registry.cppm‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -695,6 +695,12 @@ bool gcc_native_payload_is_musl(std::string_view hostArch, bool isLinux,
695695
if (hostArch == "x86_64") return false; // the glibc payload exists here
696696
// "Native" = no explicit target, or one naming this same machine. A CROSS
697697
// target keeps its own payload rule (the `<triple>-gcc` packages above).
698+
//
699+
// A target that names glibc (`aarch64-linux-gnu`) asks for the glibc
700+
// payload, which `xim:gcc` publishes for aarch64 since 16.1.0 (a Luban
701+
// system's own gcc is that one): answering it with musl-gcc built for
702+
// another C library than the one named.
703+
if (target.env == "gnu") return false;
698704
return target.empty()
699705
|| (target.os == "linux" && target.arch == hostArch);
700706
}

‎tests/unit/test_toolchain_registry.cpp‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,9 +222,13 @@ TEST(ToolchainRegistry, NativeGccPayloadFollowsWhatTheArchActuallyPublishes) {
222222
EXPECT_FALSE(gcc_native_payload_is_musl(
223223
"x86_64", true, {"x86_64", "linux", "gnu"}));
224224

225-
// aarch64: the glibc package has no asset, musl-gcc does.
225+
// aarch64 with no target: musl-gcc, the payload every version publishes.
226226
EXPECT_TRUE(gcc_native_payload_is_musl("aarch64", true, none));
227227
EXPECT_TRUE(gcc_native_payload_is_musl(
228+
"aarch64", true, {"aarch64", "linux", "musl"}));
229+
// A target that names glibc asks for the glibc payload (xim:gcc publishes
230+
// aarch64 since 16.1.0; a Luban system's own gcc is that one).
231+
EXPECT_FALSE(gcc_native_payload_is_musl(
228232
"aarch64", true, {"aarch64", "linux", "gnu"}));
229233

230234
// A CROSS target keeps its own payload rule — this is about the native

‎tests/unit/test_windows_defaults.cpp‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,3 +126,22 @@ TEST(LinuxDefaults, NativeArm64UsesLlvmAndOtherDefaultsRemainStable) {
126126
EXPECT_EQ(row->pin, pins::kFirstRunLinuxAarch64);
127127
EXPECT_FALSE(target->pin_is_capability());
128128
}
129+
130+
// A Luban system's /etc/mcpp/config.toml names its own gcc on the host's
131+
// triple (gcc@16.1.0 + aarch64-linux-gnu); the aarch64-linux-gnu row's llvm
132+
// convention replaced it with a download (xim-pkgindex#986, editions CI on
133+
// arm). The configured pair for the host's own target is kept; a cross target
134+
// and a remembered default without a target are not this case.
135+
TEST(LinuxDefaults, AConfiguredPairForTheHostsOwnTargetKeepsItsToolchain) {
136+
namespace tr = mcpp::toolchain::triple;
137+
using mcpp::build::TcOrigin;
138+
using mcpp::build::configured_native_pair;
139+
auto arm = tr::parse("aarch64-linux-gnu");
140+
auto x86 = tr::parse("x86_64-linux-gnu");
141+
auto winGnu = tr::parse("x86_64-windows-gnu");
142+
ASSERT_TRUE(arm && x86 && winGnu);
143+
EXPECT_TRUE(configured_native_pair(true, TcOrigin::GlobalDefault, *arm, *arm));
144+
EXPECT_FALSE(configured_native_pair(false, TcOrigin::GlobalDefault, *arm, *arm)) << "--target names it";
145+
EXPECT_FALSE(configured_native_pair(true, TcOrigin::FirstRun, *arm, *arm)) << "mcpp's own guess";
146+
EXPECT_FALSE(configured_native_pair(true, TcOrigin::GlobalDefault, *winGnu, *x86)) << "a cross target";
147+
}

0 commit comments

Comments
 (0)