Skip to content

meshcore-native builds differ between checkouts of one commit: build.sh links sources in find order #809

Closed

Description

@hamsolodev

What happened

Two checkouts of the same meshcore-native commit build different binaries. The symbols and their sizes are identical (nm -S, sorted), but their order differs, so the SHA-256 differs. I expected the same sources, toolchain and SOURCE_DATE_EPOCH to give the same bytes, so that a build can be checked against a recorded hash.

The cause is in build.sh. The candidate source list (build.sh:162-174, at main 9097ca8) comes from seven find calls, unsorted. The compile loop appends each object in that order (:179-183), and the link passes them in that order (:222). find returns the filesystem's directory order, which depends on how the checkout was made: RadioLib's Hal and Module came out in opposite orders in the two checkouts below.

How to reproduce it

  1. Clone meshcore-native main and MeshCore companion-v1.18.0 (checkout A), and make a cp -a copy of both (checkout B).
  2. Build companion_radio in each with build.sh, in the same container image, with SOURCE_DATE_EPOCH set to MeshCore's commit time (RadioLib's __DATE__/__TIME__ would differ otherwise).
  3. Compare the hashes.
companion_radio simple_repeater
A, as it is 5ffeb331…16f6dd 5e3c0606…bf5782
B, as it is bd6e4cbb…0c1491 f8c96798…57ade4
A and B, sorted b5023b7c…81876c, both d238be03…cc05c, both

Version

meshcore-native main at 9097ca8 (and the companion-v1.18.0 tag), built with MeshBench v0.4.1's toolchain image steps, Go 1.27.3 / g++ from Debian trixie.

Platform

Linux

Anything else

Fix: MeshBench/meshcore-native#36 sorts the list with LC_ALL=C sort, a two-line change. With it, both checkouts give the same hashes for both roles, the symbols are unchanged, and the patched companion behaves as before in the protocol checks I run against it (57 cases).

The plain *.cpp globs elsewhere in build.sh (:46, :194, :210, :217) are sorted by the shell's collation, so a non-ASCII file name could still order differently by locale. Every name there is ASCII today, so I left them out of the one change.

Activity

  1. A13xB0 commented on Nov 21, 2026

    @A13xB0
    Collaborator

    Fixed by MeshBench/meshcore-native#36. Thanks for the detailed report and the fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions