Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ARM and noASM implementation for Fr #285

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Conversation

nixw4
Copy link

@nixw4 nixw4 commented Aug 6, 2024

Mainlining of changes done in 0xPolygonID/witnesscalc.

Allows building c++ witness calc as a shared/static lib with assembly optimizations for x86_64, & arm64 (and without in pure cpp, so potentially could be compiled for other architectures) and for Linux, MacOS, iOS & Android.

@olomix
Copy link
Contributor

olomix commented Aug 7, 2024

Maybe it would be reasonable to create a readme file inside *_cpp directory with instruction on how to build it?
Right now, I'm trying to build a C++ witness calculator and I'm failing :(. What I'm doing..

  1. Create a simple circuit2.circom file with following content:
pragma circom 2.0.0;

template Multiplier2(){
   //Declaration of signals
   signal input in1;
   signal input in2;
   signal output out;
   out <== in1 * in2;
}

component main = Multiplier2();
  1. circom -c circuit2.circom
  2. cd circuit2_cpp && mkdir build && cd build
  3. cmake ..
  4. Get the following error:
Building for
CMAKE_HOST_SYSTEM_NAME=Darwin
CMAKE_SYSTEM_NAME=
ARCH=x86_64
-- The CXX compiler identification is AppleClang 15.0.0.15000309
-- The ASM compiler identification is AppleClang
-- Found assembler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
USE_ASM=ON
CIRCUIT_NAME=circuit
HAS_PARALLELISM=OFF
CMAKE_CROSSCOMPILING=FALSE
-- Configuring done (0.2s)
CMake Error at CMakeLists.txt:90 (add_library):
  Cannot find source file:

    circuit.cpp

  Tried extensions .c .C .c++ .cc .cpp .cxx .cu .mpp .m .M .mm .ixx .cppm
  .ccm .cxxm .c++m .h .hh .h++ .hm .hpp .hxx .in .txx .f .F .for .f77 .f90
  .f95 .f03 .hip .ispc


CMake Error at CMakeLists.txt:90 (add_library):
  No SOURCES given to target: witnesscalc_circuit


CMake Error at CMakeLists.txt:91 (add_library):
  No SOURCES given to target: witnesscalc_circuitStatic

@OBrezhniev
Copy link
Member

Use scripts from makefile instead of running cmake directly.

@diega
Copy link

diega commented Jan 3, 2025

Is there any chance this could be considered for merging? I tried building my circuit using cmake .. -DUSE_ASM=NO -DCIRCUIT_NAME=circuit_name and I ended up having problems linking to gmp like:

fr_raw_generic.cpp:14:22: error: no matching function for call to '__gmpn_add_n'

I had to add the following to CMakeLists.txt:

find_library(GMP_LIBRARIES gmp REQUIRED)
get_filename_component(GMP_DIR ${GMP_LIBRARIES} DIRECTORY)
find_path(GMP_INCLUDE_DIR gmp.h REQUIRED)
include_directories(${GMP_INCLUDE_DIR})
[...]
target_link_libraries(${CIRCUIT_EXECUTABLE} ${GMP_LIBRARIES})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants