LLVM-CBE is a C-backend for LLVM, i.e. a tool that turns LLVM bitcode 1 into C

Overview

Rust bindings for LLVM-CBE (HALTED)

LLVM-CBE is a C-backend for LLVM, i.e. a tool that turns LLVM bitcode 1 into C. It requires to be built near LLVM, which was found to be so heavy dependency that shipping it as Cargo crate would be absurd.

Motivation

The goal that the authors have in mind is combining LLVM-CBE with SWIG for the purpose of facilitation cross-language code reuse. SWIG is a software development tool that connects programs written in C and C++ with a variety of high-level programming languages: (1) C# (Mono and MS .NET), (2) D, (3) Go, (4) Guile, (5) Java, (6) JavaScript (Node.js, V8, and WebKit), (7) Lua, (8) MzScheme/Racket, (9) OCaml, (10) Octave, (11) Perl, (12) PHP, (13) Python, (14) R, (15) Ruby, (16) Scilab, and (17) Tcl/Tk. For every of the earlier mentioned target languages, SWIG can generate wrappers around C libraries produced by LLVM-CBE.

Generation of these libraries-wrappers from LLVM bitcode would be possible for all programming languages whose build tools offer LLVM IR generation: (1) Rust, (2) ActionScript, (3) Ada, (4) C#, (5) Common Lisp, (6) PicoListp, (7) Crystal, (8) CUDA, (9) D, (10) Delphi, (11) Dylan, (12) Forth, (13) Fortran, (14) Free Basic, (15) Free Pascal, (16) Graphical G, (17) Halide, (18) Haskell, (19) Java bytecode, (20) Julia, (21) Kotlin, (22) Lua, (23) Objective-C, (24) OpenCL, (25) PostreSQL and PLpgSQL, (26) Ruby, (27) Scala, (28) Swift, (29) XC, (30) Xojo, and (31) Zig.2

Current goal: Rust

At the time of writing, rustc - the standard compiler for the Rust programming language - relies on LLVM compiler infrastructure for machine code generation and optimization. For that, rustc internally, after transforming the Rust source code through a series of other Intermediate Representations (IRs), eventually produces so-called LLVM IR that then gets handled by LLVM infrastructure. You can learn more about LLVM IR and LLVM Bitcode File Format here.

Thus, this combination when applied for Rust would be not just on par with cbindgen but would also be considerably better.

F.A.Q.

  • Q: What does *-sys mean? A: *-sys is a naming convention for crates that help Rust programs use C ("system") libraries, e.g. libz-sys, kernel32-sys, lcms2-sys.3

License

Licensed under either of Apache License, Version 2.0 or MIT license at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this crate by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Footnotes

  1. There is no typo. Bitcode, as the maintainers admit, sometimes indeed is anachronistically called bytecode.

  2. https://en.wikipedia.org/wiki/LLVM

  3. https://kornel.ski/rust-sys-crate

You might also like...
Turns lines of text into SVG files.

Sentences 2 svg Does what it says on the tin. This takes in a file with some sentences and outputs numbered svgs. There are 3 arguments to keep in min

SubZero - a standalone web server that turns your database directly into a REST/GraphQL api

What is this? This is a demo repository for the new subzero codebase implemented in Rust. subZero is a standalone web server that turns your database

NixEl is a Rust library that turns Nix code into a variety of correct, typed, memory-safe data-structures

🐉 NixEL Lexer, Parser, Abstract Syntax Tree and Concrete Syntax Tree for the Nix Expressions Language. NixEl is a Rust library that turns Nix code in

Turns running Rust code into a serializable data structure.

WasmBox WasmBox turns running Rust code into a serializable data structure. It does this by compiling it to WebAssembly and running it in a sandbox. T

More beautiful HTML reports for llvm-cov/cargo-llvm-cov

