Giter Club home page Giter Club logo

lilac's Introduction

Welcome to LILAC

LILAC is a Language to language Interoperability LAyer Compiler - with a goal that producing bindings across languages.

Interoperability across languages always sucks developers... (Especially, For managed languages such as Java, C#, Python)

For example, between C++ and C#:

  • C++/CLI couldn't support modern C++ well
  • In addition, C++/CLI doesn't support GNU/Linux
  • P/Invoke couldn't support C++ well because of name mangling etc.

But, with power of LLVM, we hope that LILAC will generate bindings between C++ and C# ...or what else! (Actually, For the languages not supporting LLVM, We need to implement frontend for each languages)

Let's break down language barrier!

Supported Languages

Language Backend Frontend
C++ ? O
C# O ?
  • O : Implemented.
  • ? : Not implemented, but planned.
  • ! : Work in Progress

Getting Started

See Getting Started

lilac's People

Contributors

sharp0802 avatar

Stargazers

jist avatar Dimi_Trader avatar DevZeta avatar

Watchers

 avatar

lilac's Issues

Crash with new code skeleton

Clang crashes with new code skeleton:

PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0.	Program arguments: /usr/bin/clang++ -S -emit-llvm -fno-discard-value-names -fplugin=/home/sharp0802/CLionProjects/lilac/cmake-build-debug/langs/cxx/frontend/lilac-cxx.so a.cpp
1.	a.cpp:42:5: current parser token 'void'
2.	a.cpp:12:1: parsing namespace 'TestNS1'
3.	a.cpp:41:35: parsing function body 'TestNS1::TestNS0::TestClass::StaticMethod'
 #0 0x0000608402b78698 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/usr/bin/clang+++0x3226698)
 #1 0x0000608402b760e0 llvm::sys::RunSignalHandlers() (/usr/bin/clang+++0x32240e0)
 #2 0x0000608402ae8c79 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
 #3 0x000078c1dc250ae0 (/usr/bin/../lib/libc.so.6+0x3cae0)
 #4 0x0000608402d18844 clang::SourceManager::getDecomposedExpansionLoc(clang::SourceLocation) const (/usr/bin/clang+++0x33c6844)
 #5 0x0000608402d1fc61 clang::SourceManager::getFileCharacteristic(clang::SourceLocation) const (/usr/bin/clang+++0x33cdc61)
 #6 0x0000608402cfd76d clang::DiagnosticIDs::getDiagnosticSeverity(unsigned int, clang::SourceLocation, clang::DiagnosticsEngine const&) const (/usr/bin/clang+++0x33ab76d)
 #7 0x00006084055f50f2 clang::sema::AnalysisBasedWarnings::IssueWarnings(clang::sema::AnalysisBasedWarnings::Policy, clang::sema::FunctionScopeInfo*, clang::Decl const*, clang::QualType) (/usr/bin/clang+++0x5ca30f2)
 #8 0x0000608404d8a0fe clang::Sema::PopFunctionScopeInfo(clang::sema::AnalysisBasedWarnings::Policy const*, clang::Decl const*, clang::QualType) (/usr/bin/clang+++0x54380fe)
 #9 0x0000608404eef0cb clang::Sema::ActOnFinishFunctionBody(clang::Decl*, clang::Stmt*, bool) (/usr/bin/clang+++0x559d0cb)
#10 0x0000608404d1e0b5 clang::Parser::ParseFunctionStatementBody(clang::Decl*, clang::Parser::ParseScope&) (/usr/bin/clang+++0x53cc0b5)
#11 0x0000608404c5073d clang::Parser::ParseFunctionDefinition(clang::ParsingDeclarator&, clang::Parser::ParsedTemplateInfo const&, clang::Parser::LateParsedAttrList*) (/usr/bin/clang+++0x52fe73d)
#12 0x0000608404c7300b clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&, clang::DeclaratorContext, clang::ParsedAttributes&, clang::Parser::ParsedTemplateInfo&, clang::SourceLocation*, clang::Parser::ForRangeInit*) (/usr/bin/clang+++0x532100b)
#13 0x0000608404c4f39c clang::Parser::ParseDeclOrFunctionDefInternal(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec&, clang::AccessSpecifier) (/usr/bin/clang+++0x52fd39c)
#14 0x0000608404c4ec49 clang::Parser::ParseDeclarationOrFunctionDefinition(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*, clang::AccessSpecifier) (/usr/bin/clang+++0x52fcc49)
#15 0x0000608404c4dda9 clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*) (/usr/bin/clang+++0x52fbda9)
#16 0x0000608404c913d7 clang::Parser::ParseInnerNamespace(llvm::SmallVector<clang::Parser::InnerNamespaceInfo, 4u> const&, unsigned int, clang::SourceLocation&, clang::ParsedAttributes&, clang::BalancedDelimiterTracker&) (/usr/bin/clang+++0x533f3d7)
#17 0x0000608404c914e2 clang::Parser::ParseInnerNamespace(llvm::SmallVector<clang::Parser::InnerNamespaceInfo, 4u> const&, unsigned int, clang::SourceLocation&, clang::ParsedAttributes&, clang::BalancedDelimiterTracker&) (/usr/bin/clang+++0x533f4e2)
#18 0x0000608404c90b95 clang::Parser::ParseNamespace(clang::DeclaratorContext, clang::SourceLocation&, clang::SourceLocation) (/usr/bin/clang+++0x533eb95)
#19 0x0000608404c70c80 clang::Parser::ParseDeclaration(clang::DeclaratorContext, clang::SourceLocation&, clang::ParsedAttributes&, clang::ParsedAttributes&, clang::SourceLocation*) (/usr/bin/clang+++0x531ec80)
#20 0x0000608404c4d67b clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*) (/usr/bin/clang+++0x52fb67b)
#21 0x0000608404c4be67 clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) (/usr/bin/clang+++0x52f9e67)
#22 0x0000608404c466ce clang::ParseAST(clang::Sema&, bool, bool) (/usr/bin/clang+++0x52f46ce)
#23 0x000060840349f66d clang::FrontendAction::Execute() (/usr/bin/clang+++0x3b4d66d)
#24 0x0000608403402b84 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/usr/bin/clang+++0x3ab0b84)
#25 0x000078c1dc03196e lilac::cxx::LilacAction::EndSourceFileAction() /home/sharp0802/CLionProjects/lilac/langs/cxx/frontend/src/pluginaction.cxx:36:13
#26 0x000060840349f7bc clang::FrontendAction::EndSourceFile() (/usr/bin/clang+++0x3b4d7bc)
#27 0x0000608403402b3c clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/usr/bin/clang+++0x3ab0b3c)
#28 0x0000608403562edd clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/usr/bin/clang+++0x3c10edd)
#29 0x00006084009d841a cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/usr/bin/clang+++0x108641a)
#30 0x00006084009d55eb ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#31 0x0000608403262379 void llvm::function_ref<void ()>::callback_fn<clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const::$_0>(long) Job.cpp:0:0
#32 0x0000608402ae8a28 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/usr/bin/clang+++0x3196a28)
#33 0x0000608403261b94 clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const (/usr/bin/clang+++0x390fb94)
#34 0x00006084032209b1 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/usr/bin/clang+++0x38ce9b1)
#35 0x0000608403220cae clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const (/usr/bin/clang+++0x38cecae)
#36 0x000060840323ee9c clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/usr/bin/clang+++0x38ece9c)
#37 0x00006084009d4ca8 clang_main(int, char**, llvm::ToolContext const&) (/usr/bin/clang+++0x1082ca8)
#38 0x00006084009e4a13 main (/usr/bin/clang+++0x1092a13)
#39 0x000078c1dc239c88 (/usr/bin/../lib/libc.so.6+0x25c88)
#40 0x000078c1dc239d4c __libc_start_main (/usr/bin/../lib/libc.so.6+0x25d4c)
#41 0x00006084009d2df5 _start (/usr/bin/clang+++0x1080df5)
clang++: error: clang frontend command failed with exit code 139 (use -v to see invocation)
clang version 19.0.0git (https://github.com/llvm/llvm-project 527e7328607ea0a55855e53a59c5030a7d07a554)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
clang++: error: unable to execute command: Segmentation fault (core dumped)
clang++: note: diagnostic msg: Error generating preprocessed source(s).

a.cpp:

namespace TestNS1
{
    enum TestEnum
    {
        A = 0x0001,
        B = -0x0002,
        C = +0x0010
    };
}

namespace TestNS1::TestNS0
{
    class [[lilac::export]] TestClass
    {
        long _field0[64];
        float _field1[64];
        double _field2[64];

        void PrivateMethod();

    public:
		[[lilac::export]]
        static int StaticMethod();

        void PublicMethod(TestClass tc, TestEnum te);
    };

    struct TestStruct
    {
        long _field0[64];
        float _field1[64];
        double _field2[64];

		[[gnu::visibility("default"), lilac::export]]
        TestClass PublicMethod(TestStruct& ts);
    };

    void GlobalFunction();

    int TestClass::StaticMethod() { return 0; }
    void TestClass::PrivateMethod() {}
    void TestClass::PublicMethod(TestClass tc, TestEnum te) {}
    TestClass TestStruct::PublicMethod(TestStruct& ts) { return {}; }
}

A mis-expected type-casting in `lilac::cxx::ExportAttrInfo`

In #1:

if (auto* const record = clang::cast<clang::RecordDecl>(decl))
...
else if (auto* const property = clang::cast<clang::MSPropertyDecl>(decl))
...
else if (auto* const function = clang::cast<clang::FunctionDecl>(decl))

If the type of decl can be either clang::RecordDecl or clang::MSPropertyDecl or clang::FunctionDecl, clang::dyn_cast should be used rather than clang::cast.

clang::cast causes exception when an argument cannot be cast into type parameter.

Thus, above code should be to:

if (auto* const record = clang::dyn_cast<clang::RecordDecl>(decl))
...
else if (auto* const property = clang::dyn_cast<clang::MSPropertyDecl>(decl))
...
else if (auto* const function = clang::dyn_cast<clang::FunctionDecl>(decl))

Obsess new compilation process

Current codebase using legacy compilation process (e.g. Create explicit IH file etc...)

We need to migrate codebase to new compilation process.

(Make huge change on codebase is too dangerous to proceed in-place; Create new branch)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.