public inbox for gentoo-dev@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-dev] [PATCH 0/5] Fixing automagic dependencies on gtk[wayland,X],
@ 2024-06-23 17:35 Eli Schwartz
  2024-06-23 17:35 ` [gentoo-dev] [PATCH 1/5] gui-libs/gtk: add a "poison" macro support to disable X/wayland Eli Schwartz
                   ` (6 more replies)
  0 siblings, 7 replies; 12+ messages in thread
From: Eli Schwartz @ 2024-06-23 17:35 UTC (permalink / raw)
  To: gentoo-dev; +Cc: gnome, xfce, binhost

There is a bug in how gtk 3 and gtk 4 are built against by other
packages. GTK supports optionally enabling X and wayland support -- when
you do so, the ABI of GTK changes.

It is historically common for X11 packages to check for a macro provided
by GTK that says "built with X11 support". This goes back to the days
when X11 was the only backend shipped with GTK, and the main use of the
macro was to check whether to use X11 or rather to use, say, the win32
or Quartz (macOS) backends. The pattern has continued now that Linux has
two backends.

The result of this is that many packages really need to support their
own IUSE="X wayland" (because they can conditionally build code for
that) and also need to make sure that USE flag is actually respected.
Failure to do this means that when rebuilding GTK with different USE
flags, all applications linking to GTK need to be rebuilt too, but
portage doesn't know that.

It also means that binhosts -- such as the one officially hosted by
Gentoo -- have bad binaries that don't actually match the packages users
have installed. This is particularly bad since it breaks expectations
and is quite hard to debug. This has hit people a bunch of times when
trying to install the xfce desktop environment, in particular.


There are a couple possible solutions that have been considered, both by
me and others.

- simply demand upstream software implements configure options allowing
  automagic dependencies to be selected in src_configure. Advantage:
  every software should be doing this!!! Disadvantage: they currently do
  not and demanding they do it doesn't actually mean they are doing it.
  We can't just refuse to fix ebuilds that are broken, because it's
  upstream's job to fix it.

- bind packages tightly to whether gtk is built with wayland, via
  gtk[wayland=]. Advantage: metadata is always valid, and all builds of
  the package which have wayland symbols also depend on wayland support.
  Disadvantage: users have to toggle USE="wayland" on all packages at
  the same time, and cannot build libxfce4ui without wayland support,
  then enable wayland for gtk, without rebuilding.

- package.use.force gtk[wayland]. Advantage: nobody can rebuild gtk
  without part of its ABI, so other packages always have the symbols
  they need. Disadvantage: nobody can rebuild gtk without functionality
  they don't use.

- adopt new functionality in EAPI 9. Currently we have slot
  dependencies, which PMS carves out as a carefully scoped case where it
  performs delayed metadata lookup at the time of building a package,
  and updates RDEPEND values in place for the built package (to write
  out the exact slot value being built against). A similar trick could
  be used to expand "?" and "=" USE dependencies to also support looking
  up the value of the USE that was built against, e.g.
  RDEPEND="
      x11-libs/gtk+:3[X:?,wayland:?]
  "
  meaning that building, say, libxfce4ui on a system with gtk+[wayland]
  installed would propagate that dependency, but building it on a system
  without a wayland-enabled gtk+ would not require any specific build of
  gtk+. Advantage: packages could accurately model how they were built.
  Disadvantage: any fix that requires "wait for new EAPI to be agreed on
  and implemented" isn't a practical solution to current problems today.

- What I propose in this patchset. Hack a custom gentoo feature into the
  GTK headers. GTK normally behaves exactly as it's supposed to
  upstream, but we add the ability to pass a define via `append-cflags`
  that makes the GTK headers tell an outright lie and claim its API
  doesn't exist. Which is what we want -- we want packages to be able to
  compile *as if* GTK wasn't built with support for a given backend.
  This disables the automagic as if option 1 (implementing configure
  options) was carried out. Advantage: automatically support proper
  control of features. Disadvantage: requires patching GTK and
  then still adding workarounds for each package that needs it.


Bug: https://bugs.gentoo.org/624960 (gtk ticket)
Bug: https://bugs.gentoo.org/680496 (future EAPI)
Bug: https://bugs.gentoo.org/873520 (libxfce4ui, some discussion on options)
Bug: https://bugs.gentoo.org/927952 (wxGTK)
Bug: https://bugs.gentoo.org/865659 (gtk-vnc)


PR: https://github.com/gentoo/gentoo/pull/37259