💄 llvm-cov-pretty More beautiful HTML reports for llvm-cov (cargo-llvm-cov specifically). Dark theme support (switches automatically based on your br

Qovery Engine is an open-source abstraction layer library that turns easy apps deployment on AWS, GCP, Azure, and other Cloud providers in just a few minutes.
Qovery Engine is an open-source abstraction layer library that turns easy apps deployment on AWS, GCP, Azure, and other Cloud providers in just a few minutes.

Qovery Engine is an open-source abstraction layer library that turns easy apps deployment on AWS, GCP, Azure, and other Cloud providers in just a few minutes.

🛠️ An experimental functional systems programming language, written in Rust and powered by LLVM as a backend.
🛠️ An experimental functional systems programming language, written in Rust and powered by LLVM as a backend.

An experimental functional systems programming language, written in Rust, and powered by LLVM as a backend. 🎯 Goal: The intent is to create a program

A render-backend independant egui backend for sdl2

A Sdl2 + Egui Backend An egui backend for sdl2 unbound to any renderer-backend. You can include it like so: [dependencies] egui_sdl2_platform = "0.1.0

An event replay tool for the Trento storage backend.

photofinish - a little, handy tool to replay events This tiny CLI tool aims to fulfill the need to replay some events and get fixtures. Photofinish re

This tool is for those who often want to search for a string deeply into a directory in recursive mode, but not with the great tool: grep, ack, ripgrep .........一个工具最大的价值不是它有多少功能,而是它能够让你以多快的速度达成所愿...... High-performance automatic differentiation of LLVM.
High-performance automatic differentiation of LLVM.

The Enzyme High-Performance Automatic Differentiator of LLVM Enzyme is a plugin that performs automatic differentiation (AD) of statically analyzable

dm-jitaux is a Rust-based JIT compiler using modified auxtools, dmasm and Inkwell LLVM wrapper for boosting Byond DM performance without any hassle!

dm-jitaux is a Rust-based JIT compiler using modified auxtools, dmasm and Inkwell LLVM wrapper for boosting Byond DM performance without any hassle (such as rewriting/refactroing your DM code).

 Gecko is a high-level, general-purpose programming language built on top of the LLVM project.
Gecko is a high-level, general-purpose programming language built on top of the LLVM project.

Gecko is a high-level, general-purpose programming language built on top of the LLVM project. Gecko Technology & principles Gecko is a general-purpose

mollusc is a collection of pure-Rust libraries for parsing, interpreting, and analyzing LLVM.

mollusc is a collection of pure-Rust libraries for parsing, interpreting, and analyzing LLVM.

Symbolic execution of LLVM IR with an engine written in Rust

haybale: Symbolic execution of LLVM IR, written in Rust haybale is a general-purpose symbolic execution engine written in Rust. It operates on LLVM IR

An esoteric language/compiler written with Rust and Rust LLVM bindings

MeidoLang (メイドラング) A not so useful and esoteric language. The goal of this project was to contain some quirky or novel syntax in a stack-style program

Inkwell - It's a New Kind of Wrapper for Exposing LLVM (Safely)

Inkwell(s) It's a New Kind of Wrapper for Exposing LLVM (Safely) Inkwell aims to help you pen your own programming languages by safely wrapping llvm-s

LLVM tutorial in Rust language

Status Everything works. State corresponds to the Chapter 7 of the original tutorial (i.e. mutable variables implemented). TODO list. LLVM tutorial in

(Toy) Compiler Infrastructure influenced by LLVM written in Rust

Sericum Compiler Infrastructure influenced by LLVM written in Rust Do not expect too much stuff! To Do Implement basic block parameters Make it possib

Comments
  • Support for older GCC versions

    Support for older GCC versions

    On some versions, for example 9.3.0 (Ubuntu 9.3.0-17ubuntu1~20.04), the code produced by LLVM-CBE would fail to get compiled by gcc like this

    main.cbe.c:59:10: error: conflicting types for built-in function ‘printf’; expected ‘int(const char *, ...)’ [-Werror=builtin-declaration-mismatch]
       59 | uint32_t printf(uint8_t*, ...);
          |          ^~~~~~
    main.cbe.c:3:1: note: ‘printf’ is declared in header ‘<stdio.h>’
        2 | #include <stdint.h>
      +++ |+#include <stdio.h>
        3 | #ifndef __cplusplus
    cc1: all warnings being treated as errors
    

    In order to solve the issue, @AP2008 suggested to use -Wno-format that presumably must solve the issue.

    opened by JohnScience 0
Owner
Dmitrii - Demenev
Rust developer trying his best to make the world a better place
Dmitrii - Demenev
An esoteric language/compiler written with Rust and Rust LLVM bindings

MeidoLang (メイドラング) A not so useful and esoteric language. The goal of this project was to contain some quirky or novel syntax in a stack-style program

null 0 Dec 24, 2021
(Toy) Compiler Infrastructure influenced by LLVM written in Rust

Sericum Compiler Infrastructure influenced by LLVM written in Rust Do not expect too much stuff! To Do Implement basic block parameters Make it possib

uint256_t 384 Dec 19, 2022
A Comprehensive Web Fuzzer and Content Discovery Tool

rustbuster A Comprehensive Web Fuzzer and Content Discovery Tool Introduction Check the blog post: Introducing Rustbuster — A Comprehensive Web Fuzzer

Francesco Soncina 467 Dec 26, 2022
A fast, simple, recursive content discovery tool written in Rust.

A simple, fast, recursive content discovery tool written in Rust ?? Releases ✨ Example Usage ✨ Contributing ✨ Documentation ?? ?? What the heck is a f

epi 3.6k Dec 30, 2022
ctfsak is a tool to speed up common operations needed during CTFs

ctfsak (CTF Swiss Army Knife) This is a tool to help saving time during CTFs, where it's common to have to do a lot of encoding/decoding, encrypting/d

null 1 Dec 1, 2022
Binary coverage tool without binary modification for Windows

Summary Mesos is a tool to gather binary code coverage on all user-land Windows targets without need for source or recompilation. It also provides an

null 381 Dec 22, 2022
subscout is a simple, nimble subdomain enumeration tool written in Rust language

subscout is a simple, nimble subdomain enumeration tool written in Rust language. It is designed to help bug bounty hunters, security professionals and penetration testers discover subdomains of a given target domain.

Dom Sec 5 Apr 5, 2023
A simple command line tool which quickly audits the Disallow entries of a site's robots.txt.

Domo Arigato A simple command line tool which quickly audits the Disallow entries of a site's robots.txt. Disallow entries can be used to stop search

Ember Hext 20 Apr 17, 2023
Easy c̵̰͠r̵̛̠ö̴̪s̶̩̒s̵̭̀-t̶̲͝h̶̯̚r̵̺͐e̷̖̽ḁ̴̍d̶̖̔ ȓ̵͙ė̶͎ḟ̴͙e̸̖͛r̶̖͗ë̶̱́ṉ̵̒ĉ̷̥e̷͚̍ s̷̹͌h̷̲̉a̵̭͋r̷̫̊ḭ̵̊n̷̬͂g̵̦̃ f̶̻̊ơ̵̜ṟ̸̈́ R̵̞̋ù̵̺s̷̖̅ţ̸͗!̸̼͋

Rust S̵̓i̸̓n̵̉ I̴n̴f̶e̸r̵n̷a̴l mutability! Howdy, friendly Rust developer! Ever had a value get m̵̯̅ð̶͊v̴̮̾ê̴̼͘d away right under your nose just when

null 294 Dec 23, 2022
1️⃣ el lisp number uno - one lisp to rule them all 🏆

luno el lisp number uno luno is the one lisp to rule them all. Still experimental, do not use it in production yet. goals embeddable small size simple

Eva Pace 3 Apr 25, 2022