LLVMSharp icon indicating copy to clipboard operation
LLVMSharp copied to clipboard

LLVM.GetTargetFromTriple in OO api

Open lukechu10 opened this issue 5 years ago • 4 comments

There does not seem to be an equivalent method in the object oriented api.

lukechu10 avatar Aug 14 '20 22:08 lukechu10

Yes I also realized this, this is the only way I could make it work:

unsafe
{
    fixed (byte* ptr = Encoding.ASCII.GetBytes("data-layout"))
        LLVM.SetDataLayout(Module, (sbyte*)ptr);
    fixed (byte* ptr = Encoding.ASCII.GetBytes("target"))
        LLVM.SetTarget(Module, (sbyte*)ptr);
}

Unsafe, but works. Also GetBitcodeModule functions seem to be not ported to object orinted API either.

jangofett4 avatar Aug 25 '20 09:08 jangofett4

Yes I also realized this, this is the only way I could make it work:

unsafe
{
    fixed (byte* ptr = Encoding.ASCII.GetBytes("data-layout"))
        LLVM.SetDataLayout(Module, (sbyte*)ptr);
    fixed (byte* ptr = Encoding.ASCII.GetBytes("target"))
        LLVM.SetTarget(Module, (sbyte*)ptr);
}

Unsafe, but works. Also GetBitcodeModule functions seem to be not ported to object orinted API either.

Thanks a lot. I have been looking for a workaround for weeks now. 😃

lukechu10 avatar Aug 25 '20 16:08 lukechu10

Yeah, no problem 😉. I want create a new pull request for these missing methods but I need to research the code structure more.
Edit: Probably related #141 (?)

jangofett4 avatar Aug 26 '20 11:08 jangofett4

The nicer managed wrapper tries to mirror the C++ API structure where possible, there are naturally chunks missing and so not everything can be mirrored perfectly.

tannergooding avatar Aug 27 '20 16:08 tannergooding