Skip to content

feat!: Upgrade LLVM code in tket-qsystem and qis-compiler#1422

Merged
aborgna-q merged 24 commits intoab/hugr-0.26.0from
george/llvmup
Mar 17, 2026
Merged

feat!: Upgrade LLVM code in tket-qsystem and qis-compiler#1422
aborgna-q merged 24 commits intoab/hugr-0.26.0from
george/llvmup

Conversation

@cgh-qtnm
Copy link
Contributor

@cgh-qtnm cgh-qtnm commented Feb 26, 2026

BREAKING CHANGE: The hugr-llvm LLVM version is being upgraded to 21.1, and code that depends on it here needs to be updated as well. This also includes an MSRV change to 1.91 to match hugr. See the hugr PR for details.

Closes #1421

@hugrbot
Copy link
Collaborator

hugrbot commented Feb 26, 2026

This PR contains breaking changes to the public Rust API.

cargo-semver-checks summary
    Building tket v0.17.0 (current)
error: running cargo-doc on crate 'tket' failed with output:
-----
 Compiling proc-macro2 v1.0.106
 Compiling unicode-ident v1.0.24
 Compiling quote v1.0.45
 Compiling serde_core v1.0.228
 Compiling libc v0.2.183
 Compiling serde v1.0.228
 Compiling find-msvc-tools v0.1.9
 Compiling autocfg v1.5.0
 Compiling shlex v1.3.0
 Compiling num-traits v0.2.19
 Compiling syn v2.0.117
 Compiling jobserver v0.1.34
 Compiling cc v1.2.57
  Checking either v1.15.0
  Checking once_cell v1.21.4
 Compiling version_check v0.9.5
  Checking memchr v2.8.0
  Checking cfg-if v1.0.4
  Checking equivalent v1.0.2
  Checking hashbrown v0.16.1
 Compiling semver v1.0.27
 Compiling crossbeam-utils v0.8.21
  Checking indexmap v2.13.0
 Compiling lazy_static v1.5.0
 Compiling anyhow v1.0.102
 Compiling radium v0.7.0
 Compiling pkg-config v0.3.32
 Compiling strsim v0.11.1
 Compiling zstd-sys v2.0.16+zstd.1.5.7
 Compiling thiserror v2.0.18
 Compiling thiserror v1.0.69
  Checking tap v1.0.1
 Compiling ucd-trie v0.1.7
 Compiling ident_case v1.0.1
 Compiling zmij v1.0.21
 Compiling unicode-segmentation v1.12.0
 Compiling pest v2.8.6
 Compiling darling_core v0.23.0
 Compiling convert_case v0.10.0
  Checking wyz v0.5.1
  Checking foldhash v0.1.5
  Checking itoa v1.0.17
 Compiling serde_derive v1.0.228
 Compiling thiserror-impl v2.0.18
 Compiling thiserror-impl v1.0.69
 Compiling typeid v1.0.3
 Compiling serde_json v1.0.149
 Compiling unicode-xid v0.2.6
 Compiling getrandom v0.4.2
  Checking funty v2.0.0
 Compiling derive_more-impl v2.1.1
 Compiling darling_macro v0.23.0
  Checking hashbrown v0.15.5
 Compiling pest_meta v2.8.6
  Checking smallvec v1.15.1
  Checking bitvec v1.0.1
  Checking crossbeam-epoch v0.9.18
 Compiling slotmap_fork_lmondada v1.0.8
 Compiling rayon-core v1.13.0
 Compiling zerocopy v0.8.42
 Compiling regex-lite v0.1.9
 Compiling zstd-safe v7.2.4
 Compiling erased-serde v0.4.10
 Compiling ref-cast v1.0.25
 Compiling heck v0.5.0
 Compiling convert_case v0.4.0
 Compiling paste v1.0.15
  Checking pin-project-lite v0.2.17
 Compiling winnow v0.7.15
  Checking fixedbitset v0.5.7
 Compiling llvm-sys v211.0.0
  Checking petgraph v0.8.3
 Compiling derive_more v0.99.20
 Compiling toml_parser v1.0.9+spec-1.1.0
 Compiling strum_macros v0.28.0
  Checking derive_more v2.1.1
  Checking crossbeam-deque v0.8.6
 Compiling pest_generator v2.8.6
 Compiling darling v0.23.0
 Compiling ref-cast-impl v1.0.25
 Compiling serde_derive_internals v0.29.1
 Compiling aho-corasick v1.1.4
 Compiling rustc_version v0.4.1
 Compiling ahash v0.8.12
  Checking itertools v0.14.0
  Checking regex-syntax v0.8.10
  Checking arrayvec v0.5.2
  Checking byteorder v1.5.0
 Compiling cgmath v0.18.0
 Compiling typetag v0.2.21
  Checking unicode-width v0.2.2
 Compiling toml_datetime v1.0.0+spec-1.1.0
 Compiling rustix v1.1.4
  Checking rustc-hash v2.1.1
  Checking typed-arena v2.0.2
  Checking pretty v0.12.5
 Compiling toml_edit v0.25.4+spec-1.1.0
  Checking regex-automata v0.4.14
  Checking fxhash v0.2.1
 Compiling schemars_derive v1.2.1
 Compiling rstest_macros v0.26.1
  Checking strum v0.28.0
 Compiling pest_derive v2.8.6
 Compiling serde_with_macros v3.18.0
  Checking ordered-float v5.1.0
 Compiling derive-where v1.6.1
 Compiling tracing-attributes v0.1.31
 Compiling delegate v0.13.5
 Compiling typetag-impl v0.2.21
  Checking smol_str v0.3.6
  Checking tracing-core v0.1.36
  Checking itertools v0.13.0
  Checking approx v0.4.0
  Checking inventory v0.3.22
  Checking utf8-width v0.1.8
  Checking linux-raw-sys v0.12.1
  Checking capnp v0.25.2
  Checking base64 v0.22.1
 Compiling parking_lot_core v0.9.12
  Checking bitflags v2.11.0
  Checking bumpalo v3.20.2
 Compiling syn v1.0.109
  Checking dyn-clone v1.0.20
  Checking relrc v0.5.0
  Checking schemars v1.2.1
 Compiling enum_dispatch v0.3.13
  Checking hugr-model v0.26.0
  Checking html-escape v0.2.13
  Checking tracing v0.1.44
  Checking portgraph v0.15.3
  Checking serde_with v3.18.0
  Checking rayon v1.11.0
 Compiling regex v1.12.3
  Checking zstd v0.13.3
 Compiling proc-macro-crate v3.5.0
 Compiling futures-macro v0.3.32
 Compiling pastey v0.2.1
 Compiling fixedbitset v0.4.2
  Checking futures-task v0.3.32
  Checking fastrand v2.3.0
  Checking futures-core v0.3.32
 Compiling glob v0.3.3
  Checking allocator-api2 v0.2.21
  Checking slab v0.4.12
  Checking downcast-rs v2.0.2
 Compiling inkwell v0.8.0
 Compiling relative-path v1.9.3
  Checking scopeguard v1.2.0
  Checking static_assertions v1.1.0
  Checking hashbrown v0.14.5
  Checking hugr-core v0.26.0
  Checking lock_api v0.4.14
  Checking futures-util v0.3.32
  Checking tempfile v3.27.0
 Compiling petgraph v0.6.5
 Compiling ascent_base v0.8.0