Eli Schwartz (5):
  gui-libs/gtk: add a "poison" macro support to disable X/wayland
  net-libs/gtk-vnc: prevent automagically building against
    gtk[X,wayland]
  x11-libs/wxGTK: prevent automagically building against gtk[X,wayland]
  xfce-base/libxfce4ui: prevent automagically building against
    gtk[wayland]
  dev-libs/libportal: prevent automagically building against
    gtk[X,wayland]

 ...0.7.1.ebuild => libportal-0.7.1-r1.ebuild} | 14 +++++++----
 ...-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 ++++++
 ...c-1.3.1.ebuild => gtk-vnc-1.3.1-r1.ebuild} | 12 ++++++---
 profiles/features/big-endian/package.use.mask |  1 +
 ....2.1-r4.ebuild => wxGTK-3.2.2.1-r5.ebuild} | 10 +++++---
 ...8.6.ebuild => libxfce4ui-4.18.6-r1.ebuild} | 11 +++++---
 10 files changed, 74 insertions(+), 29 deletions(-)
 copy dev-libs/libportal/{libportal-0.7.1.ebuild => libportal-0.7.1-r1.ebuild} (83%)
 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%)
 copy net-libs/gtk-vnc/{gtk-vnc-1.3.1.ebuild => gtk-vnc-1.3.1-r1.ebuild} (76%)
 copy x11-libs/wxGTK/{wxGTK-3.2.2.1-r4.ebuild => wxGTK-3.2.2.1-r5.ebuild} (95%)
 copy xfce-base/libxfce4ui/{libxfce4ui-4.18.6.ebuild => libxfce4ui-4.18.6-r1.ebuild} (82%)

-- 
2.44.2



^ permalink raw reply	[flat|nested] 12+ messages in thread

* [gentoo-dev] [PATCH 1/5] gui-libs/gtk: add a "poison" macro support to disable X/wayland
  2024-06-23 17:35 [gentoo-dev] [PATCH 0/5] Fixing automagic dependencies on gtk[wayland,X], Eli Schwartz
@ 2024-06-23 17:35 ` Eli Schwartz
  2024-06-24  9:08   ` Florian Schmaus
  2024-06-26  9:03   ` Sam James
  2024-06-23 17:35 ` [gentoo-dev] [PATCH 2/5] net-libs/gtk-vnc: prevent automagically building against gtk[X,wayland] Eli Schwartz
                   ` (5 subsequent siblings)
  6 siblings, 2 replies; 12+ messages in thread
From: Eli Schwartz @ 2024-06-23 17:35 UTC (permalink / raw)
  To: gentoo-dev; +Cc: gnome, xfce, binhost

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.

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
 }
-- 
2.44.2



^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [gentoo-dev] [PATCH 2/5] net-libs/gtk-vnc: prevent automagically building against gtk[X,wayland]
  2024-06-23 17:35 [gentoo-dev] [PATCH 0/5] Fixing automagic dependencies on gtk[wayland,X], Eli Schwartz
  2024-06-23 17:35 ` [gentoo-dev] [PATCH 1/5] gui-libs/gtk: add a "poison" macro support to disable X/wayland Eli Schwartz
@ 2024-06-23 17:35 ` Eli Schwartz
  2024-06-23 17:35 ` [gentoo-dev] [PATCH 3/5] x11-libs/wxGTK: " Eli Schwartz
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 12+ messages in thread
From: Eli Schwartz @ 2024-06-23 17:35 UTC (permalink / raw)
  To: gentoo-dev; +Cc: gnome, xfce, binhost

e.g. the upstream code checks whether GDK_WINDOWING_WAYLAND is defined
by the gtk headers, and if so will compile against the wayland symbols
it provides. This means that gtk-vnc built on a system with
gtk+[-wayland] will be compatible with anything, but when built on a
system with gtk+[wayland], requires that at runtime.

This cannot be expressed with USE flags.

We could bind tightly to whether gtk was built with wayland (and X), and
in the process, arbitrarily restrict gtk-vnc[-wayland] to only build and
install on a system with gtk+[-wayland].

But we recently added a hack to gtk itself which allows hiding the
automagic macros entirely. Inject this via append-cflags if the USE
flags aren't set, to simulate building on a system with more minimal gtk
packages.

Bug: https://bugs.gentoo.org/624960
Closes: https://bugs.gentoo.org/865659
Signed-off-by: Eli Schwartz <eschwartz93@gmail.com>
---
 ...{gtk-vnc-1.3.1.ebuild => gtk-vnc-1.3.1-r1.ebuild} | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)
 copy net-libs/gtk-vnc/{gtk-vnc-1.3.1.ebuild => gtk-vnc-1.3.1-r1.ebuild} (76%)

diff --git a/net-libs/gtk-vnc/gtk-vnc-1.3.1.ebuild b/net-libs/gtk-vnc/gtk-vnc-1.3.1-r1.ebuild
similarity index 76%
copy from net-libs/gtk-vnc/gtk-vnc-1.3.1.ebuild
copy to net-libs/gtk-vnc/gtk-vnc-1.3.1-r1.ebuild
index 252a0fcc4541..3c2eb470aa1a 100644
--- a/net-libs/gtk-vnc/gtk-vnc-1.3.1.ebuild
+++ b/net-libs/gtk-vnc/gtk-vnc-1.3.1-r1.ebuild
@@ -5,15 +5,15 @@ EAPI=8
 
 PYTHON_COMPAT=( python3_{10..12} )
 
-inherit gnome.org vala meson python-any-r1 xdg
+inherit flag-o-matic gnome.org vala meson python-any-r1 xdg
 
 DESCRIPTION="VNC viewer widget for GTK"
 HOMEPAGE="https://wiki.gnome.org/Projects/gtk-vnc https://gitlab.gnome.org/GNOME/gtk-vnc"
 
 LICENSE="LGPL-2.1+"
 SLOT="0"
-KEYWORDS="~alpha amd64 ~arm arm64 ~ia64 ~loong ~ppc ppc64 ~riscv ~sparc x86"
-IUSE="+introspection pulseaudio sasl +vala"
+KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~ia64 ~loong ~ppc ~ppc64 ~riscv ~sparc ~x86"
+IUSE="+introspection pulseaudio sasl +vala wayland X"
 REQUIRED_USE="vala? ( introspection )"
 
 RDEPEND="
@@ -23,7 +23,7 @@ RDEPEND="
 	>=net-libs/gnutls-3.6.0:0=
 	>=sys-libs/zlib-1.2.11
 	sasl? ( >=dev-libs/cyrus-sasl-2.1.27:2 )
-	>=x11-libs/gtk+-3.22.0:3[introspection?]
+	>=x11-libs/gtk+-3.22.0:3[introspection?,wayland?,X?]
 	>=x11-libs/cairo-1.15.0
 	>=x11-libs/libX11-1.6.5
 	pulseaudio? ( media-libs/libpulse )
@@ -48,6 +48,10 @@ src_prepare() {
 }
 
 src_configure() {
+	# defang automagic dependencies, bug #927952
+	use wayland || append-cflags -DGENTOO_GTK_HIDE_WAYLAND
+	use X || append-cflags -DGENTOO_GTK_HIDE_X11
+
 	local emesonargs=(
 		$(meson_feature introspection)
 		$(meson_feature pulseaudio)
-- 
2.44.2



^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [gentoo-dev] [PATCH 3/5] x11-libs/wxGTK: prevent automagically building against gtk[X,wayland]
  2024-06-23 17:35 [gentoo-dev] [PATCH 0/5] Fixing automagic dependencies on gtk[wayland,X], Eli Schwartz
  2024-06-23 17:35 ` [gentoo-dev] [PATCH 1/5] gui-libs/gtk: add a "poison" macro support to disable X/wayland Eli Schwartz
  2024-06-23 17:35 ` [gentoo-dev] [PATCH 2/5] net-libs/gtk-vnc: prevent automagically building against gtk[X,wayland] Eli Schwartz
@ 2024-06-23 17:35 ` Eli Schwartz
  2024-06-23 17:35 ` [gentoo-dev] [PATCH 4/5] xfce-base/libxfce4ui: prevent automagically building against gtk[wayland] Eli Schwartz
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 12+ messages in thread
From: Eli Schwartz @ 2024-06-23 17:35 UTC (permalink / raw)
  To: gentoo-dev; +Cc: gnome, xfce, binhost

The upstream code checks whether GDK_WINDOWING_WAYLAND is defined by the
gtk headers, and if so will compile against the wayland symbols it
provides. This despite that wxGTK has a wayland USE flag, and checks it
in the build system -- just not for this.

This means that when built on a system with gtk+[-wayland]
will be compatible with anything, but when built on a system with
gtk+[wayland], requires that at runtime regardless of USE flag.

This cannot be expressed with USE flags. We could bind tightly to
whether gtk was built with wayland and arbitrarily restrict
wxGTK[-wayland] to only build and install on a system with
gtk+[-wayland].

But we recently added a hack to gtk itself which allows hiding the
automagic macros entirely. Inject this via append-cflags if the USE
flags aren't set, to simulate building on a system with more minimal gtk
packages.

Bug: https://bugs.gentoo.org/624960
Closes: https://bugs.gentoo.org/927952
Signed-off-by: Eli Schwartz <eschwartz93@gmail.com>
---
 ...wxGTK-3.2.2.1-r4.ebuild => wxGTK-3.2.2.1-r5.ebuild} | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
 copy x11-libs/wxGTK/{wxGTK-3.2.2.1-r4.ebuild => wxGTK-3.2.2.1-r5.ebuild} (95%)

diff --git a/x11-libs/wxGTK/wxGTK-3.2.2.1-r4.ebuild b/x11-libs/wxGTK/wxGTK-3.2.2.1-r5.ebuild
similarity index 95%
copy from x11-libs/wxGTK/wxGTK-3.2.2.1-r4.ebuild
copy to x11-libs/wxGTK/wxGTK-3.2.2.1-r5.ebuild
index a9276d1c119a..260365bf3510 100644
--- a/x11-libs/wxGTK/wxGTK-3.2.2.1-r4.ebuild
+++ b/x11-libs/wxGTK/wxGTK-3.2.2.1-r5.ebuild
@@ -20,8 +20,8 @@ S="${WORKDIR}/wxWidgets-${PV}"
 
 LICENSE="wxWinLL-3 GPL-2 doc? ( wxWinFDL-3 )"
 SLOT="${WXRELEASE}"
-KEYWORDS="~alpha amd64 arm arm64 ~hppa ~ia64 ~loong ~mips ppc ppc64 ~riscv sparc x86 ~amd64-linux ~x86-linux"
-IUSE="+X curl doc debug keyring gstreamer libnotify +lzma opengl pch sdl +spell test tiff wayland webkit"
+KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~loong ~mips ~ppc ~ppc64 ~riscv ~sparc ~x86 ~amd64-linux ~x86-linux"
+IUSE="+X curl doc debug keyring gstreamer libnotify +lzma opengl pch sdl +spell test tiff wayland webkit X"
 REQUIRED_USE="test? ( tiff ) tiff? ( X ) spell? ( X ) keyring? ( X )"
 RESTRICT="!test? ( test )"
 
@@ -38,7 +38,7 @@ RDEPEND="
 		media-libs/libpng:0=[${MULTILIB_USEDEP}]
 		sys-libs/zlib[${MULTILIB_USEDEP}]
 		x11-libs/cairo[${MULTILIB_USEDEP}]
-		x11-libs/gtk+:3[wayland?,${MULTILIB_USEDEP}]
+		x11-libs/gtk+:3[wayland?,X?,${MULTILIB_USEDEP}]
 		x11-libs/gdk-pixbuf:2[${MULTILIB_USEDEP}]
 		x11-libs/libSM[${MULTILIB_USEDEP}]
 		x11-libs/libX11[${MULTILIB_USEDEP}]
@@ -127,6 +127,10 @@ src_prepare() {
 }
 
 multilib_src_configure() {
+	# defang automagic dependencies, bug #927952
+	use wayland || append-cflags -DGENTOO_GTK_HIDE_WAYLAND
+	use X || append-cflags -DGENTOO_GTK_HIDE_X11
+
 	# Workaround for bug #915154
 	append-ldflags $(test-flags-CCLD -Wl,--undefined-version)
 
-- 
2.44.2



^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [gentoo-dev] [PATCH 4/5] xfce-base/libxfce4ui: prevent automagically building against gtk[wayland]
  2024-06-23 17:35 [gentoo-dev] [PATCH 0/5] Fixing automagic dependencies on gtk[wayland,X], Eli Schwartz
                   ` (2 preceding siblings ...)
  2024-06-23 17:35 ` [gentoo-dev] [PATCH 3/5] x11-libs/wxGTK: " Eli Schwartz
@ 2024-06-23 17:35 ` Eli Schwartz
  2024-06-23 17:35 ` [gentoo-dev] [PATCH 5/5] dev-libs/libportal: prevent automagically building against gtk[X,wayland] Eli Schwartz
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 12+ messages in thread
From: Eli Schwartz @ 2024-06-23 17:35 UTC (permalink / raw)
  To: gentoo-dev; +Cc: gnome, xfce, binhost

The upstream code checks whether GDK_WINDOWING_WAYLAND is defined by the
gtk headers, and if so will compile against the wayland symbols it
provides.

This means that libxfce4ui built on a system with gtk+[-wayland]
will be compatible with anything, but when built on a system with
gtk+[wayland], requires that at runtime regardless of USE flag.

This cannot be expressed with USE flags. We could bind tightly to
whether gtk was built with wayland and arbitrarily restrict
libxfce4ui[-wayland] to only build and install on a system with
gtk+[-wayland].

But we recently added a hack to gtk itself which allows hiding the
automagic macros entirely. Inject this via append-cflags if the USE
flags aren't set, to simulate building on a system with more minimal gtk
packages.

Fixed upstream in:
https://gitlab.xfce.org/xfce/libxfce4ui/-/commit/967359624e408365b4c027bab66e737063af604b
and hence only worked around for 4.18.

Bug: https://bugs.gentoo.org/624960
Closes: https://bugs.gentoo.org/873520
Signed-off-by: Eli Schwartz <eschwartz93@gmail.com>
---
 ...e4ui-4.18.6.ebuild => libxfce4ui-4.18.6-r1.ebuild} | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)
 copy xfce-base/libxfce4ui/{libxfce4ui-4.18.6.ebuild => libxfce4ui-4.18.6-r1.ebuild} (82%)

diff --git a/xfce-base/libxfce4ui/libxfce4ui-4.18.6.ebuild b/xfce-base/libxfce4ui/libxfce4ui-4.18.6-r1.ebuild
similarity index 82%
copy from xfce-base/libxfce4ui/libxfce4ui-4.18.6.ebuild
copy to xfce-base/libxfce4ui/libxfce4ui-4.18.6-r1.ebuild
index bc3c10b62bdf..888730690ed9 100644
--- a/xfce-base/libxfce4ui/libxfce4ui-4.18.6.ebuild
+++ b/xfce-base/libxfce4ui/libxfce4ui-4.18.6-r1.ebuild
@@ -3,7 +3,7 @@
 
 EAPI=8
 
-inherit xdg-utils vala
+inherit flag-o-matic xdg-utils vala
 
 DESCRIPTION="Unified widget and session management libs for Xfce"
 HOMEPAGE="
@@ -14,13 +14,13 @@ SRC_URI="https://archive.xfce.org/src/xfce/${PN}/${PV%.*}/${P}.tar.bz2"
 
 LICENSE="LGPL-2+ GPL-2+"
 SLOT="0"
-KEYWORDS="~alpha amd64 arm arm64 ~hppa ~ia64 ~loong ~mips ppc ppc64 ~riscv ~sparc x86 ~amd64-linux ~x86-linux"
-IUSE="glade +introspection startup-notification system-info vala"
+KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~loong ~mips ~ppc ~ppc64 ~riscv ~sparc ~x86 ~amd64-linux ~x86-linux"
+IUSE="glade +introspection startup-notification system-info vala wayland"
 REQUIRED_USE="vala? ( introspection )"
 
 DEPEND="
 	>=dev-libs/glib-2.66.0
-	>=x11-libs/gtk+-3.24.0:3[introspection?,X]
+	>=x11-libs/gtk+-3.24.0:3[introspection?,wayland?,X]
 	x11-libs/libX11
 	x11-libs/libICE
 	x11-libs/libSM
