[PATCH] D76547: [WebAssembly] Add `wasm-exported` function attribute

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Mar 29 11:10:23 PDT 2023


aaron.ballman added a comment.

In D76547#4231422 <https://reviews.llvm.org/D76547#4231422>, @sbc100 wrote:

> The reason `__attribute__((export_name("foo")))` doesn't work in all use cases is that we have a lot of existing code that uses the `EMSCRIPTEN_KEEPALIVE` macro.     We also have run into other folks who want to include this is some kind of `FOO_API`, or `EXPORT_API` type macros.  Its not possible to have such a macro map to the existing export_name since they don't include the symbol name: e.g:
>
>   EMSCRIPTEN_KEEPALIVE int foo();`
>   
>   JNI_EXPORT int myfunct();
>
> In these cases we need something that uses the llvm symbol name for the export.

I think there's two ways we could address this without adding a new attribute (maybe you've thought of this and have reasons for this to be a bad suggestion):

- It seems that `export_name` doesn't care if you put in an empty string for the argument, so we could treat that case as meaning "export with the name of the symbol this attribute is attached to"
- We could allow `export_name` to take zero or one argument. The one-argument form is the same as it is today, but the zero argument form exports with the name of the symbol the attribute is attached to.

Do you think either of those could work?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D76547/new/

https://reviews.llvm.org/D76547



More information about the cfe-commits mailing list