Skip to content

Commit 7af80ff

Browse files
authored
chore(bb): make compile on stock mac clang (#8278)
xcode clang does not support all of c++20 it seems e.g. can't do Constructor(A,B,C) where A B and C are the members of a struct with only default constructors. Some common issues that come up like the uint64_t/size_t split
1 parent 6194b94 commit 7af80ff

File tree

10 files changed

+29
-32
lines changed

10 files changed

+29
-32
lines changed

barretenberg/cpp/src/barretenberg/aztec_ivc/aztec_ivc.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ void AztecIVC::complete_kernel_circuit_logic(ClientCircuit& circuit)
1414
{
1515
circuit.databus_propagation_data.is_kernel = true;
1616

17-
// Peform recursive verification and databus consistency checks for each entry in the verification queue
17+
// Perform recursive verification and databus consistency checks for each entry in the verification queue
1818
for (auto& [proof, vkey, type] : verification_queue) {
1919
// Construct stdlib verification key and proof
2020
auto stdlib_proof = bb::convert_proof_to_witness(&circuit, proof);

barretenberg/cpp/src/barretenberg/commitment_schemes/ipa/ipa.test.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -300,9 +300,9 @@ TEST_F(IPATest, GeminiShplonkIPAWithShift)
300300
std::string label = "Gemini:a_" + std::to_string(l);
301301
const auto& evaluation = gemini_opening_pairs[l + 1].evaluation;
302302
prover_transcript->send_to_verifier(label, evaluation);
303-
opening_claims.emplace_back(gemini_witnesses[l], gemini_opening_pairs[l]);
303+
opening_claims.push_back({ gemini_witnesses[l], gemini_opening_pairs[l] });
304304
}
305-
opening_claims.emplace_back(gemini_witnesses[log_n], gemini_opening_pairs[log_n]);
305+
opening_claims.push_back({ gemini_witnesses[log_n], gemini_opening_pairs[log_n] });
306306

307307
const auto opening_claim = ShplonkProver::prove(this->ck(), opening_claims, prover_transcript);
308308
IPA::compute_opening_proof(this->ck(), opening_claim, prover_transcript);

barretenberg/cpp/src/barretenberg/commitment_schemes/kzg/kzg.test.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -134,9 +134,9 @@ TYPED_TEST(KZGTest, GeminiShplonkKzgWithShift)
134134
std::string label = "Gemini:a_" + std::to_string(l);
135135
const auto& evaluation = gemini_opening_pairs[l + 1].evaluation;
136136
prover_transcript->send_to_verifier(label, evaluation);
137-
opening_claims.emplace_back(gemini_witnesses[l], gemini_opening_pairs[l]);
137+
opening_claims.push_back({ gemini_witnesses[l], gemini_opening_pairs[l] });
138138
}
139-
opening_claims.emplace_back(gemini_witnesses[log_n], gemini_opening_pairs[log_n]);
139+
opening_claims.push_back({ gemini_witnesses[log_n], gemini_opening_pairs[log_n] });
140140

141141
// Shplonk prover output:
142142
// - opening pair: (z_challenge, 0)

barretenberg/cpp/src/barretenberg/crypto/merkle_tree/indexed_tree/indexed_tree.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,7 @@ void IndexedTree<Store, HashingPolicy>::perform_insertions(size_t total_leaves,
446446

447447
// We now kick off multiple workers to perform the low leaf updates
448448
// We create set of signals to coordinate the workers as the move up the tree
449-
std::shared_ptr<std::vector<Signal>> signals = std::make_shared<std::vector<Signal>>();
449+
auto signals = std::make_shared<std::vector<Signal>>();
450450
std::shared_ptr<Status> status = std::make_shared<Status>();
451451
// The first signal is set to 0. This ensures the first worker up the tree is not impeded
452452
signals->emplace_back(0);

barretenberg/cpp/src/barretenberg/crypto/merkle_tree/lmdb_store/lmdb_store.test.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include <cstdlib>
66
#include <filesystem>
77
#include <stdexcept>
8+
#include <thread>
89
#include <vector>
910

1011
#include "barretenberg/common/serialize.hpp"

barretenberg/cpp/src/barretenberg/crypto/merkle_tree/signal.hpp

+16-15
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,27 @@
44

55
namespace bb::crypto::merkle_tree {
66
/**
7-
* @brief Used in parallel insertions in the the IndexedTree. Workers signal to other following workes as they move up
7+
* @brief Used in parallel insertions in the IndexedTree. Workers signal to other following workes as they move up
88
* the level of the tree.
99
*
1010
*/
1111
class Signal {
1212
public:
13-
Signal(uint32_t initial_level = 1)
14-
: signal_(initial_level){};
13+
explicit Signal(uint32_t initial_level = 1)
14+
: signal_(std::make_unique<std::atomic<uint32_t>>(initial_level)){};
1515
~Signal() = default;
1616
Signal(const Signal& other)
17-
: signal_(other.signal_.load())
17+
: signal_(std::make_unique<std::atomic<uint32_t>>(other.signal_->load()))
1818
{}
19-
Signal(const Signal&& other) = delete;
19+
Signal(Signal&& other) = default;
2020
Signal& operator=(const Signal& other)
2121
{
2222
if (this != &other) {
23-
signal_.store(other.signal_.load());
23+
signal_->store(other.signal_->load());
2424
}
2525
return *this;
2626
}
27-
Signal& operator=(const Signal&& other) = delete;
27+
Signal& operator=(Signal&& other) = default;
2828

2929
/**
3030
* @brief Causes the thread to wait until the required level has been signalled
@@ -33,10 +33,10 @@ class Signal {
3333
*/
3434
void wait_for_level(uint32_t level = 0)
3535
{
36-
uint32_t current_level = signal_.load();
36+
uint32_t current_level = signal_->load();
3737
while (current_level > level) {
38-
signal_.wait(current_level);
39-
current_level = signal_.load();
38+
signal_->wait(current_level);
39+
current_level = signal_->load();
4040
}
4141
}
4242

@@ -47,17 +47,18 @@ class Signal {
4747
*/
4848
void signal_level(uint32_t level = 0)
4949
{
50-
signal_.store(level);
51-
signal_.notify_all();
50+
signal_->store(level);
51+
signal_->notify_all();
5252
}
5353

5454
void signal_decrement(uint32_t delta = 1)
5555
{
56-
signal_.fetch_sub(delta);
57-
signal_.notify_all();
56+
signal_->fetch_sub(delta);
57+
signal_->notify_all();
5858
}
5959

6060
private:
61-
std::atomic<uint32_t> signal_;
61+
// apple clang has issues if this cannot be move-constructed, so we wrap in unique_ptr
62+
std::unique_ptr<std::atomic<uint32_t>> signal_;
6263
};
6364
} // namespace bb::crypto::merkle_tree
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#pragma once
22

3-
#include <cstdint>
3+
#include <cstddef>
44
namespace bb::crypto::merkle_tree {
5-
using index_t = uint64_t;
5+
using index_t = size_t;
66
} // namespace bb::crypto::merkle_tree

barretenberg/cpp/src/barretenberg/sumcheck/sumcheck.hpp

+3-7
Original file line numberDiff line numberDiff line change
@@ -431,13 +431,9 @@ polynomials that are sent in clear.
431431

432432
std::vector<FF> libra_evaluations;
433433
libra_evaluations.reserve(multivariate_d);
434-
zk_sumcheck_data = ZKSumcheckData<Flavor>(eval_masking_scalars,
435-
masking_terms_evaluations,
436-
libra_univariates,
437-
libra_scaling_factor,
438-
libra_challenge,
439-
libra_running_sum,
440-
libra_evaluations);
434+
zk_sumcheck_data = ZKSumcheckData<Flavor>{ eval_masking_scalars, masking_terms_evaluations, libra_univariates,
435+
libra_scaling_factor, libra_challenge, libra_running_sum,
436+
libra_evaluations };
441437
};
442438

443439
/**

barretenberg/cpp/src/barretenberg/vm/avm/tests/helpers.test.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
#include "barretenberg/vm/avm/trace/helper.hpp"
44
#include "barretenberg/vm/constants.hpp"
55
#include "common.test.hpp"
6-
#include <bits/utility.h>
76

87
namespace tests_avm {
98

barretenberg/cpp/src/barretenberg/vm/avm/tests/slice.test.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ class AvmSliceTests : public ::testing::Test {
100100
}
101101

102102
// Check that the extra final row is well-formed.
103-
EXPECT_THAT(trace.at(static_cast<size_t>(last_row_idx + 1)),
103+
EXPECT_THAT(trace.at(static_cast<uint64_t>(last_row_idx + 1)),
104104
AllOf(SLICE_ROW_FIELD_EQ(addr, FF(dst_offset) + FF(copy_size)),
105105
SLICE_ROW_FIELD_EQ(col_offset, col_offset + copy_size),
106106
SLICE_ROW_FIELD_EQ(cnt, 0),

0 commit comments

Comments
 (0)