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

fix: Build on stock apple clang. #592

Merged
merged 4 commits into from
Jul 11, 2023
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
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