Skip to content

Another hook for codegen to help with WebAssembly #24038

Closed
@tshort

Description

@tshort

At ExportWebAssembly, I've prototyped a package for converting Julia code to WebAssembly. It uses the awesome LLVM package, and much of this code is straight from CUDAnative. This approach works much better than my previous efforts of trying to get julia --output-bc incantations to work.

Right now, it works fine for code using StaticArrays and other immutables. Nothing works that uses ccall's, though. Using Emscripten, I've gotten big chunks of libjulia and libuv compiled to bitcode, so if I can get the ccall's to link with that bitcode, that will open up much more Julia code that will compile to WebAssembly/JavaScript.

llvmcall's are handled fine by this package. In llvmcall's, you can include calls to functions that are declared but not defined. So, it may be possible to convert a ccall to an llvmcall with a declared function and let the linking happen later.

Supporting ccall may require changes to codegen in Julia. So, would it be appropriate to add another hook or two to those added by @maleadt (#19290, #23581)? To get at the ccall's before they are converted to calls to memory addresses, it looks like I need a hook earlier in the codegen process (here?).

If hooks aren't the way to go, are there any other suggestions?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions