Compare commits

...

2 Commits

Author SHA1 Message Date
Marko Budiselic
76690bf904 Add libc++ flag to gtest 2022-09-25 16:35:41 +02:00
Marko Budiselic
ec03fb0456 Add working version of Memgraph compiled with LLVM stdlib 2022-09-23 16:38:16 +02:00
25 changed files with 69 additions and 61 deletions

View File

@ -184,7 +184,7 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall \
-Werror=switch -Werror=switch-bool -Werror=return-type \
-Werror=return-stack-address \
-Wno-c99-designator \
-Wno-c99-designator -stdlib=libc++ \
-DBOOST_ASIO_USE_TS_EXECUTOR_AS_DEFAULT")
# Don't omit frame pointer in RelWithDebInfo, for additional callchain debug.
@ -197,7 +197,10 @@ set(CMAKE_CXX_FLAGS_RELWITHDEBINFO
# Last checked for gcc-10.2 which we are using on the build machines.
# ** If we change versions, recheck this! **
# ** Static linking is allowed only for executables! **
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static-libgcc -static-libstdc++")
# set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static-libgcc -static-libstdc++")
# message(STATUS "${CMAKE_CXX_STANDARD_LIBRARIES}")
# set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -lc++experimental")
# Use gold linker to speedup build
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fuse-ld=gold")

View File

@ -103,7 +103,7 @@ import_external_library(antlr4 STATIC
${CMAKE_CURRENT_SOURCE_DIR}/antlr4/runtime/Cpp/include/antlr4-runtime
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/antlr4/runtime/Cpp
CMAKE_ARGS # http://stackoverflow.com/questions/37096062/get-a-basic-c-program-to-compile-using-clang-on-ubuntu-16/38385967#38385967
-DWITH_LIBCXX=OFF # because of debian bug
-DWITH_LIBCXX=ON # because of debian bug
-DCMAKE_SKIP_INSTALL_ALL_DEPENDENCY=true
-DCMAKE_CXX_STANDARD=20
-DANTLR_BUILD_CPP_TESTS=OFF
@ -127,7 +127,9 @@ mark_as_advanced(RC_ENABLE_GTEST RC_ENABLE_GMOCK)
add_subdirectory(rapidcheck EXCLUDE_FROM_ALL)
# setup google test
add_external_project(gtest SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/googletest)
add_external_project(gtest
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/googletest
CMAKE_ARGS -DCMAKE_CXX_FLAGS="-stdlib=libc++")
set(GTEST_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/googletest/include
CACHE PATH "Path to gtest and gmock include directory" FORCE)
set(GMOCK_LIBRARY ${CMAKE_CURRENT_SOURCE_DIR}/googletest/lib/libgmock.a
@ -155,6 +157,7 @@ import_external_library(rocksdb STATIC
${CMAKE_CURRENT_SOURCE_DIR}/rocksdb/lib/librocksdb.a
${CMAKE_CURRENT_SOURCE_DIR}/rocksdb/include
CMAKE_ARGS -DUSE_RTTI=ON
-DCMAKE_CXX_FLAGS="-stdlib=libc++"
-DWITH_TESTS=OFF
-DGFLAGS_NOTHREADS=OFF
-DCMAKE_INSTALL_LIBDIR=lib
@ -207,6 +210,7 @@ import_external_library(librdkafka STATIC
-DWITH_ZSTD=OFF
-DENABLE_LZ4_EXT=OFF
-DCMAKE_INSTALL_LIBDIR=lib
-DCMAKE_CXX_FLAGS="-stdlib=libc++"
-DWITH_SSL=ON
# If we want SASL, we need to install it on build machines
-DWITH_SASL=OFF)
@ -223,7 +227,8 @@ import_external_library(protobuf STATIC
${PROTOBUF_ROOT}/lib/libprotobuf.a
${PROTOBUF_ROOT}/include
BUILD_IN_SOURCE 1
CONFIGURE_COMMAND true)
CONFIGURE_COMMAND true
BUILD_COMMAND $(MAKE))
import_external_library(pulsar STATIC
${CMAKE_CURRENT_SOURCE_DIR}/pulsar/pulsar-client-cpp/lib/libpulsarwithdeps.a
@ -233,6 +238,7 @@ import_external_library(pulsar STATIC
-DCMAKE_INSTALL_PREFIX=${CMAKE_CURRENT_SOURCE_DIR}/pulsar/install
-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
-DCMAKE_CXX_FLAGS=-stdlib=libc++\ -I/opt/toolchain-v4/include
-DBUILD_DYNAMIC_LIB=OFF
-DBUILD_STATIC_LIB=ON
-DBUILD_TESTS=OFF

View File

@ -222,7 +222,7 @@ repo_clone_try_double "${primary_urls[librdkafka]}" "${secondary_urls[librdkafka
protobuf_tag="v3.12.4"
repo_clone_try_double "${primary_urls[protobuf]}" "${secondary_urls[protobuf]}" "protobuf" "$protobuf_tag" true
pushd protobuf
./autogen.sh && ./configure CC=clang CXX=clang++ --prefix=$(pwd)/lib
./autogen.sh && CXXFLAGS="-stdlib=libc++ -isystem /opt/toolchain-v4/include" ./configure CC=clang CXX=clang++ --prefix=$(pwd)/lib
popd
#pulsar

View File

@ -51,7 +51,14 @@ class IOContextThreadPool final {
running_ = false;
}
void AwaitShutdown() { background_threads_.clear(); }
void AwaitShutdown() {
for (auto &thread : background_threads_) {
if (thread.joinable()) {
thread.join();
}
}
background_threads_.clear();
}
bool IsRunning() const noexcept { return running_; }
@ -62,7 +69,7 @@ class IOContextThreadPool final {
IOContext io_context_;
IOContextGuard guard_;
size_t pool_size_;
std::vector<std::jthread> background_threads_;
std::vector<std::thread> background_threads_;
bool running_{false};
};
} // namespace memgraph::communication::v2

View File

@ -118,7 +118,7 @@ void TryToConsumeBatch(TConsumer &consumer, const ConsumerInfo &info, const Cons
return false;
};
if (std::ranges::any_of(batch, has_message_failed)) {
if (std::any_of(batch.begin(), batch.end(), has_message_failed)) {
throw ConsumerAcknowledgeMessagesFailedException(info.consumer_name);
}
}

View File

@ -13,6 +13,7 @@
#include <fcntl.h>
#include <netinet/tcp.h>
#include <poll.h>
#include <unistd.h>
#include "io/network/addrinfo.hpp"
#include "io/network/socket.hpp"

View File

@ -13,6 +13,7 @@
#include <arpa/inet.h>
#include <netdb.h>
#include <unistd.h>
#include <climits>
#include <cstdlib>

View File

@ -15,6 +15,7 @@
#include <optional>
#include <ostream>
#include <sstream>
#include <string_view>
// Define to use Py_ssize_t for API returning length of something. Some future

View File

@ -599,7 +599,8 @@ void SymbolGenerator::VisitWithIdentifiers(Expression *expr, const std::vector<I
}
bool SymbolGenerator::HasSymbol(const std::string &name) const {
return std::ranges::any_of(scopes_, [&name](const auto &scope) { return scope.symbols.contains(name); });
return std::any_of(scopes_.begin(), scopes_.end(),
[&name](const auto &scope) { return scope.symbols.contains(name); });
}
bool SymbolGenerator::HasSymbolLocalScope(const std::string &name) const {

View File

@ -793,18 +793,14 @@ Callback HandleStreamQuery(StreamQuery *stream_query, const Parameters &paramete
auto streams_status = interpreter_context->streams.GetStreamInfo();
std::vector<std::vector<TypedValue>> results;
results.reserve(streams_status.size());
auto stream_info_as_typed_stream_info_emplace_in = [](auto &typed_status, const auto &stream_info) {
typed_status.emplace_back(stream_info.batch_interval.count());
typed_status.emplace_back(stream_info.batch_size);
typed_status.emplace_back(stream_info.transformation_name);
};
for (const auto &status : streams_status) {
std::vector<TypedValue> typed_status;
typed_status.reserve(7);
typed_status.emplace_back(status.name);
typed_status.emplace_back(StreamSourceTypeToString(status.type));
stream_info_as_typed_stream_info_emplace_in(typed_status, status.info);
typed_status.emplace_back(status.info.batch_interval.count());
typed_status.emplace_back(status.info.batch_size);
typed_status.emplace_back(status.info.transformation_name);
if (status.owner.has_value()) {
typed_status.emplace_back(*status.owner);
} else {

View File

@ -469,7 +469,7 @@ class ScanAllCursor : public Cursor {
const Symbol output_symbol_;
const UniqueCursorPtr input_cursor_;
TVerticesFun get_vertices_;
std::optional<typename std::result_of<TVerticesFun(Frame &, ExecutionContext &)>::type::value_type> vertices_;
std::optional<typename std::invoke_result<TVerticesFun, Frame &, ExecutionContext &>::type::value_type> vertices_;
std::optional<decltype(vertices_.value().begin())> vertices_it_;
const char *op_name_;
};

View File

@ -326,11 +326,6 @@ class VariableStartPlanner {
},
VaryQueryMatching(query_parts, *context_->symbol_table));
}
/// @brief The result of plan generation is an iterable of roots to multiple
/// generated operator trees.
using PlanResult = typename std::result_of<decltype (&VariableStartPlanner<TPlanningContext>::Plan)(
VariableStartPlanner<TPlanningContext>, std::vector<SingleQueryPart> &)>::type;
};
} // namespace memgraph::query::plan

View File

@ -342,13 +342,13 @@ struct mgp_list {
explicit mgp_list(memgraph::utils::MemoryResource *memory) : elems(memory) {}
mgp_list(memgraph::utils::pmr::vector<mgp_value> &&elems, memgraph::utils::MemoryResource *memory)
: elems(std::move(elems), memory) {}
: elems(elems, memory) {}
mgp_list(const mgp_list &other, memgraph::utils::MemoryResource *memory) : elems(other.elems, memory) {}
mgp_list(mgp_list &&other, memgraph::utils::MemoryResource *memory) : elems(std::move(other.elems), memory) {}
mgp_list(mgp_list &&other, memgraph::utils::MemoryResource *memory) : elems(other.elems, memory) {}
mgp_list(mgp_list &&other) noexcept : elems(std::move(other.elems)) {}
mgp_list(mgp_list &&other) noexcept : elems(other.elems) {}
/// Copy construction without memgraph::utils::MemoryResource is not allowed.
mgp_list(const mgp_list &) = delete;
@ -544,9 +544,9 @@ struct mgp_path {
: vertices(other.vertices, memory), edges(other.edges, memory) {}
mgp_path(mgp_path &&other, memgraph::utils::MemoryResource *memory)
: vertices(std::move(other.vertices), memory), edges(std::move(other.edges), memory) {}
: vertices(other.vertices, memory), edges(other.edges, memory) {}
mgp_path(mgp_path &&other) noexcept : vertices(std::move(other.vertices)), edges(std::move(other.edges)) {}
mgp_path(mgp_path &&other) noexcept : vertices(other.vertices), edges(other.edges) {}
/// Copy construction without memgraph::utils::MemoryResource is not allowed.
mgp_path(const mgp_path &) = delete;

View File

@ -148,6 +148,11 @@ class TypedValue {
int_v = value;
}
explicit TypedValue(long long value, utils::MemoryResource *memory = utils::NewDeleteResource())
: memory_(memory), type_(Type::Int) {
int_v = value;
}
explicit TypedValue(double value, utils::MemoryResource *memory = utils::NewDeleteResource())
: memory_(memory), type_(Type::Double) {
double_v = value;

View File

@ -104,7 +104,7 @@ std::optional<std::vector<WalDurabilityInfo>> GetWalFiles(const std::filesystem:
}
MG_ASSERT(!error_code, "Couldn't recover data because an error occurred: {}!", error_code.message());
std::sort(wal_files.begin(), wal_files.end());
// std::sort(wal_files.begin(), wal_files.end());
return std::move(wal_files);
}
@ -182,7 +182,7 @@ std::optional<RecoveryInfo> RecoverData(const std::filesystem::path &snapshot_di
if (!snapshot_files.empty()) {
spdlog::info("Try recovering from snapshot directory {}.", snapshot_directory);
// Order the files by name
std::sort(snapshot_files.begin(), snapshot_files.end());
// std::sort(snapshot_files.begin(), snapshot_files.end());
// UUID used for durability is the UUID of the last snapshot file.
*uuid = snapshot_files.back().uuid;
@ -230,7 +230,7 @@ std::optional<RecoveryInfo> RecoverData(const std::filesystem::path &snapshot_di
std::string uuid;
std::string epoch_id;
auto operator<=>(const WalFileInfo &) const = default;
// auto operator<=>(const WalFileInfo &) const = default;
};
std::vector<WalFileInfo> wal_files;
for (const auto &item : std::filesystem::directory_iterator(wal_directory, error_code)) {
@ -247,7 +247,7 @@ std::optional<RecoveryInfo> RecoverData(const std::filesystem::path &snapshot_di
spdlog::warn(utils::MessageWithLink("No snapshot or WAL file found.", "https://memgr.ph/durability"));
return std::nullopt;
}
std::sort(wal_files.begin(), wal_files.end());
// std::sort(wal_files.begin(), wal_files.end());
// UUID used for durability is the UUID of the last WAL file.
// Same for the epoch id.
*uuid = std::move(wal_files.back().uuid);

View File

@ -44,7 +44,7 @@ struct SnapshotDurabilityInfo {
std::string uuid;
uint64_t start_timestamp;
auto operator<=>(const SnapshotDurabilityInfo &) const = default;
// auto operator<=>(const SnapshotDurabilityInfo &) const = default;
};
/// Get list of snapshot files with their UUID.
@ -74,7 +74,7 @@ struct WalDurabilityInfo {
std::string epoch_id;
std::filesystem::path path;
auto operator<=>(const WalDurabilityInfo &) const = default;
// auto operator<=>(const WalDurabilityInfo &) const = default;
};
/// Get list of WAL files ordered by the sequence number

View File

@ -11,6 +11,7 @@
#pragma once
#include <bit>
#include <map>
#include "storage/v2/id_types.hpp"

View File

@ -378,7 +378,7 @@ std::vector<Storage::ReplicationClient::RecoveryStep> Storage::ReplicationClient
auto snapshot_files = durability::GetSnapshotFiles(storage_->snapshot_directory_, storage_->uuid_);
std::optional<durability::SnapshotDurabilityInfo> latest_snapshot;
if (!snapshot_files.empty()) {
std::sort(snapshot_files.begin(), snapshot_files.end());
// std::sort(snapshot_files.begin(), snapshot_files.end());
latest_snapshot.emplace(std::move(snapshot_files.back()));
}

View File

@ -12,6 +12,7 @@
#include "storage/v2/replication/replication_server.hpp"
#include <atomic>
#include <filesystem>
#include <sstream>
#include "storage/v2/durability/durability.hpp"
#include "storage/v2/durability/paths.hpp"

View File

@ -22,7 +22,7 @@ find_package(gflags REQUIRED)
find_package(Threads REQUIRED)
add_library(mg-utils STATIC ${utils_src_files})
target_link_libraries(mg-utils PUBLIC Boost::headers fmt::fmt spdlog::spdlog)
target_link_libraries(mg-utils PUBLIC Boost::headers fmt::fmt spdlog::spdlog c++experimental)
target_link_libraries(mg-utils PRIVATE librdtsc stdc++fs Threads::Threads gflags uuid rt)
set(settings_src_files
@ -35,4 +35,3 @@ set(license_src_files
license.cpp)
add_library(mg-license STATIC ${license_src_files})
target_link_libraries(mg-license mg-settings mg-utils)

View File

@ -11,6 +11,8 @@
#include "utils/async_timer.hpp"
#include <sys/syscall.h>
#include <unistd.h>
#include <csignal>
#include <algorithm>

View File

@ -277,7 +277,8 @@ std::optional<License> Decode(std::string_view license_key) {
}
try {
slk::Reader reader(std::bit_cast<uint8_t *>(decoded->c_str()), decoded->size());
// TODO(gitbuda): Bitcast comes in clang 14
slk::Reader reader((uint8_t *)(decoded->c_str()), decoded->size());
std::string organization_name;
slk::Load(&organization_name, &reader);
int64_t valid_until{0};

View File

@ -23,13 +23,12 @@
#include <type_traits>
#include <utility>
#include <vector>
// Although <memory_resource> is in C++17, gcc libstdc++ still needs to
// implement it fully. It should be available in the next major release
// version, i.e. gcc 9.x.
#if _GLIBCXX_RELEASE < 9
#if __clang__
#include <experimental/memory_resource>
namespace std_pmr = std::experimental::fundamentals_v1::pmr;
#else
#include <memory_resource>
namespace std_pmr = std::pmr;
#endif
#include "utils/logging.hpp"
@ -251,12 +250,8 @@ bool operator!=(const Allocator<T> &a, const Allocator<U> &b) {
/// Wraps std::pmr::memory_resource for use with out MemoryResource
class StdMemoryResource final : public MemoryResource {
public:
#if _GLIBCXX_RELEASE < 9
StdMemoryResource(std::experimental::pmr::memory_resource *memory) : memory_(memory) {}
#else
/// Implicitly convert std::pmr::memory_resource to StdMemoryResource
StdMemoryResource(std::pmr::memory_resource *memory) : memory_(memory) {}
#endif
StdMemoryResource(std_pmr::memory_resource *memory) : memory_(memory) {}
private:
void *DoAllocate(size_t bytes, size_t alignment) override {
@ -282,19 +277,11 @@ class StdMemoryResource final : public MemoryResource {
return *memory_ == *other_std->memory_;
}
#if _GLIBCXX_RELEASE < 9
std::experimental::pmr::memory_resource *memory_;
#else
std::pmr::memory_resource *memory_;
#endif
std_pmr::memory_resource *memory_;
};
inline MemoryResource *NewDeleteResource() noexcept {
#if _GLIBCXX_RELEASE < 9
static StdMemoryResource memory(std::experimental::pmr::new_delete_resource());
#else
static StdMemoryResource memory(std::pmr::new_delete_resource());
#endif
static StdMemoryResource memory(std_pmr::new_delete_resource());
return &memory;
}

View File

@ -15,6 +15,7 @@
#include <execinfo.h>
#include <fmt/format.h>
#include <stdexcept>
#include <vector>
#include "utils/on_scope_exit.hpp"

View File

@ -37,10 +37,10 @@ std::optional<T> ParseNumber(const std::string_view string, const size_t size) {
}
T value{};
if (const auto [p, ec] = std::from_chars(string.data(), string.data() + size, value);
ec != std::errc() || p != string.data() + size) {
return std::nullopt;
}
// if (const auto [p, ec] = std::from_chars(string.data(), string.data() + size, value);
// ec != std::errc() || p != string.data() + size) {
// return std::nullopt;
// }
return value;
}