[PATCH] D76547: [WebAssembly] Add `wasm-exported` function attribute
Sam Clegg via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Mar 29 10:46:03 PDT 2023
sbc100 added a comment.
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.
However, as I mention in my earlier comment I have since realized that these attributes cannot be applies the llvm GlobalValues in general only the Functions... and the idea behind EMSCRIPTEN_KEEPALIVE is that it can be used to tag both functions and data symbols (addresses).
Sadly I don't see any way to attach attributes to data symbols in llvm today.. we have visibility but not attribute bag :(
================
Comment at: clang/lib/Sema/SemaDeclAttr.cpp:7572
+ if (FD->isThisDeclarationADefinition()) {
+ S.Diag(D->getLocation(), diag::err_alias_is_definition) << FD << 0;
+ return;
----------------
aaron.ballman wrote:
> Is this diagnostic actually correct? It's for use with the alias and ifunc attributes, so I'm surprised to see it here.
It does look incorrect yes, this is copy-pasted from the exist `ExportNameAttr` so I guess that is wrong too.
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