-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
Remove NO_DYNAMIC_EXECUTION option #5911
Comments
There are a few things on the way here. Without them The first is
|
I think we can focus on wasm, yeah. That's what matters going forward.
I'm not familiar with the embind code. Perhaps @AlexPerrot knows? |
re: |
Well, people might be using the API in their own projects. Hard to say how popular it is, we could ask on the mailing list perhaps. But in any case, for people not using it, it doesn't do any harm, so it shouldn't be a problem for the goal in this issue? |
Cool, yeah, that's what I was thinking. If it's not depended on by the emscripten runtime then it seems like it wouldn't be a problem for NO_DYNAMIC_EXECUTION. |
From option description The only practical difference would be when build is tested in non-CSP environment (like Node.js for instance on CI server) and deployed in CPS environment that forbids Effectively most of the builds should already be free from I'll start with removing conditionals where possible first, but not sure it is feasible to remove this option entirely. |
I think I've removed it in https://github.com/nazar-pc/emscripten/tree/NO_DYNAMIC_EXECUTION-elimination-1, will submit PR once #5934 is merged, currently waiting on CI in my fork. Here is how mentioned branch from my fork behaves:
|
Overall that sounds good, although I'm not sure yet what |
Here is relevant snippet of code with that #if BINARYEN_METHOD != 'native-wasm'
function doJustAsm(global, env, providedBuffer) {
// if no Module.asm, or it's the method handler helper (see below), then apply
// the asmjs
if (typeof Module['asm'] !== 'function' || Module['asm'] === methodHandler) {
if (!Module['asmPreload']) {
// you can load the .asm.js file before this, to avoid this sync xhr and eval
eval(Module['read'](asmjsCodeFile));
} else {
Module['asm'] = Module['asmPreload'];
}
}
if (typeof Module['asm'] !== 'function') {
Module['printErr']('asm evalling did not set the module properly');
return false;
}
return Module['asm'](global, env, providedBuffer);
}
#endif // BINARYEN_METHOD != 'native-wasm' |
Oh, right, for loading asm.js in wasm mode, we do need it. That's a pretty rare case, though (normal asm.js doesn't use it, nor wasm in wasm mode), so it's kind of like |
Regarding to |
Yes, it does nothing in |
I think the only reason to use |
I guessed it was for debugging, but wasn't aware about stack trace. With stack trace the most useful thing I've got is following: function make_my_func (func) {
Object.defineProperty(func, 'name', {value: 'my_func'});
func.displayName = 'my_func';
func.toString = function () {return 'function my_func () {}'};
var obj = {};
obj['my_func'] = func;
return obj['my_func'].bind(obj);
}
console.log(make_my_func(function () {console.log(new Error);})()) But it doesn't work in Firefox at all. Looks like |
So it seems There are some other tricks but all these are buggy on Firefox. 🤔 var dynamicName = "wow";
var obj = {};
// appears as `function obj[dynamicName]()` on stack trace and the name property is empty
obj[dynamicName] = function() { throw new Error("wow") }
// ES2015+ only. Appears as `function obj()` on stack trace and the name property is `wow`
obj = { [dynamicName]() { throw new Error("wow") } } |
No, The only things that works for stack trace in Chromium is I'm not sure what to do here. It feels like too much pride for |
On Node 8:
I hope we can do some mixed method to make it work (nearly) everywhere but it seems hard on Firefox. And we are yet to mention ChackraCore and JSC. PS: Opened a bug for Firefox (although it's for ES2015) https://bugzilla.mozilla.org/show_bug.cgi?id=1427228 |
Hi everyone, I hope it's okay if I throw in a question into this issue since I am quite sure it's related. Since libsodium.js included WebAssembly support, I have a problem using it in Chrome with CSP headers, disallowing
I found out that it crashes at preamble.js:2234 using the The problem is not that the WebAssembly code was not executed but that the error was thrown without being caught. Is there anything we can do about that? HTML example<html>
<head>
<meta http-equiv="Content-Security-Policy" content="default-src 'self'; connect-src 'self' data:; script-src 'self' 'unsafe-inline'">
</head>
<body>
<script>
window.sodium = {
onload: function (sodium) {
let key = sodium.crypto_sign_keypair();
console.log(key);
}
};
</script>
<script src="sodium.js" async></script>
</body>
</html> |
I've run into similar issues, and IIRC the root cause is that the Chrome team specifically opted to have unsafe-eval block WebAssembly compilation on the main thread, in the absence of a more suitable wasm-specific CSP directive. This causes libsodium to abort compiling wasm and fall back to asm.js.
|
@buu700 Thank you for the quick reply! I'd be very happy if you could fix (if you point me into the right direction, I also might be able to fix it in a PR, would be happy to do it but don't know where to start) |
I'm not sure I understand the onAbort issue discussed here, please lets open a new issue for it with more details (or a PR with a fix if someone is already working on that). |
This looks like great progress. We should not delete the Otherwise to be warnings free, projects that wanted |
@juj, It doesn't prevent compilation from happening, doesn't break anything, but makes developers aware that the option is gone and they can drop it if they don't have legacy stuff. It is just a harmless warning, why bother keeping it in code base? I'd rather add something like |
I can see merits to both sides there... At least the useless options should be removed when doing a major release. |
This issue has been automatically marked as stale because there has been no activity in the past year. It will be closed automatically if no further activity occurs in the next 7 days. Feel free to re-open at any time if this issue is still relevant. |
Looks like the only uses for this flag left are in embind (and the run_script function). I'll take a swing at the embind code. It all works without dynamic execution; maybe we can just delete the dynamic execution branches and update the tests. |
This issue has been automatically marked as stale because there has been no activity in the past year. It will be closed automatically if no further activity occurs in the next 30 days. Feel free to re-open at any time if this issue is still relevant. |
Once #5751 is merged
NO_DYNAMIC_EXECUTION
would either be no-op or very close to that.Should be possible to remove it as redundant entirely.
The text was updated successfully, but these errors were encountered: