dotnet / LLVMSharp

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

System.EntryPointNotFoundException of LLVM.InitializeNativeAsmPrinter() #200

Closed CWKSC closed 1 year ago

CWKSC commented 1 year ago
<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net7.0</TargetFramework>
    <ImplicitUsings>enable</ImplicitUsings>
    <Nullable>enable</Nullable>
    <RuntimeIdentifier Condition="'$(RuntimeIdentifier)' == ''">$(NETCoreSdkRuntimeIdentifier)</RuntimeIdentifier>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="libLLVM" Version="15.0.0" />
    <PackageReference Include="LLVMSharp" Version="5.0.0" />
  </ItemGroup>

</Project>

image

LLVM.InitializeNativeAsmPrinter();
LLVM.InitializeNativeTarget();
System.EntryPointNotFoundException: 'Unable to find an entry point named 'LLVMInitializeNativeAsmPrinter' in DLL 'libLLVM'.'
tannergooding commented 1 year ago

Hmmm, this does appear to be missing from the exports in the official LLVM-C.dll binary.

tannergooding commented 1 year ago

@CWKSC, just noticed but you're referencing LLVMSharp 5.0.0. Can you please update to v15.0.0

CWKSC commented 1 year ago

Do you mean changing LLVMSharp from 5.0.0 to 15.0.0

<ItemGroup>
    <PackageReference Include="libLLVM" Version="15.0.0" />
-   <PackageReference Include="LLVMSharp" Version="5.0.0" />
+   <PackageReference Include="LLVMSharp" Version="15.0.0" />
</ItemGroup>

But the latest version of LLVMSharp is 5.0.0 in NuGet.

image

This will produce NU1102 Unable to find package if I directly change it.

If I understand correctly, the library works when both libLLVM and LLVMSharp are installed.

If I only install LLVMSharp

image

This will be using outdated LibLLVM (5.0.1)

When I install both,

image

The dependency inside LLVMSharp is changed.

Sorry if any misunderstanding.

tannergooding commented 1 year ago

The latest version is 15.0.0-beta1: https://www.nuget.org/packages/LLVMSharp/15.0.0-beta1

It's not visible because you don't have the include pre-release check box checked.

The 5.0.0 version is over 5 years old and significantly out of date and while the new version is still marked "pre-release" it is generally better and overall more stable.

CWKSC commented 1 year ago

Oh, thank you!

I changed it, and I found that API became very complicated and unusual

image

LLVMOpaqueType**, sbyte*

This is using LLVMSharp.Interop; instead of using LLVMSharp; now

Is this normal?

Sorry I'm not familiar.

tannergooding commented 1 year ago

Yes. The entire API surface was redone to be more correct, have fewer breaking changes, and to be blittable.