diff --git a/.github/resources/prover/windows.Makefile b/.github/resources/prover/windows.Makefile index eb255e7..8bc079c 100644 --- a/.github/resources/prover/windows.Makefile +++ b/.github/resources/prover/windows.Makefile @@ -3,9 +3,13 @@ #Build targets host: rm -rf build_prover && mkdir build_prover && cd build_prover && \ - cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=../package && \ + cmake .. \ + -DCMAKE_BUILD_TYPE=Release + -DCMAKE_INSTALL_PREFIX=../package && \ make -j$(nproc) -vvv && make install +# Copy of the original host target, with specific flags for Windows x86_64 to add patches, missing libraries and +# include paths host_windows_x86_64: rm -rf build_prover && mkdir build_prover && cd build_prover && \ cmake .. \ diff --git a/.github/resources/prover/windows.build_gmp.sh b/.github/resources/prover/windows.build_gmp.sh index 9930e7c..245ec0a 100755 --- a/.github/resources/prover/windows.build_gmp.sh +++ b/.github/resources/prover/windows.build_gmp.sh @@ -82,6 +82,8 @@ build_host() mkdir "$BUILD_DIR" cd "$BUILD_DIR" + # The following line is a workaround for the Windows build due to an existing incompatibility with current compiler + # when building GMP. CFLAGS="-O2 -std=gnu17" CXXFLAGS="-O2 -std=gnu++17" \ ../configure --prefix="$PACKAGE_DIR" --with-pic --disable-fft && make -j${NPROC} && diff --git a/.github/resources/prover/windows.mman_patch.hpp b/.github/resources/prover/windows.mman_patch.hpp index 9e1db06..718acb3 100644 --- a/.github/resources/prover/windows.mman_patch.hpp +++ b/.github/resources/prover/windows.mman_patch.hpp @@ -1,3 +1,5 @@ +// Workaround for Windows where some mman functions are not defined + #ifdef _WIN32 #include inline int madvise(void*, size_t, int) { return 0; } diff --git a/.github/resources/prover/windows.src-CMakeLists.txt b/.github/resources/prover/windows.src-CMakeLists.txt index 724528b..d97580f 100644 --- a/.github/resources/prover/windows.src-CMakeLists.txt +++ b/.github/resources/prover/windows.src-CMakeLists.txt @@ -1,5 +1,7 @@ -link_directories(/lib) -set(COMMON_LIBS /lib/libmman.a) +# Workaround for CMake on Windows to +# Added explicit linking (e.g., mman), which are otherwise resolved transitively on Linux and macOS. + +find_library(MMAN_LIB mman PATHS /lib NO_DEFAULT_PATH REQUIRED) link_libraries(${GMP_LIB}) @@ -124,13 +126,19 @@ set_target_properties(rapidsnarkStaticFrFq PROPERTIES POSITION_INDEPENDENT_CODE set_target_properties(rapidsnarkStaticFrFq PROPERTIES OUTPUT_NAME rapidsnark-fr-fq) add_executable(prover main_prover.cpp) -target_link_libraries(prover rapidsnarkStatic fr fq ${COMMON_LIBS}) +target_link_libraries( + prover rapidsnarkStatic + fr fq ${MMAN_LIB} # Explicit linking +) add_executable(verifier main_verifier.cpp) -target_link_libraries(verifier rapidsnarkStatic fr fq ${COMMON_LIBS}) +target_link_libraries( + verifier rapidsnarkStatic + fr fq ${MMAN_LIB} # Explicit linking +) add_library(rapidsnark SHARED ${LIB_SOURCES}) -target_link_libraries(rapidsnark ${COMMON_LIBS}) +target_link_libraries(rapidsnark ${MMAN_LIB}) # Explicit linking if((USE_LOGGER OR NOT USE_OPENMP) AND NOT TARGET_PLATFORM MATCHES "android") target_link_libraries(prover pthread) @@ -146,7 +154,10 @@ option(BUILD_TESTS "Build the tests" ON) if(BUILD_TESTS) enable_testing() add_executable(test_public_size test_public_size.c) - target_link_libraries(test_public_size rapidsnarkStaticFrFq pthread ${COMMON_LIBS}) + target_link_libraries( + test_public_size rapidsnarkStaticFrFq pthread + ${MMAN_LIB} # Explicit linking + ) add_test(NAME test_public_size COMMAND test_public_size circuit_final.zkey 86 WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/testdata) endif() diff --git a/.github/resources/prover/windows.uio.h b/.github/resources/prover/windows.uio.h index 9032e0c..8ac0de2 100644 --- a/.github/resources/prover/windows.uio.h +++ b/.github/resources/prover/windows.uio.h @@ -1,3 +1,5 @@ +// Workaround for Windows UIO header, as it's not available by default + #ifndef SYS_UIO_H #define SYS_UIO_H diff --git a/.github/resources/witness-generator/macos.gmp_patch.hpp b/.github/resources/witness-generator/macos.gmp_patch.hpp index ff06356..53ff683 100644 --- a/.github/resources/witness-generator/macos.gmp_patch.hpp +++ b/.github/resources/witness-generator/macos.gmp_patch.hpp @@ -1,13 +1,13 @@ +// Workaround for a known macOS issue where certain GMP functions fail to compile +// due to strict type checking, despite uint64_t and mp_limb_t being the same size. +// These wrappers explicitly cast uint64_t parameters to mp_limb_t to resolve the mismatch. + #ifndef GMP_PATCH_CAST_HPP #define GMP_PATCH_CAST_HPP #include #include -// Workaround for a known macOS issue where certain GMP functions fail to compile -// due to strict type checking, despite uint64_t and mp_limb_t being the same size. -// These wrappers explicitly cast uint64_t parameters to mp_limb_t to resolve the mismatch. - // Arithmetic Wrappers inline mp_limb_t gmp_add_n_cast(uint64_t* rp, const uint64_t* up, const uint64_t* vp, mp_size_t n) { return mpn_add_n(reinterpret_cast(rp),