Conversation
|
Code size report: |
|
The issue with locally-built tools under EIM may have been found, see espressif/idf-im-ui#1067 (comment) It'd be great if somebody could try this out on macOS after editing the PATH variable to remove the directories mentioned in the comment linked above, as EIM also installs its own version of clang. So I can at least update the documentation mentioning whether EIM can be used to build MicroPython on macOS :) |
9c3bf6d to
d34951a
Compare
|
I've been told EIM does take over a default LLVM installation to use its own, but that's a Xtensa + RV32 cross compiler only. So, unless Espressif updates its clang version to also target x86_64 and AArch64, this method is not usable on macOS or on systems where there's no GCC installed (*BSDs, maybe?). |
|
Thinking a bit more about this, there may be a "cleaner" solution if Espressif can't (or won't) fix things on their end. If
then, in theory this should work for Linux, WSL, and macOS. |
|
This should make it work under Linux, both using GCC and LLVM to build No idea about building this from Windows outside WSL, but hey, maybe they broke that too... |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #19657 +/- ##
=======================================
Coverage 98.55% 98.55%
=======================================
Files 182 182
Lines 23335 23335
Branches 5 5
=======================================
Hits 22998 22998
Misses 336 336
Partials 1 1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
8df81d6 to
c846a59
Compare
Octoprobe PR report
Failures |
projectgus
left a comment
There was a problem hiding this comment.
Hi @agatti, sorry it took me a while to review. This looks good! I have a bunch of suggestions but they're all based around comments and naming - mostly spelling out what EIM is the first time it's mentioned each time - I'd not heard of it until recently, and I assume most people MicroPython won't yet be familiar with it either.
Thanks for working through this support!
Also TIL about posix shell command -v. Had somehow got this far without ever noticing it. Very handy!
| # Workaround for building with EIM. EIM takes over an existing LLVM | ||
| # installation (so macOS won't ever be able to compile anything) and adds | ||
| # directories to the PATH variable whose files collide with an existing GCC | ||
| # installation as they recursively add any directory named `bin` under the tools | ||
| # root of the currently chosen ESP-IDF environment. Of course nobody would ever | ||
| # build local binaries to do any pre or post build actions or anything else for | ||
| # an ESP32 project, right? |
There was a problem hiding this comment.
Suggest giving a little more context and being really specific about what EIM behaviour we're working around here, because this Makefile isn't part of esp32 port so the reader may not have any idea what they're looking at.
Something like the following (but feel free to change):
| # Workaround for building with EIM. EIM takes over an existing LLVM | |
| # installation (so macOS won't ever be able to compile anything) and adds | |
| # directories to the PATH variable whose files collide with an existing GCC | |
| # installation as they recursively add any directory named `bin` under the tools | |
| # root of the currently chosen ESP-IDF environment. Of course nobody would ever | |
| # build local binaries to do any pre or post build actions or anything else for | |
| # an ESP32 project, right? | |
| # Workaround for building native mpy-cross when invoked inside | |
| # Espressif Installation Manager (EIM) environment. | |
| # | |
| # EIM prepends an LLVM installation in front of the system PATH (so macOS can't | |
| # compile native binaries) and adds directories to the PATH variable whose files | |
| # collide with an existing GCC installation as they recursively add any directory | |
| # named `bin` under the tools root of the currently chosen ESP-IDF environment. | |
| # Of course nobody would ever build native binaries to do any pre or post build | |
| # actions or anything else for an ESP32 project, right? |
(Left your snarky rhetorical question in as I appreciated it! 😁 )
There was a problem hiding this comment.
Thanks for the update!
Regarding the rhetorical question, I'm still wondering why they're doing this. It seems that at least one of the developers working on EIM is based in central Europe, if they show up at Espressif's devcon in Milan this November I'll try to ask them about this.
| ifneq ($(IDF_TOOLS_PATH),) | ||
| SPACE := $(subst ,, ) | ||
| PATH_COPY := $(PATH) | ||
| PATH = $(subst $(SPACE),:,$(filter-out $(IDF_TOOLS_PATH)%,$(subst :,$(SPACE),$(PATH_COPY)))) |
There was a problem hiding this comment.
| PATH = $(subst $(SPACE),:,$(filter-out $(IDF_TOOLS_PATH)%,$(subst :,$(SPACE),$(PATH_COPY)))) | |
| # Filter out any IDF_TOOLS_PATH directories from the PATH | |
| PATH = $(subst $(SPACE),:,$(filter-out $(IDF_TOOLS_PATH)%,$(subst :,$(SPACE),$(PATH_COPY)))) |
(That's right, isn't it?)
|
|
||
| HELP_BUILD_ERROR ?= "See \033[1;31mhttps://github.com/micropython/micropython/wiki/Build-Troubleshooting\033[0m" | ||
|
|
||
| # Check if it's exported from EIM first |
There was a problem hiding this comment.
| # Check if it's exported from EIM first | |
| # Check if it's exported from Espressif Installation Manager (EIM) first |
|
|
||
| To obtain the toolchain and set up your environment, the Espressif instructions | ||
| will guide you to either use the `install.sh` (or `install.bat` if you're on | ||
| Windows) script, or to use their toolchain and environment manager, EIM. |
There was a problem hiding this comment.
| Windows) script, or to use their toolchain and environment manager, EIM. | |
| Windows) script, or to use their Espressif Installation Manager (EIM). |
| Installation via the EIM tool | ||
| ----------------------------- |
There was a problem hiding this comment.
| Installation via the EIM tool | |
| ----------------------------- | |
| Installation via Espressif Installation Manager (EIM) tool | |
| ------------------------------------------------------------- |
This commit lets the ESP32 port makefile work in environments set up via EIM (Espressif's SDK/toolchain manager) instead of the regular SDK export script. EIM-activated environment do not place `idf.py` into the system's PATH, so the Makefile needs to know where to look for it if it cannot be found right away. However, EIM does set up an environment variable that points to the environment root, and therefore picking up idf.py from there is trivial. As a bonus, if the makefile cannot find idf.py, it will report a more sensible error to the user rather than a generic "file not found" message. The documentation was also updated to mention EIM and the current state of things when using such a tool to manage your ESP-IDF SDKs. Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
This commit updates the build infrastructure to undo the local compiler takeover done by Espressif's EIM tool, allowing the ESP32 port to build correctly from an EIM-activated environment. EIM would blindly edit the PATH environment variable to replace any local LLVM installation with its own bare-metal version, and add all directories named `bin` from their tools directory. Three of those directories have files whose name clashes with local GCC installations. As we may build `mpy-cross` for the host system as part of the build process of the ESP32 port, that's unfortunately a workaround we have to add ourselves. Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
|
Thanks for the review! I've updated the text where suggested and cleaned things up a bit. The EIM installation section now also has some more information on what a working setup could look like, with what to select on certain EIM prompts. ESP-IDF 5.3 and 5.4 set IDF_PATH as well, so the ESP32 Makefile was updated to check whether such a variable exists in the first place, and bail out if not as that indicates an environment that is probably not set up correctly. Following on that, there's also a check on whether IDF_PATH points to a valid path (as in, directory containing For |
Summary
This PR lets the ESP32 port makefile work in environments set up via EIM (Espressif's SDK/toolchain manager) instead of the regular SDK export script.
EIM-activated environment do not place
idf.pyinto the system's PATH, so the Makefile needs to know where to look for it if it cannot be found right away. However, EIM does set up an environment variable that points to the environment root, and therefore picking up idf.py from there is trivial. As a bonus, if the makefile cannot find idf.py, it will report a more sensible error to the user rather than a generic "file not found" message.The documentation was also updated to mention EIM and the current state of things when using such a tool to manage your ESP-IDF SDKs.
This should close #19390.
Testing
An ESP32 build was initiated successfully with the environment set up by
export.fishfrom a previously set up SDK using the regular git checkout +install.shmethod, then from an environment activated via EIM, and finally with no environment set up to see the new error message.Trade-offs and Alternatives
Currently there is a known issue with EIM preventing building
mpy-crossfrom the same environment it sets up for cross-compilation builds (see espressif/idf-im-ui#1067). However, this PR contains a workaround for this situation.Generative AI
I did not use generative AI tools when creating this PR.