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

Consider LLVM as an alternative to C #1991

Closed
Techcable opened this Issue Nov 10, 2017 · 3 comments

Comments

Projects
None yet
3 participants
@Techcable

Techcable commented Nov 10, 2017

Is this on the roadmap?
Using C as an intermediate language is not only slow to compile but isn't very portable and may create low-quality code.
How difficult would switching directly to emitting LLVM be? Could you consider changing your internals to pave the way for a future switch to LLVM? I feel like the hardest part would be handling C interoperability, but LLVM makes this somewhat elegant. You could still emit everything directly in pure-python code since Numba has already created the excellent llvmlite bindings.

The benefits of this change could be enormous, not only for performance and compilation speed but for the quality of the generated code and the build system.
I hope you consider this to help move past the limitations of using C as an intermediate representation!

Thanks for your time,
- Techcable

@scoder

This comment has been minimized.

Show comment
Hide comment
@scoder

scoder Nov 10, 2017

Contributor

Is this on the roadmap?

Wrong question. If someone implements this, and proves along the way that it's worth doing, then I doubt that we'd reject the pull requests for it.

However, it's not obvious to me that such an approach has advantages. I consider C (and C++) an excellent language target that results in a very high portability. It makes it rather easy for developers to ship the generated C code to their users and have them compile it on their side with pretty much any C compiler. Restricting that to LLVM would in fact reduce the wideness of Cython's applicability.

Could you elaborate what benefits you expect from targeting LLVM specifically instead of generic C?

Contributor

scoder commented Nov 10, 2017

Is this on the roadmap?

Wrong question. If someone implements this, and proves along the way that it's worth doing, then I doubt that we'd reject the pull requests for it.

However, it's not obvious to me that such an approach has advantages. I consider C (and C++) an excellent language target that results in a very high portability. It makes it rather easy for developers to ship the generated C code to their users and have them compile it on their side with pretty much any C compiler. Restricting that to LLVM would in fact reduce the wideness of Cython's applicability.

Could you elaborate what benefits you expect from targeting LLVM specifically instead of generic C?

@Techcable Techcable changed the title from Consider directly emitting llvm IR to Consider LLVM as an alternative to C Nov 17, 2017

@stefanos82

This comment has been minimized.

Show comment
Hide comment
@stefanos82

stefanos82 Dec 13, 2017

As far as I know, Nim and Crystal are two languages that emit optimized C code for the sake of performance and portability.

What makes you think C compiles slow?

As far as I can tell, (from a personal experience) it compiles like a bullet comparing it with C++'s compilation time.

Now, about LLVM IR support; how is LLVM supposed to bridge the CPython API with the intermediate representation?

Will it be able to emit CPython extension code without any possible problem?

If you have any example to make it clearer, it would be really interesting to study it.

Another negative impact I see is that it would force developers to use a compiler other than what they actually use or feel comfortable with.

Cython as it is, it works just fine.

All it needs is love and caring around those nasty bugs, that's all.

stefanos82 commented Dec 13, 2017

As far as I know, Nim and Crystal are two languages that emit optimized C code for the sake of performance and portability.

What makes you think C compiles slow?

As far as I can tell, (from a personal experience) it compiles like a bullet comparing it with C++'s compilation time.

Now, about LLVM IR support; how is LLVM supposed to bridge the CPython API with the intermediate representation?

Will it be able to emit CPython extension code without any possible problem?

If you have any example to make it clearer, it would be really interesting to study it.

Another negative impact I see is that it would force developers to use a compiler other than what they actually use or feel comfortable with.

Cython as it is, it works just fine.

All it needs is love and caring around those nasty bugs, that's all.

@scoder scoder added R: wontfix and removed unclear labels Dec 15, 2017

@scoder

This comment has been minimized.

Show comment
Hide comment
@scoder

scoder Dec 15, 2017

Contributor

I'm closing this for now, assuming that no-one's really going to give it a serious try.
Basically, it's a lot of work that adds lots of complexity with a very uncertain gain.

Contributor

scoder commented Dec 15, 2017

I'm closing this for now, assuming that no-one's really going to give it a serious try.
Basically, it's a lot of work that adds lots of complexity with a very uncertain gain.

@scoder scoder closed this Dec 15, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment