diff --git a/Artifacts.toml b/Artifacts.toml new file mode 100644 index 00000000..ca912817 --- /dev/null +++ b/Artifacts.toml @@ -0,0 +1,2 @@ +[MLIRdist] +git-tree-sha1 = "7a30d5d08131c8d72e002314ee933895a1bed594" diff --git a/Project.toml b/Project.toml index fc201332..bcd28f39 100644 --- a/Project.toml +++ b/Project.toml @@ -6,9 +6,9 @@ version = "0.1.0" CEnum = "fa961155-64e5-5f13-b03f-caf6b980ea82" LLVM = "929cbde3-209d-540e-8aea-75f648917ca0" Libdl = "8f399da3-3557-5675-b5ff-fb832c97cbdb" -MLIR_jll = "a70bccb4-a5c0-5e2e-a329-e731972457e8" +Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f" [compat] CEnum = "0.4" -julia = "1.9" LLVM = "5" +julia = "1.9" diff --git a/src/MLIR.jl b/src/MLIR.jl index 0cd33a6d..9ddc6976 100644 --- a/src/MLIR.jl +++ b/src/MLIR.jl @@ -1,5 +1,7 @@ module MLIR +include("get_artifact.jl") + import LLVM module API @@ -7,9 +9,12 @@ module API # MLIR C API import ..LLVM - using MLIR_jll + + using Pkg.Artifacts + MLIRdist_path = artifact"MLIRdist" + const mlir_c = joinpath(MLIRdist_path, "mlir/lib/libMLIR-C.so") + let - # ver = string(LLVM.version().major) ver = "18" dir = joinpath(@__DIR__, "..", "lib", ver) if !isdir(dir) diff --git a/src/get_artifact.jl b/src/get_artifact.jl new file mode 100644 index 00000000..0a6a1561 --- /dev/null +++ b/src/get_artifact.jl @@ -0,0 +1,20 @@ +using Pkg.Artifacts + +function __init__() + artifact_toml = joinpath(@__DIR__, "../Artifacts.toml") + + MLIRdist_hash = artifact_hash("MLIRdist", artifact_toml) + + if MLIRdist_hash == nothing || !artifact_exists(MLIRdist_hash) + MLIRdist_hash = create_artifact() do artifact_dir + @info "Downloading MLIR distribution (this can take a while ~700MB)" + temp = download("https://github.com/makslevental/mlir-wheels/releases/download/latest/mlir-18.0.0.2023121501+bf2b035e-py3-none-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl") + @info "Unzipping $temp to $artifact_dir (unzip should be installed on your system)" + run(`unzip -q $temp -d $artifact_dir`) + end + bind_artifact!( + artifact_toml, + "MLIRdist", + MLIRdist_hash) + end +end