JuliaLabs / MLIR.jl

MIT License
56 stars 9 forks source link

Add example of loading standalone dialect #49

Open vchuravy opened 9 months ago

vchuravy commented 9 months ago

Using an assertion build of Julia 1.10

LLVM_ASSERTIONS=1
FORCE_ASSERTIONS=1

override JULIA_BUILD_MODE=debug

The goal is to see if we can dynamically load extension dialects.

cd test/standalone
julia --project=. build_local.jl
julia --project=Standalone
(Standalone) pkg> dev ../..
(Standalone) pkg> test

Currently fails with:

     Testing Running tests...
ERROR: LoadError: LLVM error: can't create Attribute 'mlir::StringAttr' because storage uniquer isn't initialized: the dialect was likely not loaded, or the attribute wasn't added with addAttributes<...>() in the Dialect::initialize() method.
Stacktrace:
 [1] handle_error(reason::Cstring)
   @ LLVM ~/.julia/packages/LLVM/5aiiG/src/core/context.jl:118
 [2] mlirDialectHandleLoadDialect
   @ MLIR.API ~/src/MLIR/src/API/15/libMLIR_h.jl:469 [inlined]
 [3] load_dialect(ctx::MLIR.IR.Context)
   @ Standalone ~/src/MLIR/test/standalone/Standalone/src/Standalone.jl:21
 [4] (::var"#1#2")()
   @ Main ~/src/MLIR/test/standalone/Standalone/test/runtests.jl:8
 [5] context!(f::var"#1#2", ctx::MLIR.IR.Context)
   @ MLIR.IR ~/src/MLIR/src/IR/state.jl:37
 [6] top-level scope
   @ ~/src/MLIR/test/standalone/Standalone/test/runtests.jl:4
 [7] include(fname::String)
   @ Base.MainInclude ./client.jl:489
 [8] top-level scope
   @ none:6
in expression starting at /home/vchuravy/src/MLIR/test/standalone/Standalone/test/runtests.jl:4
ERROR: Package Standalone errored during testing
vchuravy commented 9 months ago

@wsmoses @stephenneuendorffer any ideas on the error? I am trying to reproduce how the python extensions are handled. The big difference I am able to ascertain is that they use one big C library for all extensions?