Ts/Go bindings #5738
Replies: 11 comments 17 replies
-
Thanks for transferring it, I should have done so already. Coincidentally I learned yesterday that there is a repository with go bindings. I think the model used for the Julia bindings would be easier to manage:
We stopped short, very unfortunately, of other steps that would be useful:
|
Beta Was this translation helpful? Give feedback.
-
I looked at the Go bindings in https://github.com/mitchellh/go-z3. I agree with you; the model used for the Julia bindings it's definitely easier to manage and even to maintain. This week I'll start working on it. From time to time I'll notify here the status of the work. (I also changed the title of the discussion in order to include Go) |
Beta Was this translation helpful? Give feedback.
-
Hi @NikolajBjorner, happy new year! I began working on the bindings. In particular, I started considering the tools available for such a task. Here's the result:
The best solution I have found so far is emscripten, a very powerful and flexible compiler. It's easy to install and pretty straightforward to use for everyone who's familiar with gcc/clang options. I'm going to use it to generate javascript bindings (in order to wrap them into Typescript interfaces), but it can be used for generating wasm output files as well. I'm going on with emscripten. |
Beta Was this translation helpful? Give feedback.
-
Note also the activity around #5746. There are a couple of takeaways: |
Beta Was this translation helpful? Give feedback.
-
I've started working on TypeScript bindings here, built on top of wasm. It has auto-generated well-typed native bindings and the beginnings of a wrapper to provide a more user-friendly Python-style library. The Python library is > 10k lines of code, so it'll be a long while before it reaches parity, but it's a start. @aestriplex (or anyone) if you want to collaborate, pull requests very welcome! This weekend I should have it to a state where there's CI and linting and so on. It's pretty straightforward to port the Python bindings, there's just a lot to be done. (The native bindings do technically work without a wrapper, but they're pretty hard to use - I'm not sure they're worth publishing on their own.) @NikolajBjorner how do tests work? I'd like to port tests if there are existing ones - either tests of the underlying C bindings or (ideally) tests of the Python API. |
Beta Was this translation helpful? Give feedback.
-
I'll start focusing on the Golang bindings then. |
Beta Was this translation helpful? Give feedback.
-
Above I was speculating about what it would take to change update_api.py and didn't find it too appealing to touch. The script that auto-generates the js bindings https://github.com/bakkot/z3-js-bindings/blob/0fa155fb243015168e4750e25c6fe7713e919855/build/wrapper.ts |
Beta Was this translation helpful? Give feedback.
-
@NikolajBjorner OK, I have the raw TypeScript bindings in a state I'm happy with. I've updated the readme for the project. Specifically:
I'd like to contribute these to this repository. Some questions about that:
|
Beta Was this translation helpful? Give feedback.
-
Very nice!
Azure Pipelines are a little different from GitHub Actions and when I started with Azure Pipelines the GitHub actions did not yet exist. For python (pypi) I have an account and set up secrets appropriately in the build pipeline to be able to upload. For nuget I have something similar, in principle, but it doesn't work so I just upload manually. It is better to have set up an account and keys. You can have your own account and keys and publish under your naming convention and I can replicate it for z3 (we would either need different names for the npm or transfer/share ownership). For the pypi z3-solver I was added as co-owner. Based on what I can see on https://www.npmjs.com/ and other online material on Github Actions and npm the setup looks similar. I created a "z3-solver" package and sent an invitation to your email address. If this works, then we are good. So I suggest:
All these steps can be done in your own repository to start with so don't require round-tripping with the main branch during development. I currently doubt that integrating the js as part of the main build as a flag makes sense: (1) The integration process for the wasm tools is still heavier than issuing an apt-get or similar. (2) he hosted images seem to have some but still limited support for empscripten (microsoft.net.sdk.emscripten on https://github.com/actions/virtual-environments/blob/main/images/win/Windows2022-Readme.md) and nothing for Ubuntu 20). (3) it seems like extra work and unknown who would need this. There is going to be some value to having the GitHub actions ported to the Azure pipeline nightly and release scripts because the process for uploading artifacts to GitHub releases is streamlined. But this is much less useful than simply uploading to an npm registry from what I can tell. |
Beta Was this translation helpful? Give feedback.
-
@NikolajBjorner I started the wrapping of the C++ library on my fork. I'm writing a "refactored" version of z3++.h in order to make it compatible with SWIG and Go. Right now, I'm focusing on:
On my fork you can see the complete refactoring of the first three classes. Just as an example, replacing
with
on line 130, required more than 500 substitutions throughout the code. So, it may take a while, but if we choose to not use the C library, it's the only way to make SWIG compile the code. |
Beta Was this translation helpful? Give feedback.
-
Hi @NikolajBjorner, |
Beta Was this translation helpful? Give feedback.
-
@NikolajBjorner I closed the issue #5736 and I moved here the discussion, in order to keep clean the issues board.
Unfortunately I don't know much about WebAssembly, so I cannot contribute to that part of the codebase. Nevertheless, if you think it could be an audience for either Ts or Go bindings, I can start working on it. For what concerns Ts/JS, yes, there is a SWIG interface available for C++, so I would start from that.
Beta Was this translation helpful? Give feedback.
All reactions