Closed huyuguang closed 5 years ago
I use a dirty trick to workaround this issue:
std::vector<size_t> &alt_bn128_G2::wnaf_window_table() {
static std::vector<size_t> _wnaf_window_table_;
return _wnaf_window_table_;
}
std::vector<size_t> &alt_bn128_G2::fixed_base_exp_window_table(){
static std::vector<size_t> _fixed_base_exp_window_table_;
return _fixed_base_exp_window_table_;
}
alt_bn128_G2 &alt_bn128_G2::G2_zero() {
static alt_bn128_G2 _G2_zero_;
return _G2_zero_;
}
alt_bn128_G2 &alt_bn128_G2::G2_one() {
static alt_bn128_G2 _G2_one_;
return _G2_one_;
}
So the key is: do not use global variables of the mcl type, use functions with a static variable.
I init the mcl with code like:
And I got an exception in xbyak.h RegExp::RegExp(...). The caller function is
MixPack::init
and the code isthis->m = Xbyak::util::rsp + rspPos;
The static const Xbyak::util::rsp is not initialized yet. I print the rsp, looks like:
I understand that the c++ static variables init order is somehow like magic. So it seems that I should not init the mcl by a static variable's constructor. But I need to define some global variables looks like:
So, what should I do? Any suggestion? Thanks.