-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Disallow exports that are not valid C/C++ identifiers #23563
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
as I mentioned in #23560 it's actually JS identifier rules that matter here, not C; are they different? |
JS identifier rules are a bit more relaxed. You can do |
We can always relax things later if had the need to. |
6015bc4
to
363482c
Compare
I use `std.isdentifier()` here from python since it has the same rules for valid identifiers are C/C++. We could try instead to allow this but I'm not sure it worth it given that our inputs are almost exclusively compiled from C/C++/rust. See emscripten-core#23560
363482c
to
999b54e
Compare
I propose that we land this and then consider expanding later. |
OK to land this? |
This change broke rust linking. Apparently Rust likes to put Details
|
And do those symbols need to be exported? One problem is that we cannot create JS symbols with names like so we would have to figure out what to when these symbols are exported. How are these symbols been exported exactly? |
It's linking with |
llvm-readobj shows they have
|
Strange, with visibility=hidden i would not expect that linker to export the symbol. Any idea whats up with that? |
Nope, I will investigate when I have a chance and see if I can figure out what's happening. Since with |
They are definitely showing up as exports in the final linked so: Details
|
Perhaps they are marked with an explicit "export_name" in the linking section of the object file. Perhaps that is taking precedence over the visibility=hidden but perhaps it should not? |
I'll try to see. The first step is to minimize the reproducer. I bet it'll fail even for a hello world style example. |
@sbc100 could we revert this in the meantime to unbreak rust? |
But wouldn't that result in invalid JS being genrated? i.e. all the unexpected exports are exported as JS symbols, and this is an invalid JS symbols? Or is this only when generating a side module? I suppose to would limit the error to when we are actually generating JS (i.e. not when building a side module)? |
Yes, limiting the check to when not building a side module would work for our purposes. |
If you would like to submit such a PR, I think would be acceptable. I would like to see this investigated more (i.e. please include a comment and link to a bug) and fixed at some point though since those symbols should not be exported, should they? |
I use
std.isdentifier()
here from python since it has the same rules for valid identifiers are C/C++.We could try instead to allow this but I'm not sure it worth it given that our inputs are almost exclusively compiled from C/C++/rust.
See #23560