-
Notifications
You must be signed in to change notification settings - Fork 735
Avoid writing to file in emsdk_env.csh / emsdk_env.sh #544
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
Conversation
This is an alternative fix for emscripten-core/emscripten#9090 which recently came up again after #539. Tested with bash, tcsh and fish.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Neat! Am I correct that this does not change the behavior on Windows?
Yeah.. the race condition still exist on windows... but its always be there and nobody seems to complain. i imagine if you had emsdk_env.bat in your shell startup and up opened a lot of shells at the same time you might see this issue. Honestly I don't know enough about windows |
emscripten-core/emsdk#544 changed `emsdk construct_env` to print messages to stderr.
This wasa temporary file that `construct_env` used to create. Now it just writes to stdout (as of #544).
This wasa temporary file that `construct_env` used to create. Now it just writes to stdout (as of #544).
This was an internal script that we used to generate up until #544. Now we avoid writing that file at all and emsdk_env.sh is instead sourced directly. This should fix the docker CI issues we have been having.
This was an internal script that we used to generate up until #544. Now we avoid writing that file at all and emsdk_env.sh is instead sourced directly. This should fix the docker CI issues we have been having.
This was an internal script that we used to generate up until #544. Now we avoid writing that file at all and emsdk_env.sh is instead sourced directly. This should fix the docker CI issues we have been having.
This was an internal script that we used to generate up until #544. Now we avoid writing that file at all and emsdk_env.sh is instead sourced directly. This should fix the docker CI issues we have been having.
Is there a reason why Line 2588 in e88a3c5
|
Yes, it is so that the stdout of construct_env can be directly evaluated by the shell.
This is technique that I borrowed from ssh-agent:
And also from homebrew (https://docs.brew.sh/Homebrew-on-Linux):
Is it causing trouble? We could consider simply removing the logging. |
Running
in a Python script via the subprocess module the emcc command fails since the environment variables set in the first command are not set in the second command since it uses a new shell. And chaining them with But please don't remove the logging :) |
That doesn't seem like a very sustainable solution. I agree we should work on finding one, but currently the output of these commands is not designed to machine parse-able like that and as far as I know the output logged during these commands is not guaranteed not to change. But you pose an interesting problem here. Normally the answer would be that you should install and activate the SDK before running the python script, or re-start python to pick up the new environment variable, but I can see how that is not a very satisfying answer. Most other SDKs that I know of have the same problem (e.g. homebrew, or fuschia). In emsdk as with those other SDKs the environment variables would need to be set in the calling shell (the shell that loads python). Is there any way you can change your setup to work this way around? If not, I can try to work on a more long-term solution for you that doesn't involve parsing log messages. |
I'm not sure how else to setup the emscripten environment. The Python script drives our wasm build (which itself is using CMake). Probably a way around it would be using a batch or powershell script which takes over the activation of the sdk and then call the python script from within that batch/ps script. Adding another script file is not something I would like to do. But I also understand that there can be no guarantee that I can rely on parsing the emsdk output. |
I think the best solution is for you to run The stdout of e.g on my machine I get:
So you it should be pretty easy to parse and inject into your env. |
Yes |
(Actually the emsdk.bat file will execute If you want to see the contents of |
This is very helpful, thanks! One more thing for the future to consider is when more than one version can be installed at the same time that the |
That is why we have |
I think I don't understand when to use Because as I understand |
|
This is an alternative fix for
emscripten-core/emscripten#9090 which recently
came up again after #539.
Tested with bash, tcsh and fish.