Skip to content

Commit

Permalink
Increase minimum clang version to 15, implement more of StaticVector …
Browse files Browse the repository at this point in the history
…and use std::span in LifecycleManagers
  • Loading branch information
Oipo committed Feb 21, 2024
1 parent c20924b commit 59d95e2
Show file tree
Hide file tree
Showing 13 changed files with 272 additions and 99 deletions.
10 changes: 2 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ endif()
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS_EQUAL "11.2")
message(FATAL_ERROR "Gcc 11.2 and below not supported. See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95137")
endif()
if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS "14")
message(FATAL_ERROR "Clang below version 14 does not implement enough of C++20 to use Ichor.")
if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS "15")
message(FATAL_ERROR "Clang below version 15 does not implement enough of C++20 to use Ichor.")
endif()

set(ICHOR_TOP_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
Expand Down Expand Up @@ -268,12 +268,6 @@ if(ICHOR_USE_SANITIZERS)
else()
set(ICHOR_SANITIZE_OPTIONS -fsanitize=address,undefined)

if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND CMAKE_CXX_COMPILER_VERSION VERSION_EQUAL "14")
message(WARNING "Clang version 14 has a bug that prevents coroutines and UBSan to be used together. See https://github.com/llvm/llvm-project/issues/49689")
message(WARNING "DISABLED UBSAN, THIS MAY NOT BE WHAT YOU EXPECT!")
set(ICHOR_SANITIZE_OPTIONS -fsanitize=address)
endif()

target_compile_options(ichor PUBLIC ${ICHOR_SANITIZE_OPTIONS} -fno-omit-frame-pointer)
target_link_options(ichor PUBLIC ${ICHOR_SANITIZE_OPTIONS})
target_compile_definitions(ichor PUBLIC __SANITIZE_ADDRESS__ _GLIBCXX_SANITIZE_VECTOR)
Expand Down
4 changes: 2 additions & 2 deletions docs/01-GettingStarted.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## Compiling Ichor

Compiling is done through the help of CMake. Ichor requires at least gcc 11.3 (due to [this gcc bug](https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95137)), clang 14 or MSVC 2022, and is tested with gcc 11.3, 12.1, clang 14, clang 15 and clang 16 and MSVC 2022.
Compiling is done through the help of CMake. Ichor requires at least gcc 11.3 (due to [this gcc bug](https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95137)), clang 15 or MSVC 2022, and is tested with gcc 11.3, 12.1, clang 15, clang 18 and MSVC 2022.

The easiest is to build it with the provided Dockerfile:

Expand Down Expand Up @@ -568,7 +568,7 @@ The default priority for events is 1000. For dependency related things (like sta
### Memory allocation
Ichor used to provide `std::pmr::memory_resource` based allocation, however that had a big impact on the ergonomy of the code. Moreover, clang 14 does not support `<memory_resource>` at all. Instead, Ichor recommends using mimalloc to reduce the resource contention when using multiple threads.
Ichor used to provide `std::pmr::memory_resource` based allocation, however that had a big impact on the ergonomy of the code. Moreover, clang 15 does not support `<memory_resource>` at all. Instead, Ichor recommends using mimalloc to reduce the resource contention when using multiple threads.
### Multiple Threads
Expand Down
4 changes: 2 additions & 2 deletions include/ichor/DependencyManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include <chrono>
#include <atomic>
#include <mutex>
#include <span>
#include <ichor/interfaces/IFrameworkLogger.h>
#include <ichor/dependency_management/AdvancedService.h>
#include <ichor/events/InternalEvents.h>
Expand Down Expand Up @@ -474,7 +475,7 @@ namespace Ichor {

[[nodiscard]] std::vector<Dependency> getDependencyRequestsForService(ServiceIdType svcId) const noexcept;
[[nodiscard]] std::vector<NeverNull<IService const *>> getDependentsForService(ServiceIdType svcId) const noexcept;
[[nodiscard]] IStaticVector<Dependency> const & getProvidedInterfacesForService(ServiceIdType svcId) const noexcept;
[[nodiscard]] std::span<Dependency const> getProvidedInterfacesForService(ServiceIdType svcId) const noexcept;
[[nodiscard]] std::vector<DependencyTrackerKey> getTrackersForService(ServiceIdType svcId) const noexcept;

/// Returns a list of currently known services and their status.
Expand Down Expand Up @@ -698,7 +699,6 @@ namespace Ichor {
unordered_map<uint64_t, std::unique_ptr<Event>> _scopedEvents{}; // key = promise id
unordered_map<uint64_t, EventWaiter> _eventWaiters{}; // key = event id
unordered_map<uint64_t, EventWaiter> _dependencyWaiters{}; // key = event id
StaticVector<Ichor::Dependency, 0> _emptyInterfaces{};
IEventQueue *_eventQueue;
IFrameworkLogger *_logger{};
std::atomic<bool> _started{false};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -335,8 +335,8 @@ namespace Ichor::Detail {
return static_cast<IService const *>(&_service);
}

[[nodiscard]] const IStaticVector<Dependency>& getInterfaces() const noexcept final {
return _interfaces;
[[nodiscard]] std::span<Dependency const> getInterfaces() const noexcept final {
return std::span<Dependency const>{_interfaces.begin(), _interfaces.size()};
}

[[nodiscard]] Properties const & getProperties() const noexcept final {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ namespace Ichor::Detail {
return &_service;
}

[[nodiscard]] const IStaticVector<Dependency>& getInterfaces() const noexcept final {
return _interfaces;
[[nodiscard]] std::span<Dependency const> getInterfaces() const noexcept final {
return std::span<Dependency const>{_interfaces.begin(), _interfaces.size()};
}

[[nodiscard]] Properties const & getProperties() const noexcept final {
Expand Down
3 changes: 2 additions & 1 deletion include/ichor/dependency_management/ILifecycleManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#include <string_view>
#include <memory>
#include <span>
#include "AdvancedService.h"
#include <ichor/Common.h>
#include <ichor/stl/StaticVector.h>
Expand Down Expand Up @@ -31,7 +32,7 @@ namespace Ichor {
[[nodiscard]] virtual ServiceState getServiceState() const noexcept = 0;
[[nodiscard]] virtual NeverNull<IService*> getIService() noexcept = 0;
[[nodiscard]] virtual NeverNull<IService const*> getIService() const noexcept = 0;
[[nodiscard]] virtual const IStaticVector<Dependency>& getInterfaces() const noexcept = 0;
[[nodiscard]] virtual std::span<Dependency const> getInterfaces() const noexcept = 0;
[[nodiscard]] virtual Properties const & getProperties() const noexcept = 0;
[[nodiscard]] virtual DependencyRegister const * getDependencyRegistry() const noexcept = 0;
virtual void insertSelfInto(uint64_t keyOfInterfaceToInject, ServiceIdType serviceIdOfOther, std::function<void(NeverNull<void*>, IService&)>&) = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ namespace Ichor::Detail {
std::terminate();
}

[[nodiscard]] const IStaticVector<Dependency>& getInterfaces() const noexcept final {
return _interfaces;
[[nodiscard]] std::span<Dependency const> getInterfaces() const noexcept final {
return std::span<Dependency const>{_interfaces.begin(), _interfaces.size()};
}

[[nodiscard]] Properties const & getProperties() const noexcept final {
Expand Down
4 changes: 2 additions & 2 deletions include/ichor/dependency_management/LifecycleManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,8 @@ namespace Ichor::Detail {
return static_cast<IService const *>(&_service);
}

[[nodiscard]] const IStaticVector<Dependency>& getInterfaces() const noexcept final {
return _interfaces;
[[nodiscard]] std::span<Dependency const> getInterfaces() const noexcept final {
return std::span<Dependency const>{_interfaces.begin(), _interfaces.size()};
}

[[nodiscard]] Properties const & getProperties() const noexcept final {
Expand Down
4 changes: 2 additions & 2 deletions include/ichor/dependency_management/QueueLifecycleManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ namespace Ichor::Detail {
return &_service;
}

[[nodiscard]] const IStaticVector<Dependency>& getInterfaces() const noexcept final {
return _interfaces;
[[nodiscard]] std::span<Dependency const> getInterfaces() const noexcept final {
return std::span<Dependency const>{_interfaces.begin(), _interfaces.size()};
}

[[nodiscard]] Properties const & getProperties() const noexcept final {
Expand Down
Loading

0 comments on commit 59d95e2

Please sign in to comment.