Git Product home page Git Product logo

Comments (3)

nathan-at-least avatar nathan-at-least commented on September 16, 2024

Note, this blog post describes the same kind of issue and introduces a new C++0x language extension to address the issue:

Perhaps libsnark should use that mechanism?

from libsnark.

daira avatar daira commented on September 16, 2024

Ugh, how many hacky workarounds is C++ going to add in the language to address broken linker technology? :-/

from libsnark.

madars avatar madars commented on September 16, 2024

In libsnark each Fp_model<num_limbs, modulus> is used in conjunction with particular elliptic curve choices. Given this the following should work:

  • in fp.hpp mark each static data member of Fp_model as extern. For example,
template<mp_size_t n, const bigint<n>& modulus>
extern size_t Fp_model<n, modulus>::num_bits

This would ensure that translation units for your executable won't declare their own copy of those symbols.

  • For each use of Fp_model declare the static data members inside the CURVE_init.cpp. E.g. inside curves/bn128/bn128_init.cpp, we would have size_t Fp_model<bn128_r_limbs, bn128_modulus_r>::num_bits.

Of course, The amount of boilerplate can be reduced by an appropriate DECLARE_FP_MODEL_STATIC_MEMBERS(num_limbs, modulus) macro.

We rely on extern template anyway, so maybe solution based on that would be a better choice.

By the way, I was unable to exhibit the behavior you observe on my machine: all static members of template instantiations get "weak" bindings in libsnark.so so the dynamic linker should just DTRT. But that might just be an artifact of my setup (g++ 5.2.1 on Ubuntu wily).

from libsnark.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.