Skip to content
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

Add support for Haiku #1840

Open
nexus6-haiku opened this issue Mar 28, 2024 · 3 comments
Open

Add support for Haiku #1840

nexus6-haiku opened this issue Mar 28, 2024 · 3 comments

Comments

@nexus6-haiku
Copy link

I'm working on porting CppSharp to Haiku where we have a .NET SDK. It's not officially supported yet but it works pretty well.
I've made all the necessary changes to support the new OS (x64 only) including providing a pre-built LLVM package (LLVM17 it's the latest we have, atm).
I have a question on how to generate the bindings in src/CppParser/Bindings/CSharp.
Currently I'm using a copy from Linux or MacOS but clearly it's not going to work as I get tons of errors like:

Generating bindings for Encodings (CSharp)
  Unhandled exception. System.EntryPointNotFoundException: Unable to find an entry point named '?' in shared library 'Std-symbols'.
     at Std.BasicStringExtensions.__Internal.Data(IntPtr __instance)
     at Std.BasicStringExtensions.Data(BasicString`3 this) in /boot/home/workspace/CppSharp/src/CppParser/Bindings/CSharp/x86_64-unknown-haiku/Std.cs:line 540
     at CppSharp.Parser.CppParserOptions.get_ClangVersion() in /boot/home/workspace/CppSharp/src/CppParser/Bindings/CSharp/x86_64-unknown-haiku/CppSharp.CppParser.cs:line 41009
     at CppSharp.Parser.ParserOptions.get_BuiltinsDirBasePath() in /boot/home/workspace/CppSharp/src/Parser/ParserOptions.cs:line 408
     at CppSharp.Parser.ParserOptions.get_BuiltinsDir() in /boot/home/workspace/CppSharp/src/Parser/ParserOptions.cs:line 421
     at CppSharp.Parser.ParserOptions.SetupIncludes(TargetPlatform targetPlatform) in /boot/home/workspace/CppSharp/src/Parser/ParserOptions.cs:line 428
     at CppSharp.Parser.ParserOptions.Setup(TargetPlatform targetPlatform) in /boot/home/workspace/CppSharp/src/Parser/ParserOptions.cs:line 316
     at CppSharp.Driver.Setup() in /boot/home/workspace/CppSharp/src/Generator/Driver.cs:line 57
     at CppSharp.ConsoleDriver.Run(ILibrary library) in /boot/home/workspace/CppSharp/src/Generator/Driver.cs:line 399
     at CppSharp.Tests.EncodingsTestsGenerator.Main(String[] args) in /boot/home/workspace/CppSharp/tests/dotnet/Encodings/Encodings.Gen.cs:line 27

I'm a bit confused on how the process is supposed to be. Could these bindings be generated on Haiku itself or do I need to do it from another platform?
I've gone through #1708 and #1825 but have not fully grasped how to create the bindings. Is there a step-by-step guide or could anyone provide some guidance?

@nexus6-haiku
Copy link
Author

I've just built CppSharp on MacOS 14.4 (Intel) and I get the exact same error.
I have net8.0 installed so I forced the target framework with

./build.sh -configuration Release -platform x64 -target-framework net8.0

On Haiku I just add -os haiku.

My main concern on generating the bindings remains but I'm wondering if there's another issue here.

@tritao
Copy link
Collaborator

tritao commented Apr 17, 2024

Hello,

Missed this post, those bindings are generated by the ParserGen tool: https://github.com/mono/CppSharp/blob/main/src/CppParser/ParserGen/ParserGen.cs

You first will need to bootstrap the Haiku project from Linux, you will need to copy all the necessary system include header files to Linux and go from there.

@nexus6-haiku
Copy link
Author

Hello @tritao,
I've managed to compile the project from Haiku itself using the Linux bindings and all tests passed except 4, which was a good result.
I've also managed to re-generate them from Haiku.
Then I had to (re)apply a patch to LLVM that is not available yet in the version required by CppSharp to enable TLS (it has been merged upstream after that).
Now I get two type of errors in different points:

/boot/home/workspace/dotnet/CppSharp/build/gen/Encodings/Std.cs(229,43): error CS1001: Identifier expected [/boot/home/workspace/dotnet/CppSharp/tests/dotnet/Encodings/Encodings.CSharp.csproj]
/boot/home/workspace/dotnet/CppSharp/build/gen/Encodings/Std.cs(299,29): error CS1031: Type expected [/boot/home/workspace/dotnet/CppSharp/tests/dotnet/Encodings/Encodings.CSharp.csproj]
/boot/home/workspace/dotnet/CppSharp/build/gen/Encodings/Std.cs(308,88): error CS1031: Type expected [/boot/home/workspace/dotnet/CppSharp/tests/dotnet/Encodings/Encodings.CSharp.csproj]

and

/boot/home/workspace/dotnet/CppSharp/build/gen/VTables/Std.cs(233,43): error CS1001: Identifier expected [/boot/home/workspace/dotnet/CppSharp/tests/dotnet/VTables/VTables.CSharp.csproj]
/boot/home/workspace/dotnet/CppSharp/build/gen/VTables/Std.cs(303,29): error CS1031: Type expected [/boot/home/workspace/dotnet/CppSharp/tests/dotnet/VTables/VTables.CSharp.csproj]
/boot/home/workspace/dotnet/CppSharp/build/gen/VTables/Std.cs(312,88): error CS1031: Type expected [/boot/home/workspace/dotnet/CppSharp/tests/dotnet/VTables/VTables.CSharp.csproj]

These are mainly due to the lack of a type parameter, for example:

public unsafe partial class Allocator<> : IDisposable

Generating bindings for NamespacesDerived (CSharp)
Linking library libNamespacesBase-symbols.so...
Linking success.
CppSharp.Generator.Tests -> /boot/home/workspace/dotnet/CppSharp/bin/Release_x64/CppSharp.Generator.Tests.dll
Linking library libNamespacesDerived-symbols.so...
Linking success.
Linking library libStd-symbols.so...
Linking success.
Linking library libCSharp-symbols.so...
Linking success.
Symbol not found: _ZN48SpecializationOfClassWithNonTypeTemplateArgumentD2Ev
Symbol not found: _ZN48SpecializationOfClassWithNonTypeTemplateArgumentC2Ev
Symbol not found: HasPureVirtualWithDefaultArg_HasPureVirtualWithDefaultArg
Symbol not found: ProtectedConstructorDestructor_ProtectedConstructorDestructor
Compilation succeeded: /boot/home/workspace/dotnet/CppSharp/build/gen/NamespacesDerived/Std.dll.
CppSharp.Parser.Gen -> /boot/home/workspace/dotnet/CppSharp/bin/Release_x64/CppSharp.Parser.Gen.dll
CppSharp.CLI -> /boot/home/workspace/dotnet/CppSharp/bin/Release_x64/CppSharp.CLI.dll
/boot/home/workspace/dotnet/CppSharp/build/gen/CSharp/CSharp.cs(18241,40): warning CS8500: This takes the address of, gets the size of, or declares a pointer to a managed type ('T') [/boot/home/workspace/dotnet/CppSharp/tests/dotnet/CSharp/CSharp.CSharp.csproj]
CSharp.CSharp -> /boot/home/workspace/dotnet/CppSharp/build/gen/CSharp/CSharp.CSharp.dll
CSharp.Tests.CSharp -> /boot/home/workspace/dotnet/CppSharp/build/gen/CSharp/CSharp.Tests.CSharp.dll
Compilation succeeded: /boot/home/workspace/dotnet/CppSharp/build/gen/NamespacesDerived/NamespacesBase.dll.
Compilation succeeded: /boot/home/workspace/dotnet/CppSharp/build/gen/NamespacesDerived/NamespacesDerived.dll.
Common.Gen -> /boot/home/workspace/dotnet/CppSharp/bin/Release_x64/Common.Gen.dll

Just as an example there is a symbol _ZN48SpecializationOfClassWithNonTypeTemplateArgumentaSEOS_ that unmangled is SpecializationOfClassWithNonTypeTemplateArgument::operator=(SpecializationOfClassWithNonTypeTemplateArgument&&)

Do you have any idea where to look at?
Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants