-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
__embind_initialize_bindings is stripped from export table in Release + pthreads build #22968
Comments
Metadce can strip things that are not used, so somehow it is not seeing a use of that function, is my best guess. Do you have a testcase showing the issue that we can investigate? cc @brendandahl |
@laminowany can you share more details about your use case? What link flags are you using? I assume you are using pthreads since that is the only place _embind_initialize_bindings is called. |
I don't really have minimal reproducible case yet, I was trying to build https://github.com/mitchcurtis/slate with Qt dev built from source. Linker flags are following: |
I don't see either The resulting code should therefor not contains a call to emscripten/src/runtime_pthread.js Lines 168 to 175 in bd2de9c
Can you confirm where the call from If possible perhaps you can bisect to figure out which change caused the regression: https://emscripten.org/docs/contributing/developers_guide.html#bisecting |
Can you link with |
Output looks following: https://pastebin.com/A9aVVTx7 Relevant part is here I guess:
|
Can you attach a copy of |
Here is the entire |
From what I tested the breakage was somewhere between 3.1.56 and 3.1.58 version. |
This seems to be a culprit: 37e1e68 |
There is some kind of bug in DCE here though since |
@sbc100 that does sound likely. Looking at the |
This is fix for me: https://github.com/emscripten-core/emscripten/compare/main...laminowany:emscripten:22968?expand=1 But I dont know if its a "proper" fix. The problems is that here it gets filtered out and not marked as a root: Line 793 in 1092ec3
While it was rooted in previous emscripten |
@laminowany That works around it, but I think there is something else going on here. I am pretty sure the issue is that This diff renames the SOCKFS one: diff --git a/src/library_sockfs.js b/src/library_sockfs.js
index e5c1b8674..5d33996ab 100644
--- a/src/library_sockfs.js
+++ b/src/library_sockfs.js
@@ -287,7 +287,7 @@ addToLibrary({
}
};
- function handleMessage(data) {
+ function handleSocketMessage(data) {
if (typeof data == 'string') {
var encoder = new TextEncoder(); // should be utf-8
data = encoder.encode(data); // make a typed array from the string
@@ -331,7 +331,7 @@ addToLibrary({
if (!isBinary) {
return;
}
- handleMessage((new Uint8Array(data)).buffer); // copy from node Buffer -> ArrayBuffer
+ handleSocketMessage((new Uint8Array(data)).buffer); // copy from node Buffer -> ArrayBuffer
});
peer.socket.on('close', function() {
SOCKFS.emit('close', sock.stream.fd);
@@ -351,7 +351,7 @@ addToLibrary({
SOCKFS.emit('close', sock.stream.fd);
};
peer.socket.onmessage = function peer_socket_onmessage(event) {
- handleMessage(event.data);
+ handleSocketMessage(event.data);
};
peer.socket.onerror = function(error) {
// The WebSocket spec only allows a 'simple event' to be thrown on error, @laminowany can you see if that fixes it? It does for me locally, but I am just running the specific tools not the full Assuming that fixes it, the proper fix is to fix |
Nice work find that alon! What a horrible bug |
I tested your patch @kripken and it does solve a problem on my machine, thanks for looking into it! |
@laminowany Ok, #23159 should fix this properly. If it's not too much trouble, can you try that PR on your code? |
I tested with my code and #23159 does fix it for me! |
Perfect, thanks @laminowany ! I'll land it as soon as tests pass. |
…en-core#23159) Other than simple defined functions (function foo() {}), JS also has arrow functions and object methods. We need to be aware of those in metadce. This fixes emscripten-core#22968 which was an issue with an object method that enclosed a function of the same name as another toplevel function. To fix this, this PR makes us aware of such scopes, and we do not optimize functions in them. That is, we only ever optimize defined functions at the toplevel scope, and anything enclosed is considered fixed.
This is a regression in 3.1.70, on previously tested version 3.1.56 it worked correctly. My application gets undefined reference to __embind_initialize_bindings during runtime.
There is a code which adds
__embind_initialize_bindings
to exported symbols:emscripten/tools/link.py
Lines 508 to 509 in 119a427
but this seems to be stripped during call to binaryen:
emscripten/tools/building.py
Lines 842 to 847 in 119a427
The binaryen takes an DCEGraph as an input, and when I inspect the json of graph it has following entry:
I can fix this issue by manually editing this intermediate file and changing this entry to:
My guess:
_embind_initialize_bindings
should be marked withroot: true
but for some reason is not.Another workaround is manually exporting this function via:
EXPORTED_FUNCTIONS=_main,__embind_initialize_bindings"
but I believe it should not be needed.
This issue is similiar to: #21844
The text was updated successfully, but these errors were encountered: