mirror of
https://github.com/logos-blockchain/logos-blockchain-pocs.git
synced 2026-01-18 13:03:09 +00:00
Add required resources for compilation.
This commit is contained in:
parent
bcebe758ec
commit
52e0bf95de
100
.github/resources/prover/windows.Makefile
vendored
Normal file
100
.github/resources/prover/windows.Makefile
vendored
Normal file
@ -0,0 +1,100 @@
|
||||
###
|
||||
|
||||
#Build targets
|
||||
host:
|
||||
rm -rf build_prover && mkdir build_prover && cd build_prover && \
|
||||
cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=../package && \
|
||||
make -j$(nproc) -vvv && make install
|
||||
|
||||
host_windows_x86_64:
|
||||
rm -rf build_prover && mkdir build_prover && cd build_prover && \
|
||||
cmake .. \
|
||||
-DUSE_ASM=OFF \
|
||||
-DCMAKE_BUILD_TYPE=Release \
|
||||
-DCMAKE_INSTALL_PREFIX=../package \
|
||||
-DCMAKE_EXE_LINKER_FLAGS="-L/lib -lmman" \
|
||||
-DCMAKE_CXX_FLAGS="-I/include -include mman_patch.hpp -include cstdint -Duint=unsigned\ int -Du_int32_t=uint32_t -Du_int64_t=uint64_t" && \
|
||||
make -j$(nproc) -vvv && make install
|
||||
|
||||
host_noasm:
|
||||
rm -rf build_prover_noasm && mkdir build_prover_noasm && cd build_prover_noasm && \
|
||||
cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=../package_noasm -DUSE_ASM=NO && \
|
||||
make -j$(nproc) -vvv && make install
|
||||
|
||||
host_arm64:
|
||||
rm -rf build_prover_arm64 && mkdir build_prover_arm64 && cd build_prover_arm64 && \
|
||||
cmake .. -DTARGET_PLATFORM=aarch64 -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=../package_arm64 && \
|
||||
make -j$(nproc) -vvv && make install
|
||||
|
||||
android:
|
||||
rm -rf build_prover_android && mkdir build_prover_android && cd build_prover_android && \
|
||||
cmake .. -DTARGET_PLATFORM=ANDROID -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=../package_android -DBUILD_TESTS=OFF -DUSE_OPENMP=OFF && \
|
||||
make -j$(nproc) -vvv && make install
|
||||
|
||||
android_openmp:
|
||||
rm -rf build_prover_android_openmp && mkdir build_prover_android_openmp && cd build_prover_android_openmp && \
|
||||
cmake .. -DTARGET_PLATFORM=ANDROID -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=../package_android_openmp -DBUILD_TESTS=OFF -DUSE_OPENMP=ON && \
|
||||
make -j$(nproc) -vvv && make install
|
||||
|
||||
android_x86_64:
|
||||
rm -rf build_prover_android_x86_64 && mkdir build_prover_android_x86_64 && cd build_prover_android_x86_64 && \
|
||||
cmake .. -DTARGET_PLATFORM=ANDROID_x86_64 -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=../package_android_x86_64 -DBUILD_TESTS=OFF -DUSE_OPENMP=OFF && \
|
||||
make -j$(nproc) -vvv && make install
|
||||
|
||||
android_openmp_x86_64:
|
||||
rm -rf build_prover_android_openmp_x86_64 && mkdir build_prover_android_openmp_x86_64 && cd build_prover_android_openmp_x86_64 && \
|
||||
cmake .. -DTARGET_PLATFORM=ANDROID_x86_64 -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=../package_android_openmp_x86_64 -DBUILD_TESTS=OFF -DUSE_OPENMP=ON && \
|
||||
make -j$(nproc) -vvv && make install
|
||||
|
||||
ios:
|
||||
@if [ ! -d "./depends/gmp/package_ios_arm64" ]; then echo "Looks like gmp lib is not built. Run './build_gmp.sh ios' first." && exit 1; fi
|
||||
rm -rf build_prover_ios && mkdir build_prover_ios && cd build_prover_ios && \
|
||||
cmake .. -GXcode -DTARGET_PLATFORM=IOS -DCMAKE_INSTALL_PREFIX=../package_ios && \
|
||||
xcodebuild -destination 'generic/platform=iOS' -scheme rapidsnarkStatic -project rapidsnark.xcodeproj -configuration Release && \
|
||||
xcodebuild -destination 'generic/platform=iOS' -scheme rapidsnark -project rapidsnark.xcodeproj -configuration Release CODE_SIGNING_ALLOWED=NO && \
|
||||
cp ../depends/gmp/package_ios_arm64/lib/libgmp.a src/Release-iphoneos && \
|
||||
echo "" && echo "iOS Simulator artifacts built in build_prover_ios/src/Release-iphoneos" && echo ""
|
||||
|
||||
ios_simulator:
|
||||
@if [ ! -d "./depends/gmp/package_iphone_simulator" ]; then echo "Looks like gmp lib is not built. Run './build_gmp.sh ios_simulator' first." && exit 1; fi
|
||||
rm -rf build_prover_ios_simulator && mkdir build_prover_ios_simulator && cd build_prover_ios_simulator && \
|
||||
cmake .. -GXcode -DTARGET_PLATFORM=IOS_SIMULATOR -DCMAKE_INSTALL_PREFIX=../package_ios_simulator -DUSE_ASM=NO && \
|
||||
xcodebuild -destination 'generic/platform=iOS Simulator' -scheme rapidsnarkStatic -project rapidsnark.xcodeproj && \
|
||||
xcodebuild -destination 'generic/platform=iOS Simulator' -scheme rapidsnark -project rapidsnark.xcodeproj CODE_SIGNING_ALLOWED=NO ARCHS=arm64 && \
|
||||
cp ../depends/gmp/package_iphone_simulator/lib/libgmp.a src/Debug-iphonesimulator && \
|
||||
echo "" && echo "iOS Simulator artifacts built in build_prover_ios_simulator/src/Debug-iphonesimulator" && echo ""
|
||||
|
||||
macos_arm64:
|
||||
@if [ ! -d "./depends/gmp/package_macos_arm64" ]; then echo "Looks like gmp lib is not built. Run './build_gmp.sh macos_arm64' first." && exit 1; fi
|
||||
rm -rf build_prover_macos_arm64 && mkdir build_prover_macos_arm64 && cd build_prover_macos_arm64 && \
|
||||
cmake .. -DTARGET_PLATFORM=macos_arm64 -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=../package_macos_arm64 && \
|
||||
make -j$(nproc) -vvv && make install
|
||||
|
||||
macos_x86_64:
|
||||
@if [ ! -d "./depends/gmp/package_macos_x86_64" ]; then echo "Looks like gmp lib is not built. Run './build_gmp.sh macos_x86_64' first." && exit 1; fi
|
||||
rm -rf build_prover_macos_x86_64 && mkdir build_prover_macos_x86_64 && cd build_prover_macos_x86_64 && \
|
||||
cmake .. -DTARGET_PLATFORM=macos_x86_64 -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=../package_macos_x86_64 && \
|
||||
make -j$(nproc) -vvv && make install
|
||||
|
||||
clean:
|
||||
rm -rf build_prover \
|
||||
build_prover_macos_arm64 \
|
||||
build_prover_macos_x86_64 \
|
||||
build_prover_android \
|
||||
build_prover_android_x86_64 \
|
||||
build_prover_ios \
|
||||
build_prover_ios_simulator \
|
||||
package \
|
||||
package_macos_arm64 \
|
||||
package_macos_x86_64 \
|
||||
package_android \
|
||||
package_android_x86_64 \
|
||||
package_ios \
|
||||
package_ios_simulator \
|
||||
depends/gmp/package \
|
||||
depends/gmp/package_macos_arm64 \
|
||||
depends/gmp/package_macos_x86_64 \
|
||||
depends/gmp/package_android_arm64 \
|
||||
depends/gmp/package_android_x86_64 \
|
||||
depends/gmp/package_ios_arm64 \
|
||||
depends/gmp/package_iphone_simulator
|
||||
421
.github/resources/prover/windows.build_gmp.sh
vendored
Executable file
421
.github/resources/prover/windows.build_gmp.sh
vendored
Executable file
@ -0,0 +1,421 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -e
|
||||
|
||||
NPROC=8
|
||||
fetch_cmd=$( (type wget > /dev/null 2>&1 && echo "wget") || echo "curl -O" )
|
||||
|
||||
usage()
|
||||
{
|
||||
echo "USAGE: $0 <target>"
|
||||
echo "where target is one of:"
|
||||
echo " ios: build for iOS arm64"
|
||||
echo " ios_simulator: build for iPhone Simulator for arm64/x86_64 (fat binary)"
|
||||
echo " macos: build for macOS for arm64/x86_64 (fat binary)"
|
||||
echo " macos_arm64: build for macOS arm64"
|
||||
echo " macos_x86_64: build for macOS x86_64"
|
||||
echo " android: build for Android arm64"
|
||||
echo " android_x86_64: build for Android x86_64"
|
||||
echo " host: build for this host"
|
||||
echo " host_noasm: build for this host without asm optimizations (e.g. needed for macOS)"
|
||||
echo " aarch64: build for Linux aarch64"
|
||||
|
||||
exit 1
|
||||
}
|
||||
|
||||
get_gmp()
|
||||
{
|
||||
GMP_NAME=gmp-6.2.1
|
||||
GMP_ARCHIVE=${GMP_NAME}.tar.xz
|
||||
GMP_URL=https://ftp.gnu.org/gnu/gmp/${GMP_ARCHIVE}
|
||||
|
||||
if [ ! -f ${GMP_ARCHIVE} ]; then
|
||||
|
||||
$fetch_cmd ${GMP_URL}
|
||||
fi
|
||||
|
||||
|
||||
if [ ! -d gmp ]; then
|
||||
|
||||
tar -xvf ${GMP_ARCHIVE}
|
||||
mv ${GMP_NAME} gmp
|
||||
fi
|
||||
}
|
||||
|
||||
build_aarch64()
|
||||
{
|
||||
PACKAGE_DIR="$GMP_DIR/package_aarch64"
|
||||
BUILD_DIR=build_aarch64
|
||||
|
||||
if [ -d "$PACKAGE_DIR" ]; then
|
||||
echo "aarch64 package is built already. See $PACKAGE_DIR"
|
||||
return 1
|
||||
fi
|
||||
|
||||
|
||||
export TARGET=aarch64-linux-gnu
|
||||
|
||||
echo $TARGET
|
||||
|
||||
rm -rf "$BUILD_DIR"
|
||||
mkdir "$BUILD_DIR"
|
||||
cd "$BUILD_DIR"
|
||||
|
||||
../configure --host $TARGET --prefix="$PACKAGE_DIR" --with-pic --disable-fft &&
|
||||
make -j${NPROC} &&
|
||||
make install
|
||||
|
||||
cd ..
|
||||
}
|
||||
|
||||
build_host()
|
||||
{
|
||||
PACKAGE_DIR="$GMP_DIR/package"
|
||||
BUILD_DIR=build
|
||||
|
||||
if [ -d "$PACKAGE_DIR" ]; then
|
||||
echo "Host package is built already. See $PACKAGE_DIR"
|
||||
return 1
|
||||
fi
|
||||
|
||||
rm -rf "$BUILD_DIR"
|
||||
mkdir "$BUILD_DIR"
|
||||
cd "$BUILD_DIR"
|
||||
|
||||
CFLAGS="-O2 -std=gnu17" CXXFLAGS="-O2 -std=gnu++17" \
|
||||
../configure --prefix="$PACKAGE_DIR" --with-pic --disable-fft &&
|
||||
make -j${NPROC} &&
|
||||
make install
|
||||
|
||||
cd ..
|
||||
}
|
||||
|
||||
build_host_noasm()
|
||||
{
|
||||
PACKAGE_DIR="$GMP_DIR/package"
|
||||
BUILD_DIR=build
|
||||
|
||||
if [ -d "$PACKAGE_DIR" ]; then
|
||||
echo "Host package is built already. See $PACKAGE_DIR"
|
||||
return 1
|
||||
fi
|
||||
|
||||
rm -rf "$BUILD_DIR"
|
||||
mkdir "$BUILD_DIR"
|
||||
cd "$BUILD_DIR"
|
||||
|
||||
../configure --prefix="$PACKAGE_DIR" --with-pic --disable-fft --disable-assembly &&
|
||||
make -j${NPROC} &&
|
||||
make install
|
||||
|
||||
cd ..
|
||||
}
|
||||
|
||||
build_android()
|
||||
{
|
||||
PACKAGE_DIR="$GMP_DIR/package_android_arm64"
|
||||
BUILD_DIR=build_android_arm64
|
||||
|
||||
if [ -d "$PACKAGE_DIR" ]; then
|
||||
echo "Android package is built already. See $PACKAGE_DIR"
|
||||
return 1
|
||||
fi
|
||||
|
||||
if [ -z "$ANDROID_NDK" ]; then
|
||||
|
||||
echo "ERROR: ANDROID_NDK environment variable is not set."
|
||||
echo " It must be an absolute path to the root directory of Android NDK."
|
||||
echo " For instance /home/test/Android/Sdk/ndk/23.1.7779620"
|
||||
return 1
|
||||
fi
|
||||
|
||||
if [ "$(uname)" == "Darwin" ]; then
|
||||
export TOOLCHAIN=$ANDROID_NDK/toolchains/llvm/prebuilt/darwin-x86_64
|
||||
else
|
||||
export TOOLCHAIN=$ANDROID_NDK/toolchains/llvm/prebuilt/linux-x86_64
|
||||
fi
|
||||
|
||||
export TARGET=aarch64-linux-android
|
||||
export API=21
|
||||
|
||||
export AR=$TOOLCHAIN/bin/llvm-ar
|
||||
export CC=$TOOLCHAIN/bin/$TARGET$API-clang
|
||||
export AS=$CC
|
||||
export CXX=$TOOLCHAIN/bin/$TARGET$API-clang++
|
||||
export LD=$TOOLCHAIN/bin/ld
|
||||
export RANLIB=$TOOLCHAIN/bin/llvm-ranlib
|
||||
export STRIP=$TOOLCHAIN/bin/llvm-strip
|
||||
|
||||
echo "$TOOLCHAIN"
|
||||
echo "$TARGET"
|
||||
|
||||
rm -rf "$BUILD_DIR"
|
||||
mkdir "$BUILD_DIR"
|
||||
cd "$BUILD_DIR"
|
||||
|
||||
../configure --host $TARGET --prefix="$PACKAGE_DIR" --with-pic --disable-fft &&
|
||||
make -j${NPROC} &&
|
||||
make install
|
||||
|
||||
cd ..
|
||||
}
|
||||
|
||||
build_android_x86_64()
|
||||
{
|
||||
PACKAGE_DIR="$GMP_DIR/package_android_x86_64"
|
||||
BUILD_DIR=build_android_x86_64
|
||||
|
||||
if [ -d "$PACKAGE_DIR" ]; then
|
||||
echo "Android package is built already. See $PACKAGE_DIR"
|
||||
return 1
|
||||
fi
|
||||
|
||||
if [ -z "$ANDROID_NDK" ]; then
|
||||
|
||||
echo "ERROR: ANDROID_NDK environment variable is not set."
|
||||
echo " It must be an absolute path to the root directory of Android NDK."
|
||||
echo " For instance /home/test/Android/Sdk/ndk/23.1.7779620"
|
||||
return 1
|
||||
fi
|
||||
|
||||
if [ "$(uname)" == "Darwin" ]; then
|
||||
export TOOLCHAIN=$ANDROID_NDK/toolchains/llvm/prebuilt/darwin-x86_64
|
||||
else
|
||||
export TOOLCHAIN=$ANDROID_NDK/toolchains/llvm/prebuilt/linux-x86_64
|
||||
fi
|
||||
|
||||
export TARGET=x86_64-linux-android
|
||||
export API=21
|
||||
|
||||
export AR=$TOOLCHAIN/bin/llvm-ar
|
||||
export CC=$TOOLCHAIN/bin/$TARGET$API-clang
|
||||
export AS=$CC
|
||||
export CXX=$TOOLCHAIN/bin/$TARGET$API-clang++
|
||||
export LD=$TOOLCHAIN/bin/ld
|
||||
export RANLIB=$TOOLCHAIN/bin/llvm-ranlib
|
||||
export STRIP=$TOOLCHAIN/bin/llvm-strip
|
||||
|
||||
echo "$TOOLCHAIN"
|
||||
echo $TARGET
|
||||
|
||||
rm -rf "$BUILD_DIR"
|
||||
mkdir "$BUILD_DIR"
|
||||
cd "$BUILD_DIR"
|
||||
|
||||
../configure --host $TARGET --prefix="$PACKAGE_DIR" --with-pic --disable-fft &&
|
||||
make -j${NPROC} &&
|
||||
make install
|
||||
|
||||
cd ..
|
||||
}
|
||||
|
||||
build_ios()
|
||||
{
|
||||
PACKAGE_DIR="$GMP_DIR/package_ios_arm64"
|
||||
BUILD_DIR=build_ios_arm64
|
||||
|
||||
if [ -d "$PACKAGE_DIR" ]; then
|
||||
echo "iOS package is built already. See $PACKAGE_DIR"
|
||||
return 1
|
||||
fi
|
||||
|
||||
export SDK="iphoneos"
|
||||
export TARGET=arm64-apple-darwin
|
||||
export MIN_IOS_VERSION=8.0
|
||||
|
||||
export ARCH_FLAGS="-arch arm64 -arch arm64e"
|
||||
export OPT_FLAGS="-O3 -g3 -fembed-bitcode"
|
||||
HOST_FLAGS="${ARCH_FLAGS} -miphoneos-version-min=${MIN_IOS_VERSION} -isysroot $(xcrun --sdk ${SDK} --show-sdk-path)"
|
||||
|
||||
CC=$(xcrun --find --sdk "${SDK}" clang)
|
||||
export CC
|
||||
CXX=$(xcrun --find --sdk "${SDK}" clang++)
|
||||
export CXX
|
||||
CPP=$(xcrun --find --sdk "${SDK}" cpp)
|
||||
export CPP
|
||||
export CFLAGS="${HOST_FLAGS} ${OPT_FLAGS}"
|
||||
export CXXFLAGS="${HOST_FLAGS} ${OPT_FLAGS}"
|
||||
export LDFLAGS="${HOST_FLAGS}"
|
||||
|
||||
echo $TARGET
|
||||
|
||||
rm -rf "$BUILD_DIR"
|
||||
mkdir "$BUILD_DIR"
|
||||
cd "$BUILD_DIR"
|
||||
|
||||
../configure --host $TARGET --prefix="$PACKAGE_DIR" --with-pic --disable-fft --disable-assembly &&
|
||||
make -j${NPROC} &&
|
||||
make install
|
||||
|
||||
cd ..
|
||||
}
|
||||
|
||||
build_ios_simulator()
|
||||
{
|
||||
libs=()
|
||||
for ARCH in "arm64" "x86_64"; do
|
||||
case "$ARCH" in
|
||||
"arm64" )
|
||||
echo "Building for iPhone Simulator arm64"
|
||||
ARCH_FLAGS="-arch arm64 -arch arm64e"
|
||||
;;
|
||||
"x86_64" )
|
||||
echo "Building for iPhone Simulator x86_64"
|
||||
ARCH_FLAGS="-arch x86_64"
|
||||
;;
|
||||
* )
|
||||
echo "Incorrect iPhone Simulator arch"
|
||||
exit 1
|
||||
esac
|
||||
|
||||
BUILD_DIR="build_iphone_simulator_${ARCH}"
|
||||
PACKAGE_DIR="$GMP_DIR/package_iphone_simulator_${ARCH}"
|
||||
libs+=("${PACKAGE_DIR}/lib/libgmp.a")
|
||||
|
||||
if [ -d "$PACKAGE_DIR" ]; then
|
||||
echo "iPhone Simulator ${ARCH} package is built already. See $PACKAGE_DIR. Skip building this ARCH."
|
||||
continue
|
||||
fi
|
||||
|
||||
rm -rf "$BUILD_DIR"
|
||||
mkdir "$BUILD_DIR"
|
||||
cd "$BUILD_DIR"
|
||||
|
||||
../configure --prefix="${PACKAGE_DIR}" \
|
||||
CC="$(xcrun --sdk iphonesimulator --find clang)" \
|
||||
CFLAGS="-O3 -isysroot $(xcrun --sdk iphonesimulator --show-sdk-path) ${ARCH_FLAGS} -fvisibility=hidden -mios-simulator-version-min=8.0" \
|
||||
LDFLAGS="" \
|
||||
--host ${ARCH}-apple-darwin --disable-assembly --enable-static --disable-shared --with-pic &&
|
||||
make -j${NPROC} &&
|
||||
make install
|
||||
|
||||
cd ..
|
||||
done
|
||||
|
||||
mkdir -p "${GMP_DIR}/package_iphone_simulator/lib"
|
||||
lipo "${libs[@]}" -create -output "${GMP_DIR}/package_iphone_simulator/lib/libgmp.a"
|
||||
echo "Wrote universal fat library for iPhone Simulator arm64/x86_64 to ${GMP_DIR}/package_iphone_simulator/lib/libgmp.a"
|
||||
}
|
||||
|
||||
build_macos_arch()
|
||||
{
|
||||
ARCH="$1"
|
||||
case "$ARCH" in
|
||||
"arm64" )
|
||||
ARCH_FLAGS="-arch arm64 -arch arm64e"
|
||||
;;
|
||||
"x86_64" )
|
||||
ARCH_FLAGS="-arch x86_64"
|
||||
;;
|
||||
* )
|
||||
echo "Incorrect arch"
|
||||
exit 1
|
||||
esac
|
||||
|
||||
BUILD_DIR="build_macos_${ARCH}"
|
||||
PACKAGE_DIR="$GMP_DIR/package_macos_${ARCH}"
|
||||
if [ -d "$PACKAGE_DIR" ]; then
|
||||
echo "macOS ${ARCH} package is built already. See $PACKAGE_DIR. Skip building this ARCH."
|
||||
return
|
||||
fi
|
||||
rm -rf "$BUILD_DIR"
|
||||
mkdir "$BUILD_DIR"
|
||||
cd "$BUILD_DIR"
|
||||
../configure --prefix="${PACKAGE_DIR}" \
|
||||
CC="$(xcrun --sdk macosx --find clang)" \
|
||||
CFLAGS="-O3 -isysroot $(xcrun --sdk macosx --show-sdk-path) ${ARCH_FLAGS} -fvisibility=hidden -mmacos-version-min=14.0" \
|
||||
LDFLAGS="" \
|
||||
--host "${ARCH}-apple-darwin" --disable-assembly --enable-static --disable-shared --with-pic &&
|
||||
make -j${NPROC} &&
|
||||
make install
|
||||
cd ..
|
||||
}
|
||||
|
||||
build_macos_fat()
|
||||
{
|
||||
echo "Building for macOS arm64"
|
||||
build_macos_arch "arm64"
|
||||
echo "Building for macOS x86_64"
|
||||
build_macos_arch "x86_64"
|
||||
|
||||
gmp_lib_arm64="$GMP_DIR/package_macos_arm64/lib/libgmp.a"
|
||||
gmp_lib_x86_64="$GMP_DIR/package_macos_x86_64/lib/libgmp.a"
|
||||
gmp_lib_fat="$GMP_DIR/package_macos/lib/libgmp.a"
|
||||
|
||||
mkdir -p "${GMP_DIR}/package_macos/lib"
|
||||
lipo "${gmp_lib_arm64}" "${gmp_lib_x86_64}" -create -output "${gmp_lib_fat}"
|
||||
mkdir -p "${GMP_DIR}/package_macos/include"
|
||||
cp "${GMP_DIR}/package_macos_arm64/include/gmp.h" "${GMP_DIR}/package_macos/include/"
|
||||
echo "Wrote universal fat library for macOS arm64/x86_64 to ${GMP_DIR}/package_macos/lib/libgmp.a"
|
||||
}
|
||||
|
||||
if [ $# -ne 1 ]; then
|
||||
usage
|
||||
fi
|
||||
|
||||
TARGET_PLATFORM=$(echo "$1" | tr "[:upper:]" "[:lower:]")
|
||||
|
||||
cd depends
|
||||
|
||||
get_gmp
|
||||
|
||||
cd gmp
|
||||
|
||||
GMP_DIR=$PWD
|
||||
|
||||
case "$TARGET_PLATFORM" in
|
||||
|
||||
"ios" )
|
||||
echo "Building for ios"
|
||||
build_ios
|
||||
;;
|
||||
|
||||
"ios_simulator" )
|
||||
echo "Building for iPhone Simulator"
|
||||
build_ios_simulator
|
||||
;;
|
||||
|
||||
"macos" )
|
||||
echo "Building fat library for macOS"
|
||||
build_macos_fat
|
||||
;;
|
||||
|
||||
"macos_arm64" )
|
||||
echo "Building library for macOS arm64"
|
||||
build_macos_arch "arm64"
|
||||
;;
|
||||
|
||||
"macos_x86_64" )
|
||||
echo "Building library for macOS x86_64"
|
||||
build_macos_arch "x86_64"
|
||||
;;
|
||||
|
||||
"android" )
|
||||
echo "Building for android"
|
||||
build_android
|
||||
;;
|
||||
|
||||
"android_x86_64" )
|
||||
echo "Building for android x86_64"
|
||||
build_android_x86_64
|
||||
;;
|
||||
|
||||
"host" )
|
||||
echo "Building for this host"
|
||||
build_host
|
||||
;;
|
||||
|
||||
"host_noasm" )
|
||||
echo "Building for this host without asm optimizations (e.g. needed for macOS)"
|
||||
build_host_noasm
|
||||
;;
|
||||
|
||||
"aarch64" )
|
||||
echo "Building for linux aarch64"
|
||||
build_aarch64
|
||||
;;
|
||||
|
||||
* )
|
||||
usage
|
||||
|
||||
esac
|
||||
5
.github/resources/prover/windows.mman_patch.hpp
vendored
Normal file
5
.github/resources/prover/windows.mman_patch.hpp
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
#ifdef _WIN32
|
||||
#include <cstddef>
|
||||
inline int madvise(void*, size_t, int) { return 0; }
|
||||
#define MADV_SEQUENTIAL 0
|
||||
#endif
|
||||
170
.github/resources/prover/windows.src-CMakeLists.txt
vendored
Normal file
170
.github/resources/prover/windows.src-CMakeLists.txt
vendored
Normal file
@ -0,0 +1,170 @@
|
||||
link_directories(/lib)
|
||||
set(COMMON_LIBS /lib/libmman.a)
|
||||
|
||||
link_libraries(${GMP_LIB})
|
||||
|
||||
add_definitions(${GMP_DEFINIONS})
|
||||
|
||||
if(USE_ASM)
|
||||
if(ARCH MATCHES "arm64")
|
||||
add_definitions(-DUSE_ASM -DARCH_ARM64)
|
||||
elseif(ARCH MATCHES "x86_64")
|
||||
add_definitions(-DUSE_ASM -DARCH_X86_64)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(DEFINED BITS_PER_CHUNK)
|
||||
add_definitions(-DMSM_BITS_PER_CHUNK=${BITS_PER_CHUNK})
|
||||
endif()
|
||||
|
||||
if(USE_ASM AND ARCH MATCHES "x86_64")
|
||||
|
||||
if (CMAKE_HOST_SYSTEM_NAME MATCHES "Darwin" AND NOT TARGET_PLATFORM MATCHES "^android(_x86_64)?")
|
||||
set(NASM_FLAGS -fmacho64 --prefix _)
|
||||
else()
|
||||
set(NASM_FLAGS -felf64 -DPIC)
|
||||
endif()
|
||||
|
||||
add_custom_command(OUTPUT ${CMAKE_SOURCE_DIR}/build/fq_asm.o
|
||||
COMMAND nasm ${NASM_FLAGS} fq.asm -o fq_asm.o
|
||||
DEPENDS ${CMAKE_SOURCE_DIR}/build/fq.asm
|
||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/build)
|
||||
|
||||
add_custom_command(OUTPUT ${CMAKE_SOURCE_DIR}/build/fr_asm.o
|
||||
COMMAND nasm ${NASM_FLAGS} fr.asm -o fr_asm.o
|
||||
DEPENDS ${CMAKE_SOURCE_DIR}/build/fr.asm
|
||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/build)
|
||||
endif()
|
||||
|
||||
set(FR_SOURCES
|
||||
../build/fr.hpp
|
||||
../build/fr.cpp
|
||||
)
|
||||
|
||||
if(USE_ASM)
|
||||
if(ARCH MATCHES "arm64")
|
||||
set(FR_SOURCES ${FR_SOURCES} ../build/fr_raw_arm64.s ../build/fr_raw_generic.cpp ../build/fr_generic.cpp)
|
||||
elseif(ARCH MATCHES "x86_64")
|
||||
set(FR_SOURCES ${FR_SOURCES} ../build/fr_asm.o)
|
||||
endif()
|
||||
else()
|
||||
set(FR_SOURCES ${FR_SOURCES} ../build/fr_generic.cpp ../build/fr_raw_generic.cpp)
|
||||
endif()
|
||||
|
||||
add_library(fr STATIC ${FR_SOURCES})
|
||||
set_target_properties(fr PROPERTIES POSITION_INDEPENDENT_CODE ON)
|
||||
|
||||
link_libraries(fr)
|
||||
|
||||
set(FQ_SOURCES
|
||||
../build/fq.hpp
|
||||
../build/fq.cpp
|
||||
)
|
||||
|
||||
if(USE_ASM)
|
||||
if(ARCH MATCHES "arm64")
|
||||
set(FQ_SOURCES ${FQ_SOURCES} ../build/fq_raw_arm64.s ../build/fq_raw_generic.cpp ../build/fq_generic.cpp)
|
||||
elseif(ARCH MATCHES "x86_64")
|
||||
set(FQ_SOURCES ${FQ_SOURCES} ../build/fq_asm.o)
|
||||
endif()
|
||||
else()
|
||||
set(FQ_SOURCES ${FQ_SOURCES} ../build/fq_raw_generic.cpp ../build/fq_generic.cpp)
|
||||
endif()
|
||||
|
||||
add_library(fq STATIC ${FQ_SOURCES})
|
||||
set_target_properties(fq PROPERTIES POSITION_INDEPENDENT_CODE ON)
|
||||
|
||||
link_libraries(fq)
|
||||
|
||||
|
||||
if(OpenMP_CXX_FOUND)
|
||||
add_definitions(-DUSE_OPENMP)
|
||||
add_compile_options(${OpenMP_CXX_FLAGS})
|
||||
endif()
|
||||
|
||||
set(LIB_SOURCES
|
||||
binfile_utils.hpp
|
||||
binfile_utils.cpp
|
||||
zkey_utils.hpp
|
||||
zkey_utils.cpp
|
||||
wtns_utils.hpp
|
||||
wtns_utils.cpp
|
||||
logger.hpp
|
||||
logger.cpp
|
||||
fileloader.cpp
|
||||
fileloader.hpp
|
||||
prover.cpp
|
||||
prover.h
|
||||
verifier.cpp
|
||||
verifier.h
|
||||
../depends/ffiasm/c/misc.cpp
|
||||
../depends/ffiasm/c/naf.cpp
|
||||
../depends/ffiasm/c/splitparstr.cpp
|
||||
../depends/ffiasm/c/alt_bn128.cpp
|
||||
)
|
||||
|
||||
if(USE_LOGGER)
|
||||
set(LIB_SOURCES ${LIB_SOURCES} logger.cpp)
|
||||
add_definitions(-DUSE_LOGGER)
|
||||
endif()
|
||||
|
||||
include_directories(
|
||||
../src
|
||||
../build
|
||||
../depends/ffiasm/c
|
||||
../depends/json/single_include
|
||||
/include
|
||||
)
|
||||
|
||||
add_library(rapidsnarkStatic STATIC ${LIB_SOURCES})
|
||||
set_target_properties(rapidsnarkStatic PROPERTIES OUTPUT_NAME rapidsnark)
|
||||
|
||||
add_library(rapidsnarkStaticFrFq STATIC ${LIB_SOURCES} ${FQ_SOURCES} ${FR_SOURCES})
|
||||
set_target_properties(rapidsnarkStaticFrFq PROPERTIES POSITION_INDEPENDENT_CODE ON)
|
||||
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})
|
||||
|
||||
add_executable(verifier main_verifier.cpp)
|
||||
target_link_libraries(verifier rapidsnarkStatic fr fq ${COMMON_LIBS})
|
||||
|
||||
add_library(rapidsnark SHARED ${LIB_SOURCES})
|
||||
target_link_libraries(rapidsnark ${COMMON_LIBS})
|
||||
|
||||
if((USE_LOGGER OR NOT USE_OPENMP) AND NOT TARGET_PLATFORM MATCHES "android")
|
||||
target_link_libraries(prover pthread)
|
||||
target_link_libraries(verifier pthread)
|
||||
endif()
|
||||
|
||||
if(USE_SODIUM)
|
||||
target_link_libraries(prover sodium)
|
||||
endif()
|
||||
|
||||
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})
|
||||
add_test(NAME test_public_size COMMAND test_public_size circuit_final.zkey 86
|
||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/testdata)
|
||||
endif()
|
||||
|
||||
if(OpenMP_CXX_FOUND)
|
||||
|
||||
if(TARGET_PLATFORM MATCHES "android")
|
||||
target_link_libraries(prover -static-openmp -fopenmp)
|
||||
target_link_libraries(verifier -static-openmp -fopenmp)
|
||||
target_link_libraries(rapidsnark -static-openmp -fopenmp)
|
||||
|
||||
elseif(CMAKE_HOST_SYSTEM_NAME STREQUAL "Linux")
|
||||
target_link_libraries(prover OpenMP::OpenMP_CXX)
|
||||
target_link_libraries(verifier OpenMP::OpenMP_CXX)
|
||||
target_link_libraries(test_public_size OpenMP::OpenMP_CXX)
|
||||
endif()
|
||||
|
||||
endif()
|
||||
|
||||
|
||||
add_executable(test_prover test_prover.cpp)
|
||||
17
.github/resources/prover/windows.uio.h
vendored
Normal file
17
.github/resources/prover/windows.uio.h
vendored
Normal file
@ -0,0 +1,17 @@
|
||||
#ifndef SYS_UIO_H
|
||||
#define SYS_UIO_H
|
||||
|
||||
#include <inttypes.h>
|
||||
#include <unistd.h>
|
||||
|
||||
struct iovec
|
||||
{
|
||||
void *iov_base;
|
||||
size_t iov_len;
|
||||
};
|
||||
|
||||
ssize_t readv(int fildes, const struct iovec *iov, int iovcnt);
|
||||
ssize_t writev(int fildes, const struct iovec *iov, int iovcnt);
|
||||
|
||||
#endif
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
CC = g++
|
||||
CFLAGS = -std=c++11 -O3 -I. -I/opt/homebrew/include -include gmp_patch.macos.hpp
|
||||
CFLAGS = -std=c++11 -O3 -I. -I/opt/homebrew/include -include gmp_patch.hpp
|
||||
LDFLAGS = -L/opt/homebrew/lib -lgmp
|
||||
|
||||
DEPS_HPP = circom.hpp calcwit.hpp fr.hpp pol.cpp
|
||||
Loading…
x
Reference in New Issue
Block a user