Skip to content

Import attribute #68

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

Closed
Jiboo opened this issue Oct 22, 2018 · 6 comments
Closed

Import attribute #68

Jiboo opened this issue Oct 22, 2018 · 6 comments

Comments

@Jiboo
Copy link

Jiboo commented Oct 22, 2018

Hello,

As there is a reflection about a dedicated export attribute in #64, I wondered if there would be any interest for an import attribute?

With a string argument, it may allow imports from multiple modules/host-namespaces, lifting the restriction on --allow-undefined-file to import only from "env".
It would make it more convenient for embeders to specify their API, and users to compile against it.

// env.h
__attribute__((wasm_import("env"))) void print_i32(int32_t);
__attribute__((wasm_import("env"))) void print_i64(int64_t);
...

// test.c
#include <env.h>
__attribute__((wasm_export)) void hello() { print_i32(789); }

Thanks,
JB.

@sbc100
Copy link
Member

sbc100 commented Oct 22, 2018

There is work in progress on this already: #55

@xtuc
Copy link
Contributor

xtuc commented Oct 22, 2018

FYI I made WebAssembly/binaryen#1500 some time ago

@sbc100
Copy link
Member

sbc100 commented Oct 22, 2018

Yes WebAssembly/binaryen#1500 looks very similar, but for the .s file format rather than the binary.

@Jiboo
Copy link
Author

Jiboo commented Oct 22, 2018

Thanks, although I'm not sure about how to be able to output this attribute (to the .s) from clang?

I stumbled into the "import_module" attribute, but it look like it didn't make it into upstream (can't find "import_module" in tools/clang/include/clang/Basic/Attr.td).

It looks implemented for rust.

@xtuc
Copy link
Contributor

xtuc commented Oct 22, 2018

Interesting, I didn't know that PR against LLVM, but I did implement it on my side as well. (Edit: or I don't remember)

First I bypassed LLVM, see https://github.com/xtuc/holyc/blob/master/include/webassembly/esm.h but the plan was to implement some syntax in the frontend.

@Jiboo
Copy link
Author

Jiboo commented Oct 22, 2018

@xtuc oh, didn't though about dumping it using __asm__

I guess I'll close this as some work along this direction (import attribute) already were investigated.

Thanks again,
JB.

@Jiboo Jiboo closed this as completed Oct 22, 2018
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

3 participants