This is an automated email from the ASF dual-hosted git repository. sjanc pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/mynewt-newt.git
commit 30084df03115f6ab3338899753c6efa458ff5811 Author: Szymon Janc <[email protected]> AuthorDate: Wed Oct 21 02:06:15 2026 +0200 newt/builder: Generate link tables in deterministic order Link tables were collected by iterating over map of resolved packages, so their order in generated linker script changed randomly between builds. With more than one non-empty link table this changes layout of the resulting binary. Collect link tables from packages sorted by name. Assisted-by: Claude:claude-opus-5-5 --- newt/builder/extcmd.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/newt/builder/extcmd.go b/newt/builder/extcmd.go index 67bc62e5..4f2eb6eb 100644 --- a/newt/builder/extcmd.go +++ b/newt/builder/extcmd.go @@ -27,6 +27,7 @@ import ( "github.com/kballard/go-shellquote" log "github.com/sirupsen/logrus" + "mynewt.apache.org/newt/newt/pkg" "mynewt.apache.org/newt/newt/stage" "mynewt.apache.org/newt/util" ) @@ -223,8 +224,14 @@ func (t *TargetBuilder) generateLinkTables() { return } - for _, pkg := range t.res.LpkgRpkgMap { - s = append(s, pkg.Lpkg.LinkTables()...) + // Sort packages so that order of link tables (and so binary layout) + // does not depend on map iteration order. + lpkgs := make([]*pkg.LocalPackage, 0, len(t.res.LpkgRpkgMap)) + for lpkg := range t.res.LpkgRpkgMap { + lpkgs = append(lpkgs, lpkg) + } + for _, lpkg := range pkg.SortLclPkgs(lpkgs) { + s = append(s, lpkg.LinkTables()...) } if len(s) == 0 {
