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
fix: export libuv symbols #24659
fix: export libuv symbols #24659
Conversation
💖 Thanks for opening this pull request! 💖 We use semantic commit messages to streamline the release process. Before your pull request can be merged, you should update your pull request title to start with a semantic prefix. Examples of commit messages with semantic prefixes:
Things that will help get your PR across the finish line:
We get a lot of pull requests on this repo, so please be patient and we will get back to you as soon as we can. |
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.
I seem to recall discussing this with @codebytere and this isn't exactly what we want to be doing, the symbols are being stripped forcefully adding them again is just working around a problem that we are causing
Thanks for the quick respond! For context, I got an undefined symbol error when trying to load a native module that works in node, the reason I found is because node exports a few extra symbols that electron is missing. I followed the docs and stripped the symbols made a patched release build here https://github.com/koonpeng/electron/releases/tag/v9.0.5. Comparing that to the official release, teokp@teokp-Desktop:~/Downloads$ nm -D ./electron-v9.0.5-linux-x64/electron | awk '{print $3}' > default.txt
teokp@teokp-Desktop:~/Downloads$ nm -D ./electron-v9.0.5-linux-x64-koonpeng/electron | awk '{print $3}' > patched.txt
teokp@teokp-Desktop:~/Downloads$ git diff default.txt patched.txt
diff --git a/default.txt b/patched.txt
index c188ec7..29e92b7 100644
--- a/default.txt
+++ b/patched.txt
@@ -1589,6 +1589,10 @@ uv_cpu_info
uv_cwd
uv_default_loop
uv_disable_stdio_inheritance
+uv_dlclose
+uv_dlerror
+uv_dlopen
+uv_dlsym
uv_err_name
uv_err_name_r
uv_exepath It seems that only 4 more libuv symbols are added, filesize remains pretty much identical. I'm not very sure if this is the correct way to fix it so I'm happy to hear other suggestions. |
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.
I understand the motivation behind this and also want to fix it, but I don't believe that passing a reference to a generate static library file in this manner is the best choice here - it's somewhat brittle and I'd prefer to look into determining why the small handful of missing symbols are missing and fix that more directly as Sam says above.
I explored abit further on this, it looks like node's build script also uses I'm not sure how to go about this, in node's docs it says that libuv is purposefully re-exported and should be usable by native modules. If electron aims to support native modules, should it add
|
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.
These symbols are missing in Electron because they are not used anywhere in our codebase and the linker removes them automatically. This problem happens on all platforms so a linux-only fix would not be enough.
We can probably explicitly reference the symbols via -u
linker flag: https://stackoverflow.com/a/8907422.
node uses Actually the problem doesn't happen in Windows because libuv is built as a shared library, I wasn't able to test on mac so I don't know if it works. I have a test project here https://github.com/koonpeng/electron-uv-test. I can try adding a test case that use that module and see if it works on the CI, in the meantime I will convert this to a draft. |
Thanks for providing the test project, I confirm that this problem also happens on macOS. I'm good with the |
I tried using force_load and whole-archive flags like in node but I'm still getting symbol errors in the mac tests. It's hard for me to test without a mac. |
1ea8fdb
to
7c77854
Compare
Thanks for adding the test, I have added a commit to make it work on mac, it turns out we should use the |
@koonpeng can you please rebase this on master? |
7c77854
to
555beac
Compare
Failure is known on macOS - will merge when the Linux rerun passes. |
555beac
to
c03eacb
Compare
The failing mac test is unrelated. |
Congrats on merging your first pull request! 🎉🎉🎉 |
Release Notes Persisted
|
Description of Change
Forces libuv symbols to be exported, this fixes #24428.
Checklist
npm test
passesRelease Notes
Notes: Fixed undefined symbol error when loading native modules that uses
uv_dlopen