GithubHelp home page GithubHelp logo

Plans for Julia 1.7 about cxx.jl HOT 13 CLOSED

00sapo avatar 00sapo commented on August 16, 2024 2
Plans for Julia 1.7

from cxx.jl.

Comments (13)

Gnimuc avatar Gnimuc commented on August 16, 2024 10

Just to share some updates on this.

I reimplemented some basic Cxx utilities on top of ClangCompiler.jl in the rebuild-clang-compiler branch. (still WIP...)

Basically, it reworked some of the utilities in initialization.jl on top of ClangCompiler.jl with which you can directly create a Clang compiler instance from a real .cpp file(it's more like Clang.jl's compiler initialization).

Helper functions like addHeaderDir and cxxinclude are not implemented because we can directly write the code in the .cpp file with the new initialization API. They can be easily implemented in ClangCompiler.jl if there is any need in the future. As a result, the major functionalities of the cxx macro can be provided by directly writing C++ code in this .cpp file.

As for type translation(i.e. mapping between a Julia Datatype and a Clang QualType), we still use the method in cxxtypes.jl as the type hierarchy on the Julia side. The functionalities related to Clang types are partially moved into ClangCompiler.jl.

The next step is implementing an LLVM level of type translation(stripmodifier&resolvemodifier in the codegen.jl), so Julia types and Clang types can match at the LLVM IR level.

To lower a Clang type to LLVM type, we need to use some methods from the CodeGenTypes class which is not in the public headers of Clang. This adds another wrinkle to the build process: as Julia maintains a patched version of LLVM/Clang source code, to maximize the compatibility, we need to use patched source code when building our wrapper library. But at this moment, the patched code can not be easily accessed, yet(see JuliaPackaging/Yggdrasil#692 (comment)). (UPDATE 7/10/2021: we now have everything we need in the upstream, but I don't have time working on this until the end of this year.)

Then, we need some wrapper functions for creating Clang function decls, manipulating arguments, parsing the function body, and emitting the LLVM IR. The emitted LLVM IR for the C++ function can be inlined(cloned) into a new LLVM::Function created via LLVM.jl, so we can call it by using Julia's llvmcall.

The last step is to resurrect the icxx string macro. The interpolation feature needs some source code editing utilities like automatically generating Julia variables(symbols) and then handle them on the Clang side via sema(the semantic analysis module).

As for the @cxx macro, it's a bit convoluted than the icxx macro and I don't know much about what needs to be done to resurrect it.

from cxx.jl.

oschulz avatar oschulz commented on August 16, 2024 10

As for the @cxx macro, it's a bit convoluted than the icxx macro

Just speaking for myself, I'd be happy having Cxx.jl back on current Julia versions even if it's without the @cxx macro for now.

from cxx.jl.

Gnimuc avatar Gnimuc commented on August 16, 2024 4

We should add support for Julia 1.6 firstly, as it's probably the next LTS version. I started working on it two weeks ago following the way described in #486 (comment). If you'd like to help and don't know where to start, you can find me in the #clang channel on Slack.

from cxx.jl.

00sapo avatar 00sapo commented on August 16, 2024 2

Fine, I have just joined the #clang channel. I don't have so much time in this period, but I could help you as soon as I'll have a bit more time (mainly during we).

Also, I'm not expert about LLVM/clang, but I would like to learn!

from cxx.jl.

Gnimuc avatar Gnimuc commented on August 16, 2024

I just changed my mind due to some issues with 1.6(LLVM11), see JuliaPackaging/Yggdrasil#3315 (comment).

from cxx.jl.

PallHaraldsson avatar PallHaraldsson commented on August 16, 2024

With 1.7 now out, does it seem like it could be supported, or are there any known showstoppers to it getting supported? Would such support still likely break in any later version, or has there been some new development already to stop that?

Since Julia 1.0 is no longer LTS, it's not likely package authors are going to keep it as a lower bound, and may then go for 1.6, or 1.7. Unless [we make it] known it should be 1.3. Are there any other reasons, than this package to do that? And many cons to do that?

from cxx.jl.

Gnimuc avatar Gnimuc commented on August 16, 2024

The biggest problem is we lack active developers.

from cxx.jl.

00sapo avatar 00sapo commented on August 16, 2024

Hello, do you have any news about the development status?

from cxx.jl.

alhirzel avatar alhirzel commented on August 16, 2024

Hey @Gnimuc, I really appreciate your work on this package over the years. I wonder what steps could be taken by community members to increase participation? Do you have any recommendations or requests that we could help with?

from cxx.jl.

Gnimuc avatar Gnimuc commented on August 16, 2024

A good starting point is to read the comments in the source code to get a big picture. The next step is probably to get familiar with those LLVM/Clang APIs used in the project. If you're new to LLVM/Clang, it's highly recommended to compile the LLVM/Clang source code and browse the code using an IDE because you might need to reference the implementation of certain APIs to understand why some codes in the bootstrap.cpp are implemented in that way. A basic understanding of how Julia codegen works is also needed. Then, you can pick up some test cases and additional bug fixes.

from cxx.jl.

Gnimuc avatar Gnimuc commented on August 16, 2024

I forgot to mention how to compile the bootstrap library libcxxffi. You could take https://github.com/Gnimuc/libcxxffi as an example. It will be much easier for new contributors to get involved in the development of the package if #496 gets merged.

from cxx.jl.

Gnimuc avatar Gnimuc commented on August 16, 2024

Feel free to ask any questions in the Slack #clang channel.

from cxx.jl.

Gnimuc avatar Gnimuc commented on August 16, 2024

I'm closing this. See #496 for what feature has been resurrected and what is not.

from cxx.jl.

Related Issues (20)

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.