Commit Graph

566 Commits

Author SHA1 Message Date
Marco Trevisan (Treviño)
fb5a50900e girepository: Disable ASAN when building our typelib
We don't care about memory issues during this phase while we should test
this separately
2024-05-24 15:30:42 +02:00
Marco Trevisan (Treviño)
5ca20f7dc0 girepository: Always use currently built GLib to run g-ir-scanner
If we use the system libraries we can't really debug it, so ensure we're
using the currently built libraries for it too.

We're doing it globally to ensure that we're testing the result that
this version of the libraries are building
2024-05-24 15:27:53 +02:00
Marco Trevisan (Treviño)
e07f8a807a meson: Preload sanitizer libraries before than any other library
In some test cases (but not only) GLib needs to preload libraries when
launching executables, however this doesn't work well with ASAN because
libasan needs to be the first library to be loaded in such case.

We've been ignoring the error so far, using verify_asan_link_order=false
ASAN option, but this is not the correct way because it implies that
we don't check any pre-loaded library, as we instead should.

So in the platforms we know, get the proper sanitizer libraries paths
and pre-load them when required.

We don't do it for installed tests since the full paths may change in
the target system, so ignoring the error is safer.

This meson code has been used for various years now in fprintd project
to run tests in CI in both fedora and debian-based systems with no
issues, so I consider it reliable.

In case no preload variables are found the default ignore mode is used
2024-05-23 19:34:21 +02:00
Marco Trevisan (Treviño)
8a9e510d4c build/tests: Automatically set ASAN_OPTIONS if preloading is required
If preloading a library is required asan doesn't work properly because
it requires to be the first loaded library to test everything, however
the behavior can be worked around using an ASAN_OPTIONS variable, so do
this to prevent the tests to fail completely

But instead of having to do it at test level, manage this at wider scope
2024-05-23 18:53:46 +02:00
Marco Trevisan (Treviño)
ab2e68cf75 build: Define the preload variable name and separator globally
We may need this in multiple tests, so let's share the value
2024-05-23 18:53:45 +02:00
Marco Trevisan (Treviño)
0dec04c504 build: Add variable to check if a GNU C compiler is used
This applies to both gcc and clang, without having to repeat the same
check multiple times and involving strings
2024-05-22 19:18:24 +02:00
Michael Catanzaro
153cda6669 Convert systemtap from bool to feature option type
Now systemtap can be enabled by default in distros that use
-Dauto_features=enabled or for developers who already have systemtap
installed, while it's still disabled for developers who do not have
systemtap installed. See #3354
2024-05-17 15:22:41 -05:00
Michael Catanzaro
ed020a688a Convert dtrace from bool to feature option type
Now dtrace can be enabled by default in distros that use
-Dauto_features=enabled or for developers who already have dtrace
installed, while it's still disabled for developers who do not have
dtrace installed. See #3354
2024-05-17 15:22:41 -05:00
Marco Trevisan (Treviño)
0eb6c85606 build: Define glib_sanitizers variable to easily get the sanitizers in use
It's an array containing the list of sanitizers in use, normally it
contains a value, but in some cases may have more than one (e.g.
'address' and 'undefined').

And so use it to avoid repeated checks
2024-05-10 02:15:52 +02:00
Fabrice Fontaine
4e6dc4dee0 link with -latomic when needed
Some architecture such as sparc and some flavors of arm needs -latomic
to avoid the following build failure:

