From 39eceb27273b1d5930a6c2ad29f7f75688e9446f Mon Sep 17 00:00:00 2001 From: David Heidelberg Date: Wed, 7 Feb 2024 00:38:46 +0100 Subject: [PATCH] fixes to squash Signed-off-by: David Heidelberg --- CMakeLists.txt | 9 +++++---- doc/compiling/README.md | 1 + src/gui/guiTable.cpp | 2 +- src/script/lua_api/l_server.cpp | 14 +++++++------- 4 files changed, 14 insertions(+), 12 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e256b717ffb42..134c72d672e4d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.5) +cmake_minimum_required(VERSION 3.9) # Set policies up to 3.9 since we want to enable the IPO option if(${CMAKE_VERSION} VERSION_LESS 3.9) @@ -44,11 +44,12 @@ set(BUILD_UNITTESTS TRUE CACHE BOOL "Build unittests") set(BUILD_BENCHMARKS FALSE CACHE BOOL "Build benchmarks") set(BUILD_DOCUMENTATION TRUE CACHE BOOL "Build documentation") -set(ENABLE_LTO TRUE CACHE BOOL "Use Link Time Optimization") +set(DEFAULT_ENABLE_LTO TRUE) # by default don't enable on Debug builds to get faster builds if(CMAKE_BUILD_TYPE STREQUAL "Debug") - set(ENABLE_LTO FALSE) + set(DEFAULT_ENABLE_LTO FALSE) endif() +set(ENABLE_LTO ${DEFAULT_ENABLE_LTO} CACHE BOOL "Use Link Time Optimization") set(DEFAULT_RUN_IN_PLACE FALSE) if(WIN32) @@ -72,7 +73,7 @@ if(NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE Release CACHE STRING "Build type: Debug or Release" FORCE) endif() -# CMake >= 3.9.0 supports LTO/IPO. +# FIXME: Windows build fails in multiple places to link, needs to be investigated. if (ENABLE_LTO AND NOT WIN32) include(CheckIPOSupported) check_ipo_supported(RESULT lto_supported OUTPUT lto_output) diff --git a/doc/compiling/README.md b/doc/compiling/README.md index f4812e77d36a8..cdc39b2173a8f 100644 --- a/doc/compiling/README.md +++ b/doc/compiling/README.md @@ -28,6 +28,7 @@ General options and their default values: ENABLE_REDIS=ON - Build with libhiredis; Enables use of Redis map backend ENABLE_SPATIAL=ON - Build with LibSpatial; Speeds up AreaStores ENABLE_SOUND=ON - Build with OpenAL, libogg & libvorbis; in-game sounds + ENABLE_LTO=ON - Build with IPO/LTO optimizations (smaller and more efficient than regular build) ENABLE_LUAJIT=ON - Build with LuaJIT (much faster than non-JIT Lua) ENABLE_PROMETHEUS=OFF - Build with Prometheus metrics exporter (listens on tcp/30000 by default) ENABLE_SYSTEM_GMP=ON - Use GMP from system (much faster than bundled mini-gmp) diff --git a/src/gui/guiTable.cpp b/src/gui/guiTable.cpp index ad1bf88c0c473..7d2cf66f351ea 100644 --- a/src/gui/guiTable.cpp +++ b/src/gui/guiTable.cpp @@ -210,7 +210,7 @@ void GUITable::setTable(const TableOptions &options, s32 colcount = columns.size(); assert(colcount >= 1); // rowcount = ceil(cellcount / colcount) but use integer arithmetic - s32 rowcount = std::min(((u32)content.size() + colcount - 1) / colcount, (u32)INT_MAX); + s32 rowcount = std::min(((u32)content.size() + colcount - 1) / colcount, (u32)S32_MAX); assert(rowcount >= 0); // Append empty strings to content if there is an incomplete row s32 cellcount = rowcount * colcount; diff --git a/src/script/lua_api/l_server.cpp b/src/script/lua_api/l_server.cpp index d8f0c09c7a75a..21ec176171780 100644 --- a/src/script/lua_api/l_server.cpp +++ b/src/script/lua_api/l_server.cpp @@ -167,13 +167,6 @@ int ModApiServer::l_get_player_information(lua_State *L) return 1; } - /* - Be careful not to introduce a depdendency on the connection to - the peer here. This function is >>REQUIRED<< to still be able to return - values even when the peer unexpectedly disappears. - Hence all the ConInfo values here are optional. - */ - ClientInfo info; if (!server->getClientInfo(player->getPeerId(), info)) { warningstream << FUNCTION_NAME << ": no client info?!" << std::endl; @@ -198,6 +191,13 @@ int ModApiServer::l_get_player_information(lua_State *L) } lua_settable(L, table); + /* + Be careful not to introduce a depdendency on the connection to + the peer here. This function is >>REQUIRED<< to still be able to return + values even when the peer unexpectedly disappears. + Hence all the ConInfo values here are optional. + */ + auto getConInfo = [&] (con::rtt_stat_type type, float *value) -> bool { return server->getClientConInfo(player->getPeerId(), type, value); };