Skip to content

Commit 267678c

Browse files
authored
Upgrade to LLVM 21 (#31)
`cargo test` passes at least. Although I also updated `setup.sh`, it looks like [`llvm@21` may not exist in Homebrew yet][1]. @femtomc's changes in mlir-rs/mlir-sys#71 suggest an alternative way to install LLVM in CI. Still, this works end-to-end with Melior for my use cases when combined with mlir-rs/mlir-sys#71 and mlir-rs/melior#731, if that is useful to know. I don't know if this warrants a version bump as #25 did (seems like the maintainer's call) (Succeeds #28 which I made from the wrong branch) [1]: https://formulae.brew.sh/formula/
1 parent 6c53490 commit 267678c

File tree

6 files changed

+19
-11
lines changed

6 files changed

+19
-11
lines changed

Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,13 @@ documentation = "https://mlir-rs.github.io/tblgen-rs/tblgen/"
1212
exclude = ["doc/"]
1313

1414
[features]
15-
default = ["llvm20-0"]
15+
default = ["llvm21-0"]
1616
llvm16-0 = []
1717
llvm17-0 = []
1818
llvm18-0 = []
1919
llvm19-0 = []
2020
llvm20-0 = []
21+
llvm21-0 = []
2122

2223
[dependencies]
2324
thiserror = "2.0.12"

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,6 @@ Read the documentation at https://mlir-rs.github.io/tblgen-rs/tblgen/.
2121

2222
## Supported LLVM Versions
2323

24-
An installation of LLVM is required to use this crate. Both LLVM 16, 17, 18 and 19 are supported and can be selected using feature flags.
24+
An installation of LLVM is required to use this crate. Any of LLVM 16, 17, 18, 19, 20, and 21 are supported and can be selected using feature flags.
2525

2626
The `TABLEGEN_<version>_PREFIX` environment variable can be used to specify a custom directory of the LLVM installation.

build.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,10 @@ const LLVM_MAJOR_VERSION: usize = if cfg!(feature = "llvm16-0") {
1616
18
1717
} else if cfg!(feature = "llvm19-0") {
1818
19
19-
} else {
19+
} else if cfg!(feature = "llvm20-0") {
2020
20
21+
} else {
22+
21
2123
};
2224

2325
fn main() {

src/lib.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@
2222
//! # Supported LLVM Versions
2323
//!
2424
//! An installation of LLVM is required to use this crate.
25-
//! The versions of LLVM currently supported are 16.x.x (default) and 17.x.x.
26-
//! Different LLVM version can be selected using features flags (llvm16-0 or
27-
//! llvm17-0).
25+
//! The versions of LLVM currently supported are 16.x.x, 17.x.x, 18.x.x,
26+
//! 19.x.x, 20.x.x, and 21.x.x. Different LLVM version can be selected using
27+
//! features flags (e.g., `llvm16-0` or `llvm17-0`).
2828
//!
2929
//! The `TABLEGEN_<version>_PREFIX` environment variable can be used to specify
3030
//! a custom directory of the LLVM installation.
@@ -67,7 +67,7 @@
6767
//! .add_source(r#"include "mlir/IR/OpBase.td""#)?
6868
//! .add_include_directory(&format!(
6969
//! "{}/include",
70-
//! std::env::var("TABLEGEN_200_PREFIX")?
70+
//! std::env::var("TABLEGEN_210_PREFIX")?
7171
//! ))
7272
//! .parse()?;
7373
//! let i32_def = keeper.def("I32").expect("has I32 def");
@@ -88,7 +88,7 @@
8888
//! .add_source_file("mlir/IR/OpBase.td")
8989
//! .add_include_directory(&format!(
9090
//! "{}/include",
91-
//! std::env::var("TABLEGEN_200_PREFIX")?
91+
//! std::env::var("TABLEGEN_210_PREFIX")?
9292
//! ))
9393
//! .parse()?;
9494
//! let i32_def = keeper.def("I32").expect("has I32 def");

src/record_keeper.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,12 @@
1010

1111
use std::marker::PhantomData;
1212

13-
#[cfg(any(feature = "llvm18-0", feature = "llvm19-0", feature = "llvm20-0"))]
13+
#[cfg(any(
14+
feature = "llvm18-0",
15+
feature = "llvm19-0",
16+
feature = "llvm20-0",
17+
feature = "llvm21-0"
18+
))]
1419
use crate::error::TableGenError;
1520
#[cfg(any(feature = "llvm16-0", feature = "llvm17-0"))]
1621
use crate::error::{SourceLocation, TableGenError, WithLocation};

tools/setup.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22

33
set -e
44

5-
llvm_version=20
5+
llvm_version=21
66

77
brew update
88
brew install llvm@$llvm_version
99

1010
llvm_prefix=$(brew --prefix llvm@$llvm_version)
1111

12-
echo TABLEGEN_200_PREFIX=$llvm_prefix >>$GITHUB_ENV
12+
echo TABLEGEN_210_PREFIX=$llvm_prefix >>$GITHUB_ENV
1313
echo PATH=$llvm_prefix/bin:$PATH >>$GITHUB_ENV
1414
echo LIBRARY_PATH=$llvm_prefix/lib:$LIBRARY_PATH >>$GITHUB_ENV
1515
echo LD_LIBRARY_PATH=$llvm_prefix/lib:$LD_LIBRARY_PATH >>$GITHUB_ENV

0 commit comments

Comments
 (0)