0.7.1 --- no loop becomes a C runtime call, at any optimization - #20
Merged
Conversation
An optimizing compiler replaced wide_length's counting loop with wcslen and a byte loop in win.cpp with strlen. The C library above is openkal-musl, whose wchar_t is thirty-two bits, so its wcslen read the command line two units at a time: every argument of a program built with --release was shortened by a different amount. -fno-builtin keeps the loops, and the no-C-runtime-symbol check now builds the release profile as well as dev.
This was referenced Sep 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Every program built with
--releaseforx86_64-windows-gnuabove this packagereceived a shortened argument vector, by a different number of bytes per argument
and per run, and the dev profile never showed it:
The optimizer recognised
wide_lengthinsrc/env.cpp— a loop countingsixteen-bit units to a terminator — and replaced it with a call to
wcslen.This package uses no C runtime symbol by design, so the call resolved to the C
library above it: openkal-musl, whose
wchar_tis thirty-two bits. Itswcslenread the command line two units at a time, so
prepare()recorded wrong lengthsfor every argument and every environment entry. Disassembly of
prepare()in arelease consumer shows
callq wcslentwice; with this change it shows none.The same holds for bytes: a release build of this package's own objects
references
strlen(fromsrc/win.cpp), which the "no C runtime symbol" checkdid not see because it builds the dev profile only.
-fno-builtinbeside-fno-exceptions -fno-rtti: the loops stay loops.memsetis still emitted, and was already in the permitted set.and the release profile.
Found through lsp-mcpp, whose release-built tools rejected
--timeoutas--timeouon windows-2022. Measured under Wine: a release build of a programthat prints its arguments and
kal_env_arglengths is wrong before this changeand matches the dev build after it.