• Re: [gentoo-dev] [PATCH 1/5] gui-libs/gtk: add a "poison" macro support

    From Sam James@21:1/5 to Eli Schwartz on Wed Jun 26 11:10:02 2024
    Eli Schwartz <eschwartz93@gmail.com> writes:

    Many packages perform automagic dependencies on gdk's backend
    implementations by checking if the macro is defined and then using the
    code it unlocks, rather than having a buildsystem option such as -Dwayland=true.

    Doesn't gtk3 need this too? Also, could we have an upstream report
    making them aware of this for gtk4?

    It's unfeasible to patch every such package's source code to add
    configure options and respect them. Instead add a truly filthy hack and permit gtk itself to selectively show or hide the windowing system in
    use.

    Bug: https://bugs.gentoo.org/624960
    Signed-off-by: Eli Schwartz <eschwartz93@gmail.com>
    ---
    ...-poison-macro-to-hide-GDK_WINDOWING_.patch | 25 ++++++++++---------
    gui-libs/gtk/gtk-4.12.5-r1.ebuild | 7 ++++++
    ...-4.12.5-r1.ebuild => gtk-4.12.5-r2.ebuild} | 9 ++++++-
    ...gtk-4.14.4.ebuild => gtk-4.14.3-r1.ebuild} | 7 ++++++
    ...gtk-4.14.3.ebuild => gtk-4.14.4-r1.ebuild} | 7 ++++++
    5 files changed, 42 insertions(+), 13 deletions(-)
    copy {x11-libs/gtk+ => gui-libs/gtk}/files/0001-gdk-add-a-poison-macro-to-hide-GDK_WINDOWING_.patch (86%)
    copy gui-libs/gtk/{gtk-4.12.5-r1.ebuild => gtk-4.12.5-r2.ebuild} (94%)
    rename gui-libs/gtk/{gtk-4.14.4.ebuild => gtk-4.14.3-r1.ebuild} (96%)
    rename gui-libs/gtk/{gtk-4.14.3.ebuild => gtk-4.14.4-r1.ebuild} (96%)

    diff --git a/x11-libs/gtk+/files/0001-gdk-add-a-poison-macro-to-hide-GDK_WINDOWING_.patch b/gui-libs/gtk/files/0001-gdk-add-a-poison-macro-to-hide-GDK_WINDOWING_.patch
    similarity index 86%
    copy from x11-libs/gtk+/files/0001-gdk-add-a-poison-macro-to-hide-GDK_WINDOWING_.patch
    copy to gui-libs/gtk/files/0001-gdk-add-a-poison-macro-to-hide-GDK_WINDOWING_.patch
    index 9bba12f8445b..4e078610f8cb 100644
    --- a/x11-libs/gtk+/files/0001-gdk-add-a-poison-macro-to-hide-GDK_WINDOWING_.patch
    +++ b/gui-libs/gtk/files/0001-gdk-add-a-poison-macro-to-hide-GDK_WINDOWING_.patch
    @@ -1,4 +1,4 @@
    -From 25bdad805bb9e16032baf4480e9c1e432ddef49b Mon Sep 17 00:00:00 2001
    +From 0537043f72ea1a634b101efa9e11cc0a22baaf71 Mon Sep 17 00:00:00 2001
    From: Eli Schwartz <eschwartz93@gmail.com>
    Date: Wed, 19 Jun 2024 21:28:31 -0400
    Subject: [PATCH] gdk: add a "poison" macro to hide GDK_WINDOWING_*
    @@ -34,10 +34,10 @@ Signed-off-by: Eli Schwartz <eschwartz93@gmail.com>
    3 files changed, 15 insertions(+)

    diff --git a/gdk/gdkconfig.h.meson b/gdk/gdkconfig.h.meson
    -index 7db19e0470..6bee207e94 100644
    +index d5b48f3184..22baab52ae 100644
    --- a/gdk/gdkconfig.h.meson
    +++ b/gdk/gdkconfig.h.meson
    -@@ -10,9 +10,16 @@
    +@@ -10,10 +10,17 @@
    G_BEGIN_DECLS


    @@ -46,21 +46,22 @@ index 7db19e0470..6bee207e94 100644
    +#endif
    +
    #mesondefine GDK_WINDOWING_BROADWAY
    + #mesondefine GDK_WINDOWING_MACOS
    +
    +#ifndef GENTOO_GTK_HIDE_WAYLAND
    #mesondefine GDK_WINDOWING_WAYLAND
    +#endif
    +
    #mesondefine GDK_WINDOWING_WIN32
    - #mesondefine GDK_WINDOWING_QUARTZ

    + #mesondefine GDK_RENDERING_CAIRO
    diff --git a/gdk/wayland/gdkwayland.h b/gdk/wayland/gdkwayland.h
    -index 2b79295add..5f0e9cfa81 100644
    +index 846445910e..5d84619295 100644
    --- a/gdk/wayland/gdkwayland.h
    +++ b/gdk/wayland/gdkwayland.h
    -@@ -25,6 +25,10 @@
    - #ifndef __GDK_WAYLAND_H__
    - #define __GDK_WAYLAND_H__
    +@@ -24,6 +24,10 @@
    +
    + #pragma once

    +#ifdef GENTOO_GTK_HIDE_WAYLAND
    + #error "A Gentoo ebuild has hidden wayland and it cannot be used in this compilation unit. Please file a bug if you see this error."
    @@ -70,12 +71,12 @@ index 2b79295add..5f0e9cfa81 100644

    #define __GDKWAYLAND_H_INSIDE__
    diff --git a/gdk/x11/gdkx.h b/gdk/x11/gdkx.h
    -index 1f64bccb6d..256c83015e 100644
    +index 6bef6b6de8..d4f8b94550 100644
    --- a/gdk/x11/gdkx.h
    +++ b/gdk/x11/gdkx.h
    -@@ -25,6 +25,10 @@
    - #ifndef __GDK_X_H__
    - #define __GDK_X_H__
    +@@ -24,6 +24,10 @@
    +
    + #pragma once

    +#ifdef GENTOO_GTK_HIDE_X11
    + #error "A Gentoo ebuild has hidden x11 and it cannot be used in this compilation unit. Please file a bug if you see this error."
    diff --git a/gui-libs/gtk/gtk-4.12.5-r1.ebuild b/gui-libs/gtk/gtk-4.12.5-r1.ebuild
    index cd5ffd7bad88..aec0c8889e71 100644
    --- a/gui-libs/gtk/gtk-4.12.5-r1.ebuild
    +++ b/gui-libs/gtk/gtk-4.12.5-r1.ebuild
    @@ -100,6 +100,13 @@ BDEPEND="
    )
    "

    +PATCHES=(
    + # Gentoo-specific patch to add a "poison" macro support, allowing other ebuilds
    + # with USE="-wayland -X" to trick gtk into claiming that it wasn't built with
    + # such support.
    + "${FILESDIR}"/0001-gdk-add-a-poison-macro-to-hide-GDK_WINDOWING_.patch +)
    +
    python_check_deps() {
    python_has_version "dev-python/pygobject:3[${PYTHON_USEDEP}]" || return
    }
    diff --git a/gui-libs/gtk/gtk-4.12.5-r1.ebuild b/gui-libs/gtk/gtk-4.12.5-r2.ebuild
    similarity index 94%
    copy from gui-libs/gtk/gtk-4.12.5-r1.ebuild
    copy to gui-libs/gtk/gtk-4.12.5-r2.ebuild
    index cd5ffd7bad88..2b6fd10d8caa 100644
    --- a/gui-libs/gtk/gtk-4.12.5-r1.ebuild
    +++ b/gui-libs/gtk/gtk-4.12.5-r2.ebuild
    @@ -16,7 +16,7 @@ REQUIRED_USE="
    test? ( introspection )
    "

    -KEYWORDS="~alpha amd64 arm arm64 ~ia64 ~loong ppc ppc64 ~riscv sparc x86" +KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~ia64 ~loong ~ppc ~ppc64 ~riscv ~sparc ~x86"

    COMMON_DEPEND="
    >=dev-libs/glib-2.76.0:2
    @@ -100,6 +100,13 @@ BDEPEND="
    )
    "

    +PATCHES=(
    + # Gentoo-specific patch to add a "poison" macro support, allowing other ebuilds
    + # with USE="-wayland -X" to trick gtk into claiming that it wasn't built with
    + # such support.
    + "${FILESDIR}"/0001-gdk-add-a-poison-macro-to-hide-GDK_WINDOWING_.patch +)
    +
    python_check_deps() {
    python_has_version "dev-python/pygobject:3[${PYTHON_USEDEP}]" || return
    }
    diff --git a/gui-libs/gtk/gtk-4.14.4.ebuild b/gui-libs/gtk/gtk-4.14.3-r1.ebuild
    similarity index 96%
    rename from gui-libs/gtk/gtk-4.14.4.ebuild
    rename to gui-libs/gtk/gtk-4.14.3-r1.ebuild
    index 7f0c8930ab74..6bd05ace61ea 100644
    --- a/gui-libs/gtk/gtk-4.14.4.ebuild
    +++ b/gui-libs/gtk/gtk-4.14.3-r1.ebuild
    @@ -108,6 +108,13 @@ BDEPEND="
    )
    "

    +PATCHES=(
    + # Gentoo-specific patch to add a "poison" macro support, allowing other ebuilds
    + # with USE="-wayland -X" to trick gtk into claiming that it wasn't built with
    + # such support.
    + "${FILESDIR}"/0001-gdk-add-a-poison-macro-to-hide-GDK_WINDOWING_.patch +)
    +
    python_check_deps() {
    python_has_version "dev-python/pygobject:3[${PYTHON_USEDEP}]" || return
    }
    diff --git a/gui-libs/gtk/gtk-4.14.3.ebuild b/gui-libs/gtk/gtk-4.14.4-r1.ebuild
    similarity index 96%
    rename from gui-libs/gtk/gtk-4.14.3.ebuild
    rename to gui-libs/gtk/gtk-4.14.4-r1.ebuild
    index 7f0c8930ab74..6bd05ace61ea 100644
    --- a/gui-libs/gtk/gtk-4.14.3.ebuild
    +++ b/gui-libs/gtk/gtk-4.14.4-r1.ebuild
    @@ -108,6 +108,13 @@ BDEPEND="
    )
    "

    +PATCHES=(
    + # Gentoo-specific patch to add a "poison" macro support, allowing other ebuilds
    + # with USE="-wayland -X" to trick gtk into claiming that it wasn't built with
    + # such support.
    + "${FILESDIR}"/0001-gdk-add-a-poison-macro-to-hide-GDK_WINDOWING_.patch +)
    +
    python_check_deps() {
    python_has_version "dev-python/pygobject:3[${PYTHON_USEDEP}]" || return
    }

    --=-=-Content-Type: application/pgp-signature; name="signature.asc"

    -----BEGIN PGP SIGNATURE-----

    iOUEARYKAI0WIQQlpruI3Zt2TGtVQcJzhAn1IN+RkAUCZnvZVV8UgAAAAAAuAChp c3N1ZXItZnByQG5vdGF0aW9ucy5vcGVucGdwLmZpZnRoaG9yc2VtYW4ubmV0MjVB NkJCODhERDlCNzY0QzZCNTU0MUMyNzM4NDA5RjUyMERGOTE5MA8cc2FtQGdlbnRv by5vcmcACgkQc4QJ9SDfkZCPvQEArQn28el4YACPW5CxYnBEhduqnxEKybqWCv/f qedCsJsA/2P0+7ARwXm4DMUdzCd3sa5qigwmhH3Mcs0/8348fYIP
    =sgTz
    -----END PGP SIGNATURE-----

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Sam James@21:1/5 to Eli Schwartz on Thu Jun 27 07:00:01 2024
    Eli Schwartz <eschwartz93@gmail.com> writes:

    On 6/26/24 5:03 AM, Sam James wrote:
    Eli Schwartz <eschwartz93@gmail.com> writes:

    Many packages perform automagic dependencies on gdk's backend
    implementations by checking if the macro is defined and then using the
    code it unlocks, rather than having a buildsystem option such as
    -Dwayland=true.

    Doesn't gtk3 need this too? Also, could we have an upstream report
    making them aware of this for gtk4?


    Yes, gtk3 needs this too (and patches in this series depend on it).

    At https://github.com/gentoo/gentoo/pull/37259 there are 6 patches, not
    5 -- I appear to have accidentally excluded the first patch when sending
    it to the list, unsure how that happened. It's almost ccompletely
    copy/paste from gtk4.

    Thanks for clarifying - I was convinced I'd seen you show me it (I
    probably saw it on the branch) but I didn't think to check the PR.


    As far as reporting this upstream goes, I'm somewhat nervous they will suggest you should simply build against what you use and require what
    you build against. It's not a completely unreasonable suggestion, in
    fact it's the one I described as option 4 and Gentoo simply cannot use
    it today since it would require new EAPI.

    I tend to agree. I see this as kind of our fault / a Gentoo-ish problem.

    --=-=-Content-Type: application/pgp-signature; name="signature.asc"

    -----BEGIN PGP SIGNATURE-----

    iOUEARYKAI0WIQQlpruI3Zt2TGtVQcJzhAn1IN+RkAUCZnzxhl8UgAAAAAAuAChp c3N1ZXItZnByQG5vdGF0aW9ucy5vcGVucGdwLmZpZnRoaG9yc2VtYW4ubmV0MjVB NkJCODhERDlCNzY0QzZCNTU0MUMyNzM4NDA5RjUyMERGOTE5MA8cc2FtQGdlbnRv by5vcmcACgkQc4QJ9SDfkZDjLwD+Pw12PNCLXsRquNNnrKUyny6gDg/POmTQBqgS aAZtkrsA/jnd9MJBO1kf4YZbPPruIDcM0nj03Kwg1txduCmaH+oI
    =mYeJ
    -----END PGP SIGNATURE-----

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Mart Raudsepp@21:1/5 to Sam James on Wed Jul 3 13:20:01 2024
    On Thu, 2024-06-27 at 05:58 +0100, Sam James wrote:
    Eli Schwartz <eschwartz93@gmail.com> writes:

    On 6/26/24 5:03 AM, Sam James wrote:
    Eli Schwartz <eschwartz93@gmail.com> writes:

    Many packages perform automagic dependencies on gdk's backend implementations by checking if the macro is defined and then
    using the
    code it unlocks, rather than having a buildsystem option such
    as
    -Dwayland=true.

    Doesn't gtk3 need this too? Also, could we have an upstream
    report
    making them aware of this for gtk4?


    Yes, gtk3 needs this too (and patches in this series depend on it).

    At https://github.com/gentoo/gentoo/pull/37259 there are 6 patches,
    not
    5 -- I appear to have accidentally excluded the first patch when
    sending
    it to the list, unsure how that happened. It's almost ccompletely copy/paste from gtk4.

    Thanks for clarifying - I was convinced I'd seen you show me it (I
    probably saw it on the branch) but I didn't think to check the PR.


    As far as reporting this upstream goes, I'm somewhat nervous they
    will
    suggest you should simply build against what you use and require
    what
    you build against. It's not a completely unreasonable suggestion,
    in
    fact it's the one I described as option 4 and Gentoo simply cannot
    use
    it today since it would require new EAPI.

    I tend to agree. I see this as kind of our fault / a Gentoo-ish
    problem.


    Please do see about approaching upstream about this in the context of
    GTK4 in a constructive friendly manner, perhaps from the angle of how
    to transition any distribution to a GTK that does not include X11
    support with less migrational pain - this should be of interest for
    more cases than Gentoo.

    Maybe the idea about selecting backend stubs to include for their API functions, which would just end up returning what a fully enabled
    backend would return when the running environment is NOT that backend
    (e.g. when gdk-x11 functions are called in a wayland native app or gdk-
    wayland functions are called when X11 or Xwayland is in use).

    If that gains some traction, maybe we could also do this for GTK3 as
    well.

    Given how we'd have to end up maintaining this long term, such upstream discussions are sort of a soft blocker for proceeding with the
    patchset, as far as I'm concerned.


    Mart

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)