error: No suitable version of LLVM was found system-wide or pointed
            to by LLVM_SYS_211_PREFIX.
     
            Consider using `llvmenv` to compile an appropriate copy of LLVM, and
            refer to the llvm-sys documentation for more information.
     
            llvm-sys: https://crates.io/crates/llvm-sys
            llvmenv: https://crates.io/crates/llvmenv
 --> /home/runner/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/llvm-sys-211.0.0/src/lib.rs:532:1
  |
532 | / std::compile_error!(concat!(
533 | |     "No suitable version of LLVM was found system-wide or pointed
534 | |        to by LLVM_SYS_",
535 | |     env!("CARGO_PKG_VERSION_MAJOR"),
...   |
542 | |        llvmenv: https://crates.io/crates/llvmenv"
543 | | ));
  | |__^

error: could not compile `llvm-sys` (lib) due to 1 previous error
warning: build failed, waiting for other jobs to finish...

-----

error: failed to build rustdoc for crate tket v0.17.0
note: this is usually due to a compilation error in the crate,
    and is unlikely to be a bug in cargo-semver-checks
note: the following command can be used to reproduce the error:
    cargo new --lib example &&
        cd example &&
        echo '[workspace]' >> Cargo.toml &&
        cargo add --path /home/runner/work/tket2/tket2/PR_BRANCH/tket --features binary-eccs,default,llvm,portmatching,rewrite-tracing &&
        cargo check &&
        cargo doc

  Building tket-qsystem v0.23.0 (current)
