dotnet / LLVMSharp

LLVM bindings for .NET Standard written in C# using ClangSharp
MIT License
838 stars 95 forks source link

Linking external native functions #188

Closed RecursiveDescent closed 2 years ago

RecursiveDescent commented 2 years ago

So I'm working on a compiler where I am trying to generate a linux executable, and I've got the object file generating as well as linking it with libc.

But no matter what I try I can't get LLVMSharp to generate an external symbol.

I would think this is how I'm supposed to do it but there must be something I'm missing, since llvm isn't even generating the symbol at all when I run strings on it.

LLVMValueRef fn = LLVM.AddFunction(Module, member.Name, fntype);

fn.SetLinkage(LLVMLinkage.LLVMExternalLinkage);

My bad.. It turns out my compiler wasn't even calling the function and I didn't realize it. It's unfortunate I can't delete this because this is quite an embarrassing flop for me.

tannergooding commented 2 years ago

It's unfortunate I can't delete this because this is quite an embarrassing flop for me.

Absolutely no worries. Everyone misses stuff at times and I've opened plenty of similar issues in my time <3