-
Notifications
You must be signed in to change notification settings - Fork 64
Web export: add -Zdefault-visibility=hidden
#127
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
SvizelPritula
left a comment
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.
Looks good!
src/toolchain/export-web.md
Outdated
| "-C", "link-args=-pthread", # /!\ Read 'Thread support' below regarding this flag | ||
| "-C", "target-feature=+atomics", # /!\ Read 'Thread support' below regarding this flag | ||
| "-C", "link-args=-sSIDE_MODULE=2", | ||
| "-C", "-Zdefault-visibility=hidden", |
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 think you meant this?
| "-C", "-Zdefault-visibility=hidden", | |
| "-Z", "default-visibility=hidden", |
src/toolchain/export-web.md
Outdated
| RUSTFLAGS="-C link-args=-pthread \ | ||
| -C target-feature=+atomics \ | ||
| -C link-args=-sSIDE_MODULE=2 \ | ||
| -C -Zdefault-visibility=hidden \ |
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.
| -C -Zdefault-visibility=hidden \ | |
| -Z default-visibility=hidden \ |
src/toolchain/export-web.md
Outdated
| -C link-args=-pthread \ | ||
| -C target-feature=+atomics \ | ||
| -C link-args=-sSIDE_MODULE=2 \ | ||
| -C default-visibility=hidden \ |
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.
| -C default-visibility=hidden \ | |
| -Z default-visibility=hidden \ |
| A bit of background: The compiled Wasm binary is a _side module_ which is dynamically loaded by Godot's _main module_ at runtime. | ||
| This is very similar to how dynamic libraries and executables work. | ||
|
|
||
| The [`default-visibility=hidden` flag][rustc-visibility] ensures that symbols of each side module are private to that module. |
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.
Could this affect user (non-gdext internal) code somehow? If this is the default, how can it be selectively turned off?
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 currently don't see a use case where one wouldn't want that -- it would mean explicitly sharing symbols with other side modules (Godot or extensions) -- and there are better ways to communicate with them (GDExtension itself) 🤔
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 don't think it can be selectively turned off right now, which is unfortunate. There is an RFC, though.
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 still think that the toolchain's behaviour is buggy, I believe normally only #[unsafe(no_mangle)] should be exported like this. As I mentioned in my comment, on x86-64 Linux all non-mangled objects end up as LOCAL.
|
|
||
| In addition, please note that **godot-rust 0.3 or later** is required to fix this error. | ||
|
|
||
| 4. `LinkError: WebAssembly.instantiate(): Import #6 "env" "__cpp_exception": tag import requires a WebAssembly.Tag` |
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.
Wonder if we could also mention something about this bug in this section, but I suppose it doesn't lead to one specific error, rather being undefined behavior / a race condition.
679d349 to
735f53b
Compare
|
Thanks a lot @PgBiel! The different formatting and order of Regarding "what if one forgets |
Interesting. Would be nice indeed i possible. More generally, though, I really wish we could just manage those flags for the user. Would be nice if we could figure out a way to set "defaults"... I remember looking into some solution involving |
See godot-rust/gdext#968 (comment)