error: running cargo-doc on crate 'tket-qsystem' failed with output:
-----
 Compiling proc-macro2 v1.0.106
 Compiling quote v1.0.45
 Compiling unicode-ident v1.0.24
 Compiling libc v0.2.183
 Compiling serde_core v1.0.228
 Compiling find-msvc-tools v0.1.9
 Compiling shlex v1.3.0
  Checking once_cell v1.21.4
  Checking cfg-if v1.0.4
 Compiling syn v2.0.117
 Compiling jobserver v0.1.34
 Compiling cc v1.2.57
 Compiling serde v1.0.228
 Compiling autocfg v1.5.0
 Compiling num-traits v0.2.19
 Compiling version_check v0.9.5
 Compiling memchr v2.8.0
  Checking either v1.15.0
 Compiling heck v0.5.0
 Compiling semver v1.0.27
 Compiling hashbrown v0.16.1
 Compiling equivalent v1.0.2
 Compiling crossbeam-utils v0.8.21
 Compiling anyhow v1.0.102
 Compiling lazy_static v1.5.0
 Compiling pkg-config v0.3.32
 Compiling indexmap v2.13.0
 Compiling zstd-sys v2.0.16+zstd.1.5.7
 Compiling strsim v0.11.1
  Checking unicode-width v0.2.2
  Checking smallvec v1.15.1
 Compiling thiserror v2.0.18
 Compiling zmij v1.0.21
 Compiling getrandom v0.4.2
 Compiling ucd-trie v0.1.7
 Compiling unicode-segmentation v1.12.0
 Compiling ident_case v1.0.1
 Compiling darling_core v0.23.0
 Compiling pest v2.8.6
 Compiling convert_case v0.10.0
 Compiling unicode-xid v0.2.6
  Checking itoa v1.0.17
 Compiling serde_derive v1.0.228
 Compiling thiserror-impl v2.0.18
  Checking foldhash v0.1.5
 Compiling serde_json v1.0.149
 Compiling typeid v1.0.3
 Compiling radium v0.7.0
 Compiling darling_macro v0.23.0
  Checking hashbrown v0.15.5
 Compiling derive_more-impl v2.1.1
 Compiling pest_meta v2.8.6
 Compiling slotmap_fork_lmondada v1.0.8
  Checking tracing-core v0.1.36
 Compiling winnow v0.7.15
 Compiling ref-cast v1.0.25
 Compiling regex-lite v0.1.9
  Checking tap v1.0.1
 Compiling thiserror v1.0.69
 Compiling zstd-safe v7.2.4
  Checking pin-project-lite v0.2.17
  Checking fixedbitset v0.5.7
 Compiling rustix v1.1.4
 Compiling erased-serde v0.4.10
 Compiling toml_parser v1.0.9+spec-1.1.0
  Checking petgraph v0.8.3
  Checking derive_more v2.1.1
  Checking wyz v0.5.1
 Compiling llvm-sys v211.0.0
 Compiling pest_generator v2.8.6
 Compiling darling v0.23.0
 Compiling ref-cast-impl v1.0.25
 Compiling strum_macros v0.28.0
 Compiling thiserror-impl v1.0.69
  Checking crossbeam-epoch v0.9.18
 Compiling serde_derive_internals v0.29.1
 Compiling rustc_version v0.4.1
  Checking itertools v0.14.0
  Checking aho-corasick v1.1.4
  Checking arrayvec v0.5.2
  Checking regex-syntax v0.8.10
 Compiling paste v1.0.15
  Checking bitflags v2.11.0
 Compiling cgmath v0.18.0
  Checking rustc-hash v2.1.1
 Compiling typetag v0.2.21
  Checking typed-arena v2.0.2
 Compiling rayon-core v1.13.0
  Checking funty v2.0.0
  Checking byteorder v1.5.0
  Checking linux-raw-sys v0.12.1
 Compiling convert_case v0.4.0
 Compiling toml_datetime v1.0.0+spec-1.1.0
 Compiling zerocopy v0.8.42
 Compiling toml_edit v0.25.4+spec-1.1.0
 Compiling derive_more v0.99.20
  Checking bitvec v1.0.1
  Checking fxhash v0.2.1
 Compiling regex-automata v0.4.14
  Checking pretty v0.12.5
  Checking strum v0.28.0
 Compiling rstest_macros v0.26.1
 Compiling schemars_derive v1.2.1
  Checking crossbeam-deque v0.8.6
 Compiling pest_derive v2.8.6
 Compiling serde_with_macros v3.18.0
  Checking ordered-float v5.1.0
 Compiling delegate v0.13.5
 Compiling typetag-impl v0.2.21
 Compiling derive-where v1.6.1
 Compiling tracing-attributes v0.1.31
  Checking approx v0.4.0
  Checking itertools v0.13.0
 Compiling ahash v0.8.12
  Checking smol_str v0.3.6
  Checking base64 v0.22.1
  Checking fastrand v2.3.0
  Checking bumpalo v3.20.2
  Checking capnp v0.25.2
  Checking utf8parse v0.2.2
  Checking utf8-width v0.1.8
  Checking inventory v0.3.22
  Checking dyn-clone v1.0.20
  Checking schemars v1.2.1
  Checking relrc v0.5.0
  Checking html-escape v0.2.13
  Checking anstyle-parse v1.0.0
 Compiling enum_dispatch v0.3.13
  Checking tracing v0.1.44
  Checking tempfile v3.27.0
  Checking portgraph v0.15.3
  Checking serde_with v3.18.0
  Checking hugr-model v0.26.0
 Compiling regex v1.12.3
  Checking zstd v0.13.3
 Compiling proc-macro-crate v3.5.0
 Compiling futures-macro v0.3.32
  Checking anstyle v1.0.14
 Compiling relative-path v1.9.3
  Checking static_assertions v1.1.0
  Checking is_terminal_polyfill v1.70.2
 Compiling pastey v0.2.1
  Checking downcast-rs v2.0.2
  Checking futures-core v0.3.32
 Compiling glob v0.3.3
  Checking slab v0.4.12
  Checking anstyle-query v1.1.5
 Compiling parking_lot_core v0.9.12
  Checking colorchoice v1.0.5
 Compiling inkwell v0.8.0
  Checking futures-task v0.3.32
  Checking futures-util v0.3.32
  Checking anstream v1.0.0
  Checking hugr-core v0.26.0
  Checking rayon v1.11.0
error: No suitable version of LLVM was found system-wide or pointed
            to by LLVM_SYS_211_PREFIX.
     
            Consider using `llvmenv` to compile an appropriate copy of LLVM, and
            refer to the llvm-sys documentation for more information.
     
            llvm-sys: https://crates.io/crates/llvm-sys
            llvmenv: https://crates.io/crates/llvmenv
 --> /home/runner/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/llvm-sys-211.0.0/src/lib.rs:532:1
  |
532 | / std::compile_error!(concat!(
533 | |     "No suitable version of LLVM was found system-wide or pointed
534 | |        to by LLVM_SYS_",
535 | |     env!("CARGO_PKG_VERSION_MAJOR"),
...   |
542 | |        llvmenv: https://crates.io/crates/llvmenv"
543 | | ));
  | |__^

error: could not compile `llvm-sys` (lib) due to 1 previous error
warning: build failed, waiting for other jobs to finish...

-----

error: failed to build rustdoc for crate tket-qsystem v0.23.0
note: this is usually due to a compilation error in the crate,
    and is unlikely to be a bug in cargo-semver-checks
note: the following command can be used to reproduce the error:
    cargo new --lib example &&
        cd example &&
        echo '[workspace]' >> Cargo.toml &&
        cargo add --path /home/runner/work/tket2/tket2/PR_BRANCH/tket-qsystem --features cli,default,llvm &&
        cargo check &&
        cargo doc

error: aborting due to failure to build rustdoc for crate tket v0.17.0

@codecov
Copy link

codecov bot commented Feb 26, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (ab/hugr-0.26.0@82495c1). Learn more about missing BASE report.

Additional details and impacted files
@@                Coverage Diff                @@
##             ab/hugr-0.26.0    #1422   +/-   ##
=================================================
  Coverage                  ?   79.54%           
=================================================
  Files                     ?      155           
  Lines                     ?    19943           
  Branches                  ?    18953           
=================================================
  Hits                      ?    15864           
  Misses                    ?     3159           
  Partials                  ?      920           
Flag Coverage Δ
python 93.00% <ø> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@jake-arkinstall
Copy link
Contributor

jake-arkinstall commented Feb 26, 2026

Note that devenv.nix in this repo and the hugr repo will need to be updated to provide the newer LLVM and its path in env vars for local development.

If that's already been done, ignore this - the file list is pretty huge. I'm happy to do that change otherwise.

@cgh-qtnm
Copy link
Contributor Author

Note that devenv.nix in this repo and the hugr repo will need to be updated to provide the newer LLVM and its path in env vars for local development.

If that's already been done, ignore this - the file list is pretty huge. I'm happy to do that change otherwise.

I haven't done this, good catch. I'd appreciate if you make the change - better if it's tested by a devenv user anyway.

@cgh-qtnm cgh-qtnm marked this pull request as ready for review March 2, 2026 15:40
@cgh-qtnm cgh-qtnm requested a review from a team as a code owner March 2, 2026 15:40
Cargo.lock Outdated
version = "0.25.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b6baee3cc2fe4d7c5635a630341e28237f12a8e5beef31b5aaaebe93bc9ba90a"
source = "git+https://github.com/quantinuum/hugr?branch=george%2Fllvmup#7d8587c64086ea5a2a4486b23ef7b73ab2c44040"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure that we want to be depending on these branches from main here. Should we wait for an updated release of hugr?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, my plan is to release hugr first and change these to point to the release before merging.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But I hope to merge the HUGR PR + this PR + the internal PR in quick succession, hence putting them up for review together.

@cqc-alec
Copy link
Collaborator

cqc-alec commented Mar 2, 2026

Have given it a superficial review (and ignored all the snaps assuming those changes make sense). LGTM!

@cgh-qtnm
Copy link
Contributor Author

cgh-qtnm commented Mar 16, 2026

@aborgna-q This should be ready for you to merge into the release branch. Notes:

  1. Fixed what Iooks like a bug where BoolOp::not had a signature with two inputs.
  2. Wrap a bunch of TypeBase<NoRV> in vec! so that they will cast to a single-element TypeRowBase<NoRV>. Unless I'm missing something this is just due to an oversight in the type row code, we should fix it in the next HUGR release. If there's a cleaner way to fix this feel free to revert and replace.
  3. Removed remnants of stack array support.

Still a few bugs. In particular, the one about failure to monomorphize _range_comptime in the qis-compiler tests might be a hugr-llvm problem, but I'm not sure exactly what's going wrong. Let me know if further attention is needed there from me.

@aborgna-q aborgna-q self-assigned this Mar 17, 2026
@aborgna-q
Copy link
Collaborator

Made some small fixes:

  • Replaced install-llvm-action with apt install. We saw in hugr that using the former slowed down CI by an order of magnitude (Test were taking almost an hour here). Not sure why.
  • Fixed the LLVM being installed by cibuildwheel for qis-compiler. There is a big issue here in that LLVM official binaries are built with glibc 2.35 but we are trying to build linux wheels on manylinux_2_28. We have a local workaround for now, but things will improve once we have a manylinux-compatible docker image with LLVM pre-installed (WIP).
  • Updated LLVM instructions in DEVELOPMENT.md

There are still some errors shown by the workflows, but I think those are related to pass scopes and other hugr changes, so I'll merge this into the update branch and continue fixing things there.

@aborgna-q aborgna-q changed the base branch from main to ab/hugr-0.26.0 March 17, 2026 15:22
@aborgna-q aborgna-q merged commit d1c2a82 into ab/hugr-0.26.0 Mar 17, 2026
17 of 29 checks passed
@aborgna-q aborgna-q deleted the george/llvmup branch March 17, 2026 15:24
github-merge-queue bot pushed a commit that referenced this pull request Mar 19, 2026
Updates the hugr dependencies to `0.26.0`, and fixes all the breaking
changes.

I only added no-op stubs implementing `WithScope` for the local passes.
We will add the actual implementation in
#1429.

Requires updating LLVM too, so we should merge
#1422 into this PR. We also need
to delete the now removed `stack_array` lowering.

BREAKING CHANGE: Updated public `hugr` dependency to `0.26.0`.

Requires a `hugr-passes 0.26.1` patch release to include
Quantinuum/hugr#2954

---------

Co-authored-by: George Hodgkins <george.hodgkins@quantinuum.com>
Co-authored-by: Jake Arkinstall <65358059+jake-arkinstall@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Upgrade to LLVM 21

5 participants