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
error: symbol memset missing .functype when compiling .c to .s and then to wasm32 .o #53712
Comments
Here is the minified C source code that produces the same error: typedef struct {
int a;
int b[]
} c;
d() {
c *a;
int e, f;
e = g();
a = f = 0;
for (; f < e; f++)
a->b[f] = 0;
} |
@llvm/issue-subscribers-backend-webassembly |
/cc @sbc100 @aardappel |
I think you mean the opposite, defined but not declared? I do remember a few functions like |
Can repro locally with |
In |
Removing the |
No, I actually did mean declared but not defined. If you have
and compile to asm, you get
in the output. |
Possible fix here: https://reviews.llvm.org/D120365 |
Intrinsics like `memset` were not emitted as `.functype` because WebAssemblyAsmPrinter::emitExternalDecls explicitly skips symbols that are isIntrinsic. Removing that check doesn't work, since the symbol from the module refers to a 4-argument `llvm.memset.p0i8.i32` rather than the 3-argument `memset` symbol referenced in the call. Our `WebAssemblyMCLowerPrePass` however does collect the `memset` symbol, so the current solution is as simple as emitting `.functype` for those. Fixes: llvm/llvm-project#53712 Differential Revision: https://reviews.llvm.org/D120365
When using
wasi-sdk
to compile a C file to.s
and then to wasm32.o
, the second step would fail with an error message like this (compiling it to.o
directly seems to be fine):The command line to reproduce is:
We tried
13.0.0
,13.0.1
and14.0.0-rc1
llvm revisions in thewasi-sdk
build, the error persists. Since this only involves codegen and not linking with sysroot, I believe the repro can also work with a vanillaclang
installation.The commands can be run in the directory packaged in this tarball: https://drive.google.com/file/d/1ur9O8rQ0xYYLi8tmOlg79h7H0SXHPmw9/view?usp=sharing. We're still trying to come up with a minimal self-contained repro, meanwhile this is the best we have so far.
The text was updated successfully, but these errors were encountered: