Skip to content

Commit

Permalink
fix: Build on stock apple clang. (#592)
Browse files Browse the repository at this point in the history
  • Loading branch information
charlielye authored Jul 11, 2023
1 parent 26a3674 commit 0ac4bc3
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 34 deletions.
5 changes: 5 additions & 0 deletions bootstrap.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash
(cd cpp && ./bootstrap.sh)
cd ts
yarn build
npm link
14 changes: 1 addition & 13 deletions cpp/bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions cpp/src/barretenberg/polynomials/polynomial.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,13 @@ template <typename Fr> class Polynomial {
void factor_roots(std::span<const Fr> 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<Fr>() { return std::span<Fr>(coefficients_.get(), size_); }
operator std::span<const Fr>() const { return std::span<const Fr>(coefficients_.get(), size_); }
#endif

iterator begin() { return coefficients_.get(); }
iterator end() { return coefficients_.get() + size_; }
pointer data() { return coefficients_; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<Fr> 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<PolynomialStore<Fr>>);

// For example ...
// Polynomial polynomial_sum(size);
// for (const auto& [key, polynomial] : polynomial_store) {
// polynomial_sum += polynomial;
// }
}

} // namespace proof_system

0 comments on commit 0ac4bc3

Please sign in to comment.