Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
03c0c6b
fix: reset `positioned` in `Builder::clear_insertion_position` (#561)
Qwox0 Dec 21, 2024
97128a9
Add create_mcjit_execution_engine_with_memory_manager for custom MCJI…
ktanaka101 Feb 2, 2025
16313d3
docs: fix warnings and typos (#574)
airwoodix Feb 23, 2025
b63b104
FunctionType::get_param_types: support metadata type (#573)
airwoodix Feb 23, 2025
b6bf69a
CallSiteValue::get_called_fn_value: return None on indirect calls (#572)
airwoodix Feb 23, 2025
caabaa5
workflows: run rustfmt check, fix typos check (#575)
airwoodix Feb 25, 2025
b38c771
Implement feature for disabling opaque pointers on LLVM 15 and 16 (#570)
Derppening Mar 10, 2025
9f64611
fix: proper string constant handling (#577)
CertainLach Mar 10, 2025
e1a5c2f
Fix is_conditional (#583)
wtdcode Mar 26, 2025
129aa8d
Re-export Either crate. Closes #580
TheDan64 Apr 21, 2025
68c1d6b
Remove support for LLVM4-7 (#587)
TheDan64 Apr 25, 2025
f74e195
Report user's call location in case of `panic` in `into_*_value` func…
rakivo Apr 25, 2025
b8d81bf
Update versions
TheDan64 Apr 25, 2025
d7e646b
Update thiserror requirement from 1.0.48 to 2.0.11 (#564)
dependabot[bot] Apr 25, 2025
e3369e7
chore: fix warning of elided_lifetimes_in_paths in examples (#590)
hsqStephenZhang May 30, 2025
eb31b01
Add `get_bit_width` method for float type (#589)
my4ng Jun 6, 2025
50c16a6
Preliminary LLVM 19/20 support (#557)
stevefan1999-personal Aug 9, 2025
0b0a2c0
Removes uneccesary less-than 64-bit check on 32-bit value. (#593)
ErisianArchitect Aug 14, 2025
279ef78
Removed unnecessary checks from is_alignment_ok (#596)
ErisianArchitect Aug 16, 2025
7077b70
More specific errors. (#598)
ErisianArchitect Sep 3, 2025
e29a3d0
feat: make BasicBlock::new publicly accessible (#601)
fuqiuluo Sep 3, 2025
075db5c
Fix comment typos in `test_conversion_to_pointer_value` (#605)
qlpoynter Sep 23, 2025
0f8d2d6
All tests passing on Windows. (#608)
ErisianArchitect Oct 18, 2025
5b64e21
Support LLVMGetIndices (#615)
namse Oct 31, 2025
f88ccb2
Get AtomicRMWBinOp (#616)
namse Oct 31, 2025
c7a8039
Make creation of values from `LLVMValueRef` public
feds01 Sep 3, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
165 changes: 93 additions & 72 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,95 +1,116 @@
name: Test Suite and Doc

on: [push, pull_request]
on: [ push, pull_request ]

env:
CARGO_TERM_COLOR: always
DOC_LLVM_FEATURE: llvm18-0
DOC_LLVM_FEATURE: llvm18-1
DOC_LLVM_VERSION: "18.1"
DOC_PATH: target/doc

jobs:
typos:
name: Typos
lint:
name: Linting
runs-on: ubuntu-latest
steps:
- name: Install Rust Stable
uses: dtolnay/rust-toolchain@stable
- name: Install typos
uses: taiki-e/install-action@typos
- name: Run typos
run: typos .
- name: Checkout Repo
uses: actions/checkout@v4
- name: Install Rust Stable
uses: dtolnay/rust-toolchain@stable
- name: Install typos
uses: taiki-e/install-action@typos
- name: Check typos
run: typos .
- name: Check code formatting
run: cargo fmt --check
tests:
name: "LLVM ${{ matrix.llvm-version[0] }}: ${{ matrix.os }}"
runs-on: ${{ matrix.os }}
strategy:
matrix:
llvm-version:
- ["4.0", "4-0"]
- ["5.0", "5-0"]
- ["6.0", "6-0"]
- ["7.0", "7-0"]
- ["7.1", "7-0"]
- ["8.0", "8-0"]
- ["9.0", "9-0"]
- ["10.0", "10-0"]
- ["11.0", "11-0"]
- ["12.0", "12-0"]
- ["13.0", "13-0"]
- ["14.0", "14-0"]
- ["15.0", "15-0"]
- ["16.0", "16-0"]
- ["17.0", "17-0"]
- ["18.1", "18-0"]
- [ "8.0", "8-0" ]
- [ "9.0", "9-0" ]
- [ "10.0", "10-0" ]
- [ "11.0", "11-0" ]
- [ "12.0", "12-0" ]
- [ "13.0", "13-0" ]
- [ "14.0", "14-0" ]
- [ "15.0", "15-0" ]
- [ "16.0", "16-0" ]
- [ "17.0", "17-0" ]
- [ "18.1", "18-1" ]
- [ "19.1", "19-1", "19" ]
- [ "20.1", "20-1", "20" ]
include:
- os: ubuntu-20.04
# only use ubuntu-22.04 for llvm 16 and llvm 17
- os: ubuntu-22.04
llvm-version: ["16.0", "16-0"]
- os: ubuntu-22.04
llvm-version: ["17.0", "17-0"]
- os: ubuntu-22.04
steps:
- name: Checkout Repo
uses: actions/checkout@v4
- name: Install LLVM and Clang (LLVM >= 7.1)
uses: KyleMayes/install-llvm-action@v2
if: ${{ matrix.llvm-version[0] > 7 }}
with:
version: ${{ matrix.llvm-version[0] }}
- name: Install LLVM and Clang (LLVM <= 7)
uses: KyleMayes/install-llvm-action@v1
if: ${{ matrix.llvm-version[0] <= 7 }}
with:
version: ${{ matrix.llvm-version[0] }}
- name: llvm-config
run: llvm-config --version --bindir --libdir
- name: Install Rust Stable
uses: dtolnay/rust-toolchain@stable
- name: Build
run: cargo build --release --features llvm${{ matrix.llvm-version[1] }} --verbose
- name: Run tests
run: cargo test --release --features llvm${{ matrix.llvm-version[1] }} --verbose
- name: Build example
run: cargo build --example kaleidoscope --features llvm${{ matrix.llvm-version[1] }} --verbose
- name: Checkout Repo
uses: actions/checkout@v4
- name: Install Dependencies
run: sudo apt update && sudo apt install -y libtinfo5
- name: Install LLVM and Clang (LLVM >= 19.1)
if: ${{ matrix.llvm-version[0] >= 19 }}
run: |
sudo apt install --no-install-recommends -y lsb-release wget software-properties-common gnupg
wget https://apt.llvm.org/llvm.sh
chmod +x llvm.sh
sudo ./llvm.sh ${{ matrix.llvm-version[2] }}
sudo apt-get update
sudo apt install --no-install-recommends -y libllvm${{ matrix.llvm-version[2] }} \
llvm-${{ matrix.llvm-version[2] }} \
llvm-${{ matrix.llvm-version[2] }}-dev \
llvm-${{ matrix.llvm-version[2] }}-runtime \
libpolly-${{ matrix.llvm-version[2] }}-dev
sudo update-alternatives --install /usr/bin/llvm-config llvm-config /usr/bin/llvm-config-${{ matrix.llvm-version[2] }} 10
- name: Install LLVM and Clang (7.1 <= LLVM <= 19)
uses: KyleMayes/install-llvm-action@v2
if: ${{ matrix.llvm-version[0] > 7 && matrix.llvm-version[0] <= 19 }}
with:
version: ${{ matrix.llvm-version[0] }}
- name: Install LLVM and Clang (LLVM <= 7)
uses: KyleMayes/install-llvm-action@v1
if: ${{ matrix.llvm-version[0] <= 7 }}
with:
version: ${{ matrix.llvm-version[0] }}
- name: llvm-config
run: llvm-config --version --bindir --libdir
- name: Install Rust Stable
uses: moonrepo/setup-rust@v1
with:
bins: cargo-nextest
- name: cargo clippy
run: cargo clippy --tests --features llvm${{ matrix.llvm-version[1] }} -- -D warnings
- name: Build
run: cargo build --release --features llvm${{ matrix.llvm-version[1] }} --verbose
- name: Run tests
run: |
cargo nextest run --release --features llvm${{ matrix.llvm-version[1] }} --verbose
cargo test --doc --release --features llvm${{ matrix.llvm-version[1] }} --verbose
- name: Build examples and run JIT for verification
run: |
cargo run --example kaleidoscope --features llvm${{ matrix.llvm-version[1] }} --verbose -- --dl --dp --dc -e "(1 + 2 + 3) / (2 + 3)"
cargo run --example jit --features llvm${{ matrix.llvm-version[1] }} --verbose
cargo run --example jit --features llvm${{ matrix.llvm-version[1] }} --verbose --release
doc:
name: Documentation
runs-on: ubuntu-20.04
needs: [typos, tests]
runs-on: ubuntu-22.04
needs: [ lint, tests ]
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
steps:
- uses: actions/checkout@v4
- uses: KyleMayes/install-llvm-action@v2
with:
version: ${{ env.DOC_LLVM_VERSION }}
- name: Install Rust Nightly
uses: dtolnay/rust-toolchain@nightly
- name: Build Documentation
run: cargo +nightly doc --features ${{ env.DOC_LLVM_FEATURE }},nightly --verbose
- name: Doc Index Page Redirection
run: echo '<meta http-equiv="refresh" content="1; url=inkwell/index.html">' > ${{ env.DOC_PATH }}/index.html
- name: Deploy Documentation
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ${{ env.DOC_PATH }}
force_orphan: true
- uses: actions/checkout@v4
- uses: KyleMayes/install-llvm-action@v2
with:
version: ${{ env.DOC_LLVM_VERSION }}
- name: Install Rust Nightly
uses: dtolnay/rust-toolchain@nightly
- name: Build Documentation
run: cargo +nightly doc --features ${{ env.DOC_LLVM_FEATURE }},nightly --verbose
- name: Doc Index Page Redirection
run: echo '<meta http-equiv="refresh" content="1; url=inkwell/index.html">' > ${{ env.DOC_PATH }}/index.html
- name: Deploy Documentation
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ${{ env.DOC_PATH }}
force_orphan: true
89 changes: 51 additions & 38 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "inkwell"
version = "0.5.0"
version = "0.6.0"
authors = ["Daniel Kolsoi <thadan64@gmail.com>"]
description = "Inkwell aims to help you pen your own programming languages by safely wrapping llvm-sys."
documentation = "https://thedan64.github.io/inkwell/"
Expand All @@ -13,33 +13,28 @@ edition = "2021"

[features]
default = ["target-all"]
typed-pointers = []

# Please update internal_macros::FEATURE_VERSIONS when adding a new LLVM version
llvm4-0 = ["llvm-sys-40"]
llvm5-0 = ["llvm-sys-50"]
llvm6-0 = ["llvm-sys-60"]
llvm7-0 = ["llvm-sys-70"]
llvm8-0 = ["llvm-sys-80"]
llvm9-0 = ["llvm-sys-90"]
llvm10-0 = ["llvm-sys-100"]
llvm11-0 = ["llvm-sys-110"]
llvm12-0 = ["llvm-sys-120"]
llvm13-0 = ["llvm-sys-130"]
llvm14-0 = ["llvm-sys-140"]
llvm8-0 = ["llvm-sys-80", "typed-pointers"]
llvm9-0 = ["llvm-sys-90", "typed-pointers"]
llvm10-0 = ["llvm-sys-100", "typed-pointers"]
llvm11-0 = ["llvm-sys-110", "typed-pointers"]
llvm12-0 = ["llvm-sys-120", "typed-pointers"]
llvm13-0 = ["llvm-sys-130", "typed-pointers"]
llvm14-0 = ["llvm-sys-140", "typed-pointers"]
llvm15-0 = ["llvm-sys-150"]
llvm16-0 = ["llvm-sys-160"]
llvm17-0 = ["llvm-sys-170"]
llvm18-0 = ["llvm-sys-180"]
llvm18-1 = ["llvm-sys-181"]
llvm19-1 = ["llvm-sys-191"]
llvm20-1 = ["llvm-sys-201"]

# Don't link against LLVM libraries. This is useful if another dependency is
# installing LLVM. See llvm-sys for more details. We can't enable a single
# `no-llvm-linking` feature across the board of llvm versions, as it'll cause
# cargo to try and download and compile them all. See
# https://github.com/rust-lang/cargo/issues/3494
llvm4-0-no-llvm-linking = ["llvm4-0", "llvm-sys-40/no-llvm-linking"]
llvm5-0-no-llvm-linking = ["llvm5-0", "llvm-sys-50/no-llvm-linking"]
llvm6-0-no-llvm-linking = ["llvm6-0", "llvm-sys-60/no-llvm-linking"]
llvm7-0-no-llvm-linking = ["llvm7-0", "llvm-sys-70/no-llvm-linking"]
llvm8-0-no-llvm-linking = ["llvm8-0", "llvm-sys-80/no-llvm-linking"]
llvm9-0-no-llvm-linking = ["llvm9-0", "llvm-sys-90/no-llvm-linking"]
llvm10-0-no-llvm-linking = ["llvm10-0", "llvm-sys-100/no-llvm-linking"]
Expand All @@ -50,7 +45,9 @@ llvm14-0-no-llvm-linking = ["llvm14-0", "llvm-sys-140/no-llvm-linking"]
llvm15-0-no-llvm-linking = ["llvm15-0", "llvm-sys-150/no-llvm-linking"]
llvm16-0-no-llvm-linking = ["llvm16-0", "llvm-sys-160/no-llvm-linking"]
llvm17-0-no-llvm-linking = ["llvm17-0", "llvm-sys-170/no-llvm-linking"]
llvm18-0-no-llvm-linking = ["llvm18-0", "llvm-sys-180/no-llvm-linking"]
llvm18-1-no-llvm-linking = ["llvm18-1", "llvm-sys-181/no-llvm-linking"]
llvm19-1-no-llvm-linking = ["llvm19-1", "llvm-sys-191/no-llvm-linking"]
llvm20-1-no-llvm-linking = ["llvm20-1", "llvm-sys-201/no-llvm-linking"]

# Linking preference.
# If none of these are enabled, it defaults to force static linking.
Expand All @@ -62,7 +59,9 @@ llvm14-0-force-dynamic = ["llvm14-0", "llvm-sys-140/force-dynamic"]
llvm15-0-force-dynamic = ["llvm15-0", "llvm-sys-150/force-dynamic"]
llvm16-0-force-dynamic = ["llvm16-0", "llvm-sys-160/force-dynamic"]
llvm17-0-force-dynamic = ["llvm17-0", "llvm-sys-170/force-dynamic"]
llvm18-0-force-dynamic = ["llvm18-0", "llvm-sys-180/force-dynamic"]
llvm18-1-force-dynamic = ["llvm18-1", "llvm-sys-181/force-dynamic"]
llvm19-1-force-dynamic = ["llvm19-1", "llvm-sys-191/force-dynamic"]
llvm20-1-force-dynamic = ["llvm20-1", "llvm-sys-201/force-dynamic"]

# Prefer dynamic linking against LLVM libraries. See llvm-sys for more details
llvm12-0-prefer-dynamic = ["llvm12-0", "llvm-sys-120/prefer-dynamic"]
Expand All @@ -71,7 +70,9 @@ llvm14-0-prefer-dynamic = ["llvm14-0", "llvm-sys-140/prefer-dynamic"]
llvm15-0-prefer-dynamic = ["llvm15-0", "llvm-sys-150/prefer-dynamic"]
llvm16-0-prefer-dynamic = ["llvm16-0", "llvm-sys-160/prefer-dynamic"]
llvm17-0-prefer-dynamic = ["llvm17-0", "llvm-sys-170/prefer-dynamic"]
llvm18-0-prefer-dynamic = ["llvm18-0", "llvm-sys-180/prefer-dynamic"]
llvm18-1-prefer-dynamic = ["llvm18-1", "llvm-sys-181/prefer-dynamic"]
llvm19-1-prefer-dynamic = ["llvm19-1", "llvm-sys-191/prefer-dynamic"]
llvm20-1-prefer-dynamic = ["llvm20-1", "llvm-sys-201/prefer-dynamic"]

# Force static linking against LLVM libraries. See llvm-sys for more details
llvm12-0-force-static = ["llvm12-0", "llvm-sys-120/force-static"]
Expand All @@ -80,7 +81,9 @@ llvm14-0-force-static = ["llvm14-0", "llvm-sys-140/force-static"]
llvm15-0-force-static = ["llvm15-0", "llvm-sys-150/force-static"]
llvm16-0-force-static = ["llvm16-0", "llvm-sys-160/force-static"]
llvm17-0-force-static = ["llvm17-0", "llvm-sys-170/force-static"]
llvm18-0-force-static = ["llvm18-0", "llvm-sys-180/force-static"]
llvm18-1-force-static = ["llvm18-1", "llvm-sys-181/force-static"]
llvm19-1-force-static = ["llvm19-1", "llvm-sys-191/force-static"]
llvm20-1-force-static = ["llvm20-1", "llvm-sys-201/force-static"]

# Prefer static linking against LLVM libraries. See llvm-sys for more details
llvm12-0-prefer-static = ["llvm12-0", "llvm-sys-120/prefer-static"]
Expand All @@ -89,7 +92,9 @@ llvm14-0-prefer-static = ["llvm14-0", "llvm-sys-140/prefer-static"]
llvm15-0-prefer-static = ["llvm15-0", "llvm-sys-150/prefer-static"]
llvm16-0-prefer-static = ["llvm16-0", "llvm-sys-160/prefer-static"]
llvm17-0-prefer-static = ["llvm17-0", "llvm-sys-170/prefer-static"]
llvm18-0-prefer-static = ["llvm18-0", "llvm-sys-180/prefer-static"]
llvm18-1-prefer-static = ["llvm18-1", "llvm-sys-181/prefer-static"]
llvm19-1-prefer-static = ["llvm19-1", "llvm-sys-191/prefer-static"]
llvm20-1-prefer-static = ["llvm20-1", "llvm-sys-201/prefer-static"]

# Don't force linking to libffi on non-windows platforms. Without this feature
# inkwell always links to libffi on non-windows platforms.
Expand Down Expand Up @@ -135,34 +140,42 @@ experimental = ["static-alloc"]
nightly = ["inkwell_internals/nightly"]

[dependencies]
inkwell_internals = { path = "./internal_macros", version = "0.10.0" }
inkwell_internals = { path = "./internal_macros", version = "0.11.0" }

llvm-sys-40 = { package = "llvm-sys", version = "40.4", optional = true }
llvm-sys-50 = { package = "llvm-sys", version = "50.4", optional = true }
llvm-sys-60 = { package = "llvm-sys", version = "60.6", optional = true }
llvm-sys-70 = { package = "llvm-sys", version = "70.4", optional = true }
llvm-sys-80 = { package = "llvm-sys", version = "80.3", optional = true }
llvm-sys-90 = { package = "llvm-sys", version = "90.2.1", optional = true }
llvm-sys-100 = { package = "llvm-sys", version = "100.2.3", optional = true }
llvm-sys-110 = { package = "llvm-sys", version = "110.0.3", optional = true }
llvm-sys-120 = { package = "llvm-sys", version = "120.2.4", optional = true }
llvm-sys-130 = { package = "llvm-sys", version = "130.0.4", optional = true }
llvm-sys-140 = { package = "llvm-sys", version = "140.0.2", optional = true }
llvm-sys-150 = { package = "llvm-sys", version = "150.0.3", optional = true }
llvm-sys-160 = { package = "llvm-sys", version = "160.1.0", optional = true }
llvm-sys-90 = { package = "llvm-sys", version = "90.2.2", optional = true }
llvm-sys-100 = { package = "llvm-sys", version = "100.2.4", optional = true }
llvm-sys-110 = { package = "llvm-sys", version = "110.0.4", optional = true }
llvm-sys-120 = { package = "llvm-sys", version = "120.3.2", optional = true }
llvm-sys-130 = { package = "llvm-sys", version = "130.1.2", optional = true }
llvm-sys-140 = { package = "llvm-sys", version = "140.1.3", optional = true }
llvm-sys-150 = { package = "llvm-sys", version = "150.2.1", optional = true }
llvm-sys-160 = { package = "llvm-sys", version = "160.2.1", optional = true }
llvm-sys-170 = { package = "llvm-sys", version = "170.2.0", optional = true }
llvm-sys-180 = { package = "llvm-sys", version = "181.2.0", optional = true }
llvm-sys-181 = { package = "llvm-sys", version = "181.2.0", optional = true }
llvm-sys-191 = { package = "llvm-sys", version = "191.0.0", optional = true }
llvm-sys-201 = { package = "llvm-sys", version = "201.0.0", optional = true }

either = "1.5"
libc = "0.2"
once_cell = "1.16"
thiserror = "1.0.48"
thiserror = "2.0.11"

static-alloc = { version = "0.2", optional = true }
serde = { version = "1.0", default-features = false, features = ["derive"], optional = true }
serde = { version = "1.0", default-features = false, features = [
"derive",
], optional = true }

[dev-dependencies]
gumdrop = "0.8.1"
regex = "1"

[target.'cfg(windows)'.dev-dependencies.windows]
version = "0.62.2"
features = [
"Win32_System_SystemInformation",
"Win32_System_Memory"
]

[badges]
codecov = { repository = "TheDan64/inkwell" }
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ Inkwell aims to help you pen your own programming languages by safely wrapping l
## Requirements

* Rust 1.56+ (Stable, Beta, or Nightly)
* One of LLVM 4-18
* One of LLVM 8-18 (WIP: 19 and 20 are barely supported without extensive tests)

## Usage

You'll need to point your Cargo.toml to use a single LLVM version feature flag corresponding to your LLVM version as such:

```toml
[dependencies]
inkwell = { version = "0.5.0", features = ["llvm18-0"] }
inkwell = { version = "0.6.0", features = ["llvm18-1"] }
```

Supported versions:
Expand Down Expand Up @@ -62,7 +62,7 @@ struct CodeGen<'ctx> {
}

impl<'ctx> CodeGen<'ctx> {
fn jit_compile_sum(&self) -> Option<JitFunction<SumFunc>> {
fn jit_compile_sum(&self) -> Option<JitFunction<'_, SumFunc>> {
let i64_type = self.context.i64_type();
let fn_type = i64_type.fn_type(&[i64_type.into(), i64_type.into(), i64_type.into()], false);
let function = self.module.add_function("sum", fn_type, None);
Expand Down
4 changes: 2 additions & 2 deletions examples/jit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ struct CodeGen<'ctx> {
execution_engine: ExecutionEngine<'ctx>,
}

impl<'ctx> CodeGen<'ctx> {
fn jit_compile_sum(&self) -> Option<JitFunction<SumFunc>> {
impl CodeGen<'_> {
fn jit_compile_sum(&self) -> Option<JitFunction<'_, SumFunc>> {
let i64_type = self.context.i64_type();
let fn_type = i64_type.fn_type(&[i64_type.into(), i64_type.into(), i64_type.into()], false);
let function = self.module.add_function("sum", fn_type, None);
Expand Down
Loading
Loading