Skip to content

WASM usage (and general cross-compiling issue) #16

@s5bug

Description

@s5bug

As of now, it's impossible to (easily, automatically) build this crate for usage on the web (or on any target other than the host machine).

The first problem you will run into is <stdlib.h> and <complex.h> not being defined.

  1. The first should be solved by making qiskit's cbindgen (in qiskit, not qiskit-rs) not include the standard includes: it doesn't look like qiskit.h needs anything from stdlib.h.
  2. The second can be solved with a simple fill assuming GCC/clang:
#if !__has_include(<complex.h>)

#define complex _Complex
#define _Complex_I ((_Complex float)__builtin_complex((float)0.0, (float)1.0))
#define I _Complex_I
#define creal(x) (__real__(x))
#define cimag(x) (__imag__(x))

#endif

After this, one will find that bindgen (in qiskit-rs, not qiskit) does not generate forwarders for the C functions. This is because qiskit-sys just builds qiskit using make, which uses the system compiler instead of the correct compiler for the target.

Image

The recommended solution as far as I know is to use the cc crate as a build-dependency, and not use the Makefile at all, but I simply don't have the energy right now to try and get that working.

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