From 9803fb09fcb465bbcb0d5508441e8287f6966b20 Mon Sep 17 00:00:00 2001 From: Evgeny Vereshchagin Date: Mon, 10 Oct 2022 06:17:38 +0000 Subject: [PATCH 1/2] ci: build dbus with clang as well It should make it possible to catch issues like like https://gitlab.freedesktop.org/dbus/dbus/-/merge_requests/357 Signed-off-by: Evgeny Vereshchagin --- .gitlab-ci.yml | 9 +++++++++ tools/ci-build.sh | 20 +++++++++++++++++++- tools/ci-install.sh | 2 ++ 3 files changed, 30 insertions(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index eef23778..2fd5a04e 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -196,6 +196,15 @@ debian meson: variables: ci_buildsys: "meson-dist" +debian meson clang debug: + extends: + - .meson-common + - .debian-build + variables: + ci_buildsys: "meson-dist" + ci_compiler: "clang" + ci_variant: "debug" + debian mingw32 autotools debug: extends: .debian-build variables: diff --git a/tools/ci-build.sh b/tools/ci-build.sh index 0e72b2d9..6420cdcb 100755 --- a/tools/ci-build.sh +++ b/tools/ci-build.sh @@ -77,6 +77,10 @@ init_wine() { # Build system under test: autotools or cmake : "${ci_buildsys:=autotools}" +# ci_compiler: +# Compiler used to build dbus: gcc or clang +: "${ci_compiler:=gcc}" + # ci_distro: # OS distribution in which we are testing # Typical values: auto (detect at runtime), ubuntu, debian; maybe fedora in future @@ -522,6 +526,12 @@ case "$ci_buildsys" in ;; (*) set -- -Db_sanitize=address,undefined "$@" + + # https://github.com/mesonbuild/meson/issues/764 + if [ "$ci_compiler" = "clang" ]; then + set -- -Db_lundef=false "$@" + fi + set -- -Db_pie=true "$@" set -- -Duser_session=true "$@" ;; @@ -531,6 +541,14 @@ case "$ci_buildsys" in ;; esac + case "$ci_compiler" in + (clang) + export CC=clang + ;; + (*) + ;; + esac + # Debian doesn't have similar convenience wrappers, but we can use # a cross-file if [ -z "$meson_setup" ] || ! command -v "$meson_setup" >/dev/null; then @@ -548,7 +566,7 @@ case "$ci_buildsys" in $meson_setup "$@" "$srcdir" meson compile -v - [ "$ci_test" = no ] || meson test + [ "$ci_test" = no ] || meson test --print-errorlogs DESTDIR=DESTDIR meson install ( cd DESTDIR && find . -ls) ;; diff --git a/tools/ci-install.sh b/tools/ci-install.sh index c53ede9b..b259a58e 100755 --- a/tools/ci-install.sh +++ b/tools/ci-install.sh @@ -148,6 +148,7 @@ case "$ci_distro" in autotools-dev ca-certificates ccache + clang cmake debhelper dh-autoreconf @@ -169,6 +170,7 @@ case "$ci_distro" in libselinux1-dev libsystemd-dev libx11-dev + llvm meson ninja-build sudo From 738d8dbe6f235b975549a063e694827b703c5887 Mon Sep 17 00:00:00 2001 From: Evgeny Vereshchagin Date: Mon, 10 Oct 2022 22:22:06 +0000 Subject: [PATCH 2/2] ci: get UBSan to fail and print full backtraces Unlike ASan, by default UBSan prints one-line warnings and keeps going and it makes it impossible for the CI to catch issues automatically when it runs the unit tests. With this patch applied the CI should be able to prevent issues like https://gitlab.freedesktop.org/smcv/dbus-issue413/-/merge_requests/1#note_1549306 from making it into the repository going forward. Signed-off-by: Evgeny Vereshchagin --- tools/ci-build.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/ci-build.sh b/tools/ci-build.sh index 6420cdcb..287b170e 100755 --- a/tools/ci-build.sh +++ b/tools/ci-build.sh @@ -269,6 +269,8 @@ esac export MAKE=${make} make="${make} -j${ci_parallel} V=1 VERBOSE=1" +export UBSAN_OPTIONS=print_stacktrace=1:print_summary=1:halt_on_error=1 + case "$ci_buildsys" in (autotools) case "$ci_variant" in