Skip to content

make: sort source wildcards so the PRG is locale-independent (#301) - #311

Merged
JC-000 merged 4 commits into
masterfrom
fix/301-locale-link-order
Oct 15, 2026
Merged

JC-000 merged 4 commits into
masterfrom
fix/301-locale-link-order

Conversation

@JC-000

@JC-000 JC-000 commented Oct 15, 2026 •

Copy link
Copy Markdown
Owner

Closes #301

Cause (verified)

GNU make 3.81 returns $(wildcard) hits in locale collation order. Probe Makefile with tls13.s tls_cert.s tls_record.s tls_record_io.s:

  • LC_ALL=C: tls13.s tls_cert.s tls_record.s tls_record_io.s
  • LC_ALL=en_US.UTF-8: tls_cert.s tls_record_io.s tls_record.s tls13.s
  • $(sort $(wildcard ...)): byte order under both.

Fix

$(sort ...) on the three wildcards (TOP_SRCS, CRYPTO_SRCS_ALL, CRYPTO_SHARED_SRCS). Audit: no other wildcard, ls or glob feeds ld65/ar65 (build_x25519.sh uses explicit arrays; write_manifest.sh pipes through sort, which is locale-collated: harmless today (same order for its 7 names across C/en_US/cs_CZ/sv_SE) but not locale-safe; libs/nistcurves Makefile has none).

Round 2 (rev-311)

  • cs_CZ.UTF-8 added: it reorders src/crypto/*.s (chacha20 after hmac_drbg); C and en_US agree there. On master cs_CZ is a third hash per product. src/crypto/shared/*.s is reordered by no locale tried, so its sort is defensive and not pinned.
  • Object list (link order) now in flags.stamp (OBJECTS=$(ALL_OBJS), 1 line): a build/ left by pre-fix master is relinked instead of "Nothing to be done". New test_stale_link_order_is_rebuilt_to_the_clean_hash.
  • Mutants, each RED: TOP unsorted (C 5e709d88 / en_US,cs_CZ 924132de); CRYPTO unsorted (cs_CZ ee6d212b vs 5e709d88); no OBJECTS in stamp (stale PRG 924132de != clean 5e709d88). Good Makefile: both tests pass; stamp suite 19/19; pytest stamp+runner_coverage+boundary 35 passed.
  • Product hashes UNCHANGED by the stamp line: make package under C and cs_CZ.UTF-8 gives the same three hashes as above.
  • Compatible with make: a linker cfg edit relinks the PRG (#305) #306: git merge-tree against its head shows 0 conflicts.
  • The test has its own certifies text; standalone main() now reports VoluntarySkip as SKIP, not FAIL.

Red-green (round 1)

New test_prg_is_independent_of_the_build_locale (in tools/test_build_flags_stamp.py, already in pytest testpaths) first proves the two locales order src/*.s differently, then builds UCI onchip under each and compares sha256.

  • origin/master Makefile: FAIL, {'C': '5e709d88...', 'en_US.UTF-8': '924132de...'}
  • with fix: PASSED: 0 failure(s) (18/18 executed); pytest on stamp + runner_coverage + pytest_boundary: 34 passed.

New release hashes (byte-order link; DIFFER from v0.5.1)

make package under LC_ALL=C and LC_ALL=en_US.UTF-8, identical:

  • ip65-onchip 1c377d34343150f59f536aeba3a468c373dbebf3a4b5ab326a5ef6b7072fbe81
  • uci-onchip 98a3d882ddb7008f6f3aa646d1cf984279840fd22e22b3dd0f80967b53cb730d
  • uci-comb 6b95c32955860c1cbcfd12e5dedc2ef732f1a189f6c639c716e2e2ea91f59430

Hardware (U64E, 48 MHz, rig_https_banner.py, en.wikipedia.org/wiki/Commodore_64, typed host)

  • uci-onchip 98a3d882...: PASS, HTTP 200, 759,171 B consumed == Content-Length
  • uci-comb 6b95c329...: PASS, HTTP 200, 759,171 B consumed == Content-Length
  • make package-verify: 14/14 checks passed, RELEASE ARTIFACTS VERIFIED
  • ip65-onchip not run on hardware (no RR-Net rig in this round).

Overlap

Overlaps #306 in tools/test_build_flags_stamp.py and the Makefile stamp area; may need a rebase after #306 merges (it was still open when this was opened).

🤖 Generated with Claude Code

JC-000 and others added 4 commits October 15, 2026 14:25
make 3.81 returns $(wildcard) in locale collation order and the lists are
the ld65 object order, so ip65-onchip, uci-onchip and uci-comb each had two
PRG hashes. $(sort) is byte order. New hashes differ from v0.5.1.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…er relink (#301)

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…ndition, wording nits (#301)

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@JC-000
JC-000 force-pushed the fix/301-locale-link-order branch from 6294297 to bfa0ed7 Compare October 15, 2026 19:27
@JC-000
JC-000 merged commit f08ddd9 into master Oct 15, 2026
@JC-000
JC-000 deleted the fix/301-locale-link-order branch October 15, 2026 19:32
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.

PRG bytes depend on the build locale (link order from an unsorted $(wildcard))

1 participant