-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Cleanup deps_info.py. NFC. #12824
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
Cleanup deps_info.py. NFC. #12824
Conversation
1dc7cef
to
50c26ef
Compare
I don't see an explanation for When you write |
Yeah it is sad that is so hard to check if/why these things are needed. I guess for each entry here we would ideally have a test that fails without it... but I don't know that we do right now. One thing we could/shoudl probably do is add comments here (even thought its json .. so crap).. so that we know why each entry is needed. |
ttyname used to be implement in JS and like many others here was move to pure C and removed in d92efe0. When it was written it JS it used to depend on malloc. |
My process for going through these was:
For example, I'm going to re-invesigate those three symbols for which I couldn't find any reason for them being here in the first place:
|
73d37e8
to
77eb1c6
Compare
I can take another look here, but I think it needs to be rebased first? |
77eb1c6
to
39bfc3e
Compare
Rebased. |
39bfc3e
to
1786f19
Compare
Ping. |
I'm unsure about the process above. Why does being or not being in JS suffice? The list here handles the case of
where |
Yes you are correct. I am not saying that a symbol being in JS or not is sufficient. I just used the heuristic of "did this function recently move from JS to native code" as a way to produce a short list for investigation. Because often then a symbol moves from JS it can be removed from this file. Not always, but often. |
However, if a function is implemented purely in C and never calls out of JS, it never needs to be in this file right? Lets take an example:
Since realpath is implemented in pure C and does not call back out to JS, wasm-ld as full visibility of all its dependencies. If needs mallco or free wasm-ld already knows this. Its only if |
(I assume I don't think that's true. For example, malloc is purely in C and never calls out to JS (well, except for growth, but in a build without growth), but we still need it here. The problem is that it is called from JS, not that it calls JS. |
Oh, do you mean to appear here as a key, as opposed to a value? Yes, something in pure C and all deps also in pure C should not appear here. Is that what you verified? |
Yes, sorry, my process here is trying to purge unneeded keys. I'm mostly ignoring the values. My hypothesis is that if given key is implemented in native code and doesn't (even transitively) call out to JS then for sure it is no longer needed in this file. I think you are in agreement with that? If a given key is implemented in native code but does transitively call out to JS than perhaps it does belong in this file. The subset of keys that I've marked as "implemented in pure C" I believe fall into the first category and obviously don't belong in this file. |
I think that's right. Going through them, the first I am unsure of is |
tmpnam looks like it call the following functions:
I can't see how any of them our call out to JS an then depend on malloc and/or free. I guess we can prove these are not needed by compiling a test program that contains nothing else:
I will do that with each of these symbols... I think I made a mistake the result would be link error right? Not a runtime error? |
My worry is To be more sure, I'd also grep the output for |
f144915
to
56bd16e
Compare
This test create a small test program for each key in deps_info.py. The it checks the compiled JS output for usage of each of the symbols declared as dependencies. If a given symbol is not used then the dependency deemed not to be invalid. Adding this test means that as we evolve the code it won't ve possible to accidentally forget to update this file. Checking for symbols that are "used" is somewhat tricky. Each symbol will be defintition appear in the output JS since we are forcing the export that those symbols. We also don't want to match of substrings or comments.
56bd16e
to
0213d41
Compare
Closing in favor a more rigorous approach in #13483 |
For these two symbols I can see no evidence as to why they were ever added here.