Skip to content

Commit 61c006f

Browse files
⬆️ deps: bump inkwell to v0.7 and use LLVM 21 (#217)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: SigureMo <[email protected]>
1 parent 17915e3 commit 61c006f

File tree

4 files changed

+36
-35
lines changed

4 files changed

+36
-35
lines changed

.github/workflows/rcalc-test.yml

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ on:
99

1010
env:
1111
CARGO_TERM_COLOR: always
12-
LLVM_VERSION: 18.1
12+
LLVM_VERSION: 21.1
13+
LLVM_VERSION_MAJOR: 21
1314

1415
jobs:
1516
test-rcalc:
@@ -22,9 +23,18 @@ jobs:
2223
- name: Update rust toolchain
2324
run: rustup update
2425
- name: Install LLVM and Clang
25-
uses: KyleMayes/install-llvm-action@v2
26-
with:
27-
version: ${{ env.LLVM_VERSION }}
26+
run: |
27+
sudo apt install --no-install-recommends -y lsb-release wget software-properties-common gnupg
28+
wget https://apt.llvm.org/llvm.sh
29+
chmod +x llvm.sh
30+
sudo ./llvm.sh ${{ env.LLVM_VERSION_MAJOR }}
31+
sudo apt-get update
32+
sudo apt install --no-install-recommends -y libllvm${{ env.LLVM_VERSION_MAJOR }} \
33+
llvm-${{ env.LLVM_VERSION_MAJOR }} \
34+
llvm-${{ env.LLVM_VERSION_MAJOR }}-dev \
35+
llvm-${{ env.LLVM_VERSION_MAJOR }}-runtime \
36+
libpolly-${{ env.LLVM_VERSION_MAJOR }}-dev
37+
sudo update-alternatives --install /usr/bin/llvm-config llvm-config /usr/bin/llvm-config-${{ env.LLVM_VERSION_MAJOR }} 10
2838
- name: Run llvm-config
2939
run: llvm-config --version --bindir --libdir
3040
- name: Cache cargo build

Cargo.lock

Lines changed: 18 additions & 25 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@ jit = ["inkwell"]
1111

1212
[dependencies]
1313
clap = { version = "4.5.38", features = ["derive"] }
14-
inkwell = { version = "0.6.0", features = ["llvm18-1"], optional = true }
14+
inkwell = { version = "0.7.1", features = ["llvm21-1"], optional = true }
1515
peg = "0.8.5"

src/visitor/jit.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,7 @@ impl<'ctx> CalculatorJIT<'ctx> {
7676
func: FuncLLVM<'ctx, FloatValue<'ctx>>,
7777
) -> Result<(), SymbolError> {
7878
let ret_type = self.double();
79-
let args_types = std::iter::repeat(ret_type)
80-
.take(argc)
79+
let args_types = std::iter::repeat_n(ret_type, argc)
8180
.map(|f| f.into())
8281
.collect::<Vec<BasicMetadataTypeEnum>>();
8382
let args_types = args_types.as_slice();
@@ -124,7 +123,7 @@ impl<'ctx> CalculatorJIT<'ctx> {
124123
Ok(())
125124
}
126125

127-
pub fn compile(&mut self, ast: &Expr) -> Option<JitFunction<CalcMain>> {
126+
pub fn compile(&mut self, ast: &Expr) -> Option<JitFunction<'_, CalcMain>> {
128127
let sig = self.double().fn_type(&[], false);
129128
let func = self.module.add_function(CALC_ENTRYPOINT, sig, None);
130129
let basic_block = self.context.append_basic_block(func, "entry");
@@ -202,8 +201,7 @@ impl<'ctx> Visitor<FloatValue<'ctx>> for CalculatorJIT<'ctx> {
202201
.build_call(func, argsv.as_slice(), "tmp")
203202
.expect("Unable to call function")
204203
.try_as_basic_value()
205-
.left()
206-
.unwrap();
204+
.unwrap_basic();
207205

208206
ret_val.into_float_value()
209207
}

0 commit comments

Comments
 (0)