Skip to content
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

Need to be able to link against other .wasm files #22

Closed
fitzgen opened this issue Jan 17, 2018 · 6 comments
Closed

Need to be able to link against other .wasm files #22

fitzgen opened this issue Jan 17, 2018 · 6 comments

Comments

@fitzgen
Copy link
Member

fitzgen commented Jan 17, 2018

There are places I'd like to write WAT directly, compile it into a .wasm in build.rs (or maybe just check in the compiled .wasm file into the repo since it is architecture independent), and then link that .wasm into my top level cdylib crate.

@pepyakin
Copy link
Member

Sounds like job for wasm-link from wabt.

@fitzgen
Copy link
Member Author

fitzgen commented Jan 17, 2018

My understanding is that when rustc starts using lld as a linker, and lld finishes its .wasm support, this issue should go away.

However, using wasm-link for now works OK. Its usability is compromised by the lack of a post_build.rs hook in cargo, especially for crates that are intended to be used as a library and want to link some .wasm, rather than the root cdylib that creates the top .wasm file.

@mgattozzi
Copy link
Contributor

Given the discussion over in cargo about post build scripts I doubt this will be the route to go. I think getting lld linker support in sooner would be the most bang for our buck as having linker support helps with other issues as well. wasm support has already been moved to upstream lld so I think this is only a matter of time till we can get it integrated into rustc.

@est31
Copy link

est31 commented Jan 17, 2018

yeah sadly post build scripts have been rejected which would have made many things a bit easier :/

For this feature we should probably wait until we can integrate LLD into rustc or ship lld together with rustc or similar.

@alexcrichton
Copy link
Contributor

@fitzgen I agree yeah that when we have lld this will probably just go away. At that point there will be a semi-standard format (I think) of "wasm object files", and I'd imagine at that point you'd just use archives and #[link] or -l flags as you do for other platforms today.

@alexcrichton
Copy link
Contributor

With LLD I believe this is now possible. Currently the foreign files need to just be compiled with clang 6 and otherwise we should be good to go.

Now that being said I think there's still a long way to go here. I'm not sure if the "object file format" is well documented or if it's easy to write a "wat" file by hand. Furthermore crates like cc don't have support for compiling "wat" at the moment as well. In any case those concerns are probably best covered in follow-up issues, so closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants