Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get building on LLVM 18.1 (...But not working) #278

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
28 changes: 28 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions pyqir/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ llvm-sys-110 = { package = "llvm-sys", version = "110.0", optional = true }
llvm-sys-120 = { package = "llvm-sys", version = "120.3", optional = true }
llvm-sys-130 = { package = "llvm-sys", version = "130.1", optional = true }
llvm-sys-140 = { package = "llvm-sys", version = "140.1", optional = true }
llvm-sys-181 = { package = "llvm-sys", version = "181", optional = true }
pyo3 = { version = "0.19", features = ["abi3-py38", "extension-module"] }
qirlib = { path = "../qirlib" }

Expand All @@ -23,6 +24,7 @@ llvm11-0 = ["llvm-sys-110", "qirlib/llvm11-0"]
llvm12-0 = ["llvm-sys-120", "qirlib/llvm12-0"]
llvm13-0 = ["llvm-sys-130", "qirlib/llvm13-0"]
llvm14-0 = ["llvm-sys-140", "qirlib/llvm14-0"]
llvm18-1 = ["llvm-sys-181", "qirlib/llvm18-1"]

[lib]
crate-type = ["cdylib"]
Expand Down
4 changes: 2 additions & 2 deletions pyqir/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -234,9 +234,9 @@ impl Builder {
.map(|(arg, ty)| arg.to_value(ty).map_err(Into::into))
.collect::<PyResult<Vec<_>>>()?;

#[allow(deprecated)]
let value = LLVMBuildCall(
let value = LLVMBuildCall2(
self.as_ptr(),
fn_type,
callee.as_ptr(),
args.as_mut_ptr(),
args.len().try_into().unwrap(),
Expand Down
2 changes: 2 additions & 0 deletions pyqir/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ extern crate llvm_sys_120 as llvm_sys;
extern crate llvm_sys_130 as llvm_sys;
#[cfg(feature = "llvm14-0")]
extern crate llvm_sys_140 as llvm_sys;
#[cfg(feature = "llvm18-1")]
extern crate llvm_sys_181 as llvm_sys;

mod builder;
mod core;
Expand Down
4 changes: 2 additions & 2 deletions pyqir/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -268,8 +268,8 @@ impl ArrayType {
///
/// :type: int
#[getter]
fn count(slf: PyRef<Self>) -> u32 {
unsafe { LLVMGetArrayLength(slf.into_super().as_ptr()) }
fn count(slf: PyRef<Self>) -> u64 {
unsafe { LLVMGetArrayLength2(slf.into_super().as_ptr()) }
}
}

Expand Down
2 changes: 2 additions & 0 deletions qirlib/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ llvm-sys-110 = { package = "llvm-sys", version = "110.0", optional = true }
llvm-sys-120 = { package = "llvm-sys", version = "120.3", optional = true }
llvm-sys-130 = { package = "llvm-sys", version = "130.1", optional = true }
llvm-sys-140 = { package = "llvm-sys", version = "140.1", optional = true }
llvm-sys-181 = { package = "llvm-sys", version = "181", optional = true }
log = "0.4"
mut_static = "5.0"

Expand All @@ -37,6 +38,7 @@ llvm11-0 = ["llvm-sys-110"]
llvm12-0 = ["llvm-sys-120"]
llvm13-0 = ["llvm-sys-130"]
llvm14-0 = ["llvm-sys-140"]
llvm18-1 = ["llvm-sys-181"]

# default to use llvm-sys for llvm linking
default = ["external-llvm-linking"]
Expand Down
44 changes: 38 additions & 6 deletions qirlib/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,29 +23,59 @@ extern crate lazy_static;
not(any(feature = "llvm12-0")),
not(any(feature = "llvm13-0")),
not(any(feature = "llvm14-0")),
not(any(feature = "llvm18-1")),
))]
compile_error!("One of the features `qirlib/llvm11-0`, `qirlib/llvm12-0`, `qirlib/llvm13-0`, and `qirlib/llvm14-0` must be used exclusive.");
compile_error!("One of the features `qirlib/llvm11-0`, `qirlib/llvm12-0`, `qirlib/llvm13-0`, `qirlib/llvm14-0`, and `qirlib/llvm18-1` must be used exclusive.");

// Make sure only one llvm option is used.
#[cfg(any(
all(
feature = "llvm11-0",
any(feature = "llvm12-0", feature = "llvm13-0", feature = "llvm14-0")
any(
feature = "llvm12-0",
feature = "llvm13-0",
feature = "llvm14-0",
feature = "llvm18-1"
)
),
all(
feature = "llvm12-0",
any(feature = "llvm11-0", feature = "llvm13-0", feature = "llvm14-0")
any(
feature = "llvm11-0",
feature = "llvm13-0",
feature = "llvm14-0",
feature = "llvm18-1"
)
),
all(
feature = "llvm13-0",
any(feature = "llvm11-0", feature = "llvm12-0", feature = "llvm14-0")
any(
feature = "llvm11-0",
feature = "llvm12-0",
feature = "llvm14-0",
feature = "llvm18-1"
)
),
all(
feature = "llvm14-0",
any(feature = "llvm11-0", feature = "llvm12-0", feature = "llvm13-0")
any(
feature = "llvm11-0",
feature = "llvm12-0",
feature = "llvm13-0",
feature = "llvm18-1"
)
),
all(
feature = "llvm18-1",
any(
feature = "llvm11-0",
feature = "llvm12-0",
feature = "llvm13-0",
feature = "llvm14-0"
)
),
))]
compile_error!("Features `qirlib/llvm11-0`, `qirlib/llvm12-0`, `qirlib/llvm13-0`, and `qirlib/llvm14-0` must be used exclusive.");
compile_error!("Features `qirlib/llvm11-0`, `qirlib/llvm12-0`, `qirlib/llvm13-0`, `qirlib/llvm14-0`, and `qirlib/llvm18-1` must be used exclusive.");

// Make sure one of the linking features is used
#[cfg(all(
Expand Down Expand Up @@ -382,6 +412,8 @@ fn locate_llvm_config() -> Option<PathBuf> {
"13"
} else if cfg!(feature = "llvm14-0") {
"14"
} else if cfg!(feature = "llvm18-1") {
"18"
} else {
"unknown"
};
Expand Down
2 changes: 2 additions & 0 deletions qirlib/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ extern crate llvm_sys_120 as llvm_sys;
extern crate llvm_sys_130 as llvm_sys;
#[cfg(feature = "llvm14-0")]
extern crate llvm_sys_140 as llvm_sys;
#[cfg(feature = "llvm18-1")]
extern crate llvm_sys_181 as llvm_sys;

#[cfg(not(feature = "no-llvm-linking"))]
pub mod builder;
Expand Down
Loading
Loading