@@ -47,6 +47,9 @@ BDEPEND="
 "
 
 src_configure() {
+	# defang automagic dependencies, bug #873520
+	use wayland || append-cflags -DGENTOO_GTK_HIDE_WAYLAND
+
 	local myconf=(
 		$(use_enable introspection)
 		$(use_enable system-info glibtop)
-- 
2.44.2



^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [gentoo-dev] [PATCH 5/5] dev-libs/libportal: prevent automagically building against gtk[X,wayland]
  2024-06-23 17:35 [gentoo-dev] [PATCH 0/5] Fixing automagic dependencies on gtk[wayland,X], Eli Schwartz
                   ` (3 preceding siblings ...)
  2024-06-23 17:35 ` [gentoo-dev] [PATCH 4/5] xfce-base/libxfce4ui: prevent automagically building against gtk[wayland] Eli Schwartz
@ 2024-06-23 17:35 ` Eli Schwartz
  2024-06-23 18:33 ` [gentoo-dev] [PATCH 0/5] Fixing automagic dependencies on gtk[wayland,X], James Le Cuirot
  2024-06-26  9:02 ` Sam James
  6 siblings, 0 replies; 12+ messages in thread
From: Eli Schwartz @ 2024-06-23 17:35 UTC (permalink / raw)
  To: gentoo-dev; +Cc: gnome, xfce, binhost

e.g. the upstream code checks whether GDK_WINDOWING_WAYLAND is defined
by the gtk headers, and if so will compile against the wayland symbols
it provides. This means that libportal built on a system with
gtk+[-wayland] will be compatible with anything, but when built on a
system with gtk+[wayland], requires that at runtime.

This cannot be expressed with USE flags.

We could bind tightly to whether gtk was built with wayland (and X), and
in the process, arbitrarily restrict libportal[-wayland] to only build
and install on a system with gtk+[-wayland].

But we recently added a hack to gtk itself which allows hiding the
automagic macros entirely. Inject this via append-cflags if the USE
flags aren't set, to simulate building on a system with more minimal gtk
packages.

Signed-off-by: Eli Schwartz <eschwartz93@gmail.com>
---
 ...rtal-0.7.1.ebuild => libportal-0.7.1-r1.ebuild} | 14 +++++++++-----
 profiles/features/big-endian/package.use.mask      |  1 +
 2 files changed, 10 insertions(+), 5 deletions(-)
 copy dev-libs/libportal/{libportal-0.7.1.ebuild => libportal-0.7.1-r1.ebuild} (83%)

diff --git a/dev-libs/libportal/libportal-0.7.1.ebuild b/dev-libs/libportal/libportal-0.7.1-r1.ebuild
similarity index 83%
copy from dev-libs/libportal/libportal-0.7.1.ebuild
copy to dev-libs/libportal/libportal-0.7.1-r1.ebuild
index 38a05311150b..af3e04a1f256 100644
--- a/dev-libs/libportal/libportal-0.7.1.ebuild
+++ b/dev-libs/libportal/libportal-0.7.1-r1.ebuild
@@ -4,7 +4,7 @@
 EAPI=8
 
 PYTHON_COMPAT=( python3_{10..12} )
-inherit meson python-any-r1 vala virtualx
+inherit flag-o-matic meson python-any-r1 vala virtualx
 
 DESCRIPTION="Flatpak portal library"
 HOMEPAGE="https://github.com/flatpak/libportal"
@@ -12,8 +12,8 @@ SRC_URI="https://github.com/flatpak/libportal/releases/download/${PV}/${P}.tar.x
 
 LICENSE="LGPL-3"
 SLOT="0/1-1-1-1" # soname of libportal{,-gtk3,-gtk4,-qt5}.so
-KEYWORDS="~alpha amd64 ~arm arm64 ~ia64 ~loong ~ppc ~ppc64 ~riscv ~sparc x86"
-IUSE="gtk gtk-doc +introspection qt5 test +vala"
+KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~ia64 ~loong ~ppc ~ppc64 ~riscv ~sparc ~x86"
+IUSE="gtk gtk-doc +introspection qt5 test +vala wayland X"
 RESTRICT="!test? ( test )"
 REQUIRED_USE="
 	gtk-doc? ( introspection )
@@ -24,8 +24,8 @@ RDEPEND="
 	>=dev-libs/glib-2.58:2
 	introspection? ( dev-libs/gobject-introspection:= )
 	gtk? (
-		x11-libs/gtk+:3
-		gui-libs/gtk:4
+		x11-libs/gtk+:3[X?,wayland?]
+		gui-libs/gtk:4[X?,wayland?]
 	)
 	qt5? (
 		dev-qt/qtcore:=
@@ -76,6 +76,10 @@ src_prepare() {
 }
 
 src_configure() {
+	# defang automagic dependencies
+	use wayland || append-cflags -DGENTOO_GTK_HIDE_WAYLAND
+	use X || append-cflags -DGENTOO_GTK_HIDE_X11
+
 	local emesonargs=(
 		$(meson_feature gtk backend-gtk3)
 		$(meson_feature gtk backend-gtk4)
diff --git a/profiles/features/big-endian/package.use.mask b/profiles/features/big-endian/package.use.mask
index 71906122232a..bbde951452d2 100644
--- a/profiles/features/big-endian/package.use.mask
+++ b/profiles/features/big-endian/package.use.mask
@@ -45,6 +45,7 @@ gui-libs/gtk wayland
 gnome-base/gnome-control-center wayland
 sys-apps/xdg-desktop-portal-gnome wayland
 net-libs/webkit-gtk:6 wayland
+dev-libs/libportal wayland
 
 # matoro <matoro_gentoo@matoro.tk> (2023-04-10)
 # media-libs/libldac casualties (#80238)
-- 
2.44.2



^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [gentoo-dev] [PATCH 0/5] Fixing automagic dependencies on gtk[wayland,X],
  2024-06-23 17:35 [gentoo-dev] [PATCH 0/5] Fixing automagic dependencies on gtk[wayland,X], Eli Schwartz
                   ` (4 preceding siblings ...)
  2024-06-23 17:35 ` [gentoo-dev] [PATCH 5/5] dev-libs/libportal: prevent automagically building against gtk[X,wayland] Eli Schwartz
@ 2024-06-23 18:33 ` James Le Cuirot
  2024-06-26  9:02 ` Sam James
  6 siblings, 0 replies; 12+ messages in thread
From: James Le Cuirot @ 2024-06-23 18:33 UTC (permalink / raw)
  To: gentoo-dev

[-- Attachment #1: Type: text/plain, Size: 2154 bytes --]

On Sun, 2024-06-23 at 13:35 -0400, Eli Schwartz wrote:
> There is a bug in how gtk 3 and gtk 4 are built against by other
> packages. GTK supports optionally enabling X and wayland support -- when
> you do so, the ABI of GTK changes.
> 
> It is historically common for X11 packages to check for a macro provided
> by GTK that says "built with X11 support". This goes back to the days
> when X11 was the only backend shipped with GTK, and the main use of the
> macro was to check whether to use X11 or rather to use, say, the win32
> or Quartz (macOS) backends. The pattern has continued now that Linux has
> two backends.
> 
> The result of this is that many packages really need to support their
> own IUSE="X wayland" (because they can conditionally build code for
> that) and also need to make sure that USE flag is actually respected.
> Failure to do this means that when rebuilding GTK with different USE
> flags, all applications linking to GTK need to be rebuilt too, but
> portage doesn't know that.
> 
> It also means that binhosts -- such as the one officially hosted by
> Gentoo -- have bad binaries that don't actually match the packages users
> have installed. This is particularly bad since it breaks expectations
> and is quite hard to debug. This has hit people a bunch of times when
> trying to install the xfce desktop environment, in particular.

<snip>

> - What I propose in this patchset. Hack a custom gentoo feature into the
>   GTK headers. GTK normally behaves exactly as it's supposed to
>   upstream, but we add the ability to pass a define via `append-cflags`
>   that makes the GTK headers tell an outright lie and claim its API
>   doesn't exist. Which is what we want -- we want packages to be able to
>   compile *as if* GTK wasn't built with support for a given backend.
>   This disables the automagic as if option 1 (implementing configure
>   options) was carried out. Advantage: automatically support proper
>   control of features. Disadvantage: requires patching GTK and
>   then still adding workarounds for each package that needs it.

Nice trick! I like it. Good work. :)

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 858 bytes --]

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [gentoo-dev] [PATCH 1/5] gui-libs/gtk: add a "poison" macro support to disable X/wayland
  2024-06-23 17:35 ` [gentoo-dev] [PATCH 1/5] gui-libs/gtk: add a "poison" macro support to disable X/wayland Eli Schwartz
@ 2024-06-24  9:08   ` Florian Schmaus
  2024-06-26  9:03   ` Sam James
  1 sibling, 0 replies; 12+ messages in thread
From: Florian Schmaus @ 2024-06-24  9:08 UTC (permalink / raw)
  To: gentoo-dev, Eli Schwartz


[-- Attachment #1.1.1: Type: text/plain, Size: 3729 bytes --]

On 23/06/2024 19.35, Eli Schwartz wrote:
> 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.
> 
> 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."

Maybe this (and the other) should state where the bug is supposed to be 
filled, so that user's don't fill bugs at the wrong venue.

- Flow

[-- Attachment #1.1.2: OpenPGP public key --]
[-- Type: application/pgp-keys, Size: 18239 bytes --]

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 618 bytes --]

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [gentoo-dev] [PATCH 0/5] Fixing automagic dependencies on gtk[wayland,X],
  2024-06-23 17:35 [gentoo-dev] [PATCH 0/5] Fixing automagic dependencies on gtk[wayland,X], Eli Schwartz
                   ` (5 preceding siblings ...)
  2024-06-23 18:33 ` [gentoo-dev] [PATCH 0/5] Fixing automagic dependencies on gtk[wayland,X], James Le Cuirot
@ 2024-06-26  9:02 ` Sam James
  6 siblings, 0 replies; 12+ messages in thread
From: Sam James @ 2024-06-26  9:02 UTC (permalink / raw)
  To: Eli Schwartz; +Cc: gentoo-dev, gnome, xfce, binhost

[-- Attachment #1: Type: text/plain, Size: 419 bytes --]

Eli Schwartz <eschwartz93@gmail.com> writes:

> There is a bug in how gtk 3 and gtk 4 are built against by other
> packages. GTK supports optionally enabling X and wayland support -- when
> you do so, the ABI of GTK changes.

The series looks good to me, but I'd like leio to ack it before we merge
it.

It's not ideal, of course, but I think it's the best option we have and
the status quo is pretty bad.

thanks,
sam

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 377 bytes --]

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [gentoo-dev] [PATCH 1/5] gui-libs/gtk: add a "poison" macro support to disable X/wayland
  2024-06-23 17:35 ` [gentoo-dev] [PATCH 1/5] gui-libs/gtk: add a "poison" macro support to disable X/wayland Eli Schwartz
  2024-06-24  9:08   ` Florian Schmaus
@ 2024-06-26  9:03   ` Sam James
  2024-06-27  4:52     ` Eli Schwartz
  1 sibling, 1 reply; 12+ messages in thread
From: Sam James @ 2024-06-26  9:03 UTC (permalink / raw)
  To: Eli Schwartz; +Cc: gentoo-dev, gnome, xfce, binhost

[-- Attachment #1: Type: text/plain, Size: 7528 bytes --]

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
>  }

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 377 bytes --]

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [gentoo-dev] [PATCH 1/5] gui-libs/gtk: add a "poison" macro support to disable X/wayland
  2024-06-26  9:03   ` Sam James
@ 2024-06-27  4:52     ` Eli Schwartz
  2024-06-27  4:58       ` Sam James
  0 siblings, 1 reply; 12+ messages in thread
From: Eli Schwartz @ 2024-06-27  4:52 UTC (permalink / raw)
  To: Sam James; +Cc: gentoo-dev, gnome, xfce, binhost


[-- Attachment #1.1.1: Type: text/plain, Size: 1098 bytes --]

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.

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.


-- 
Eli Schwartz

[-- Attachment #1.1.2: OpenPGP public key --]
[-- Type: application/pgp-keys, Size: 18399 bytes --]

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 963 bytes --]

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [gentoo-dev] [PATCH 1/5] gui-libs/gtk: add a "poison" macro support to disable X/wayland
  2024-06-27  4:52     ` Eli Schwartz
@ 2024-06-27  4:58       ` Sam James
  0 siblings, 0 replies; 12+ messages in thread
From: Sam James @ 2024-06-27  4:58 UTC (permalink / raw)
  To: Eli Schwartz; +Cc: gentoo-dev, gnome, xfce, binhost

[-- Attachment #1: Type: text/plain, Size: 1374 bytes --]

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.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 377 bytes --]

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2024-06-27  4:58 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-06-23 17:35 [gentoo-dev] [PATCH 0/5] Fixing automagic dependencies on gtk[wayland,X], Eli Schwartz
2024-06-23 17:35 ` [gentoo-dev] [PATCH 1/5] gui-libs/gtk: add a "poison" macro support to disable X/wayland Eli Schwartz
2024-06-24  9:08   ` Florian Schmaus
2024-06-26  9:03   ` Sam James
2024-06-27  4:52     ` Eli Schwartz
2024-06-27  4:58       ` Sam James
2024-06-23 17:35 ` [gentoo-dev] [PATCH 2/5] net-libs/gtk-vnc: prevent automagically building against gtk[X,wayland] Eli Schwartz
2024-06-23 17:35 ` [gentoo-dev] [PATCH 3/5] x11-libs/wxGTK: " Eli Schwartz
2024-06-23 17:35 ` [gentoo-dev] [PATCH 4/5] xfce-base/libxfce4ui: prevent automagically building against gtk[wayland] Eli Schwartz
2024-06-23 17:35 ` [gentoo-dev] [PATCH 5/5] dev-libs/libportal: prevent automagically building against gtk[X,wayland] Eli Schwartz
2024-06-23 18:33 ` [gentoo-dev] [PATCH 0/5] Fixing automagic dependencies on gtk[wayland,X], James Le Cuirot
2024-06-26  9:02 ` Sam James

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox