quil-lang / quilc

The optimizing Quil compiler.
Apache License 2.0
448 stars 73 forks source link

Add function exports for RPC API to libquilc #890

Open kartik-s opened 12 months ago

kartik-s commented 12 months ago

This PR is a proof-of-concept that demonstrates calling API functions that are currently exposed via the RPC interface through a shared library. An example Python script is included which illustrates usage.

Also see quil-lang/sbcl-librarian#43.

Build instructions on macOS

  1. Get a local copy of the SBCL source. This directory will be your SBCL_HOME in later steps.
  2. Build SBCL
    sh make.sh

    If on an Intel Mac, check out the x86-null-tn branch first, then:

    sh make.sh --without-compact-instance-header --without-immobile-space --without-immobile-code
  3. Build libsbcl.so
    sh make-shared-library.sh
  4. In quilc/lib/,
    SBCL_HOME=<directory from step 1, defaults to ~/sbcl in the Makefile> make
  5. Run the example:
    SBCL_HOME=<directory from step 1>
    PYTHONPATH=. DYLD_LIBRARY_PATH=$SBCL_HOME/src/runtime python3 ./tests/python/rpc_functions.py