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

Switch Win build to MPIR instead of GMP #15

Merged
merged 3 commits into from
Aug 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@
[submodule "libff"]
path = libff
url = https://github.com/torquem-ch/libff.git
branch = optional_openssl
branch = mpir
15 changes: 5 additions & 10 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -61,16 +61,11 @@ set(
"Default curve: one of ALT_BN128, BN128, EDWARDS, MNT4, MNT6"
FORCE
)
option(
WITH_PROCPS
"Use procps for memory profiling"
OFF
)
option(
IS_LIBFF_PARENT
"Install submodule dependencies if caller originates from here"
OFF
)
option(WITH_PROCPS "" OFF)
option(IS_LIBFF_PARENT "" OFF)
if(MSVC)
option(MPIR_INSTEAD_OF_GMP "" ON)
endif()
add_subdirectory(libff)

# Compiler options
Expand Down
11 changes: 7 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ as outlined in its [release commentary](https://ledgerwatch.github.io/turbo_geth

## Linux & macOS
Building silkworm requires:
* C++17 compiler (GCC or Clang)
* [CMake](http://cmake.org)
* [GMP](http://gmplib.org) (`sudo apt-get install libgmp3-dev` or `brew install gmp`)
* C++17 compiler (Clang or GCC)

Once the prerequisites are installed, bootstrap cmake build by running
```
Expand All @@ -40,10 +40,13 @@ or run tests
```
./tests
```
## Windows (Visual Studio Community Edition 2019)
* Download [GMP](https://github.com/ShiftMediaProject/gmp/releases) and add it to your `INCLUDE` and `PATH` environment variables.
* Install [Visual Studio](https://www.visualstudio.com/downloads/). Community edition is fine.
## Windows
* Install [Visual Studio](https://www.visualstudio.com/downloads) 2019. Community edition is fine.
* Make sure your setup includes CMake support and Windows 10 SDK.
* Install [vcpkg](https://github.com/microsoft/vcpkg#quick-start-windows).
* `.\vcpkg\vcpkg install mpir:x64-windows`
* Add <VCPKG_ROOT>\installed\x64-windows\include to your `INCLUDE` environment variable.
* Add <VCPKG_ROOT>\installed\x64-windows\bin to your `PATH` environment variable.
* Open Visual Studio and select File -> CMake...
* Browse the folder where you have cloned this repository and select the file CMakeLists.txt
* Let CMake cache generation complete (it may take several minutes)
Expand Down
11 changes: 7 additions & 4 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,19 @@
image: Visual Studio 2019
platform: x64

install:
- cd c:\Tools\vcpkg
- vcpkg install mpir:x64-windows

cache:
- C:\Tools\vcpkg\installed -> .appveyor.yml
- C:\.hunter

before_build:
- curl -o C:\gmp.zip -L https://github.com/ShiftMediaProject/gmp/releases/download/6.2.1/libgmp_6.2.1_msvc16.zip
- 7z x C:\gmp.zip -oC:\GMP
- cd "%APPVEYOR_BUILD_FOLDER%"
- git submodule update --init --recursive
- SET INCLUDE=C:\GMP\include;%INCLUDE%
- SET PATH=C:\GMP\lib\x64;%PATH%
- SET INCLUDE=C:\Tools\vcpkg\installed\x64-windows\include;%INCLUDE%
- SET PATH=C:\Tools\vcpkg\installed\x64-windows\bin;%PATH%
- cmake -H. -Bbuild

build:
Expand Down
2 changes: 1 addition & 1 deletion libff
Submodule libff updated from 1b49a6 to 96eb21
6 changes: 3 additions & 3 deletions silkworm/execution/precompiled.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -177,19 +177,19 @@ std::optional<Bytes> expmod_run(ByteView input) noexcept {

boost::multiprecision::cpp_int base{};
if (base_len) {
import_bits(base, &input[0], &input[base_len]);
import_bits(base, input.data(), input.data() + base_len);
input.remove_prefix(base_len);
}

boost::multiprecision::cpp_int exponent{};
if (exponent_len) {
import_bits(exponent, &input[0], &input[exponent_len]);
import_bits(exponent, input.data(), input.data() + exponent_len);
input.remove_prefix(exponent_len);
}

boost::multiprecision::cpp_int modulus{};
if (modulus_len) {
import_bits(modulus, &input[0], &input[modulus_len]);
import_bits(modulus, input.data(), input.data() + modulus_len);
}

if (modulus == 0) {
Expand Down