commit:     58d735480df99a296d3b65c79b65241f3454691b
Author:     Phantasm <phantasm <AT> centrum <DOT> cz>
AuthorDate: Mon Jan 26 22:10:40 2026 +0000
Commit:     David Roman <davidroman96 <AT> gmail <DOT> com>
CommitDate: Sat Jan 31 10:51:25 2026 +0000
URL:        https://gitweb.gentoo.org/repo/proj/guru.git/commit/?id=58d73548

games-util/mangohud: Add patch that fixes build with Wayland disabled

Also bumps revision in case package has been masked by users.
Upstream issue: flightlessmango/MangoHud#1872

Signed-off-by: Phantasm <phantasm <AT> centrum.cz>
Part-of: https://github.com/gentoo/guru/pull/431
Closes: https://github.com/gentoo/guru/pull/431
Closes: https://bugs.gentoo.org/968942
Signed-off-by: David Roman <davidroman96 <AT> gmail.com>

 .../files/mangohud-0.8.2-egl-wayland.patch         |  27 ++++
 games-util/mangohud/mangohud-0.8.2-r1.ebuild       | 158 +++++++++++++++++++++
 2 files changed, 185 insertions(+)

diff --git a/games-util/mangohud/files/mangohud-0.8.2-egl-wayland.patch 
b/games-util/mangohud/files/mangohud-0.8.2-egl-wayland.patch
new file mode 100644
index 0000000000..9dc2f61a4d
--- /dev/null
+++ b/games-util/mangohud/files/mangohud-0.8.2-egl-wayland.patch
@@ -0,0 +1,27 @@
+From 197e4093e4f7ba3deeb12a5e4fc90bf39aea0fc9 Mon Sep 17 00:00:00 2001
+From: Etaash Mathamsetty
+ <[email protected]>
+Date: Fri, 28 Nov 2025 11:46:10 -0600
+Subject: [PATCH] egl: Fix missing check for HAVE_WAYLAND.
+
+---
+ src/gl/inject_egl.cpp | 2 ++
+ 1 file changed, 2 insertions(+)
+
+diff --git a/src/gl/inject_egl.cpp b/src/gl/inject_egl.cpp
+index a39241c5ec..6de08e779c 100644
+--- a/src/gl/inject_egl.cpp
++++ b/src/gl/inject_egl.cpp
+@@ -239,10 +239,12 @@ EXPORT_C_(int) eglTerminate(void *display)
+ 
+     ret = pfn_eglTerminate(display);
+ 
++#ifdef HAVE_WAYLAND
+     if (ret)
+     {
+         wayland_data_unref(NULL, display);
+     }
++#endif
+ 
+     return ret;
+ }

diff --git a/games-util/mangohud/mangohud-0.8.2-r1.ebuild 
b/games-util/mangohud/mangohud-0.8.2-r1.ebuild
new file mode 100644
index 0000000000..631779142b
--- /dev/null
+++ b/games-util/mangohud/mangohud-0.8.2-r1.ebuild
@@ -0,0 +1,158 @@
+# Copyright 1999-2026 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+
+PYTHON_COMPAT=( python3_{11..14} )
+
+inherit flag-o-matic python-single-r1 meson-multilib toolchain-funcs
+
+MY_PV=$(ver_cut 1-3)
+[[ -n "$(ver_cut 4)" ]] && MY_PV_REV="-$(ver_cut 4)"
+
+DESCRIPTION="Vulkan and OpenGL overlay for monitoring FPS, sensors, system 
load and more"
+HOMEPAGE="https://github.com/flightlessmango/MangoHud";
+
+# Check subprojects/vulkan-headers.wrap for both of these values
+VK_HEADERS_VER="1.2.158"
+VK_HEADERS_MESON_WRAP_VER="2"
+
+SRC_URI="
+       
https://github.com/KhronosGroup/Vulkan-Headers/archive/v${VK_HEADERS_VER}.tar.gz
+               -> vulkan-headers-${VK_HEADERS_VER}.tar.gz
+       
https://github.com/mesonbuild/wrapdb/releases/download/vulkan-headers_${VK_HEADERS_VER}-${VK_HEADERS_MESON_WRAP_VER}/vulkan-headers_${VK_HEADERS_VER}-${VK_HEADERS_MESON_WRAP_VER}_patch.zip
+               -> 
vulkan-headers-${VK_HEADERS_VER}-${VK_HEADERS_MESON_WRAP_VER}-meson-wrap.zip
+"
+
+if [[ ${PV} == 9999 ]]; then
+       inherit git-r3
+       EGIT_REPO_URI="https://github.com/flightlessmango/MangoHud.git";
+else
+       SRC_URI+="
+               
https://github.com/flightlessmango/MangoHud/archive/v${MY_PV}${MY_PV_REV}.tar.gz
+                       -> ${P}.tar.gz
+       "
+       KEYWORDS="~amd64"
+       S="${WORKDIR}/MangoHud-${PV}"
+fi
+
+LICENSE="MIT"
+SLOT="0"
+IUSE="+dbus debug +X xnvctrl wayland mangoapp mangohudctl mangoplot 
video_cards_nvidia video_cards_amdgpu test"
+RESTRICT="!test? ( test )"
+
+REQUIRED_USE="
+       ${PYTHON_REQUIRED_USE}
+       || ( X wayland )
+       xnvctrl? ( video_cards_nvidia )
+       mangoapp? ( X )
+"
+
+BDEPEND="
+       app-arch/unzip
+       dev-util/glslang
+       test? ( dev-util/cmocka )
+       $(python_gen_cond_dep 'dev-python/mako[${PYTHON_USEDEP}]')
+"
+
+DEPEND="
+       ${PYTHON_DEPS}
+       =media-libs/imgui-1.89.9*:=[opengl,vulkan,${MULTILIB_USEDEP}]
+       =media-libs/implot-0.16*:=[${MULTILIB_USEDEP}]
+       dev-libs/spdlog:=[${MULTILIB_USEDEP}]
+       dev-libs/libfmt:=[${MULTILIB_USEDEP}]
+       dev-cpp/nlohmann_json
+       x11-libs/libxkbcommon:=[${MULTILIB_USEDEP}]
+       dbus? ( sys-apps/dbus[${MULTILIB_USEDEP}] )
+       X? ( x11-libs/libX11[${MULTILIB_USEDEP}] )
+       video_cards_nvidia? (
+               x11-drivers/nvidia-drivers[${MULTILIB_USEDEP}]
+               xnvctrl? ( x11-drivers/nvidia-drivers[static-libs] )
+       )
+       wayland? ( dev-libs/wayland[${MULTILIB_USEDEP}] )
+       mangoapp? (
+               =media-libs/imgui-1.89.9*[glfw]
+               media-libs/glfw[X(+)?,wayland(+)?]
+               media-libs/glew
+       )
+"
+
+RDEPEND="
+       ${DEPEND}
+       media-libs/libglvnd[${MULTILIB_USEDEP}]
+       media-libs/vulkan-loader[${MULTILIB_USEDEP}]
+       mangoplot? (
+               media-fonts/lato
+               $(python_gen_cond_dep '
+                       || (
+                               dev-python/matplotlib[gtk3,${PYTHON_USEDEP}]
+                               dev-python/matplotlib[qt5(-),${PYTHON_USEDEP}]
+                               dev-python/matplotlib[qt6(-),${PYTHON_USEDEP}]
+                               
dev-python/matplotlib[wxwidgets,${PYTHON_USEDEP}]
+                       )
+               ')
+       )
+"
+
+PATCHES=(
+       "${FILESDIR}/${P}-egl-wayland.patch"
+)
+
+src_unpack() {
+       default
+
+       [[ -n "${MY_PV_REV}" ]] && ( mv 
"${WORKDIR}/MangoHud-${MY_PV}${MY_PV_REV}" "${WORKDIR}/MangoHud-${PV}" || die )
+
+       if [[ $PV == 9999 ]]; then
+               git-r3_src_unpack
+       fi
+
+       unpack vulkan-headers-${VK_HEADERS_VER}.tar.gz
+       unpack 
vulkan-headers-${VK_HEADERS_VER}-${VK_HEADERS_MESON_WRAP_VER}-meson-wrap.zip
+       mv "${WORKDIR}/Vulkan-Headers-${VK_HEADERS_VER}" "${S}/subprojects/" || 
die
+}
+
+src_prepare() {
+       default
+       # replace all occurences of "#include <imgui.h>" to "#include 
<imgui/imgui.h>"
+       find . -type f -exec sed -i 's|<imgui.h>|<imgui/imgui.h>|g' {} \; || die
+       find . -type f -exec sed -i 's|"imgui.h"|<imgui/imgui.h>|g' {} \; || die
+       find . -type f -exec sed -i 
's|<imgui_internal.h>|<imgui/imgui_internal.h>|g' {} \; || die
+       find . -type f -exec sed -i 
's|"imgui_internal.h"|<imgui/imgui_internal.h>|g' {} \; || die
+       find . -type f -exec sed -i 
's|"imgui_impl_glfw.h"|<imgui/imgui_impl_glfw.h>|g' {} \; || die
+       find . -type f -exec sed -i 
's|"imgui_impl_opengl3.h"|<imgui/imgui_impl_opengl3.h>|g' {} \; || die
+}
+
+multilib_src_configure() {
+       # workaround for lld
+       # https://github.com/flightlessmango/MangoHud/issues/1240
+       if tc-ld-is-lld; then
+               append-ldflags -Wl,--undefined-version
+       fi
+
+       local emesonargs=(
+               -Dappend_libdir_mangohud=false
+               -Dinclude_doc=false
+               -Duse_system_spdlog=enabled
+               $(meson_feature video_cards_nvidia with_nvml)
+               $(meson_feature xnvctrl with_xnvctrl)
+               $(meson_feature X with_x11)
+               $(meson_feature wayland with_wayland)
+               $(meson_feature dbus with_dbus)
+               $(meson_use mangoapp mangoapp)
+               $(meson_use mangohudctl mangohudctl)
+               $(meson_feature mangoplot mangoplot)
+       )
+       meson_src_configure
+}
+
+pkg_postinst() {
+       if ! use xnvctrl; then
+               einfo ""
+               einfo "If mangohud can't get GPU load, or other GPU 
information,"
+               einfo "and you have an older Nvidia device."
+               einfo ""
+               einfo "Try enabling the 'xnvctrl' useflag."
+               einfo ""
+       fi
+}

Reply via email to