From c880be445cb99aafc3e60268b4fb9a13c6ce9bd1 Mon Sep 17 00:00:00 2001 From: Conrad Kreyling Date: Fri, 2 Feb 2024 13:35:11 -0500 Subject: [PATCH 1/3] Enable ARM64 support on LLVM builds --- .github/workflows/llvm.yml | 2 ++ build/Helpers.lua | 5 +++++ build/LLVM.lua | 6 ++++++ build/llvm/LLVM.lua | 2 +- 4 files changed, 14 insertions(+), 1 deletion(-) diff --git a/.github/workflows/llvm.yml b/.github/workflows/llvm.yml index 57dc21d4b..87b31a680 100644 --- a/.github/workflows/llvm.yml +++ b/.github/workflows/llvm.yml @@ -10,8 +10,10 @@ jobs: matrix: config: - { os: ubuntu-22.04, platform: x64, cxx: g++-11, cc: gcc-11 } + - { os: ubuntu-22.04, platform: arm64, cxx: g++-11, cc: gcc-11 } - { os: macos-11, platform: x64, cxx: clang++, cc: clang } - { os: macos-12, platform: x64, cxx: clang++, cc: clang } + - { os: macos-12, platform: arm64, cxx: clang++, cc: clang } runs-on: ${{ matrix.config.os }} diff --git a/build/Helpers.lua b/build/Helpers.lua index 0a2e030d1..96a323547 100644 --- a/build/Helpers.lua +++ b/build/Helpers.lua @@ -10,6 +10,7 @@ newoption { allowed = { { "x86", "x86 32-bits" }, { "x64", "x64 64-bits" }, + { "arm64","ARM64 64-bits" }, } } @@ -251,11 +252,15 @@ function AddPlatformSpecificFiles(folder, filename) filter { "toolset:msc*", "architecture:x86" } files { path.join(folder, "i686-pc-win32-msvc", filename) } elseif os.istarget("macosx") then + filter { "architecture:arm64" } + files { path.join(folder, "arm64-apple-darwin12.4.0", filename) } filter { "architecture:x86_64" } files { path.join(folder, "x86_64-apple-darwin12.4.0", filename) } filter {"architecture:x86" } files { path.join(folder, "i686-apple-darwin12.4.0", filename) } elseif os.istarget("linux") then + filter { "architecture:arm64" } + files { path.join(folder, "arm64-linux-gnu" .. (UseCxx11ABI() and "-cxx11abi" or ""), filename) } filter { "architecture:x86_64" } files { path.join(folder, "x86_64-linux-gnu" .. (UseCxx11ABI() and "-cxx11abi" or ""), filename) } else diff --git a/build/LLVM.lua b/build/LLVM.lua index 86fa1be6b..9ac89c54c 100644 --- a/build/LLVM.lua +++ b/build/LLVM.lua @@ -172,6 +172,12 @@ function SetupLLVMLibs() "LLVMX86CodeGen", "LLVMX86Desc", "LLVMX86Info", + "LLVMAArch64AsmParser", + "LLVMAArch64CodeGen", + "LLVMAArch64Desc", + "LLVMAArch64Disassembler", + "LLVMAArch64Info", + "LLVMAArch64Utils", "LLVMipo", "LLVMInstrumentation", "LLVMVectorize", diff --git a/build/llvm/LLVM.lua b/build/llvm/LLVM.lua index f375b39e9..015743965 100644 --- a/build/llvm/LLVM.lua +++ b/build/llvm/LLVM.lua @@ -254,7 +254,7 @@ function cmake(gen, conf, builddir, options) .. ' -DLLVM_ENABLE_ZSTD=false' .. ' -DLLVM_INCLUDE_DOCS=false' .. ' -DLLVM_INCLUDE_EXAMPLES=false' - .. ' -DLLVM_TARGETS_TO_BUILD="X86"' + .. ' -DLLVM_TARGETS_TO_BUILD="X86;AArch64"' .. ' -DLLVM_TOOL_BUGPOINT_BUILD=false' .. ' -DLLVM_TOOL_BUGPOINT_PASSES_BUILD=false' .. ' -DLLVM_TOOL_CLANG_TOOLS_EXTRA_BUILD=false' From 308d6afff08757932f4540eadd2c80744dbb39ea Mon Sep 17 00:00:00 2001 From: Conrad Kreyling Date: Fri, 2 Feb 2024 15:09:44 -0500 Subject: [PATCH 2/3] Fix missing AArch64 entry in CLI CppAbi --- src/CppParser/Bindings/CLI/Decl.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/CppParser/Bindings/CLI/Decl.h b/src/CppParser/Bindings/CLI/Decl.h index 58233c2c1..940ad9694 100644 --- a/src/CppParser/Bindings/CLI/Decl.h +++ b/src/CppParser/Bindings/CLI/Decl.h @@ -255,9 +255,10 @@ namespace CppSharp Itanium = 0, Microsoft = 1, ARM = 2, - iOS = 3, - AppleARM64 = 4, - WebAssembly = 5 + AArch64 = 3, + iOS = 4, + AppleARM64 = 5, + WebAssembly = 6 }; public enum class RecordArgABI From 343d009bfcea2e1f7875f40ecdae62520f240bc2 Mon Sep 17 00:00:00 2001 From: Conrad Kreyling Date: Fri, 2 Feb 2024 15:12:42 -0500 Subject: [PATCH 3/3] Instruct generator to build ARM64 bindings --- src/CppParser/ParserGen/ParserGen.cs | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/CppParser/ParserGen/ParserGen.cs b/src/CppParser/ParserGen/ParserGen.cs index f068a71ed..48b0ab4af 100644 --- a/src/CppParser/ParserGen/ParserGen.cs +++ b/src/CppParser/ParserGen/ParserGen.cs @@ -170,13 +170,17 @@ public static void Main(string[] args) var osxHeadersPath = Path.Combine(GetSourceDirectory("build"), @"headers\osx"); if (Directory.Exists(osxHeadersPath) || Platform.IsMacOS) { - Console.WriteLine("Generating the C# parser bindings for OSX..."); + Console.WriteLine("Generating the C# parser bindings for OSX x86..."); ConsoleDriver.Run(new ParserGen(GeneratorKind.CSharp, "i686-apple-darwin12.4.0")); Console.WriteLine(); - Console.WriteLine("Generating the C# parser bindings for OSX..."); + Console.WriteLine("Generating the C# parser bindings for OSX x64..."); ConsoleDriver.Run(new ParserGen(GeneratorKind.CSharp, "x86_64-apple-darwin12.4.0")); Console.WriteLine(); + + Console.WriteLine("Generating the C# parser bindings for OSX ARM64..."); + ConsoleDriver.Run(new ParserGen(GeneratorKind.CSharp, "arm64-apple-darwin12.4.0")); + Console.WriteLine(); } var linuxHeadersPath = Path.Combine(GetSourceDirectory("build"), @"headers\x86_64-linux-gnu"); @@ -186,10 +190,19 @@ public static void Main(string[] args) ConsoleDriver.Run(new ParserGen(GeneratorKind.CSharp, "x86_64-linux-gnu")); Console.WriteLine(); + Console.WriteLine("Generating the C# parser bindings for Linux ARM64..."); + ConsoleDriver.Run(new ParserGen(GeneratorKind.CSharp, "arm64-linux-gnu")); + Console.WriteLine(); + Console.WriteLine("Generating the C# parser bindings for Linux (GCC C++11 ABI)..."); ConsoleDriver.Run(new ParserGen(GeneratorKind.CSharp, "x86_64-linux-gnu", isGnuCpp11Abi: true)); Console.WriteLine(); + + Console.WriteLine("Generating the C# parser bindings for Linux ARM64 (GCC C++11 ABI)..."); + ConsoleDriver.Run(new ParserGen(GeneratorKind.CSharp, "arm64-linux-gnu", + isGnuCpp11Abi: true)); + Console.WriteLine(); } } }