-
Notifications
You must be signed in to change notification settings - Fork 786
Only export functions with default visibility #587
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
base: main
Are you sure you want to change the base?
Conversation
As discussed in #585, this change makes s2wasm more aware of the symbol visibility output from LLVM, and only exports global functions with default visibility (instead of all globals as before).
c7e5cca
to
1ee1d55
Compare
lgtm |
Any chance of this landing? It'd be nice to not export the world :) |
Ah yeah.... so we've been trying to bring up the remaining emscripten test suite tests for the wasm backend (which exercise a lot of emscripten features and, JS glue, etc) before landing this to see what kind of effect it had. But we are getting close on that, and we are also working on getting support in LLVM for wasm binaries (which will be a bit later), so now might be a good time to start thinking a little more about this as an ABI/convention issue. |
That makes sense - tests are good :) |
I think we'd want wasm-opt to be optional, rather than a requirement. the LLVM wasm backend has plenty of optimizations that it inherits from LLVM's target-independent code, so it produces pretty decent code quality. I could certainly imagine that wasm-opt might be able to improve on that, but we haven't done really any meaningful performance work yet. |
That's for code size. For throughput, the wasm backend emits slower code than |
Yeah; as I said we've basically been trying to mature the backend in the face of all the changes to wasm itself (and catch up to JSBackend's several-year head start). There are lots of optimization opportunities still on the table. |
Do we still need this, or can it be closed? |
I think the reason I was holding off on this was to get the rest of the emscripten testsuite passing (which @jgravelle-google has been doing, along with the various general improvements like the libc update). At that point we would be more assured that turning this on wouldn't break anything. More generally I think we still want to do this anyway, but the design for what "visibility" means (to the linker and in C++ code) should probably be done in conjunction with the other design conventions e.g. https://github.com/WebAssembly/tool-conventions/blob/master/Linking.md and https://github.com/WebAssembly/tool-conventions/blob/master/DynamicLinking.md So, short answer is, we can probably try rebasing it and turning it on more-or-less as-is shortly. If things are fine for the current emscripten+wasm-backend style of integration, then we should land it. If not, then we can close it and rethink things. |
Perhaps this would be worth landing behind a command line flag, if there is reservation to merging this? That way we can at least start running with the use cases. I'd really like to adopt this approach in my own compilation test workflows. |
I'm now working on replacing s2wasm with a different approach for connecting LLVM output to binaryen -- LLVM now has the ability to emit wasm binaries directly, so with some extra bookkeeping, we can skip the .s parsing step, which is fairly fragile due to not being a "real" .s parser. That said, this is a fairly big project, so if people want to continue maintaining s2wasm in its current form, they're welcome to. |
@sunfishcode thanks so much for your response, is https://github.com/llvm-mirror/clang/blob/master/test/Driver/wasm-toolchain.c the best place to start to try and follow this direct wasm output from llvm? |
If you're looking for a specific file, https://github.com/llvm-mirror/llvm/blob/master/lib/MC/WasmObjectWriter.cpp does a lot of the work of the actual wasm object writing. |
As discussed in #585, this change makes s2wasm more aware of the
symbol visibility output from LLVM, and only exports global functions
with default visibility (instead of all globals as before).