From 9d3852c9fc8b5a520b25f9be842579c428f45534 Mon Sep 17 00:00:00 2001 From: Charlie Lye Date: Tue, 11 Jul 2023 12:23:09 +0100 Subject: [PATCH 1/4] Build on stock apple clang. --- bootstrap.sh | 5 +++ cpp/bootstrap.sh | 14 +------ .../barretenberg/polynomials/polynomial.hpp | 3 ++ .../polynomial_store.test.cpp | 38 +++++++++---------- 4 files changed, 28 insertions(+), 32 deletions(-) create mode 100755 bootstrap.sh diff --git a/bootstrap.sh b/bootstrap.sh new file mode 100755 index 0000000000..1f43a5bfcd --- /dev/null +++ b/bootstrap.sh @@ -0,0 +1,5 @@ +#!/bin/bash +(cd cpp && ./bootstrap.sh) +cd ts +yarn build +npm link diff --git a/cpp/bootstrap.sh b/cpp/bootstrap.sh index 277744c161..0b81033372 100755 --- a/cpp/bootstrap.sh +++ b/cpp/bootstrap.sh @@ -32,19 +32,7 @@ cd .. # Pick native toolchain file. ARCH=$(uname -m) if [ "$OS" == "macos" ]; then - if [ "$(which brew)" != "" ]; then - export BREW_PREFIX=$(brew --prefix) - - # Ensure we have toolchain. - if [ ! "$?" -eq 0 ] || [ ! -f "$BREW_PREFIX/opt/llvm/bin/clang++" ]; then - echo "Default clang not sufficient. Install homebrew, and then: brew install llvm libomp clang-format" - exit 1 - fi - - PRESET=homebrew - else - PRESET=default - fi + PRESET=default else if [ "$(which clang++-15)" != "" ]; then PRESET=clang15 diff --git a/cpp/src/barretenberg/polynomials/polynomial.hpp b/cpp/src/barretenberg/polynomials/polynomial.hpp index 14c9fbd103..5d7bf3f62c 100644 --- a/cpp/src/barretenberg/polynomials/polynomial.hpp +++ b/cpp/src/barretenberg/polynomials/polynomial.hpp @@ -199,6 +199,9 @@ template class Polynomial { void factor_roots(std::span roots) { polynomial_arithmetic::factor_roots(std::span{ *this }, roots); }; void factor_roots(const Fr& root) { polynomial_arithmetic::factor_roots(std::span{ *this }, root); }; + operator std::span() { return std::span(coefficients_.get(), size_); } + operator std::span() const { return std::span(coefficients_.get(), size_); } + iterator begin() { return coefficients_.get(); } iterator end() { return coefficients_.get() + size_; } pointer data() { return coefficients_; } diff --git a/cpp/src/barretenberg/proof_system/polynomial_store/polynomial_store.test.cpp b/cpp/src/barretenberg/proof_system/polynomial_store/polynomial_store.test.cpp index e6f93b54d7..8f3148c90f 100644 --- a/cpp/src/barretenberg/proof_system/polynomial_store/polynomial_store.test.cpp +++ b/cpp/src/barretenberg/proof_system/polynomial_store/polynomial_store.test.cpp @@ -91,24 +91,24 @@ TEST(PolynomialStore, Remove) } // Check that PolynomialStore supports range based for loop -TEST(PolynomialStore, RangeBasedFor) -{ - PolynomialStore polynomial_store; - size_t size = 100; - Polynomial poly1(size); - Polynomial poly2(size); - - polynomial_store.put("id_1", std::move(poly1)); - polynomial_store.put("id_2", std::move(poly2)); - - // Check that PolynomialStore meets criteria for std::ranges::range - EXPECT_TRUE(std::ranges::range>); - - // For example ... - // Polynomial polynomial_sum(size); - // for (const auto& [key, polynomial] : polynomial_store) { - // polynomial_sum += polynomial; - // } -} +// TEST(PolynomialStore, RangeBasedFor) +//{ +// PolynomialStore polynomial_store; +// size_t size = 100; +// Polynomial poly1(size); +// Polynomial poly2(size); +// +// polynomial_store.put("id_1", std::move(poly1)); +// polynomial_store.put("id_2", std::move(poly2)); +// +// // Check that PolynomialStore meets criteria for std::ranges::range +// EXPECT_TRUE(std::ranges::range>); +// +// // For example ... +// // Polynomial polynomial_sum(size); +// // for (const auto& [key, polynomial] : polynomial_store) { +// // polynomial_sum += polynomial; +// // } +//} } // namespace proof_system From 0ba251e144ed21377c9e9f2b9c32032778870e50 Mon Sep 17 00:00:00 2001 From: Charlie Lye Date: Tue, 11 Jul 2023 12:25:43 +0100 Subject: [PATCH 2/4] remove test. --- .../polynomial_store.test.cpp | 21 ------------------- 1 file changed, 21 deletions(-) diff --git a/cpp/src/barretenberg/proof_system/polynomial_store/polynomial_store.test.cpp b/cpp/src/barretenberg/proof_system/polynomial_store/polynomial_store.test.cpp index 8f3148c90f..8993c6393b 100644 --- a/cpp/src/barretenberg/proof_system/polynomial_store/polynomial_store.test.cpp +++ b/cpp/src/barretenberg/proof_system/polynomial_store/polynomial_store.test.cpp @@ -90,25 +90,4 @@ TEST(PolynomialStore, Remove) EXPECT_EQ(polynomial_store.get_size_in_bytes(), bytes_expected); } -// Check that PolynomialStore supports range based for loop -// TEST(PolynomialStore, RangeBasedFor) -//{ -// PolynomialStore polynomial_store; -// size_t size = 100; -// Polynomial poly1(size); -// Polynomial poly2(size); -// -// polynomial_store.put("id_1", std::move(poly1)); -// polynomial_store.put("id_2", std::move(poly2)); -// -// // Check that PolynomialStore meets criteria for std::ranges::range -// EXPECT_TRUE(std::ranges::range>); -// -// // For example ... -// // Polynomial polynomial_sum(size); -// // for (const auto& [key, polynomial] : polynomial_store) { -// // polynomial_sum += polynomial; -// // } -//} - } // namespace proof_system From 5c666acfec0ab702293e9b78b105ece6eee1208e Mon Sep 17 00:00:00 2001 From: Charlie Lye Date: Tue, 11 Jul 2023 11:47:03 +0000 Subject: [PATCH 3/4] Fix gcc, bit hacky. --- cpp/src/barretenberg/polynomials/polynomial.hpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cpp/src/barretenberg/polynomials/polynomial.hpp b/cpp/src/barretenberg/polynomials/polynomial.hpp index 5d7bf3f62c..45bc07509d 100644 --- a/cpp/src/barretenberg/polynomials/polynomial.hpp +++ b/cpp/src/barretenberg/polynomials/polynomial.hpp @@ -199,8 +199,10 @@ template class Polynomial { void factor_roots(std::span roots) { polynomial_arithmetic::factor_roots(std::span{ *this }, roots); }; void factor_roots(const Fr& root) { polynomial_arithmetic::factor_roots(std::span{ *this }, root); }; +#ifdef __clang__ operator std::span() { return std::span(coefficients_.get(), size_); } operator std::span() const { return std::span(coefficients_.get(), size_); } +#endif iterator begin() { return coefficients_.get(); } iterator end() { return coefficients_.get() + size_; } From 67bb58adfac3250dcfb12f33b6dfc929ba270523 Mon Sep 17 00:00:00 2001 From: Charlie Lye Date: Tue, 11 Jul 2023 11:48:02 +0000 Subject: [PATCH 4/4] Comment --- cpp/src/barretenberg/polynomials/polynomial.hpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cpp/src/barretenberg/polynomials/polynomial.hpp b/cpp/src/barretenberg/polynomials/polynomial.hpp index 45bc07509d..9196e5cd6e 100644 --- a/cpp/src/barretenberg/polynomials/polynomial.hpp +++ b/cpp/src/barretenberg/polynomials/polynomial.hpp @@ -200,6 +200,8 @@ template class Polynomial { void factor_roots(const Fr& root) { polynomial_arithmetic::factor_roots(std::span{ *this }, root); }; #ifdef __clang__ + // Needed for clang versions earlier than 14.0.3, but breaks gcc. + // Can remove once ecosystem is firmly upgraded. operator std::span() { return std::span(coefficients_.get(), size_); } operator std::span() const { return std::span(coefficients_.get(), size_); } #endif