Skip to content

Commit

Permalink
Fix build issues (#161)
Browse files Browse the repository at this point in the history
* Fix macOS build

* cleanup

* fix

* fix

* Fix apsi arm build

* Update yacl
  • Loading branch information
anakinxc committed Jul 31, 2024
1 parent e6a0016 commit 0a668aa
Show file tree
Hide file tree
Showing 12 changed files with 55 additions and 29 deletions.
2 changes: 2 additions & 0 deletions bazel/flatbuffers.BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ psi_cmake_external(
name = "FlatBuffers",
cache_entries = {
"FLATBUFFERS_BUILD_TESTS": "OFF",
"CMAKE_EXE_LINKER_FLAGS": "-lm",
"CMAKE_INSTALL_LIBDIR": "lib",
},
lib_source = ":all_srcs",
out_binaries = ["flatc"],
Expand Down
1 change: 1 addition & 0 deletions bazel/jsoncpp.BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ psi_cmake_external(
"JSONCPP_WITH_POST_BUILD_UNITTEST": "OFF",
"BUILD_SHARED_LIBS": "OFF",
"BUILD_OBJECT_LIBS": "OFF",
"CMAKE_INSTALL_LIBDIR": "lib",
},
lib_source = "@com_github_open_source_parsers_jsoncpp//:all",
out_static_libs = ["libjsoncpp.a"],
Expand Down
1 change: 1 addition & 0 deletions bazel/libzmq.BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ psi_cmake_external(
name = "ZeroMQ",
cache_entries = {
"ZMQ_BUILD_TESTS": "OFF",
"CMAKE_INSTALL_LIBDIR": "lib",
},
lib_source = "@com_github_zeromq_libzmq//:all",
out_static_libs = ["libzmq.a"],
Expand Down
2 changes: 2 additions & 0 deletions bazel/log4cplus.BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,11 @@ psi_cmake_external(
name = "log4cplus",
cache_entries = {
"LOG4CPLUS_BUILD_TESTING": "OFF",
"LOG4CPLUS_BUILD_LOGGINGSERVER": "OFF",
"WITH_UNIT_TESTS": "OFF",
"BUILD_SHARED_LIBS": "False",
"LOG4CPLUS_ENABLE_DECORATED_LIBRARY_NAME": "OFF",
"CMAKE_INSTALL_LIBDIR": "lib",
},
lib_source = "@com_github_log4cplus_log4cplus//:all",
out_static_libs = ["liblog4cplus.a"],
Expand Down
13 changes: 13 additions & 0 deletions bazel/patches/apsi.patch
Original file line number Diff line number Diff line change
Expand Up @@ -398,3 +398,16 @@ index 4c4e116..8eb34fc 100644
}

union Request { ParmsRequest, OPRFRequest, QueryRequest }
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 78d54a6..46a452e 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -326,7 +326,7 @@ else()
endif()

# Use optimized assembly on UNIX
-if(APSI_USE_ASM AND UNIX AND NOT APPLE AND NOT CYGWIN AND NOT MINGW)
+if(APSI_USE_ASM AND UNIX AND APSI_FOURQ_AMD64 AND NOT APPLE AND NOT CYGWIN AND NOT MINGW)
check_language(ASM)
if(CMAKE_ASM_COMPILER)
enable_language(ASM)
12 changes: 8 additions & 4 deletions bazel/repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@ def _yacl():
http_archive,
name = "yacl",
urls = [
"https://github.com/secretflow/yacl/archive/refs/tags/0.4.5b3_nightly_20240722.tar.gz",
"https://github.com/secretflow/yacl/archive/refs/tags/0.4.5b4_nightly_20240731.tar.gz",
],
strip_prefix = "yacl-0.4.5b3_nightly_20240722",
sha256 = "ccca599e6ded6089c5afbb87c8f5e09383195af256caacd50089f0c7443e8604",
strip_prefix = "yacl-0.4.5b4_nightly_20240731",
sha256 = "e92484a9a60aaf86130157d9568b2bf7812bac4096cb108d565538268d74ea7e",
)

def _bazel_platform():
Expand Down Expand Up @@ -227,7 +227,11 @@ def _com_google_flatbuffers():
patches = [
"@psi//bazel:patches/flatbuffers.patch",
],
patch_args = ["-p1", "-l"],
patch_args = ["-p1"],
patch_cmds = [
# hack to make sure this file is removed
"rm grpc/BUILD.bazel",
],
build_file = "@psi//bazel:flatbuffers.BUILD",
)

Expand Down
2 changes: 1 addition & 1 deletion psi/apsi_wrapper/api/sender.cc
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ std::string Sender::RunQuery(const std::string &query_str) {
for (size_t bundle_idx = 0; bundle_idx < all_powers.size();
bundle_idx++) {
// Load input^power to all_powers[bundle_idx][exponent]
all_powers[bundle_idx][exponent] = move(q.second[bundle_idx]);
all_powers[bundle_idx][exponent] = std::move(q.second[bundle_idx]);
}
}

Expand Down
28 changes: 14 additions & 14 deletions psi/apsi_wrapper/receiver.cc
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ bool has_n_zeros(T *ptr, size_t count) {
}
} // namespace

Receiver::Receiver(::apsi::PSIParams params) : params_(move(params)) {
Receiver::Receiver(::apsi::PSIParams params) : params_(std::move(params)) {
initialize();
}

Expand All @@ -70,7 +70,7 @@ void Receiver::reset_keys() {
if (get_seal_context()->using_keyswitching()) {
::seal::Serializable<::seal::RelinKeys> relin_keys(
generator.create_relin_keys());
relin_keys_.set(move(relin_keys));
relin_keys_.set(std::move(relin_keys));
}
}

Expand Down Expand Up @@ -186,7 +186,7 @@ Receiver::ExtractHashes(const ::apsi::OPRFResponse &oprf_response,
APSI_LOG_INFO("Extracted OPRF hashes for " << oprf_response_item_count
<< " items");

return make_pair(move(items), move(label_keys));
return make_pair(std::move(items), std::move(label_keys));
}

unique_ptr<::apsi::network::SenderOperation> Receiver::CreateOPRFRequest(
Expand Down Expand Up @@ -327,7 +327,7 @@ Receiver::create_query(const vector<::apsi::HashedItem> &items,
// Now that we have the algebraized items for this bundle index, we create
// a PlaintextPowers object that computes all necessary powers of the
// algebraized items.
plain_powers.emplace_back(move(alg_items), params_, pd_);
plain_powers.emplace_back(std::move(alg_items), params_, pd_);
}
}

Expand All @@ -350,7 +350,7 @@ Receiver::create_query(const vector<::apsi::HashedItem> &items,

// Move the encrypted data to encrypted_powers
for (auto &e : encrypted_power) {
encrypted_powers[e.first].emplace_back(move(e.second));
encrypted_powers[e.first].emplace_back(std::move(e.second));
}
}
}
Expand All @@ -359,13 +359,13 @@ Receiver::create_query(const vector<::apsi::HashedItem> &items,
auto sop_query = make_unique<::apsi::network::SenderOperationQuery>();
sop_query->compr_mode = ::seal::Serialization::compr_mode_default;
sop_query->relin_keys = relin_keys_;
sop_query->data = move(encrypted_powers);
sop_query->data = std::move(encrypted_powers);
sop_query->bucket_idx = bucket_idx;
auto sop = ::apsi::to_request(move(sop_query));
auto sop = ::apsi::to_request(std::move(sop_query));

APSI_LOG_INFO("Finished creating encrypted query");

return {move(sop), itt};
return {std::move(sop), itt};
}

vector<::apsi::receiver::MatchRecord> Receiver::request_query(
Expand All @@ -377,8 +377,8 @@ vector<::apsi::receiver::MatchRecord> Receiver::request_query(

// Create query and send to Sender
auto query = create_query(items, bucket_idx);
chl.send(move(query.first));
auto itt = move(query.second);
chl.send(std::move(query.first));
auto itt = std::move(query.second);

// Wait for query response
::apsi::QueryResponse response;
Expand Down Expand Up @@ -608,11 +608,11 @@ vector<::apsi::receiver::MatchRecord> Receiver::process_result_part(
encrypted_label, label_keys[item_idx], nonce_byte_count);

// Set the label
mr.label.set(move(label));
mr.label.set(std::move(label));
}

// We are done with the MatchRecord, so add it to the mrs vector
mrs[item_idx] = move(mr);
mrs[item_idx] = std::move(mr);
});

return mrs;
Expand All @@ -639,7 +639,7 @@ vector<::apsi::receiver::MatchRecord> Receiver::process_result(
::seal::util::iter(mrs, this_mrs, size_t(0)), mrs.size(), [](auto &&I) {
if (get<1>(I) && !get<0>(I)) {
// This match needs to be merged into mrs
get<0>(I) = move(get<1>(I));
get<0>(I) = std::move(get<1>(I));
} else if (get<1>(I) && get<0>(I)) {
// If a positive MatchRecord is already present, then something is
// seriously wrong
Expand Down Expand Up @@ -705,7 +705,7 @@ void Receiver::process_result_worker(
::seal::util::iter(mrs, this_mrs, size_t(0)), mrs.size(), [](auto &&I) {
if (get<1>(I) && !get<0>(I)) {
// This match needs to be merged into mrs
get<0>(I) = move(get<1>(I));
get<0>(I) = std::move(get<1>(I));
} else if (get<1>(I) && get<0>(I)) {
// If a positive MatchRecord is already present, then something is
// seriously wrong
Expand Down
6 changes: 3 additions & 3 deletions psi/apsi_wrapper/sender.cc
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ void Sender::RunParams(
make_unique<::apsi::PSIParams>(sender_db->get_params());

try {
send_fun(chl, move(response_params));
send_fun(chl, std::move(response_params));
} catch (const exception &ex) {
APSI_LOG_ERROR(
"Failed to send response to parameter request; function threw an "
Expand Down Expand Up @@ -223,7 +223,7 @@ void Sender::RunQuery(
// Load input^power to all_powers[bundle_idx][exponent]
APSI_LOG_DEBUG("Extracting query ciphertext power "
<< exponent << " for bundle index " << bundle_idx);
all_powers[bundle_idx][exponent] = move(q.second[bundle_idx]);
all_powers[bundle_idx][exponent] = std::move(q.second[bundle_idx]);
}
}

Expand Down Expand Up @@ -319,7 +319,7 @@ void Sender::ComputePowers(
if (relinearize) {
evaluator->relinearize_inplace(prod, *relin_keys, pool);
}
powers_at_this_bundle_idx[node.power] = move(prod);
powers_at_this_bundle_idx[node.power] = std::move(prod);
}
});

Expand Down
1 change: 1 addition & 0 deletions psi/apsi_wrapper/utils/bucket.cc
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ BucketSenderDbSwitcher::BucketSenderDbSwitcher(const std::string& parent_folder,
size_t init_idx)
: parent_folder_(parent_folder), bucket_cnt_(bucket_cnt) {
SetBucketIdx(init_idx, true);
(void)bucket_cnt_;
}

void BucketSenderDbSwitcher::SetBucketIdx(size_t idx, bool forced_to_reload) {
Expand Down
4 changes: 3 additions & 1 deletion psi/apsi_wrapper/utils/csv_reader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ auto CSVReader::read() -> pair<DBData, vector<string>> {
return {UnlabeledData{}, {}};
} else {
SPDLOG_INFO("Read csv file {}, row cnt is {}", file_name_, row_cnt);
return {move(result), move(orig_items)};
return {std::move(result), std::move(orig_items)};
}
}

Expand Down Expand Up @@ -211,6 +211,8 @@ void CSVReader::bucketize(size_t bucket_cnt, const std::string& bucket_folder) {
}
}

(void)row_cnt;

for (const auto& out : bucket_os_vec) {
out->Flush();
}
Expand Down
12 changes: 6 additions & 6 deletions psi/apsi_wrapper/utils/sender_db.cc
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ shared_ptr<::apsi::sender::SenderDB> try_load_sender_db(
"PSI parameters were loaded with the SenderDB; "
"ignoring given PSI parameters");
}
result = make_shared<::apsi::sender::SenderDB>(move(data));
result = make_shared<::apsi::sender::SenderDB>(std::move(data));

// Load also the OPRF key
oprf_key.load(fs);
Expand Down Expand Up @@ -86,8 +86,8 @@ shared_ptr<::apsi::sender::SenderDB> try_load_csv_db(
return nullptr;
}

return create_sender_db(*db_data, move(params), oprf_key, nonce_byte_count,
compress);
return create_sender_db(*db_data, std::move(params), oprf_key,
nonce_byte_count, compress);
}

bool try_save_sender_db(const std::string &sdb_out_file,
Expand Down Expand Up @@ -131,7 +131,7 @@ unique_ptr<psi::apsi_wrapper::DBData> load_db(
return nullptr;
}

return make_unique<psi::apsi_wrapper::DBData>(move(db_data));
return make_unique<psi::apsi_wrapper::DBData>(std::move(db_data));
}

pair<unique_ptr<psi::apsi_wrapper::DBData>, vector<std::string>>
Expand All @@ -147,8 +147,8 @@ load_db_with_orig_items(const std::string &db_file) {
return {nullptr, orig_items};
}

return {make_unique<psi::apsi_wrapper::DBData>(move(db_data)),
move(orig_items)};
return {make_unique<psi::apsi_wrapper::DBData>(std::move(db_data)),
std::move(orig_items)};
}

shared_ptr<::apsi::sender::SenderDB> create_sender_db(
Expand Down

0 comments on commit 0a668aa

Please sign in to comment.