The xbuildenv symlink is rewritten on each pyodide xbuildenv install call. If multiple builds for different Pyodide versions run concurrently (e.g. in cibuildwheel, when running the test suite in parallel), re-resolving through the symlink at a later point could yield the wrong versioned directory. Using self.pyodide_root, which was resolved at construction time, gives us a stable, race-free path.
Thanks for the investigation. Actually, I guess this is something that we need to think more carefully about, not just for emscripten but for other config variables as well. I personally never considered concurrent builds when designing xbuildenv installation. If cibuildwheel is using parallel builds a lot, we should be make pyodide-build more concurrent-robust.
Originally posted by @ryanking13 in #321 (comment)
Thanks for the investigation. Actually, I guess this is something that we need to think more carefully about, not just for emscripten but for other config variables as well. I personally never considered concurrent builds when designing xbuildenv installation. If cibuildwheel is using parallel builds a lot, we should be make pyodide-build more concurrent-robust.
Originally posted by @ryanking13 in #321 (comment)