gthread-posix.c:(.text+0xda8): undefined reference to `__atomic_compare_exchange_4'

Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
2024-05-02 17:54:52 +02:00
Philip Withnall
b2f27beb34
build: Enable -Wnull-dereference warning
This enables `NULL` pointer dereference checking in the compiler. This
isn’t as good as static analysis, but it should hopefully catch some
simple errors without too high a false positive rate.

If the false positive rate is too high to be useful, we can always
disable it again.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>

Helps: #1767
2024-04-12 18:44:56 +01:00
L. E. Segovia
ffa639f0b7 glib/gthread-posix: Fix name of the futex_time64(2) test in the Meson log 2024-04-02 00:00:21 -03:00
Calvin Walton
013980d839 Use the python found by meson as the interpreter for installed scripts
The python interpreter found by `/usr/bin/env python3` is not
necessarily the same installation as the one that's found by meson's
`pymod.find_installation('python')`. This means that even though meson
is checking that the python installation it found includes the
'packaging' module, the scripts might not have access to that module
when run.

For distribution packaging, it's usually desirable to have python script
interpreters be fully specified paths, rather than use `/usr/bin/env`,
to ensure the scripts run using the expected python installation (i.e.
the one where the python 'packaging' dependency is installed).

The easiest way to fix this is to set the script interpreter to the
`full_path()` of the python interpreter found by meson. The specific
python interpreter that will be used can be selected through the use of
a meson machine file by overriding the "python" program. Many
distributions already have this set up using meson packaging helpers.
2024-03-25 15:17:59 -04:00
Philip Withnall
1c5f5a6914 Merge branch 'wip/chergert/gpoll-for-gmain' into 'main'
Use ppoll() when possible for more precise timeouts

See merge request GNOME/glib!3958
2024-03-22 00:17:21 +00:00
Christian Hergert
368cb7eb7b glib/gmain: use ppoll() when possible
If our GPollFunc is set to g_poll() then we can optionally use a poll()
alternative with higher precision. ppoll() provides poll() equivalence
but with timeouts in nanoseconds.

With more precise polling timouts, frame clocks and other timing sensitive
APIs are not restricted to a minimum of 1 millisecond timeout.
2024-03-21 23:46:20 +00:00
Philip Withnall
0cb5a86745 build: Post-release version bump
This opens up the development cycle for 2.82.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2024-03-20 11:54:39 +00:00
Philip Withnall
763cc3b238
2.80.0
Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2024-03-07 21:35:05 +00:00
Philip Withnall
0d31fc6df3
2.79.3
Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2024-02-27 10:11:38 +00:00
Kleis Auke Wolthuizen
72d76922dc girepository: Fix static build under Windows
Properly define `GI_STATIC_COMPILATION` when static build is enabled.
Use `library()` instead of `shared_library()` to allow selecting static builds.
2024-02-21 12:38:40 +01:00
Philip Withnall
342fa9c161
2.79.2
Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2024-02-12 23:36:25 +00:00
Philip Withnall
a7a6b93cf6 Merge branch 'th/meson-werror-fixes-2' into 'main'
[th/meson-werror-fixes-2] more workarounds for compiler warnings in meson compiler checks

See merge request GNOME/glib!3904
2024-02-08 10:28:01 +00:00
Philip Withnall
01cf3a03c2 Merge branch 'wip/smcv/lint' into 'main'
Incorporate some lint checks into `meson test`

See merge request GNOME/glib!3898
2024-02-08 01:03:01 +00:00
Simon McVittie
d7601f7eed Incorporate some lint checks into meson test
This will make it easier and more obvious for developers to run them
locally: I'm sure I'm not the only developer who had assumed that
`.gitlab-ci/` is private to the CI environment and inappropriate (or
perhaps even destructive) to run on a developer/user system.

The lint checks are automatically skipped (with TAP SKIP syntax) if we
are not in a git checkout, or if git or the lint tool is missing. They
can also be disabled explicitly with `meson test --no-suite=lint`,
which downstream distributions will probably want to do.

By default, most lint checks are reported as an "expected failure"
(with TAP TODO syntax) rather than a hard failure, because they do not
indicate a functional problem with GLib and there is a tendency for
lint tools to introduce additional checks or become more strict over
time. Developers can override this by configuring with `-Dwerror=true`
(which also makes compiler warnings into fatal errors), or by running
the test suite like `LINT_WARNINGS_ARE_ERRORS=1 meson test --suite=lint`.

One exception to this is tests/check-missing-install-tag.py, which is
checking a functionally significant feature of our build system, and
seems like it is unlikely to have false positives: if that one fails,
it is reported as a hard failure.

run-style-check-diff.sh and run-check-todos.sh are not currently given
this treatment, because they require search-common-ancestor.sh, which
uses Gitlab-CI-specific information to find out which commits are in-scope
for checking.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2024-02-08 00:18:23 +00:00
Thomas Haller
89e85717c9 build: workaround compiler warning -Wnon-null in meson detection
Otherwise, `CFLAGS='-Wall -Werror' meson build` fails detection with:

  Running compile:
  Working directory:  /data/src/glib/build/meson-private/tmpmw16de74
  Code:
   #include <fcntl.h>
                    #include <sys/types.h>
                    #include <sys/stat.h>
                    void some_func (void) {
                      open(0, O_DIRECTORY, 0);
                    }
  -----------
  Command line: `cc /data/src/glib/build/meson-private/tmpmw16de74/testfile.c -o /data/src/glib/build/meson-private/tmpmw16de74/output.obj -c -Werror -Wall -D_FILE_OFFSET_BITS=64 -O0 -std=gnu99` -> 1
  stderr:
  /data/src/glib/build/meson-private/tmpmw16de74/testfile.c: In function 'some_func':
  /data/src/glib/build/meson-private/tmpmw16de74/testfile.c:5:21: error: argument 1 null where non-null expected [-Werror=nonnull]
      5 |                     open(0, O_DIRECTORY, 0);
        |                     ^~~~
  In file included from /usr/include/features.h:503,
                   from /usr/include/fcntl.h:25,
                   from /data/src/glib/build/meson-private/tmpmw16de74/testfile.c:1:
  /usr/include/fcntl.h:212:12: note: in a call to function 'open' declared 'nonnull'
    212 | extern int __REDIRECT (open, (const char *__file, int __oflag, ...), open64)
        |            ^~~~~~~~~~
  cc1: all warnings being treated as errors
  -----------
  Checking if "open() option O_DIRECTORY" compiles: NO
2024-02-07 20:40:59 +01:00
Thomas Haller
bcb6431bff build: workaround compiler warning -Wunused-variable in meson detection
Otherwise, `CFLAGS='-Wall -Werror' meson build` fails detection with:

  Running compile:
  ...
  Command line: `cc /data/src/glib/build/meson-private/tmplkxa94er/testfile.c -o /data/src/glib/build/meson-private/tmplkxa94er/output.exe -Werror -Wall -D_FILE_OFFSET_BITS=64 -O0 -std=gnu99` -> 1
  stderr:
  /data/src/glib/build/meson-private/tmplkxa94er/testfile.c: In function 'main':
  /data/src/glib/build/meson-private/tmplkxa94er/testfile.c:3:24: error: unused variable 'codeset' [-Werror=unused-variable]
      3 |                  char *codeset = nl_langinfo (CODESET);
        |                        ^~~~~~~
  cc1: all warnings being treated as errors
  -----------
  Checking if "nl_langinfo and CODESET" : links: NO
2024-02-07 20:40:59 +01:00
Thomas Haller
509e599eed build: workaround compiler warning in meson detection of nl_langinfo()
Otherwise, `CFLAGS='-Wall -Werror' meson build` fails detection with:

  Running compile:
  Working directory:  /data/src/glib/build/meson-private/tmpa3ebpbos
  Code:
   #include <langinfo.h>
                 int main (int argc, char ** argv) {
                   char *str;
                   str = nl_langinfo (PM_STR);
                   str = nl_langinfo (D_T_FMT);
                   str = nl_langinfo (D_FMT);
                   str = nl_langinfo (T_FMT);
                   str = nl_langinfo (T_FMT_AMPM);
                   str = nl_langinfo (MON_1);
                   str = nl_langinfo (ABMON_12);
                   str = nl_langinfo (DAY_1);
                   str = nl_langinfo (ABDAY_7);
                   return 0;
                 }
  -----------
  Command line: `cc /data/src/glib/build/meson-private/tmpa3ebpbos/testfile.c -o /data/src/glib/build/meson-private/tmpa3ebpbos/output.exe -Werror -Wall -D_FILE_OFFSET_BITS=64 -O0 -std=gnu99` -> 1
  stderr:
  /data/src/glib/build/meson-private/tmpa3ebpbos/testfile.c: In function 'main':
  /data/src/glib/build/meson-private/tmpa3ebpbos/testfile.c:3:24: error: variable 'str' set but not used [-Werror=unused-but-set-variable]
      3 |                  char *str;
        |                        ^~~
  cc1: all warnings being treated as errors
  -----------
  Checking if "nl_langinfo (PM_STR)" : links: NO
2024-02-07 20:40:59 +01:00
Thomas Haller
4bdadb6ccc build: workaround compiler warning in meson detection of __uint128_t
Otherwise, `CFLAGS='-Wall -Werror' meson build` fails detection with:

  Code:
   int main() {
  static __uint128_t v1 = 100;
  static __uint128_t v2 = 10;
  static __uint128_t u;
  u = v1 / v2;
  }
  -----------
  Command line: `cc /data/src/glib/build/meson-private/tmp451h9ogd/testfile.c -o /data/src/glib/build/meson-private/tmp451h9ogd/output.obj -c -Werror -Wall -D_FILE_OFFSET_BITS=64 -O0 -std=gnu99` -> 1
  stderr:
  /data/src/glib/build/meson-private/tmp451h9ogd/testfile.c: In function 'main':
  /data/src/glib/build/meson-private/tmp451h9ogd/testfile.c:4:20: error: variable 'u' set but not used [-Werror=unused-but-set-variable]
      4 | static __uint128_t u;
        |                    ^
  cc1: all warnings being treated as errors
  -----------
  Checking if "__uint128_t available" compiles: NO
2024-02-07 20:40:59 +01:00
Thomas Haller
d0afd2b783 build: drop unused variable from "C99 snprintf" meson check
Otherwise, `CFLAGS='-Wall -Werror' meson build` fails detection with:

  Running compile:
  ...
  int
  main(void)
  {
    doit();
    exit(1);
  }
  -----------
  Command line: `cc /data/src/glib/build/meson-private/tmp7n5yqh0h/testfile.c -o /data/src/glib/build/meson-private/tmp7n5yqh0h/output.exe -Werror -Wall -D_FILE_OFFSET_BITS=64 -O0 -std=gnu99` -> 1
  stderr:
  /data/src/glib/build/meson-private/tmp7n5yqh0h/testfile.c: In function 'doit':
  /data/src/glib/build/meson-private/tmp7n5yqh0h/testfile.c:10:11: error: unused variable 'args' [-Werror=unused-variable]
     10 |   va_list args;
        |           ^~~~
  /data/src/glib/build/meson-private/tmp7n5yqh0h/testfile.c:13:33: error: '1234567' directive output truncated writing 7 bytes into a region of size 5 [-Werror=format-truncation=]
     13 |   r = snprintf(buffer, 5, "1234567");
        |                            ~~~~~^~
  /data/src/glib/build/meson-private/tmp7n5yqh0h/testfile.c:13:7: note: 'snprintf' output 8 bytes into a destination of size 5
     13 |   r = snprintf(buffer, 5, "1234567");
        |       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  cc1: all warnings being treated as errors
  -----------
  Could not compile test file /data/src/glib/build/meson-private/tmp7n5yqh0h/testfile.c: 1

  Checking if "C99 snprintf" runs: DID NOT COMPILE
2024-02-07 20:40:59 +01:00
Philip Withnall
8dee910d77 Merge branch 'th/meson-werror-fixes' into 'main'
[th/meson-werror-fixes] some fixes for meson detection failure with -Werror

See merge request GNOME/glib!3895
2024-02-07 14:26:30 +00:00
Thomas Haller
90817d0fab build: workaround meson's cc.has_member() causing compiler warning.
Otherwise, `CFLAGS='-Wall -Werror' meson build` fails with:

  ...
  #include <sys/stat.h>
          void bar(void) {
              struct stat foo;
              foo.st_mtim.tv_nsec;

          }
  -----------
  Command line: `cc /data/src/glib/build/meson-private/tmpbjjq3ikp/testfile.c -o /data/src/glib/build/meson-private/tmpbjjq3ikp/output.obj -c -O3 -Werror -Wall -D_FILE_OFFSET_BITS=64 -O0 -std=gnu99` -> 1
  stderr:
  /data/src/glib/build/meson-private/tmpbjjq3ikp/testfile.c: In function 'bar':
  /data/src/glib/build/meson-private/tmpbjjq3ikp/testfile.c:45:24: error: statement with no effect [-Werror=unused-value]
     45 |             foo.st_mtim.tv_nsec;
        |             ~~~~~~~~~~~^~~~~~~~
  cc1: all warnings being treated as errors
  -----------
  Checking whether type "struct stat" has member "st_mtim.tv_nsec" : NO
2024-02-07 14:46:51 +01:00
Thomas Haller
8ea0f7d045 build: fix detection of int64_t_typedef in meson build check
Otherwise, `CFLAGS='-Wall -Werror' meson build` fails with:

  Checking for size of "ssize_t" : 8
  Running compile:
  Working directory:  ./glib/build/meson-private/tmpgwlkasyk
  Code:
   #if defined(_AIX) && !defined(__GNUC__)
                      #pragma options langlvl=stdc99
                      #endif
                      #pragma GCC diagnostic error "-Wincompatible-pointer-types"
                      #include <stdint.h>
                      #include <stdio.h>
                      int main () {
                        int64_t i1 = 1;
                        long *i2 = &i1;
                        return 1;
                      }
  -----------
  Command line: `cc ./glib/build/meson-private/tmpgwlkasyk/testfile.c -o ./glib/build/meson-private/tmpgwlkasyk/output.obj -c -O3 -Werror -Wall -D_FILE_OFFSET_BITS=64 -O0 -std=gnu99` -> 1
  stderr:
  ./glib/build/meson-private/tmpgwlkasyk/testfile.c: In function 'main':
  ./glib/build/meson-private/tmpgwlkasyk/testfile.c:9:29: error: unused variable 'i2' [-Werror=unused-variable]
      9 |                       long *i2 = &i1;
        |                             ^~
  cc1: all warnings being treated as errors
2024-02-07 11:49:57 +01:00
Philip Withnall
9eeb8a87d3 glocalfile: Support statvfs.f_type
This is another way to get the file system type from `statvfs()`, newly
added in glibc 2.39
(https://lwn.net/ml/libc-alpha/38790850.J2Yia2DhmK@pinacolada/).

This hasn’t been tested with glibc 2.39 as I don’t have it, but the
change seems fairly straightforward.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2024-02-07 10:34:59 +00:00
Philip Withnall
3f4e6ddcd8 Merge branch 'thorough-tests-in-ci' into 'main'
build: Add thorough test setup

See merge request GNOME/glib!3838
2024-02-02 14:33:22 +00:00
Philip Withnall
5f12851312 Merge branch 'wip/oholy/libmnt_monitor' into 'main'
gunixmounts: Use libmnt_monitor API for monitoring

See merge request GNOME/glib!3845
2024-01-31 14:30:09 +00:00
Ondrej Holy
c7254fb3ad gunixmounts: Use mnt_monitor_veil_kernel option
The previous commit enabled the `/run/mount/utab` monitoring. The problem
is that the `mount-changed` signal can be emitted twice for one mount. One
for the `/proc/mounts` file change and another one for the `/run/media/utab`
file change. This is still not ideal because e.g. the `GMount` objects for
mounts with the `x-gvfs-hide` option are added and immediately removed.
Let's enable the `mnt_monitor_veil_kernel` option to avoid this.

Related: https://github.com/util-linux/util-linux/pull/2725
2024-01-31 14:53:42 +01:00
Evan Welsh
f75221c7ea girepository: Move GIR generation into girepository and prior to tests
To enable tests which depend on libgirepository's GIR and typelib,
we need to refactor the order we're currently building these items.

We can also move everything under girepository/ to cleanup the
top-level.
2024-01-30 00:50:40 -06:00
Philip Withnall
143cb92c35
2.79.1
Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2024-01-22 14:30:24 +00:00
Philip Withnall
eb19551ebe build: Add thorough test setup
This allows the tests to be run with `meson test --setup thorough` and
it will run all the GTest tests with `-m thorough`.

Since this argument isn’t supported by the Python tests, it’s not passed
to them.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2024-01-18 17:22:09 +00:00
Yegor Yefremov
c8437611f0 gmessages: add syslog support
Introduce g_log_writer_syslog() that is suitable for use as a
GLogWriterFunc and sends the log message to the syslog daemon.

Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com>
2024-01-05 21:39:25 +01:00
Michael Catanzaro
686ab492cf Merge branch 'g_get_num_processors-affinity-fix' into 'main'
Account for cpu affinity in g_get_num_processors

Closes #1010

See merge request GNOME/glib!3784
2023-12-22 16:11:46 +00:00
Kryggird
09de26185e Account for cpu affinity in g_get_num_processors 2023-12-22 16:11:45 +00:00
Philip Withnall
ec3fb9a48c Merge branch 'glib-gir-sources' into 'main'
gobject: Make GLib-2.0 gir build depend on GObject dependency

See merge request GNOME/glib!3772
2023-12-22 14:45:37 +00:00
Philip Withnall
031e65808d docs: Port the man pages from DocBook to reStructuredText
So they are consistent with the way we’re building man pages in other
projects, and because some people are allergic to XML.

This changes the build-time dependencies from `xsltproc` to `rst2man`,
and also takes the opportunity to change the `-Dman` Meson option from a
boolean to a feature (so you should use `-Dman-pages={enabled,disabled}`
now, rather than `-Dman={true,false}`).

Signed-off-by: Philip Withnall <pwithnall@gnome.org>

Helps: #3037
2023-12-21 13:34:48 +00:00
Colomban Wendling
7e9f2dadc6 Fix detecting size_t size when -Wmissing-prototypes is in CFLAGS
As this test includes `-Werror`, we need to be extra careful in which
warnings this code could trigger.
2023-12-20 21:41:33 +01:00
Marco Trevisan (Treviño)
9c4ff01feb build: Move gir generation to an introspection folder
Generating gir and typelib files has inter-dependencies that may depend
on other elements.

For example, glib requires gobject and gdump generated files require
gmodule, so we've a cyclic dependency because gmodule requires gobject,
that requires glib.

To prevent this, let's just generate the introspection files at once in
a different meson file so that we don't have to deal with this.

As per this we could even revert commit fa37ab6d0 since gio is now
compiled before the gir files.
2023-12-20 21:35:53 +01:00
Khalid Abu Shawarib
fc6f06127c build: Make packaging module required
Python module packaging is required since https://gitlab.gnome.org/GNOME/glib/-/merge_requests/3740,
so mark it as dependency in meson.
2023-12-11 01:06:15 +03:00
Philip Withnall
c40fa821b8 Merge branch 'python3.12-remove-distutils' into 'main'
Switch from the Python distutils module to the packaging module

Closes #3134

See merge request GNOME/glib!3740
2023-12-05 15:50:15 +00:00
Jordan Williams
9cd7cccdd3
Increase required Python version to 3.7
This version of Python supports the packaging module.
2023-12-01 09:51:15 -06:00
Philip Withnall
e8edaeeb87 build: Rename -Dgtk_doc option to -Ddocumentation
Because the documentation is no longer built using gtk-doc.

Keep the old option around, but deprecated.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>

Helps: #3037
2023-11-29 10:26:37 +00:00
Philip Withnall
4b8bbd6f33 meson: Fail configure if nl_langinfo() supports a weird set of options
The `#include <langinfo.h>` in `gdatetime.c` is currently predicated on
`HAVE_LANGINFO_TIME`, but it’s needed for all the `HAVE_LANGINFO_*`
features.

It seems the code implicitly assumes that `HAVE_LANGINFO_TIME` will be
true if any other `HAVE_LANGINFO_*` macros are true. While I haven’t
seen this assumption be broken in practice, it seems prudent to
explicitly encode that in the configure tests. It’s easy enough to do.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2023-11-28 23:56:22 +00:00