Thanks to visit codestin.com
Credit goes to github.com

Skip to content

extmod,rp2,esp32: Rework CMake discovery of the git submodule list for "make submodules" #16901

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed

Conversation

projectgus
Copy link
Contributor

Summary

Fixes #16870.

The existing method of grepping the output of CMake still masks errors that can occur if something else in the build isn't working. This is hard to debug. Commit 22353e9 in #16581 added an error message, but the root cause of the failure is still hidden.

Instead of capturing stdout, have CMake write a shell snippet in the build directory and then source it to set GIT_SUBMODULES in Make. This way stdout/stderr are no longer masked off, and the build will fail normally if something goes wrong.

This reverts both commits from #16581:

  • Commit 22353e9 (empty submodule list is no longer a symptom of something else)
  • Commit ec527a1 (CMake can now return normally instead of fail, so the problem with IDF Component Manager is no longer triggered.)

This work was funded through GitHub Sponsors.

Testing

  • Ran rp2 and esp32 builds locally, checked the submodule list was correct in all cases.
  • Checked that if CMake fails with an error, the error now prints on the console and the build fails at this step.
  • Ran ESP32 container build to check that the issue with older IDF Component Manager hasn't returned. (Chonky command line: podman run --rm -t -v "/home/gus/ry/george/micropython/.git:/gitdir:ro" -t docker.io/espressif/idf:v5.2.2 bash -c "export BOARD=ESP32_GENERIC_S3; git clone -b $(git branch --show-current) /gitdir micropython && make -j -C micropython/mpy-cross && echo '@@@@@@@@@@ submodules' && make -C micropython/ports/esp32 submodules V=1 BOARD=$BOARD && echo '@@@@@@@@@@ main build' && make -C micropython/ports/esp32")

Trade-offs and Alternatives

  • The make submodules run now prints some CMake informational messages, so it's noiser. Could potentially add -q to reduce this (or to reduce it unless V=1 is set), but I haven't done this as I don't want to mask useful build context.
  • Rather than going back up the stack so Make can run git submodules, we could delegate running git submodules to CMake. The "submodules" target in py/mkrules.mk is very small, we might end up with less lines of code overall by duplicating it in CMake.
  • Rather than doing any of this, we could hard-code the GIT_SUBMODULES value in rp2/Makefile and esp32/Makefile. The upside is a much simpler build stage. There are two downsides I can see:
    • Conceptually, this means each port has to know about implementation details (the submodule path) of all its external MP modules.
    • Practically, can no longer filter the list of submodules based on the board to reduce network traffic and disk usage. On ESP32 the submodule list is current the same for all boards so that doesn't have any current impact. On rp2 the list is much shorter for boards without Wi-Fi or networking, so some additional repos would be fetched unnecessarily. I'm not sure how much more traffic this would actually be, though.

The existing method of grepping the output of CMake still masks errors that
can occur if something else in the build isn't working. This is hard to
debug. Commit 22353e9 added an error message, but the root cause of the
failure is still hidden.

Instead of capturing stdout, have CMake write a shell snippet in the build
directory and then source it to set GIT_SUBMODULES in Make. This way
stdout/stderr are no longer masked off, and the build will fail normally
if something goes wrong.

This reverts both commit 22353e9 (empty submodule list is no longer a
symptom of something else) and commit ec527a1 (CMake can now return
normally instead of fail, so the problem with IDF Component Manager is no
longer triggered.)

This work was funded through GitHub Sponsors.

Signed-off-by: Angus Gratton <[email protected]>
@projectgus
Copy link
Contributor Author

projectgus commented Mar 11, 2025

@asdil12 any chance you're able to test this PR, please? make submodules probably still won't succeed, but you should get some more relevant error.

@hmaerki heads-up about another build change related to submodules. This shouldn't impact your work but it may. A pre-merge test would be appreciated if you have time. 😁

Copy link

codecov bot commented Mar 11, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.54%. Comparing base (3823aeb) to head (9f44caf).

Additional details and impacted files
@@           Coverage Diff           @@
##           master   #16901   +/-   ##
=======================================
  Coverage   98.54%   98.54%           
=======================================
  Files         169      169           
  Lines       21877    21877           
=======================================
  Hits        21558    21558           
  Misses        319      319           

☔ View full report in Codecov by Sentry.
📢 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.

Copy link

Code size report:

   bare-arm:    +0 +0.000% 
minimal x86:    +0 +0.000% 
   unix x64:    +0 +0.000% standard
      stm32:    +0 +0.000% PYBV10
     mimxrt:    +0 +0.000% TEENSY40
        rp2:    +0 +0.000% RPI_PICO_W
       samd:    +0 +0.000% ADAFRUIT_ITSYBITSY_M4_EXPRESS
  qemu rv32:    +0 +0.000% VIRT_RV32

@aylen384
Copy link

@asdil12 any chance you're able to test this PR, please? make submodules probably still won't succeed, but you should get some more relevant error.

I already tried it yesterday using the master and a fresh git checkout at a new location.
Both the master and this PR don't fail anymore with the submodules issue.

This work was funded through GitHub Sponsors.

Signed-off-by: Angus Gratton <[email protected]>
This work was funded through GitHub Sponsors.

Signed-off-by: Angus Gratton <[email protected]>
This work was funded through GitHub Sponsors.

Signed-off-by: Angus Gratton <[email protected]>
This work was funded through GitHub Sponsors.

Signed-off-by: Angus Gratton <[email protected]>
@projectgus
Copy link
Contributor Author

OK, this got a lot fiddlier than expected. Closing and going with this approach:

Rather than going back up the stack so Make can run git submodules, we could delegate running git submodules to CMake.

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

Successfully merging this pull request may close these issues.

make submodules fails in ports/rp2: Internal build error: The submodule list should not be empty.
2 participants