diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index be6f57053c..3b34b0c07f 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -105,7 +105,7 @@ Ubuntu_GCC: Ubuntu_GCC_tests: extends: Ubuntu_GCC cache: - key: Ubuntu_GCC_tests.v2 + key: Ubuntu_GCC_tests.v3 variables: CCACHE_SIZE: 1G BUILD_TESTS_ONLY: 1 @@ -125,6 +125,50 @@ Ubuntu_GCC_tests_Debug: paths: [] expire_in: 1 minute +Ubuntu_GCC_tests_asan: + extends: Ubuntu_GCC + cache: + key: Ubuntu_GCC_asan.v1 + variables: + CCACHE_SIZE: 1G + BUILD_TESTS_ONLY: 1 + CMAKE_BUILD_TYPE: Debug + CMAKE_CXX_FLAGS_DEBUG: -g -O1 -fno-omit-frame-pointer -fsanitize=address -fsanitize=pointer-compare -fsanitize=pointer-subtract -fsanitize=leak + CMAKE_EXE_LINKER_FLAGS: -fsanitize=address -fsanitize=pointer-compare -fsanitize=pointer-subtract -fsanitize=leak + ASAN_OPTIONS: halt_on_error=1:strict_string_checks=1:detect_stack_use_after_return=1:check_initialization_order=1:strict_init_order=1 + artifacts: + paths: [] + expire_in: 1 minute + +Ubuntu_GCC_tests_ubsan: + extends: Ubuntu_GCC + cache: + key: Ubuntu_GCC_ubsan.v1 + variables: + CCACHE_SIZE: 1G + BUILD_TESTS_ONLY: 1 + CMAKE_BUILD_TYPE: Debug + CMAKE_CXX_FLAGS_DEBUG: -g -O0 -fsanitize=undefined + UBSAN_OPTIONS: print_stacktrace=1:halt_on_error=1 + artifacts: + paths: [] + expire_in: 1 minute + +Ubuntu_GCC_tests_tsan: + extends: Ubuntu_GCC + cache: + key: Ubuntu_GCC_tsan.v1 + variables: + CCACHE_SIZE: 1G + BUILD_TESTS_ONLY: 1 + CMAKE_BUILD_TYPE: Debug + CMAKE_CXX_FLAGS_DEBUG: -g -O2 -fno-omit-frame-pointer -fno-optimize-sibling-calls -fsanitize=thread -fPIE + CMAKE_EXE_LINKER_FLAGS: -pthread -pie -fsanitize=thread + TSAN_OPTIONS: second_deadlock_stack=1:halt_on_error=1 + artifacts: + paths: [] + expire_in: 1 minute + Ubuntu_Static_Deps: extends: Ubuntu_Clang rules: @@ -179,7 +223,7 @@ Ubuntu_Clang: Ubuntu_Clang_tests: extends: Ubuntu_Clang cache: - key: Ubuntu_Clang_tests.v2 + key: Ubuntu_Clang_tests.v3 variables: CCACHE_SIZE: 1G BUILD_TESTS_ONLY: 1 diff --git a/CI/before_script.linux.sh b/CI/before_script.linux.sh index 801d7f0a3e..386b25bbe6 100755 --- a/CI/before_script.linux.sh +++ b/CI/before_script.linux.sh @@ -52,13 +52,25 @@ if [[ "${CMAKE_BUILD_TYPE}" ]]; then ) fi +if [[ "${CMAKE_CXX_FLAGS_DEBUG}" ]]; then + CMAKE_CONF_OPTS+=( + -DCMAKE_CXX_FLAGS_DEBUG="${CMAKE_CXX_FLAGS_DEBUG}" + ) +fi + +if [[ "${CMAKE_EXE_LINKER_FLAGS}" ]]; then + CMAKE_CONF_OPTS+=( + -DCMAKE_EXE_LINKER_FLAGS="${CMAKE_EXE_LINKER_FLAGS}" + ) +fi + mkdir -p build cd build if [[ "${BUILD_TESTS_ONLY}" ]]; then # flags specific to our test suite - CXX_FLAGS="-Wno-error=deprecated-declarations -Wno-error=nonnull -Wno-error=deprecated-copy -fsanitize=address" + CXX_FLAGS="-Wno-error=deprecated-declarations -Wno-error=nonnull -Wno-error=deprecated-copy" if [[ "${CXX}" == 'clang++' ]]; then CXX_FLAGS="${CXX_FLAGS} -Wno-error=unused-lambda-capture -Wno-error=gnu-zero-variadic-macro-arguments" fi diff --git a/CMakeLists.txt b/CMakeLists.txt index 1e0c7f7d4b..2b12c2b651 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -154,6 +154,8 @@ option(RECASTNAVIGATION_STATIC "Build recastnavigation static libraries" ${_reca option(OPENMW_USE_SYSTEM_SQLITE3 "Use system provided SQLite3 library" ON) +option(OPENMW_USE_SYSTEM_BENCHMARK "Use system Google Benchmark library." OFF) + option(OPENMW_UNITY_BUILD "Use fewer compilation units to speed up compile time" FALSE) option(OPENMW_LTO_BUILD "Build OpenMW with Link-Time Optimization (Needs ~2GB of RAM)" OFF) diff --git a/apps/benchmarks/CMakeLists.txt b/apps/benchmarks/CMakeLists.txt index ad4a21d5e4..c96531a666 100644 --- a/apps/benchmarks/CMakeLists.txt +++ b/apps/benchmarks/CMakeLists.txt @@ -1,27 +1,5 @@ -option(OPENMW_USE_SYSTEM_BENCHMARK "Use system Google Benchmark library." OFF) - if(OPENMW_USE_SYSTEM_BENCHMARK) find_package(benchmark REQUIRED) -else() - cmake_minimum_required(VERSION 3.11) - - set(BENCHMARK_ENABLE_TESTING OFF) - set(BENCHMARK_ENABLE_INSTALL OFF) - set(BENCHMARK_ENABLE_GTEST_TESTS OFF) - - set(SAVED_CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") - - string(REPLACE "-Wsuggest-override" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") - string(REPLACE "-Wundef" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") - include(FetchContent) - FetchContent_Declare(benchmark - URL https://github.com/google/benchmark/archive/refs/tags/v1.5.2.zip - URL_HASH MD5=49395b757a7c4656d70f1328d93efd00 - SOURCE_DIR fetched/benchmark - ) - FetchContent_MakeAvailableExcludeFromAll(benchmark) - - set(CMAKE_CXX_FLAGS "${SAVED_CMAKE_CXX_FLAGS}") endif() openmw_add_executable(openmw_detournavigator_navmeshtilescache_benchmark detournavigator/navmeshtilescache.cpp) diff --git a/components/misc/color.cpp b/components/misc/color.cpp index edf3435428..56520c5d74 100644 --- a/components/misc/color.cpp +++ b/components/misc/color.cpp @@ -29,7 +29,7 @@ namespace Misc for (size_t i = 0; i < rgb.size(); i++) { auto sub = hex.substr(i * 2, 2); - int v; + int v = 0; auto [_, ec] = std::from_chars(sub.data(), sub.data() + sub.size(), v, 16); if (ec != std::errc()) throw std::logic_error(std::string("Invalid hex color: ") += hex); diff --git a/extern/CMakeLists.txt b/extern/CMakeLists.txt index 27351ce675..4dd4c2b416 100644 --- a/extern/CMakeLists.txt +++ b/extern/CMakeLists.txt @@ -210,3 +210,19 @@ if (NOT OPENMW_USE_SYSTEM_SQLITE3) endif() add_subdirectory(smhasher) + +if (NOT OPENMW_USE_SYSTEM_BENCHMARK) + cmake_minimum_required(VERSION 3.11) + + set(BENCHMARK_ENABLE_TESTING OFF) + set(BENCHMARK_ENABLE_INSTALL OFF) + set(BENCHMARK_ENABLE_GTEST_TESTS OFF) + + include(FetchContent) + FetchContent_Declare(benchmark + URL https://github.com/google/benchmark/archive/refs/tags/v1.5.2.zip + URL_HASH MD5=49395b757a7c4656d70f1328d93efd00 + SOURCE_DIR fetched/benchmark + ) + FetchContent_MakeAvailableExcludeFromAll(benchmark) +endif()