From 453dbc685fe4cc05ef128c9f323f91559128a93a Mon Sep 17 00:00:00 2001 From: pentarctagon Date: Mon, 15 Jan 2024 17:00:16 -0600 Subject: [PATCH] Enable stricter checks for debug builds. Use _GLIBCXX_DEBUG, _GLIBCXX_DEBUG_PEDANTIC, and _GLIBCXX_ASSERTIONS for the debug Ubuntu build. --- .github/workflows/ci-main.yml | 17 ++++++++++++----- SConstruct | 7 +------ run_boost_tests | 2 +- src/SConscript | 4 ++-- utils/CI/mp_test_executor.sh | 3 +++ utils/CI/play_test_executor.sh | 1 + .../dockerbuilds/CI/Dockerfile-base-2204-master | 6 ++++++ 7 files changed, 26 insertions(+), 14 deletions(-) diff --git a/.github/workflows/ci-main.yml b/.github/workflows/ci-main.yml index bdac124cbd2..e7179c87145 100644 --- a/.github/workflows/ci-main.yml +++ b/.github/workflows/ci-main.yml @@ -51,8 +51,8 @@ jobs: fail-fast: false matrix: include: - - { tool: scons, cc: gcc, cxx: g++, cfg: release, lto: true } - - { tool: cmake, cc: clang, cxx: clang++, cfg: debug, lto: false } + - { tool: scons, cc: gcc, cxx: g++, cfg: debug, lto: false } + - { tool: cmake, cc: clang, cxx: clang++, cfg: release, lto: true } runs-on: ubuntu-latest container: image: wesnoth/wesnoth:2204-master @@ -70,16 +70,19 @@ jobs: steps: - { uses: actions/checkout@v3, with: { submodules: "recursive" } } -# wesnothd and campaignd should be buildable without SDL2 being present +# 1) wesnothd and campaignd should be buildable without SDL2 being present +# 2) boost is installed via apt as well as built and installed into /usr/local (for _GLIBCXX_DEBUG support in boost program options) - name: Build wesnoth, wesnothd, campaignd and unit tests id: build # needed to check step outcome run: | case $TOOL in scons) build() { + ldconfig scons "$@" build="$CFG" ctool="$CC" cxxtool="$CXX" cxx_std="$CXX_STD" \ extra_flags_config="-pipe" strict=true forum_user_handler=true \ - nls=false enable_lto="$LTO" force_color=true jobs=2 --debug=time + nls=false enable_lto="$LTO" force_color=true jobs=2 --debug=time \ + glibcxx_debug=true glibcxx_assertions=true } build wesnoth boost_unit_tests @@ -89,10 +92,14 @@ jobs: ;; cmake) build() { + ldconfig cmake "$@" -DCMAKE_BUILD_TYPE="$CFG" -DCXX_STD="$CXX_STD" \ -DEXTRA_FLAGS_CONFIG="-pipe" -DENABLE_STRICT_COMPILATION=true -DENABLE_MYSQL=true \ -DENABLE_NLS=false -DENABLE_LTO="$LTO" -DFORCE_COLOR_OUTPUT=true -DLTO_JOBS=2 . } + rm -R /usr/local/lib/cmake + rm /usr/local/lib/libboost* + rm -R /usr/local/include/boost build -DENABLE_GAME=true -DENABLE_SERVER=false -DENABLE_CAMPAIGN_SERVER=false -DENABLE_TESTS=true make conftests make VERBOSE=1 -j2 @@ -118,7 +125,7 @@ jobs: run: ./utils/CI/schema_validation.sh - name: Run WML tests if: success() || steps.build.outcome == 'success' - run: ./run_wml_tests -g -c -t 20 + run: ./run_wml_tests -g -c -t 20 -bt 1000 - name: Run play tests if: success() || steps.build.outcome == 'success' run: ./utils/CI/play_test_executor.sh diff --git a/SConstruct b/SConstruct index fa3d6837694..f40d36dea43 100755 --- a/SConstruct +++ b/SConstruct @@ -202,9 +202,7 @@ Important switches include: in build/release and copy resulting binaries into distribution/working copy root. build=debug same for debug build variant - binaries will be copied with -debug suffix build=profile build with instrumentation for a supported profiler - binaries will be copied with -profile suffix With no arguments, the recipe builds wesnoth and wesnothd. Available build targets include the individual binaries: @@ -688,9 +686,6 @@ if env["use_srcdir"] == True: else: build_dir = os.path.join("$build_dir", build) -if build == "release" : build_suffix = "" -else : build_suffix = "-" + build -Export("build_suffix") env.SConscript("src/SConscript", variant_dir = build_dir, duplicate = False) Import(binaries + ["sources"]) binary_nodes = [eval(binary) for binary in binaries] @@ -796,7 +791,7 @@ env.InstallBinary(campaignd) install = env.Alias('install', []) for installable in ('wesnoth', 'wesnothd', 'campaignd'): - if os.path.exists(installable + build_suffix) or installable in COMMAND_LINE_TARGETS or "all" in COMMAND_LINE_TARGETS: + if os.path.exists(installable) or installable in COMMAND_LINE_TARGETS or "all" in COMMAND_LINE_TARGETS: env.Alias('install', env.Alias('install-'+installable)) # diff --git a/run_boost_tests b/run_boost_tests index a1d5074311a..ebed91a49b3 100755 --- a/run_boost_tests +++ b/run_boost_tests @@ -4,7 +4,7 @@ This script runs a sequence of C++ unit test scenarios. """ -import argparse, enum, os, re, subprocess, sys +import argparse, os, subprocess, sys def get_tests(filename): test_list = [] diff --git a/src/SConscript b/src/SConscript index b06f69567b6..8af0ea3d7ca 100644 --- a/src/SConscript +++ b/src/SConscript @@ -148,9 +148,9 @@ def WesnothProgram(env, target, source, can_build, **kw): if can_build: if env["use_srcdir"] == True: - bin = env.Program(target + build_suffix, source, **kw) + bin = env.Program(target, source, **kw) else: - bin = env.Program("#/" + target + build_suffix, source, **kw) + bin = env.Program("#/" + target, source, **kw) env.Alias(target, bin) else: bin = env.Alias(target, [], error_action) diff --git a/utils/CI/mp_test_executor.sh b/utils/CI/mp_test_executor.sh index f017c1b5c7e..ee718281442 100755 --- a/utils/CI/mp_test_executor.sh +++ b/utils/CI/mp_test_executor.sh @@ -3,6 +3,9 @@ set -e #Error if any line errors set -m #Enable job control set -v #Print shell commands as they are read +if [ -f ./wesnoth ]; then client="./wesnoth"; else client="./wesnoth-debug"; fi +if [ -f ./wesnothd ]; then server="./wesnothd"; else server="./wesnothd-debug"; fi + TIMEOUT_TIME=300 LOOP_TIME=6 diff --git a/utils/CI/play_test_executor.sh b/utils/CI/play_test_executor.sh index d628dbda966..4325c432e3d 100755 --- a/utils/CI/play_test_executor.sh +++ b/utils/CI/play_test_executor.sh @@ -1,4 +1,5 @@ #!/bin/bash + gdb -q -batch -return-child-result -ex "set disable-randomization off" -ex "set style enabled on" -ex "run" -ex "thread apply all bt" -ex "quit" --args ./wesnoth -m --controller 1:ai --controller 2:ai --nogui 2> error.log error_code="$?" while grep -q 'Could not initialize SDL_video' error.log; do diff --git a/utils/dockerbuilds/CI/Dockerfile-base-2204-master b/utils/dockerbuilds/CI/Dockerfile-base-2204-master index bad74976d47..e2f2edcf602 100644 --- a/utils/dockerbuilds/CI/Dockerfile-base-2204-master +++ b/utils/dockerbuilds/CI/Dockerfile-base-2204-master @@ -24,3 +24,9 @@ RUN apt install -y -qq libpng16-16 libpng-dev libreadline6-dev libvorbis-dev lib RUN apt install -y -qq openssl gdb xvfb bzip2 git scons cmake make ccache gcc g++ clang lld doxygen graphviz lua-check WORKDIR /home/wesnoth-travis + +# build another copy of boost with _GLIBCXX_DEBUG enabled, since program options requires this +COPY boost_1_74_0.tar.gz . +RUN tar -xvzf boost_1_74_0.tar.gz && cd boost_1_74_0 && ./bootstrap.sh --with-libraries=filesystem,locale,iostreams,program_options,regex,random,thread,coroutine,context,test && ./b2 -j2 variant=debug install cxxflags='-fstack-protector-strong' define=_GLIBCXX_DEBUG=1 define=_FORTIFY_SOURCE=2 address-model=64 +RUN rm -R /home/wesnoth-travis/boost_1_74_0 +RUN rm /home/wesnoth-travis/boost_1_74_0.tar.gz \ No newline at end of file