Skip to content

Conversation

mergify[bot]
Copy link
Contributor

@mergify mergify bot commented Mar 31, 2025

Summary

We currently generate the header using cbindgen as command line tool. This works, but

  • doesn't expose all features cbindgen has (ok almost all)
  • requires users to additionally install the command line tool (and run it)
  • emits a lot of warnings we (currently?) don't know how to silence

This PR moves to using the Rust API of cbindgen and builds the header as part of the qiskit-cext compilation process. This fixes all the above points. The one down side is that the cbindgen.toml was a bit nicer to read IMO, but that's a small price to pay.

It would be nice to backport this to stable/2.0 for a smoother build process for users.

Details

  • The Makefile is slightly simpler now since we don't need to separately call the command line tool to generate the header file.
  • The resulting header file is exactly the same as before, up to an additional include guard I added in this PR

This is an automatic backport of pull request #14013 done by [Mergify](https://mergify.com).

* move cbindgen to Rust build

* add include guard

* allow cmdline build and compile-time build

* write `qiskit.h` to `crates/cext`

and use Makefile to correctly move or regenerate the file lazily

* try cleaner build setup

write header into target/qiskit.h and copy into dist/c/include with Makefile. The cargo build script tracks changes in target/qiskit.h and rebuilds if changed/deleted

Not sure if this is the best way but it seems to work :)

* try fix build deps, and fix clippy

* fix merge artifact

this is probably why CI doesn't work, we need to ensure the cdylib is built

* include dir creation as dependency

(cherry picked from commit 241818b)
@mergify mergify bot requested a review from a team as a code owner March 31, 2025 14:52
@qiskit-bot
Copy link
Collaborator

Thank you for opening a new pull request.

Before your PR can be merged it will first need to pass continuous integration tests and be reviewed. Sometimes the review process can be slow, so please be patient.

While you're waiting, please feel free to review other open PRs. While only a subset of people are authorized to approve pull requests for merging, everyone is encouraged to review open pull requests. Doing reviews helps reduce the burden on the core team and helps make the project's code better for everyone.

One or more of the following people are relevant to this code:

  • @Qiskit/terra-core

@github-actions github-actions bot added Changelog: None Do not include in changelog C API Related to the C API labels Mar 31, 2025
@github-actions github-actions bot added this to the 2.0.0 milestone Mar 31, 2025
@Cryoris Cryoris enabled auto-merge March 31, 2025 15:04
@coveralls
Copy link

Pull Request Test Coverage Report for Build 14174535970

Details

  • 26 of 26 (100.0%) changed or added relevant lines in 1 file are covered.
  • 4 unchanged lines in 2 files lost coverage.
  • Overall coverage increased (+0.01%) to 88.124%

Files with Coverage Reduction New Missed Lines %
crates/accelerate/src/unitary_synthesis.rs 1 94.79%
crates/qasm2/src/lex.rs 3 92.48%
Totals Coverage Status
Change from base Build 14174060538: 0.01%
Covered Lines: 72838
Relevant Lines: 82654

💛 - Coveralls

@Cryoris Cryoris added this pull request to the merge queue Mar 31, 2025
Merged via the queue into stable/2.0 with commit 47e8edb Mar 31, 2025
27 checks passed
@mtreinish mtreinish deleted the mergify/bp/stable/2.0/pr-14013 branch April 29, 2025 23:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C API Related to the C API Changelog: None Do not include in changelog
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants