Comments (7)
After investigating some more, note that zkVM of interest use Risc-V 32-bit instruction, see cargo toolchain update: rust-lang/rust#117958.
The compiler target-triple (an LLVM abstraction) is riscv32im-risc0-zkvm-elf
BLST C/ASM
According to BLST, when the pointer is of size 4 bytes / 32-bit, no assembly should be pulled:
#elif defined(__BLST_NO_ASM__) || \
(defined(__SIZEOF_POINTER__) && __SIZEOF_POINTER__==4)
/* inaccurate way to detect a 32-bit processor, but it's close enough */
#else
And within the code, the fallback to no_asm.h
is triggered by __BLST_NO_ASM__
which is automatically set for 32-bit platforms:
https://github.com/supranational/blst/blob/0d46eefa45fc1e57aceb42bba0e84eab3a7a9725/src/vect.h#L28-L36
#else /* 32 bits on 32-bit platforms, 64 - on 64-bit */
typedef unsigned long limb_t;
# ifdef _LP64
# define LIMB_T_BITS 64
# else
# define LIMB_T_BITS 32
# define __BLST_NO_ASM__
# endif
#endif
I conclude that for some reason the rust toolchain does not report the pointer size properly or maybe there is cross-compilation mixup somewhere.
BLST Go
Looking at BLST Go further confirm my suspicions on 32-bit platforms: https://github.com/supranational/blst/blob/0d46eefa45fc1e57aceb42bba0e84eab3a7a9725/bindings/go/blst.go#L13-L15
// #cgo CFLAGS: -I${SRCDIR}/.. -I${SRCDIR}/../../build -I${SRCDIR}/../../src -D__BLST_CGO__ -fno-builtin-memcpy -fno-builtin-memset
// #cgo amd64 CFLAGS: -D__ADX__ -mno-avx
// #cgo mips64 mips64le ppc64 ppc64le riscv64 s390x CFLAGS: -D__BLST_NO_ASM__
#cgo has no custom flags for 32-bit, I guess because it's not necessary and detected.
Though I'm not sure why specifying the non-amd64 non-aarch64 platforms is necessary either.
Current conclusion
If the custom toolchain does not setup the cross-compilation for zkVM correctly, I doubt #399 will help, the downstream application will be the better place to pass -D__BLST_NO_ASM__
.
If the custom toolchain does setup the cross-compilation correctly, then I think BLST will do the right thing™ and actually nothing will be needed on c-kzg-4844 side.
We're continuing investigation.
from c-kzg-4844.
This is worked on at zkVM-level. Closing.
from c-kzg-4844.
Hey @mratsim, is this problem specific to the Rust bindings? Would you be willing to make a PR for this?
from c-kzg-4844.
Hey again. I made a quick PR which I think will handle this. Do you have a system to test this with?
from c-kzg-4844.
Other platforms might also need something similar if they use a package manager and integrate building C libraries, like Go and Nim.
I will make a PR.
from c-kzg-4844.
Thanks for the response. Sounds good, keep us updated. I will close #399.
from c-kzg-4844.
Hey @mratsim any updates on this?
from c-kzg-4844.
Related Issues (20)
- Rust benchmarks are broken HOT 2
- Consider using a char buffer instead of FILE HOT 5
- Can I just compile as a lib in C? HOT 3
- Some ops seem exceedingly slow on Apple M2 HOT 11
- Crashes with SIGILL on Linux/amd64 i7 CPU HOT 3
- Add library prefix to all ckzg symbols HOT 7
- Broken CI in rust-windows because of rust-1.7.0 HOT 1
- Stack overflow in Rust benchmarks on Windows HOT 1
- Nodejs does not support browsers HOT 5
- Problems with cross-platform docker images HOT 6
- Release Rust bindings on crates.io HOT 3
- Support new function ckzg_load_trusted_setup_from_bytes HOT 3
- Should we make FIELD_ELEMENTS_PER_BLOB runtime-configurable? HOT 8
- Rust binding can't cross compile on Apple Silicon HOT 3
- Rust bindings lack flexibility with current structure of build script HOT 3
- Python bindings' load_trusted_setup() segfaults if file does not exist HOT 1
- Blob value in argument to context.VerifyBlobKZGProof HOT 1
- [rust] Add compute_* verify_* functionsfor KzgSettings HOT 3
- no pypi source packages HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from c-kzg-4844.