Commit Graph

26351 Commits

Author SHA1 Message Date
Michael Catanzaro
61a843564d Improve default value of glib_debug option
glib_debug is an auto option. This is clever because it allows us to
guess the best default based on the build type, while also allowing an
easy way to override if the guess is not good. Sadly, the attempt to
guess based on the build type does not work well. For example, it
considers debugoptimized builds to be debug builds, but despite the
name, it is definitely a release build type (except on Windows, which
we'll ignore here). The minsize build type has the exact same problem.
The debug option is true for both build types, but this only controls
whether debuginfo is enabled, not whether debug extras are enabled.

The plain build type has a different problem: debug is off, but the
optimization option is off too, even though plain builds are distro
builds are will almost always use optimization.

I've outlined an argument for why we should make these changes here:
https://blogs.gnome.org/mcatanzaro/2022/07/15/best-practices-for-build-options/

Specifically, Rule 4 shows all the build types and whether they
correspond to release builds or debug builds. Rule 6 argues that we
should provide good defaults for plain builds.
2022-08-03 17:07:13 -05:00
Michael Catanzaro
b8e1ecdd6b Automatically disable cast checks when building with optimization
Cast checks are slow. We seem to have some rough consensus that they are
important for debug builds, but not for release builds. Problem is, very
few apps define G_DISABLE_CAST_CHECKS for release builds. Worse, it's
undocumented, so there's no way apps could even be expected to know
about it.

We can get the right default is almost all situations by making this
depend on the __OPTIMIZE__ preprocessor definition. This is a GCC-specific
thing, although Clang supports it too. If the compiler does not define
__OPTIMIZE__, then this commit does no harm: you can still use
G_DISABLE_CAST_CHECKS as before. When checking __OPTIMIZE__, we are
supposed to ensure our code has the same behavior as it would if we do
not, which will be true except in case the check fails (which is
programmer error).

Downside: this will not automatically do the right thing with -Og,
because __OPTIMIZE__ is always defined to 1. We don't want to disable
cast checks automatically if using -O0 or -Og. There's no way to
automatically fix this, but we can create an escape hatch by allowing
you to define G_DISABLE_CAST_CHECKS=0 to force-enable cast checks. In
practice, I don't think this matters much because -Og kinda failed:
GCC's man page says it should be a superior debugging experience to -O0,
but it optimizes variables away so it's definitely not.

Another downside: this is bad if you really *do* want cast checks in
release builds. The same solution applies: define
G_DISABLE_CAST_CHECKS=0 and you'll get your cast checks.
2022-08-03 16:18:17 -05:00
Luca Bacci
cdb8e5e9c5 Fix warnings in GCancellable test 2022-08-03 20:38:59 +02:00
Luca Bacci
a1737ece06 Fix GCancellable tests for Windows 64bit
Fixes https://gitlab.gnome.org/GNOME/glib/-/issues/2703
2022-08-03 20:33:46 +02:00
Hugo Carvalho
08715a4cd1 Update Portuguese translation 2022-08-03 09:52:51 +00:00
Luca Bacci
bf028b9176 Merge branch 'protect-calls-to-msvcrt-wspawne-with-a-mutex' into 'main'
GSpawn/Win32: Provide thread-safe wrappers for _wspawn*e functions

Closes #2509

See merge request GNOME/glib!2843
2022-08-03 04:49:50 +00:00
Emmanuele Bassi
ab189ecfed Merge branch 'wip/chergert/fix-2708' into 'main'
gmain: close pidfd when finalizing GChildWatchSource

Closes #2708

See merge request GNOME/glib!2847
2022-08-02 19:53:44 +00:00
Christian Hergert
b62745fe8e gmain: close pidfd when finalizing GChildWatchSource
A file-descriptor was created with the introduction of pidfd_getfd() but
nothing is closing it when the source finalizes. The GChildWatchSource is
the creator and consumer of this FD and therefore responsible for closing
it on finalization.

The pidfd leak was introduced in !2408.

This fixes issues with Builder where anon_inode:[pidfd] exhaust the
available FD limit for the process.

Fixes #2708
2022-08-02 12:35:56 -07:00
Luca Bacci
477ff949e1 gspawn-win32: Provide thread-safe wrappers for _wspawn*e functions
_wspawn*e functions are not thread safe on the MSVCRT.dll and
the pre-2015 MSVC runtime DLLs (msvcrXXX.dll).
2022-08-02 18:47:05 +02:00
Luca Bacci
0cb43a4965 Merge branch 'g-win32-app-info-launched-signal-actually-report-pid' into 'main'
GWin32AppInfo: Fix PID reporting in launched signal

See merge request GNOME/glib!2299
2022-08-02 14:51:26 +00:00
Luca Bacci
45bdeeddff GWin32AppInfo: Actually report the GPid in the GAppLaunchContext::launched signal
We need to pass the G_SPAWN_DO_NOT_REAP_CHILD flag to g_spawn_async,
otherwise the returned child_pid will always be 0.
2022-08-02 16:38:32 +02:00
Yuri Chornoivan
ba5e403785 Update Ukrainian translation 2022-08-02 11:40:13 +00:00
Marco Trevisan
14736065c8 Merge branch 'ebassi/resource-no-display-name' into 'main'
Implement GFileIface.set_display_name() for resource files

Closes #2705

See merge request GNOME/glib!2844
2022-08-01 22:52:32 +00:00
Aleksandr Melman
985ffc3b4e Update Russian translation 2022-08-01 13:10:46 +00:00
codeboybebop
ece66f11fc gio-tool: -d option to delete attribute
gio tool has support for deleting attributes of the file. To delete attribute user
should specify type '--type="unset"'. This is not mentioned in help and therefore not
intuitive. By adding '-d' option, we make this process more obvious.

closes #2588
2022-07-31 13:19:50 -05:00
Asier Sarasua Garmendia
ecdbe3c324 Update Basque translation 2022-07-31 16:51:52 +00:00
Emmanuele Bassi
a9394bd68e Implement GFileIface.set_display_name() for resource files
Resource files cannot be renamed, and GFileIface.set_display_name() is
mandatory.

Fixes: #2705
2022-07-30 20:06:07 +01:00
Nart Tlisha
a775578b96 Update Abkhazian translation 2022-07-28 19:23:21 +00:00
Zurab Kargareteli
dea174ec67 Update Georgian translation 2022-07-28 19:14:24 +00:00
Yuri Chornoivan
9bc9a9b62a Update Ukrainian translation 2022-07-26 20:03:24 +00:00
Emmanuele Bassi
7eb791db52 Merge branch 's390x-gregex-prce2-fix' into 'main'
gregex: use correct size for pcre2_pattern_info

Closes #2699

See merge request GNOME/glib!2840
2022-07-26 15:38:21 +00:00
Hugo Carvalho
5121b9882b Update Portuguese translation 2022-07-26 14:00:48 +00:00
Hugo Carvalho
bb0f0734e5 Update Portuguese translation 2022-07-26 13:58:07 +00:00
Mamoru TASAKA
710ccee65c gregex: use correct size for pcre2_pattern_info
man pcre2_pattern_info says that the 3rd argument must
point to uint32_t variable (except for some 2nd argument value),
so correctly use it. Especially using wrong size can cause
unexpected result on big endian.

closes: #2699
2022-07-26 21:51:45 +09:00
Philip Withnall
2b21a30a59 Merge branch 'main' into 'main'
Implement xattr attribute removal

Closes #1187

See merge request GNOME/glib!2831
2022-07-26 07:58:32 +00:00
madmurphy
b295c53769 gfileinfo: Implement xattr attribute removal
Fixes: #1187
2022-07-26 07:58:32 +00:00
Emmanuele Bassi
f839eae274 Merge branch 'ebassi/application-flags' into 'main'
Introduce G_APPLICATION_DEFAULT_FLAGS

See merge request GNOME/glib!2835
2022-07-25 22:44:37 +00:00
Emmanuele Bassi
8f68c1e646 Rename G_MARKUP_PARSE_FLAGS_NONE
The prefix for GMarkupParseFlags enumeration members is G_MARKUP; this
means that G_MARKUP_PARSE_FLAGS_NONE gets split into
GLib.MarkupParseFlags.PARSE_FLAGS_NONE by the introspection scanner.

The `/*< nick=none >*/` trigraph attribute is a glib-mkenum thing, and
does not affect the introspection scanner; it would also only affect the
GEnumValue nickname, which is not used by language bindings to resolve
the name of the enumeration member. Plus, GMarkupParseFlags does not
have a corresponding GType anyway.
2022-07-25 22:30:22 +01:00
Emmanuele Bassi
aa65fc2537 Rename G_TLS_CERTIFICATE_FLAGS_NONE
The prefix is G_TLS_CERTIFICATE, not G_TLS_CERTIFICATE_FLAGS. Having
G_TLS_CERTIFICATE_FLAGS_NONE leads to a FLAGS_NONE nick in the GType,
and a FLAGS_NONE member name in the introspection data.
2022-07-25 22:30:22 +01:00
Emmanuele Bassi
09234b50fe Introduce G_APPLICATION_DEFAULT_FLAGS
Enumeration members should either have the name of the type as their
prefix, or they should all have the same prefix.

The "default flags" enumeration member for GApplicationFlags is
unfortunately named G_APPLICATION_FLAGS_NONE, while every other member
of the same type has a G_APPLICATION prefix. The result is that the nick
name of the enumeration member is "flags-none", and that language
bindings will have to use something like
Gio.ApplicationFlags.FLAGS_NONE.

To fix this API wart, we can deprecate the FLAGS_NONE member, and add a
new DEFAULT_FLAGS.
2022-07-25 22:30:22 +01:00
Philip Withnall
6629948adc Merge branch 'rybalkin-gregex-remove-match-context-limits' into 'main'
gregex: do not set match and recursion limits on match context

Closes #2700

See merge request GNOME/glib!2838
2022-07-25 16:35:23 +00:00
Aleksei Rybalkin
a2b5b9e906 gregex: add original test case for issue #2700 2022-07-25 16:57:06 +02:00
Aleksei Rybalkin
6535c77b00 gregex: do not set match and recursion limits on match context
These are not really necessary, and cause breakages (e.g. #2700).
pcre2_set_recursion_limit is also deprecated.

Fixes: #2700
2022-07-25 16:48:03 +02:00
Nart Tlisha
68a6628ffa Add Abkhazian translation 2022-07-25 13:55:56 +00:00
Aleksandr Melman
2292a23f62 Update Russian translation 2022-07-25 13:22:20 +00:00
Philip Withnall
f2aeba9a08 Merge branch 'wip/smcv/gio-launch-desktop-sd-journal' into 'main'
gio-launch-desktop: Only replace fds that point to the Journal

See merge request GNOME/glib!2836
2022-07-25 10:15:20 +00:00
Simon McVittie
94e05f7f28 gio-launch-desktop: Only replace fds that point to the Journal
If stdout is the Journal but stderr is not, then we probably only want
to redirect stdout, or vice versa.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-07-25 10:21:35 +01:00
Philip Withnall
30c840a755 Merge branch 'wip/smcv/gio-launch-desktop-sd-journal' into 'main'
Bring back gio-launch-desktop, use it to redirect stdout/stderr to the Journal

Closes #2682

See merge request GNOME/glib!2819
2022-07-24 23:31:27 +00:00
Philip Withnall
9c1b2399ec Merge branch 'iss2542' into 'main'
gio-tool: Flatten the outputed string

Closes #2542

See merge request GNOME/glib!2834
2022-07-24 23:13:06 +00:00
Simon McVittie
f736414825 gio-launch-desktop: Don't alter stdout/stderr if not already the Journal
Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-07-25 01:00:54 +02:00
Simon McVittie
6c3e52bb1d gmessages: Factor out _g_fd_is_journal into its own translation unit
I want to use this in gio-launch-desktop, but gio-launch-desktop
doesn't depend on GLib, so I can't just call g_log_writer_is_journald().

Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-07-25 01:00:54 +02:00
Simon McVittie
763643ceaa gio-launch-desktop: Redirect stdout, stderr to systemd Journal
This prevents a launched process's output from being mixed up with the
output of the parent process, which can lead to the wrong program being
blamed for warning messages.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-07-25 01:00:54 +02:00
Simon McVittie
ae15c800ce Install gio-launch-desktop in a non-PATH location
This is an internal helper executable, which users shouldn't invoke
directly (see glib#1633).

When building for a single-architecture distribution, we can install
it as ${libexecdir}/gio-launch-desktop.

When building for a multiarch distribution, installing it into an
architecture-specific location and packaging it alongside the GLib
library avoids the problem discussed in glib#1633 where it would either
cause a circular dependency between the GLib library and a common
cross-architecture package (libglib2.0-bin in Debian), or require a
separate package just to contain gio-launch-desktop, or cause different
architectures' copies to overwrite each other.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-07-25 01:00:53 +02:00
Simon McVittie
8157668eac gdesktopappinfo: Don't trust $GIO_LAUNCH_DESKTOP if setuid
gio-launch-desktop was removed before checking GIO for potentially
unsafe environment variable references, so reverting its removal brought
this one back. If a setuid program is using GAppInfo then something is
probably already horribly wrong, but let's be careful anyway.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-07-25 01:00:53 +02:00
Simon McVittie
e4e21f20e2 gio-launch-desktop: Fix a compiler warning
Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-07-25 01:00:53 +02:00
Simon McVittie
6620d28333 gio-launch-desktop: Add SPDX-License-Identifier
Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-07-25 01:00:53 +02:00
Simon McVittie
6751392934 tests: Avoid using deprecated meson.build_root
Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-07-25 01:00:53 +02:00
Simon McVittie
d0967c1d4a Revert "gdesktopappinfo: Use sh rather than gio-launch-desktop"
A shell one-liner was enough to set GIO_LAUNCHED_DESKTOP_FILE_PID,
but ideally we also want to do the equivalent of sd_journal_stream_fd()
to set up its standard output and standard error streams.

Ideally we would call sd_journal_stream_fd() in a process that will
exec the real program, otherwise it will report the wrong process ID
in the Journal, but we can't easily do that in a forked child when
using posix_spawn() for subprocesses.

This reverts commit 2b533ca99a.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-07-25 01:00:53 +02:00
Philip Withnall
206be0a8a1 Merge branch 'wip/smcv/multiarch-triggers' into 'main'
gio: Optionally install trigger executables to architecture-specific paths

See merge request GNOME/glib!2818
2022-07-24 22:57:34 +00:00
Philip Withnall
196e3605aa Merge branch 'wip/smcv/gdbus-cross-namespace' into 'main'
GDBus: Use namespace-friendly protocol for Linux message buses, and optionally other connections

See merge request GNOME/glib!2832
2022-07-24 22:55:08 +00:00