Skip to content

build: sort the source list, so the link order is the same everywhere - #36

Merged
A13xB0 merged 1 commit into
MeshBench:mainfrom
hamsolodev:build-sorted-sources
Nov 21, 2026
Merged

A13xB0 merged 1 commit into
MeshBench:mainfrom
hamsolodev:build-sorted-sources

Conversation

@hamsolodev

@hamsolodev hamsolodev commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

What this changes, and why

The candidate sources come from seven find calls, unsorted, and the objects are linked in that order. find returns the directory order, which depends on how the checkout was made, so two checkouts of one commit built binaries with the same symbols in a different order and a different hash. A fresh clone and a cp -a copy of it were enough. Sorting the list bytewise (LC_ALL=C sort) makes the link order a function of the sources alone, so a build can be checked against a recorded hash.

Verification

  • Two checkouts of main 9097ca8 with MeshCore companion-v1.18.0: A, fresh clones, and B, cp -a copies of them. Both were built with build.sh in one container image, with SOURCE_DATE_EPOCH pinned.
    • Without the change, the hashes differ between A and B for both roles: companion_radio 5ffeb331… against bd6e4cbb…, and simple_repeater 5e3c0606… against f8c96798….
    • With it, A and B match: companion_radio b5023b7c…, simple_repeater d238be03….
  • The symbols and their sizes (nm -S, sorted) are identical across all four builds of each role: 2,030 for the companion, 1,992 for the repeater. Only their order moved.
  • The patched companion passes the 57 protocol cases I run against it under MeshBench, with the same results as an unpatched build.

There's no test in the tree for this: reproducing it needs two checkouts with different directory histories, which a unit test can't make. A CI job that builds twice, once from a copy of the checkout, and compares hashes would pin it; I've left that out of this change.

Reported in MeshBench/meshbench#809.

The candidate sources come from seven find calls, unsorted, and the
objects are linked in that order. find returns the directory order,
which depends on how the checkout was made, so two checkouts of one
commit built binaries with the same symbols in a different order and a
different hash: a fresh clone and a cp -a copy of it were enough.
Sorting the list bytewise makes the link order a function of the
sources alone.
@A13xB0
A13xB0 merged commit 3ae638f into MeshBench:main Nov 21, 2026
1 check passed
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.

2 participants