Skip to content

Commit 4a190cc

Browse files
committed
fix(xlings): drop a ranges spelling that crashed the clang 20 frontend
Windows CI: `clang++: error: clang frontend command failed due to signal`, with the diagnostic file named subos_info-*.cppm. No message beyond the signal, so the offending construct is identified by removal rather than by a compiler telling us. The one exotic thing in the file was `std::ranges::find` with a member-pointer projection into std::pair; `std::ranges::sort` went with it for the same reason. Both are replaced by plain loops, which nothing here needed to be fancier than. Ruled out first: importing mcpp.platform, added in the previous commit and the only other change to this file between the run that failed a test assertion and the run that crashed the compiler. Four modules already import mcpp.libs.json and mcpp.platform together (bmi_cache, stdmod, post_install, prepare), so that combination is not it. Stated plainly because it matters for the next person: this is a hypothesis confirmed only by CI going green, not by a local reproduction. The crash needs clang 20.1.7 targeting MSVC and I have no such host.
1 parent e1dbc79 commit 4a190cc

1 file changed

Lines changed: 15 additions & 9 deletions

File tree

src/xlings/subos_info.cppm

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -160,12 +160,12 @@ Info read(const std::filesystem::path& subosDir) {
160160

161161
// Sorted by binding, matching xlings's own ordering, so two reads of one
162162
// subos produce the same environment in the same order. Ordering is not
163-
// cosmetic here: for a colon-separated list it decides which provider
164-
// wins, and libglvnd resolves GL vendors by exactly that order.
165-
std::ranges::sort(info.providers,
166-
[](Provider const& a, Provider const& b) {
167-
return a.binding < b.binding;
168-
});
163+
// cosmetic here: it decides which provider wins a list variable, and
164+
// libglvnd resolves GL vendors by exactly that order.
165+
std::sort(info.providers.begin(), info.providers.end(),
166+
[](Provider const& a, Provider const& b) {
167+
return a.binding < b.binding;
168+
});
169169

170170
if (info.schema > kSupportedSchema)
171171
info.note = std::format(
@@ -219,12 +219,18 @@ resolve_env(const Info& info, const std::filesystem::path& subosDir) {
219219
return false;
220220
};
221221

222+
// An explicit loop rather than std::ranges::find with a member-pointer
223+
// projection into std::pair. The projection form reads well and crashed
224+
// the clang 20.1.7 frontend outright when this module was compiled for
225+
// the MSVC target -- a segfault with no diagnostic beyond "clang frontend
226+
// command failed due to signal". Nothing here needs the fancier spelling.
222227
for (auto const& p : info.providers) {
223228
for (auto const& d : p.decls) {
224229
auto value = expand(d.value);
225-
auto hit = std::ranges::find(out, d.var,
226-
&std::pair<std::string, std::string>::first);
227-
if (hit == out.end()) { out.emplace_back(d.var, value); continue; }
230+
std::pair<std::string, std::string>* hit = nullptr;
231+
for (auto& kv : out)
232+
if (kv.first == d.var) { hit = &kv; break; }
233+
if (!hit) { out.emplace_back(d.var, value); continue; }
228234
if (d.op == "set") { hit->second = value; continue; }
229235
if (!contains_element(hit->second, value))
230236
hit->second = value + sep + hit->second;

0 commit comments

Comments
 (0)