-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Reimplement resolve_path
in JS NFC
#23935
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
Is there a ci failure for this problem? Or which test should I run? I only see the sigs job failing which needs an update to the expected output. |
This one fails
while the same test (without pthread)
success |
Well applying this change, I can see that diff --git a/test/test_other.py b/test/test_other.py
index ad240f4a1..d33fdf0b4 100644
--- a/test/test_other.py
+++ b/test/test_other.py
@@ -7605,12 +7605,29 @@ Module.preRun = () => {
#include <stdlib.h>
#include <string.h>
#include <dlfcn.h>
+#include "emscripten.h"
+#include <sys/stat.h>
+
+EM_JS(int, check_path, (char* cpath), {
+ const path = UTF8ToString(cpath);
+ console.log("check_path", path);
+ try {
+ const res = FS.lookupPath(path);
+ console.log("res", res);
+ } catch(e) {
+ console.log(e);
+ }
+});
int main() {
void *h;
void (*f)();
double (*f2)(double);
+ check_path("/lib/libhello1.wasm");
+ struct stat statbuf;
+ printf("res: %d\n", stat("/lib/libhello1.wasm", &statbuf));
+
h = dlopen("libhello1.wasm", RTLD_NOW);
assert(h);
f = dlsym(h, "hello1"); |
Okay I think I fixed the problem in b805542. |
Indeed. Thanks for the fix! Didn't know about the proxy parameter. The remaining issue now seems to be handling BigInt in a MEMORY64 environment. |
The memory64 test now passes for me locally. |
resolve_path
in JS NFCresolve_path
in JS NFC
@hoodmane Awesome, thanks for helping me fix the issues. |
$locateLibraryFromFS: (filename, searchDirs, maxLength = Infinity) => { | ||
// Find the library in the filesystem. | ||
// returns null if not found. | ||
if (typeof FS.lookupPath !== 'function') { |
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.
Slightly shorter:
if (typeof FS.lookupPath !== 'function') { | |
if (!FS.lookupPath) { |
} | ||
|
||
var candidates = []; | ||
if (filename.charAt(0) === '/') { // abs path |
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.
shorter:
if (filename.charAt(0) === '/') { // abs path | |
if (filename[0] === '/') { // abs path |
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.
It looks good to me, thanks @ryanking13. Let's wait for @sbc100 to review as well.
Hmm it seems the test I added breaks in CI. When I run it locally it works fine... |
I hit the merge button on this, but now looking back at the history I'm thinking it might have been premature. Ah well, we could either revert and reland or fix any problems in followups. |
Yes, lets revert this pending some more discussion. |
Can you re-open this PR? (or perhaps a new one is needed?) |
Sorry about that! |
As discussed in #23872, this PR reimplements
resolve_path
function, which is used to locate the library usingLD_LIBRARY_PATH
in JavaScript, so that it can be reused insidelibdylink.js
.Currently, this code doesn't work in thread.