From 4c48ca5fd291f4e4d4049308caa75a711fe6f33a Mon Sep 17 00:00:00 2001 From: Y_Less Date: Tue, 27 Dec 2022 15:24:44 +0000 Subject: [PATCH 1/2] Switch to using bitset2. This doesn't make a difference at this stage, but is a precursor to some other changes intended to generally improve memory consumption. Most importantly bitset2 has one very important new function - `find_first`. It isn't quite as efficient as my method was (see Hacker's Delight, ISBN 9780201914658). --- .gitmodules | 3 +++ SDK/CMakeLists.txt | 1 + SDK/include/types.hpp | 5 +++-- SDK/lib/bitset2 | 1 + 4 files changed, 8 insertions(+), 2 deletions(-) create mode 160000 SDK/lib/bitset2 diff --git a/.gitmodules b/.gitmodules index ac9dccf9d..c81f019f4 100644 --- a/.gitmodules +++ b/.gitmodules @@ -16,3 +16,6 @@ [submodule "lib/cpp-httplib"] path = lib/cpp-httplib url = git@github.com:ksenonadv/cpp-httplib.git +[submodule "SDK/lib/bitset2"] + path = SDK/lib/bitset2 + url = https://github.com/openmultiplayer/bitset2.git diff --git a/SDK/CMakeLists.txt b/SDK/CMakeLists.txt index 2d499d27b..fbcbab8cb 100644 --- a/SDK/CMakeLists.txt +++ b/SDK/CMakeLists.txt @@ -51,6 +51,7 @@ if(CMAKE_SYSTEM_PROCESSOR MATCHES "(x86)|(X86)|(amd64)|(AMD64)") endif() target_include_directories(OMP-SDK INTERFACE include/) +target_include_directories(OMP-SDK INTERFACE lib/) file(GLOB_RECURSE omp_sdk_source_list "*.hpp") diff --git a/SDK/include/types.hpp b/SDK/include/types.hpp index 778584f9a..9a590ce1a 100644 --- a/SDK/include/types.hpp +++ b/SDK/include/types.hpp @@ -1,7 +1,8 @@ #pragma once #include -#include +#include +#include #include #include #include @@ -72,7 +73,7 @@ namespace Impl using String = std::string; template -using StaticBitset = std::bitset; +using StaticBitset = Bitset2::bitset2; } diff --git a/SDK/lib/bitset2 b/SDK/lib/bitset2 new file mode 160000 index 000000000..d61e4b022 --- /dev/null +++ b/SDK/lib/bitset2 @@ -0,0 +1 @@ +Subproject commit d61e4b0222aced39f7eb5860fb213d5f34ad7607 From 4cceadbb8a569947916193133b26bf20997dfac1 Mon Sep 17 00:00:00 2001 From: Y_Less Date: Tue, 27 Dec 2022 16:26:13 +0000 Subject: [PATCH 2/2] Exclude libraries that need exceptions when they are disabled. This compiled on Windows because the code wasn't used, but failed on Linux because it was checked anyway. --- SDK/include/types.hpp | 6 ++++-- Server/Components/Unicode/CMakeLists.txt | 5 +++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/SDK/include/types.hpp b/SDK/include/types.hpp index 9a590ce1a..0dbcb5304 100644 --- a/SDK/include/types.hpp +++ b/SDK/include/types.hpp @@ -1,8 +1,10 @@ #pragma once #include +#if !defined OMP_NO_EXCEPTIONS #include #include +#endif #include #include #include @@ -69,12 +71,12 @@ using std::chrono::duration_cast; /// Don't pass these around the SDK namespace Impl { - using String = std::string; +#if !defined OMP_NO_EXCEPTIONS template using StaticBitset = Bitset2::bitset2; - +#endif } template diff --git a/Server/Components/Unicode/CMakeLists.txt b/Server/Components/Unicode/CMakeLists.txt index 8aa3ecd38..c8dab9b18 100644 --- a/Server/Components/Unicode/CMakeLists.txt +++ b/Server/Components/Unicode/CMakeLists.txt @@ -4,6 +4,11 @@ add_server_component(${ProjectId}) if (STATIC_STDCXX) # Remove any possible symbols from ICU, lower GLIBCXX version to 3.4.11 target_compile_options(${ProjectId} PRIVATE -fno-exceptions -fno-rtti) + + target_compile_definitions(${ProjectId} PRIVATE + OMP_NO_EXCEPTIONS=1 + OMP_NO_RTTI=1 + ) endif() target_link_libraries(${ProjectId} PRIVATE