zkLLVM icon indicating copy to clipboard operation
zkLLVM copied to clipboard

Compilation target gates block circuit generation

Open aleasims opened this issue 1 year ago • 0 comments

In zkLLVM we added new compilation target "assigner". This compilation target must be used in order to generate circuits: it produces LLVM assembly files which gonna be passed to assigner afterwards. It works the same way for C++ compiler and Rust compiler (in Rust this target is called "assigner-unknown-unknown").

However there is a possibility in both of that languages to explicitly specify the list of supported targets and throw a compilation error if unsupported target is used.

E.g in Rust you can write something like this:

#[cfg(not(target_arch = "x86_64"))]
compile_error!("Unsupported target");

In C++ you can write similar thing like this:

#ifndef __x86_64__
static_assert(false, "Unsupported target");
#endif

As a result, some libraries cannot be compiled for out "assigner" target at all. This compilation is simply manually aborted. And it looks pretty bad for us.

E.g Rust library getrandom, which has over 200 millions of downloads, has a fixed list of supported targets. Any other target may be compiled only when you explicitly enable custom feature for this crate. If you compile it for assigner you'll get an error:

error: target is not supported, for more information see: https://docs.rs/getrandom/#unsupported-targets
   --> /home/vt/.cargo/registry/src/github.com-1ecc6299db9ec823/getrandom-0.2.8/src/lib.rs:268:9
    |
268 | /         compile_error!("target is not supported, for more information see: \
269 | |                         https://docs.rs/getrandom/#unsupported-targets");
    | |________________________________________________________________________^

error: could not compile getrandom due to 2 previous errors

aleasims avatar Nov 18 '23 19:11 aleasims