py: Isolate mpy-cross sub-make from inherited BUILD. by pablogventura · Pull Request #19675 · micropython/micropython · GitHub
Skip to content

py: Isolate mpy-cross sub-make from inherited BUILD. - #19675

Open
pablogventura wants to merge 1 commit into
micropython:masterfrom
pablogventura:py-mpy-cross-build-isolation
Open

pablogventura wants to merge 1 commit into
micropython:masterfrom
pablogventura:py-mpy-cross-build-isolation

Conversation

@pablogventura

Copy link
Copy Markdown
Contributor

Summary

Fixes #19667.

When a port build passes BUILD= on the make command line (common for out-of-tree builds), GNU make forwards that variable into the mpy-cross bootstrap sub-make. mpy-cross then writes genhdr into the port's build directory, qstr fragments can mix with the port's, and the firmware link fails (e.g. undefined reference to mp_module_string).

USER_C_MODULES / FROZEN_MANIFEST were already cleared in both bootstraps. Empty BUILD= is not enough because BUILD ?= build in mkenv.mk does not override a defined-but-empty value. Pin BUILD to the canonical mpy-cross/build path in:

  • py/mkrules.cmake (cmake ports, including esp32)
  • py/mkrules.mk (make-based ports)

Testing

Reproduced the leak with a parent make that sets BUILD=/tmp/... and invokes the mpy-cross sub-make without pinning BUILD (binary lands in the leak dir). With the pinned BUILD=.../mpy-cross/build recipe, the binary stays under mpy-cross/build/ and the parent BUILD dir is untouched.

Did not run a full esp32 firmware build for this change (build-system only). Existing cmake CI on the PR covers the bootstrap path.

Trade-offs and Alternatives

No unix .text / .mpy delta (build system only).

Alternative of only clearing BUILD= was rejected: BUILD ?= build leaves an empty override in place.

Generative AI

I used generative AI tools when creating this PR, but a human has checked the
code and is responsible for the code and the description above.

@github-actions

github-actions Bot commented Aug 31, 2026

Copy link
Copy Markdown

@codecov

codecov Bot commented Aug 31, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.59%. Comparing base (8162451) to head (c4be68f).

Additional details and impacted files
@@           Coverage Diff           @@
##           master   #19675   +/-   ##
=======================================
  Coverage   98.59%   98.59%           
=======================================
  Files         182      182           
  Lines       23335    23335           
  Branches        5        5           
=======================================
  Hits        23006    23006           
  Misses        328      328           
  Partials        1        1           
Flag Coverage Δ
unix-coverage-32bit 98.59% <ø> (ø)
unix-coverage-64bit 98.52% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@Josverl

Josverl commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

@pablogventura,
If you want to re-trigger CI its better to do a git commit --amend --no-edit && git push --force.
That does the job, and does not push an empty commit.

@pablogventura

pablogventura commented Aug 31, 2026

Copy link
Copy Markdown
Contributor Author

Signed-off-by: Pablo Ventura <pablogventura@gmail.com>
@pablogventura
pablogventura force-pushed the py-mpy-cross-build-isolation branch from 76821c4 to c4be68f Compare September 1, 2026 13:25
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.

esp32 (cmake): mpy-cross sub-make inherits a command-line BUILD=, breaking the firmware link

2 participants