Fix an issue if user passes a relative path to Python#26799
Conversation
…m cache libraries need rebuilding. Emcc tool would spawn sub-emcc tools to rebuild the cache, with different CWD, resulting in the relative path lookups pointing to the wrong relative directories. To fix the issue, normalize the relative tool paths first.
51fe3c8 to
dfb823c
Compare
|
Surely you don't want to be setting i.e. if you did: i.e. your compile will then only be usable from a single location, even after this change, right? Another alternative here would be to set |
|
Another example that simply won't work, even with this change, if you have a relative path like this: Maybe the launcher scripts (currently the only place we reference EMSDK_PYTHON) could warn/assert if its a relative path like this. |
|
My gut impression here was to disable this support, as "this does not make sense, why would you do that?" But then when I thought about it, a) Unity has been doing this since forever, where Unity's build system programmatically launches Emscripten. So it crafts the paths on the fly. Other build system might be doing the same, so why actively break them. Sure, it is easy to migrate to absolute paths (which we did), but was equally easy to fix up Emscripten, which this PR shows. b) It can be useful for ad hoc cmdline runs in testing, e.g. c) fixing this issue is simple - why actively break something that is easy to fix.
Yes, but the above use cases a) (programmatic launching) and b) (ad hoc cmdline use) do not navigate to other directories.
Yes, but here the failure will occur when make is launching emcc, not when emcc is internally launching other emcc. It is easier to debug top-level emcc launches from the calling tools, than emcc internally launching other tools.
We could add an assert and say "this is not allowed to work", but since the fix is so simple, I thought it's more straightforward to just fix the root cause? |
|
Another option is that when we re-execute emcc internally we skip the launcher scripts and use It might also speed up the library builds. |
|
That could work, although it seems conceptually simpler to have a single loop that absolute-pathizes, rather than use |
I don't think the latter can happen since since the only sub-compiler commands emcc ever runs are |
|
Note to self: This issue really only exists because of I don't love |
Instead move the logic into system_libs.py (the only non-testing place it is used). In the test code itself, we just replace the usage with direct calls to `EMAR`, which is better for decoupling the tests from the compiler itself. This is in preparation for a change to skip the wrapper scripts when the compiler calls itself to build system libs (See emscripten-core#26799)
Ok, updated the implementation to only address Python. I think that's correct, that this won't happen to other sub-tools. |
|
I think the batch build is probably quite a significant speed improvement. Now looking at this, the code area has been refactored by quite a bit since I last looked into this. Though the important bit is that Python multiprocessing is not being used, but we run the |
| # reinitialize EMSDK_PYTHON here so that sub-tool spawns will use the same | ||
| # Python interpreter as the parent. | ||
| if os.environ.get('EMSDK_PYTHON'): | ||
| os.environ['EMSDK_PYTHON'] = sys.executable |
There was a problem hiding this comment.
Nice! That seems much better.
I also think we could probably localize this to run_build_commands in system_libs.py (since that is the only place its really needed.
But if you want to land as-is and can do some followups.
| set_config_from_tool_location('BINARYEN_ROOT', 'wasm-opt', lambda x: os.path.dirname(os.path.dirname(x))) | ||
|
|
||
| normalize_config_settings() | ||
| normalize_relative_python_path() |
There was a problem hiding this comment.
This kind of has the wrong name now.
There was a problem hiding this comment.
Hmm, yeah, not sure what's a better name here. Though I'll leave it if you want to address further.
There was a problem hiding this comment.
Yeah no worries, feel free to land
|
you can ignore the fp6 failures, those are due to a v8 update and will be fixed when llvm changes next roll in. |
Instead move the logic into system_libs.py (the only non-testing place it is used). In the test code itself, we just replace the usage with direct calls to `EMAR`, which is better for decoupling the tests from the compiler itself. This is in preparation for a change to skip the wrapper scripts when the compiler calls itself to build system libs (See #26799)
Fix an issue if user passes a relative path to Python, and some system cache libraries need rebuilding. Emcc tool would spawn sub-emcc tools to rebuild the cache, with different CWD, resulting in the relative path lookups pointing to the wrong relative directories. To fix the issue, normalize the relative tool paths first.