elvm icon indicating copy to clipboard operation
elvm copied to clipboard

undefined sym: __builtin_mul

Open aaronryank opened this issue 7 years ago • 2 comments

Frequently when using the online demo, attempting to assemble the ELVM IR just prints:

undefined sym: __builtin_mul

It seems to occur anytime multiplication is needed. For example, the code below throws the error above:

int main(void) { printf("%d", 6 * 3); }

This may not just be the online demo but I suspect that it is.

aaronryank avatar Jan 27 '18 03:01 aaronryank

I know this is a weird limitation, but you need #include <stdio.h>, which lets the compiler include https://github.com/shinh/elvm/blob/master/libc/_builtin.h .

Including this file by default would significantly slow down the compilation for minimal code. Maybe we should let compiler emit __builtin_xxx when xxx is used first time.

shinh avatar Jan 27 '18 05:01 shinh

I agree, I think _builtin.h being included by default would simplify things a lot. I can't think of many useful programs that won't use multiplication in some form.

aaronryank avatar Jan 27 '18 17:01 aaronryank