Commit Graph

528 Commits

Author SHA1 Message Date
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
Philip Withnall
8ee00cbad8 gdatetime: Disable ERA support on platforms which don’t support this
So far, that’s BSD: it supports `nl_langinfo()`, but not `ERA`.

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

Helps: #3119
2023-11-28 23:56:22 +00:00
Philip Withnall
df4aea7620 gdatetime: Add support for %E modifier to g_date_time_format()
The `%E` modifier causes dates to be formatted using an alternative era
representation for years. This doesn’t do anything for most dates, but
in locales such as Thai and Japanese it causes years to be printed using
era names.

In Thai, this means the Thai solar calendar
(https://en.wikipedia.org/wiki/Thai_solar_calendar). In Japanese, this
means Japanese era names
(https://en.wikipedia.org/wiki/Japanese_era_name).

The `%E` modifier syntax follows what’s supported in glibc — see
nl_langinfo(3).

Supporting this is quite involved, as it means loading the `ERA`
description from libc and parsing it.

Unit tests are included.

Signed-off-by: Philip Withnall <philip@tecnocode.co.uk>

Fixes: #3119
2023-11-28 19:32:02 +00:00
Philip Withnall
a8df4183e4 tests: Fix fileutils build on FreeBSD and macOS
The test needs to call `ftruncate64()` (not `ftruncate()`) to guarantee
it’s using the 64-bit version on Linux, but this doesn’t exist on other
platforms.

Test to see if it exists and, if not, skip the test.

Fixes commit cf5e371c67, and fixes CI
failures like https://gitlab.gnome.org/GNOME/glib/-/pipelines/602930.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2023-11-26 22:10:22 +00:00
Pablo Correa Gómez
8901ffeffe
ci: add muslc CI 2023-11-12 15:39:14 +01:00
Philip Withnall
342b654e35 Merge branch 'main' into 'ebassi/girepository'
This needs to be done as a merge rather than a rebase because !3642 cannot be rebased.

Conflicts:
  meson_options.txt
2023-11-08 11:54:28 +00:00
CaiJingLong
7b80f73d29 fix: about libproc.h and PROC_PIDLISTFD_SIZE 2023-11-06 14:46:52 +00:00
Alessandro Bono
168de73a73 meson: Improve PTRACE_O_EXITKILL presence check
The PTRACE_O_EXITKILL symbol in sys/ptrace.h is an enum member, not
a macro. The #ifdef check added to the GSubprocess test-case in
272ec5dbca will not detect it.

Use cc.has_header_symbol() to properly detect it. According to the
documentation: "Symbols here include function, variable, #define,
type definition, etc.".

Fixes: 272ec5dbca
Closes: https://gitlab.gnome.org/GNOME/glib/-/issues/3156
2023-10-26 10:54:34 +02:00
Philip Withnall
24a3e728ce build: Bump Meson dependency to 1.2.0
And update all the CI builds to use the latest micro release from that
series, 1.2.3.

This version bump means we can:
 - Drop some backwards-compatibility Meson checks
 - Fix a periodic CI failure caused by a now-fixed Meson bug
   (https://github.com/mesonbuild/meson/pull/10633)

It’s in line with our [Meson version policy](./docs/meson-version.md),
as Meson 1.2.1 is available in
[Debian Trixie](https://packages.debian.org/source/trixie/meson) and the
[freedesktop SDK](c95902f2ed/elements/components/meson.bst).

Signed-off-by: Philip Withnall <philip@tecnocode.co.uk>
2023-10-24 17:00:24 +01:00
Emmanuele Bassi
fe32c3f5c5 Generate introspection data
Currently, the introspection data for GLib and its sub-libraries is
generated by gobject-introspection, to avoid the cyclic dependency
between the two projects.

Since gobject-introspection is generally available on installed systems,
we can check for its presence, and generate the introspection data
directly from GLib.

This does introduce a cyclic dependency, which is why it's possible to
build GLib without introspection, then build gobject-introspection, and
finally rebuild GLib.

By having introspection data available during the GLib build, we can do
things like generating documentation; validating newly added API; and
close the loop between adding new API and it becoming available to non-C
consumers of the C ABI (i.e. language bindings).
2023-10-23 11:26:53 +01:00
Emmanuele Bassi
af36393e60 Build libgirepository as a GLib sub-library
The introspection API has lived out of tree far too long. It has the
same ABI guarantees as the rest of GLib, so it has no reason to be split
from the main library.

The gobject-introspection project can depend on libgirepository, and the
language bindings can drop the gobject-introspection-1.0 dependency.
2023-10-16 15:24:08 +01:00
Luca Bacci
337912072a Windows: Compile with the UNICODE / _UNICODE macros
It's the recommended way to build C/C++ projects on Windows, see
https://learn.microsoft.com/en-us/windows/win32/intl/conventions-for-function-prototypes
2023-10-12 11:32:03 +02:00
Philip Withnall
260b5003c6 build: Post-release version bump
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2023-10-03 10:21:56 +01:00
Benjamin Gilbert
34e457e9f1 meson: Fix Windows build with PCRE2 as sibling subproject
If glib and PCRE2 are both built for Windows as subprojects of a parent
project, cc.links() will fail because PCRE2 hasn't been built yet when
glib is being configured:

    subprojects/glib-2.78.0/meson.build:2109:20: ERROR: Dependencies must be external dependencies

609d58beea changed the detection logic to avoid cc.links() in this
case, but dd5683ce64 broke it again.  PCRE2 detection could use a
broader cleanup, but for now, make the minimum change to fix this case.

use_pcre2_static_flag ends up set to false, matching the behavior of
609d58beea.

Fixes: dd5683ce64 ("meson: Allow fallback & static build of pcre subproject")
2023-10-01 23:06:49 -05:00
Philip Withnall
3c543ef69f
2.78.0
Signed-off-by: Philip Withnall <philip@tecnocode.co.uk>
2023-09-08 14:42:18 +01:00
Philip Withnall
aa2e243dbf
2.77.3
Signed-off-by: Philip Withnall <philip@tecnocode.co.uk>
2023-08-31 11:23:47 +01:00
Philip Withnall
c00d7999b1 Merge branch 'th/use-getservbyname-r' into 'main'
gnetworkaddress: use reentrant getservbyname_r() if available

See merge request GNOME/glib!3526
2023-08-14 09:24:51 +00:00
Thomas Haller
f738c7f3db gio: use reentrant getservbyname_r() if available 2023-08-14 09:32:43 +01:00
Marc-André Lureau
4dde72e038 meson: warn if -mms-bitfields is necessary
GCC >= 4.7 and clang >= 12 don't need it. It should be left to the user
to decide what ABI convention should be used, and it creates some issues
with some tools to have this flag in cflags.

We leave the flag for now, but print a warning at compile time so people
get a chance to change their build system before we drop it from glib.pc

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2023-08-13 16:13:21 +04:00
Philip Withnall
1e8d310e6e
2.77.2
Signed-off-by: Philip Withnall <philip@tecnocode.co.uk>
2023-08-12 23:38:03 +01:00
Philip Withnall
e1f4c5806f
2.77.1
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2023-07-30 20:44:31 +03:00
Philip Withnall
627dc1415c Revert "build-sys: drop -mms-bitfields GCC flag"
This reverts commit 252bbcd207.

After further discussion in !3511, we’ve decided that there are risks
associated with this change, and it’s not the best way of addressing the
original problem.

The original motivation for the change turned out to be that
`-mms-bitfields` was not handled by `windres`, which was receiving it
from `pkg-config --cflags glib-2.0` in some projects. However, if
`windres` is claiming to accept CFLAGS then it should accept (and
ignore) `-mms-bitfields`, since the `-m` family of options are defined
in `man gcc`, just like `-I`, `-D`, etc.

There is some question that there might still be third party projects
which are built with an old enough compiler that `-mms-bitfields` is not
the compiler default. For that reason, we should either still continue
to specify `-mms-bitfields` in the `.pc` file, or add a test to assert
that third party projects are always compiled with `-mms-bitfields` set.
But adding a new test for all third-party compilations is risky (if we
get it wrong, things will break; and it’s a test which may behave
differently on different platforms), so it seems safer to just keep
`-mms-bitfields` in `.pc` for now.

Once all compilers which we require specify `-mms-bitfields` by default,
we can finally drop this flag (without adding a test for third-party
compilations).

See: https://gitlab.gnome.org/GNOME/glib/-/merge_requests/3511
2023-07-29 11:54:22 +03:00
Simon McVittie
71d44e8d71 testutils: Use prctl PR_SET_DUMPABLE to silence core dumps on Linux
Otherwise, crashing tests like assert-msg-test will still report to
pipe-based crash reporting frameworks like systemd-coredump, even though
the RLIMIT_CORE limit is zero.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2023-07-26 15:42:06 +01:00
Philip Withnall
e051f4abaf Merge branch 'win32' into 'main'
build-sys: drop -mms-bitfields GCC flag

See merge request GNOME/glib!3509
2023-07-24 15:52:10 +00:00
Marc-André Lureau
252bbcd207 build-sys: drop -mms-bitfields GCC flag
This flag is problematic for some usages, and is no longer needed since
~2012 GCC 4.7 (https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=a6c467624ade35128)

It is dropped from MINGW since:
https://github.com/msys2/MINGW-packages/pull/12891

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2023-07-24 14:45:09 +04:00
Philip Withnall
3ab16a0d18 Merge branch 'libintl_fallback' into 'main'
meson: Allow forcing fallback for libintl

Closes #3048

See merge request GNOME/glib!3497
2023-07-21 16:44:56 +00:00
Michael Catanzaro
a552bf5694 Merge branch 'revert3356' into 'main'
Revert "build/gmodule-2.0.pc: Move compiler flags from Libs to Cflags"

See merge request GNOME/glib!3504
2023-07-20 15:20:58 +00:00
Andoni Morales Alastruey
dc37ca70fe meson: help gobject-introspection locate source and build dirs
gobject-introspection is currently assuming glib subproject
is in unversioned, but gstreamer uses a versioned directory, eg:
subprojects/glib-2.74.1 instead of subprojects/glib
2023-07-20 10:49:26 +02:00
Harald van Dijk
6e29fbec2d
Revert "build/gmodule-2.0.pc: Move compiler flags from Libs to Cflags"
This reverts commit 004f48f4fc.

Per the discussion on #3356, this change was prompted by a
misunderstanding of ldflags/link_args, and it resulted in various other
packages using glib no longer getting symbols exported. This commit
restores the glib 2.76 behaviour.
2023-07-18 18:26:49 +01:00
Brendan Shanks
d0862c3692 meson: Allow forcing fallback for libintl
Closes #3048
2023-07-13 10:02:04 -07:00
Marius Kintel
0ae1b57ae4 Link with -framework Foundation and -framework AppKit to correctly link libiconv on macOS 2023-06-28 21:10:03 -04:00
Philip Withnall
d3fbb6e0fc Merge branch 'meson-intl-iconv-lookup' into 'main'
meson: try iconv in libintl lookup

See merge request GNOME/glib!3448
2023-06-28 14:48:19 +00:00
Marius Kintel
dd5683ce64 meson: Allow fallback & static build of pcre subproject
Using `allow_fallback: false` on the first check for libpcre
was unnecessary, as `required: false` already disables using
fallbacks. `allow_fallback: false` meant that
`--force-fallback-for` couldn’t work. This commit fixes that.

Also allow the fallback libpcre to be built statically so it
can be linked into GLib.

Helps: #3025
2023-06-28 14:38:36 +00:00
Jan200101
a497d5be12 meson: try iconv in libintl lookup
This was originally removed in !2734 but still appears to be required for
some MinGW setups, such as the `x86_64-w64-mingw32.static` target in
[mxe](https://github.com/mxe/mxe).

Currently, this configuration fails the libintl internal assert on line
2128, as on this platform `ngettext()` is only found inside libiconv.

This commit will look up iconv potentially twice, once as `libiconv` and
potentially once as `libintl_iconv`. This is what the code did before
!2734 landed, so it’s known to work reliably on a number of platforms.
2023-06-28 15:22:36 +01:00
Philip Withnall
c0bdc61879 meson: Export HAVE_FREE_SIZED in glibconfig.h for use in g_free()
This allows the `g_free()` wrapper introduced in the previous commit to
only be defined if `free_sized()` is actually available to improve
performance.

This avoids passing an allocation size to every `g_free()` call if it’s
not going to be used, saving a register store instruction each time.

Suggested by Marco Trevisan in
https://gitlab.gnome.org/GNOME/glib/-/merge_requests/3252#note_1660032

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2023-05-30 13:45:05 +01:00
Philip Withnall
e02fa2ec90 gfile: Ensure loff_t is defined on FreeBSD
When `copy_file_range()` support was added, I used the definition of
`copy_file_range()` from Linux, which uses `loff_t` to abstract the
different `off*_t` types.

`loff_t` doesn’t exist on FreeBSD, so this doesn’t compile, and was
caught in subsequent asynchronous CI.

Define `loff_t` with a fallback value if it’s not defined, which should
fix this and other uses of `loff_t` in `gfile.c` (for example, if
FreeBSD ever starts declaring `splice()`).

Fixes this CI failure: https://gitlab.gnome.org/GNOME/glib/-/jobs/2812302

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2023-05-15 16:22:35 +01:00
Philip Withnall
20964ad4ab Merge branch '2863-copy-file-range' into 'main'
gfile: Support copy_file_range() for file copies

Closes #2863

See merge request GNOME/glib!3328
2023-05-09 14:08:18 +00:00
Philip Withnall
0e5d9fd249 gfile: Support copy_file_range() for file copies
While it can’t be used in all situations, it is a little bit faster than
`splice()` in some situations, basically if the file system supports
copy on write. In other situations it’s no slower than `splice()`.

See `man copy_file_range` for the situations where it doesn’t work. In
all of these situations, it will return an error, and the GLib code will
fall through and try the existing `splice()` copy code instead.

From my testing of `time gio copy A B` with a 9GB file, the `splice()`
code path takes 22s, and the `copy_file_range()` code path takes 20s.

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

Fixes: #2863
2023-05-09 14:01:50 +01:00
Samuel Thibault
81d729dc53 Check for linux/netlink.h buildability
When cross-building with a non-Linux target, linux/netlink.h will not
actually be buildable, even if distributions typically put it in
/usr/include and thus exposed to the cross-compiler.
2023-05-09 13:31:28 +01:00