From e2560d1681d57e748c6f1d2392963903e1114b6a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Sat, 29 Oct 2022 04:18:15 +0200 Subject: [PATCH 1/9] gatomic: Cast the oldval pointer type to the atomic value type If glib_typeof is defined we can try to cast the old value to the atomic value type to check if it's compatible with the pointer one. Closes: #2798 --- glib/gatomic.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/glib/gatomic.h b/glib/gatomic.h index e1b5d2391..8c6a0877e 100644 --- a/glib/gatomic.h +++ b/glib/gatomic.h @@ -241,7 +241,8 @@ G_END_DECLS * https://gitlab.gnome.org/GNOME/glib/-/merge_requests/1715#note_1024120. */ #define g_atomic_pointer_compare_and_exchange(atomic, oldval, newval) \ (G_GNUC_EXTENSION ({ \ - G_STATIC_ASSERT (sizeof (oldval) == sizeof (gpointer)); \ + G_STATIC_ASSERT (sizeof (static_cast((oldval))) \ + == sizeof (gpointer)); \ glib_typeof (*(atomic)) gapcae_oldval = (oldval); \ G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gpointer)); \ (void) (0 ? (gpointer) *(atomic) : NULL); \ From fdaa8a334a5913a043966dd019262be86f910895 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Sat, 29 Oct 2022 04:12:21 +0200 Subject: [PATCH 2/9] ci: Set CFLAGS on msys2-mingw32 in yaml file as it happens for other jobs Be consistent, and based on this also perform the lcov job or not --- .gitlab-ci.yml | 1 + .gitlab-ci/test-msys2.sh | 31 +++++++++++++++++-------------- 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 0f04816ac..98a731220 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -303,6 +303,7 @@ msys2-mingw32: variables: MSYSTEM: "MINGW32" CHERE_INVOKING: "yes" + CFLAGS: -coverage -ftest-coverage -fprofile-arcs script: - C:\msys64\usr\bin\pacman --noconfirm -Syyuu --ask 20 - C:\msys64\usr\bin\bash .gitlab-ci/show-execution-environment.sh diff --git a/.gitlab-ci/test-msys2.sh b/.gitlab-ci/test-msys2.sh index a345fda6a..fa68d58f4 100755 --- a/.gitlab-ci/test-msys2.sh +++ b/.gitlab-ci/test-msys2.sh @@ -34,7 +34,6 @@ export CCACHE_BASEDIR CCACHE_DIR pip3 install --upgrade --user meson==0.60.3 PATH="$(cygpath "$USERPROFILE")/.local/bin:$HOME/.local/bin:$PATH" -CFLAGS="-coverage -ftest-coverage -fprofile-arcs" DIR="$(pwd)" export PATH CFLAGS @@ -42,20 +41,24 @@ meson --werror --buildtype debug _build cd _build ninja -lcov \ - --quiet \ - --config-file "${DIR}"/.lcovrc \ - --directory "${DIR}/_build" \ - --capture \ - --initial \ - --output-file "${DIR}/_coverage/${CI_JOB_NAME}-baseline.lcov" +if [[ "$CFLAGS" == *"-coverage"* ]]; then + lcov \ + --quiet \ + --config-file "${DIR}"/.lcovrc \ + --directory "${DIR}/_build" \ + --capture \ + --initial \ + --output-file "${DIR}/_coverage/${CI_JOB_NAME}-baseline.lcov" +fi # FIXME: fix the test suite meson test --timeout-multiplier "${MESON_TEST_TIMEOUT_MULTIPLIER}" --no-suite flaky || true -lcov \ - --quiet \ - --config-file "${DIR}"/.lcovrc \ - --directory "${DIR}/_build" \ - --capture \ - --output-file "${DIR}/_coverage/${CI_JOB_NAME}.lcov" +if [[ "$CFLAGS" == *"-coverage"* ]]; then + lcov \ + --quiet \ + --config-file "${DIR}"/.lcovrc \ + --directory "${DIR}/_build" \ + --capture \ + --output-file "${DIR}/_coverage/${CI_JOB_NAME}.lcov" +fi From 345fbe0666a3b885b0080fef5756cacd0e64fe37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Sat, 29 Oct 2022 02:29:38 +0200 Subject: [PATCH 3/9] ci/test-msys2: use $MINGW_PACKAGE_PREFIX --- .gitlab-ci/test-msys2.sh | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) mode change 100755 => 100644 .gitlab-ci/test-msys2.sh diff --git a/.gitlab-ci/test-msys2.sh b/.gitlab-ci/test-msys2.sh old mode 100755 new mode 100644 index fa68d58f4..c834e81ad --- a/.gitlab-ci/test-msys2.sh +++ b/.gitlab-ci/test-msys2.sh @@ -1,29 +1,24 @@ #!/bin/bash -set -e +set -ex export PATH="/c/msys64/$MSYSTEM/bin:$PATH" -if [[ "$MSYSTEM" == "MINGW32" ]]; then - export MSYS2_ARCH="i686" -else - export MSYS2_ARCH="x86_64" -fi pacman --noconfirm -Suy pacman --noconfirm -S --needed \ base-devel \ lcov \ - mingw-w64-$MSYS2_ARCH-ccache \ - mingw-w64-$MSYS2_ARCH-gettext \ - mingw-w64-$MSYS2_ARCH-libffi \ - mingw-w64-$MSYS2_ARCH-meson \ - mingw-w64-$MSYS2_ARCH-pcre2 \ - mingw-w64-$MSYS2_ARCH-python3 \ - mingw-w64-$MSYS2_ARCH-python-pip \ - mingw-w64-$MSYS2_ARCH-toolchain \ - mingw-w64-$MSYS2_ARCH-zlib \ - mingw-w64-$MSYS2_ARCH-libelf + "${MINGW_PACKAGE_PREFIX}"-ccache \ + "${MINGW_PACKAGE_PREFIX}"-gettext \ + "${MINGW_PACKAGE_PREFIX}"-libffi \ + "${MINGW_PACKAGE_PREFIX}"-meson \ + "${MINGW_PACKAGE_PREFIX}"-pcre2 \ + "${MINGW_PACKAGE_PREFIX}"-python3 \ + "${MINGW_PACKAGE_PREFIX}"-python-pip \ + "${MINGW_PACKAGE_PREFIX}"-toolchain \ + "${MINGW_PACKAGE_PREFIX}"-zlib \ + "${MINGW_PACKAGE_PREFIX}"-libelf mkdir -p _coverage mkdir -p _ccache From e320149c39369a6b9cdcaf6cb7b719d6eae3d2f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Sat, 29 Oct 2022 04:14:29 +0200 Subject: [PATCH 4/9] ci: Add an msys2-clang64 job to run only on schedules It has enough particularities to require a job to monitor failures --- .gitlab-ci.yml | 22 ++++++++++++++++++++++ .gitlab-ci/test-msys2.sh | 10 +++++++++- 2 files changed, 31 insertions(+), 1 deletion(-) mode change 100644 => 100755 .gitlab-ci/test-msys2.sh diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 98a731220..4dcab274e 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -318,6 +318,28 @@ msys2-mingw32: - _build/meson-logs - _coverage/ +msys2-clang64: + extends: .only-schedules + stage: build + tags: + - win32-ps + needs: [] + variables: + MSYSTEM: "CLANG64" + CHERE_INVOKING: "yes" + script: + - C:\msys64\usr\bin\pacman --noconfirm -Syyuu --ask 20 + - C:\msys64\usr\bin\bash .gitlab-ci/show-execution-environment.sh + - C:\msys64\usr\bin\bash -lc "bash -x ./.gitlab-ci/test-msys2.sh" + artifacts: + reports: + junit: "_build/meson-logs/testlog.junit.xml" + name: "glib-${env:CI_JOB_NAME}-${env:CI_COMMIT_REF_NAME}" + when: always + expire_in: 1 week + paths: + - _build/meson-logs + vs2017-x64: extends: .only-default stage: build diff --git a/.gitlab-ci/test-msys2.sh b/.gitlab-ci/test-msys2.sh old mode 100644 new mode 100755 index c834e81ad..85394a754 --- a/.gitlab-ci/test-msys2.sh +++ b/.gitlab-ci/test-msys2.sh @@ -32,7 +32,15 @@ PATH="$(cygpath "$USERPROFILE")/.local/bin:$HOME/.local/bin:$PATH" DIR="$(pwd)" export PATH CFLAGS -meson --werror --buildtype debug _build +if [[ "$MSYSTEM" == "CLANG64" ]]; then + # FIXME: fix the clang build warnings + # shellcheck disable=SC2086 + meson ${MESON_COMMON_OPTIONS} _build +else + # shellcheck disable=SC2086 + meson ${MESON_COMMON_OPTIONS} --werror _build +fi + cd _build ninja From d7a6305ba472392d48e193006dacc510ab7a32f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Sat, 29 Oct 2022 04:15:28 +0200 Subject: [PATCH 5/9] glib/gnulib/meson: Disable some warnings on clang windows builds We have gnulib warnings in windows under clang: ../glib/gnulib/vasnprintf.c:2429:21: warning: variable 'flags' set but not used [-Wunused-but-set-variable] int flags = dp->flags; ^ ../glib/gnulib/vasnprintf.c:4853:19: warning: unannotated fall-through between switch labels [-Wimplicit-fallthrough] case TYPE_LONGINT: ^ See: https://gitlab.gnome.org/3v1n0/glib/-/jobs/2361750 --- glib/gnulib/meson.build | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/glib/gnulib/meson.build b/glib/gnulib/meson.build index bdd623385..c8040f648 100644 --- a/glib/gnulib/meson.build +++ b/glib/gnulib/meson.build @@ -3,6 +3,13 @@ extra_gnulib_args = cc.get_supported_arguments([ '-Wno-format-nonliteral', '-Wno-duplicated-branches']) +if host_system == 'windows' and cc.get_id() == 'clang' + extra_gnulib_args += cc.get_supported_arguments([ + '-Wno-unused-but-set-variable', + '-Wno-implicit-fallthrough', + ]) +endif + math_h_config = configuration_data () unneeded_funcs = [ From 7dc19632f3115e3f517c6bc80436fe72c1dcdeb4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Sat, 29 Oct 2022 04:16:00 +0200 Subject: [PATCH 6/9] glib/tests/cxx: Ensure NULL is always casted to a pointer type Otherwise it may not be recognized as valid sentinel --- glib/tests/cxx.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/glib/tests/cxx.cpp b/glib/tests/cxx.cpp index 045457c6e..aa5e0cb57 100644 --- a/glib/tests/cxx.cpp +++ b/glib/tests/cxx.cpp @@ -186,7 +186,11 @@ test_steal_pointer (void) int main (int argc, char *argv[]) { +#if __cplusplus >= 201103L g_test_init (&argc, &argv, NULL); +#else + g_test_init (&argc, &argv, static_cast(NULL)); +#endif g_test_add_func ("/C++/typeof", test_typeof); g_test_add_func ("/C++/atomic-pointer-compare-and-exchange", test_atomic_pointer_compare_and_exchange); From 126b822137871ddce594af4371d4e9aba3a733e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Sat, 29 Oct 2022 04:57:35 +0200 Subject: [PATCH 7/9] gfileutils: Use correct type comparison for length length is defined as an unsigned size value, so can't compare it with a signed one --- glib/gfileutils.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/glib/gfileutils.c b/glib/gfileutils.c index f0c8f6776..44c22f3ee 100644 --- a/glib/gfileutils.c +++ b/glib/gfileutils.c @@ -1143,7 +1143,7 @@ write_to_file (const gchar *contents, { gssize s; - s = write (fd, contents, MIN (length, G_MAXSSIZE)); + s = write (fd, contents, MIN (length, G_MAXSIZE)); if (s < 0) { From 69f7aa57470229498435bb936207cca3ee7796c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Sat, 29 Oct 2022 14:23:40 +0200 Subject: [PATCH 8/9] meson: Ignore -Wstring-plus-int in C It's not really a problem for us, it would be only in c++. --- meson.build | 1 + 1 file changed, 1 insertion(+) diff --git a/meson.build b/meson.build index c49815a9c..1b2601791 100644 --- a/meson.build +++ b/meson.build @@ -467,6 +467,7 @@ if cc.get_id() == 'gcc' or cc.get_id() == 'clang' '-Werror=implicit-function-declaration', '-Werror=missing-prototypes', '-Werror=pointer-sign', + '-Wno-string-plus-int', ] warning_cxx_args = warning_common_args warning_objc_args = warning_c_args From dd422a058833afa5461668c791071f441cc6ec02 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Mon, 31 Oct 2022 11:59:39 +0100 Subject: [PATCH 9/9] gio/tests/win32-streams: Avoid doing sign casting when we can the offset can be just an unsigned parameter so that we don't have to cast the sizeof (DATA) result. --- gio/tests/win32-streams.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/gio/tests/win32-streams.c b/gio/tests/win32-streams.c index 6451a9faa..9c32a56b2 100644 --- a/gio/tests/win32-streams.c +++ b/gio/tests/win32-streams.c @@ -40,7 +40,8 @@ static gpointer writer_thread (gpointer user_data) { GOutputStream *out; - gssize nwrote, offset; + gssize nwrote; + size_t offset; GError *err = NULL; HANDLE out_handle; @@ -58,7 +59,7 @@ writer_thread (gpointer user_data) g_usleep (10); offset = 0; - while (offset < (gssize) sizeof (DATA)) + while (offset < sizeof (DATA)) { nwrote = g_output_stream_write (out, DATA + offset, sizeof (DATA) - offset,