Stream: cranelift

Topic: using cranelift as a backend for a non-rust compiler


view this post on Zulip Alec Thomas (Oct 10 2020 at 10:25):

hi, I've been investigating a bunch of compiler backends (LLVM, QBE ), and came across CLIF. my compiler is not written in rust, so i was wondering if there's existing command-line tooling that can accept CLIF and generate executables, or is the only interface via rust?

the closest i could find is this PR: https://github.com/bytecodealliance/cranelift/pull/872

This PR allows users to execute CLIF functions from the command line by running clif-util run [-v] {file}*. It will look for functions with a signature like () -> bool that have a run: comment a...

view this post on Zulip bjorn3 (Oct 10 2020 at 12:27):

There is currently no C api for Cranelift. As for a program that accepts clif ir in text form and creates an executable, there is none either. The main problem here is that cranelift-module (the interface used to "glue" multiple functions together) doesn't have a text form. This would be useful for other things too though. I have opened #2285 for this.

view this post on Zulip Alec Thomas (Oct 11 2020 at 04:34):

ok, thanks for clarifying

view this post on Zulip Carlo Kok (Oct 12 2020 at 06:22):

I started on https://gist.github.com/carlokok/d0d079dba76ee253a1571d58f2e791fb some time ago (it might/will be slightly out of date); could be a good starting point. I have a version at home that's slightly more up to date.

GitHub Gist: instantly share code, notes, and snippets.

view this post on Zulip Carlo Kok (Oct 12 2020 at 06:23):

generates a fairly decent C header with cbindgen.


Last updated: Oct 23 2024 at 20:03 UTC