From e9789c9dff4d06da5bd2a920a4f730238ca9e9b1 Mon Sep 17 00:00:00 2001 From: Charlie Lye Date: Tue, 11 Jul 2023 13:08:36 +0100 Subject: [PATCH] fix: Build on stock apple clang. (https://github.com/AztecProtocol/barretenberg/pull/592) --- circuits/cpp/barretenberg/bootstrap.sh | 5 +++++ circuits/cpp/barretenberg/cpp/bootstrap.sh | 14 +------------ .../barretenberg/polynomials/polynomial.hpp | 7 +++++++ .../polynomial_store.test.cpp | 21 ------------------- 4 files changed, 13 insertions(+), 34 deletions(-) create mode 100755 circuits/cpp/barretenberg/bootstrap.sh diff --git a/circuits/cpp/barretenberg/bootstrap.sh b/circuits/cpp/barretenberg/bootstrap.sh new file mode 100755 index 00000000000..1f43a5bfcd2 --- /dev/null +++ b/circuits/cpp/barretenberg/bootstrap.sh @@ -0,0 +1,5 @@ +#!/bin/bash +(cd cpp && ./bootstrap.sh) +cd ts +yarn build +npm link diff --git a/circuits/cpp/barretenberg/cpp/bootstrap.sh b/circuits/cpp/barretenberg/cpp/bootstrap.sh index 277744c161a..0b81033372d 100755 --- a/circuits/cpp/barretenberg/cpp/bootstrap.sh +++ b/circuits/cpp/barretenberg/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/circuits/cpp/barretenberg/cpp/src/barretenberg/polynomials/polynomial.hpp b/circuits/cpp/barretenberg/cpp/src/barretenberg/polynomials/polynomial.hpp index 14c9fbd1039..9196e5cd6eb 100644 --- a/circuits/cpp/barretenberg/cpp/src/barretenberg/polynomials/polynomial.hpp +++ b/circuits/cpp/barretenberg/cpp/src/barretenberg/polynomials/polynomial.hpp @@ -199,6 +199,13 @@ 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__ + // 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 + iterator begin() { return coefficients_.get(); } iterator end() { return coefficients_.get() + size_; } pointer data() { return coefficients_; } diff --git a/circuits/cpp/barretenberg/cpp/src/barretenberg/proof_system/polynomial_store/polynomial_store.test.cpp b/circuits/cpp/barretenberg/cpp/src/barretenberg/proof_system/polynomial_store/polynomial_store.test.cpp index e6f93b54d7f..8993c6393b3 100644 --- a/circuits/cpp/barretenberg/cpp/src/barretenberg/proof_system/polynomial_store/polynomial_store.test.cpp +++ b/circuits/cpp/barretenberg/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