commit:     02627a66a2883017dc5888ce730e9d4f63e9ed86
Author:     Eli Schwartz <eschwartz <AT> gentoo <DOT> org>
AuthorDate: Tue Sep  3 04:58:42 2024 +0000
Commit:     Eli Schwartz <eschwartz <AT> gentoo <DOT> org>
CommitDate: Tue Sep  3 05:29:23 2024 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=02627a66

kde-apps/gwenview: apply patch to fix UB due to ODR violations

Closes: https://bugs.gentoo.org/921649
Acked-by: Sam James <sam <AT> gentoo.org>
Signed-off-by: Eli Schwartz <eschwartz <AT> gentoo.org>

 kde-apps/gwenview/files/gwenview-24.08.0-odr.patch | 58 ++++++++++++++++++++++
 ...w-24.08.0.ebuild => gwenview-24.05.2-r2.ebuild} | 10 ++--
 ...w-24.08.0.ebuild => gwenview-24.08.0-r1.ebuild} |  4 ++
 3 files changed, 69 insertions(+), 3 deletions(-)

diff --git a/kde-apps/gwenview/files/gwenview-24.08.0-odr.patch 
b/kde-apps/gwenview/files/gwenview-24.08.0-odr.patch
new file mode 100644
index 000000000000..148921f18169
--- /dev/null
+++ b/kde-apps/gwenview/files/gwenview-24.08.0-odr.patch
@@ -0,0 +1,58 @@
+From b5cc214574eeb62f469a058daf52cd92270e4aa9 Mon Sep 17 00:00:00 2001
+From: Eli Schwartz <[email protected]>
+Date: Tue, 3 Sep 2024 00:40:11 -0400
+Subject: [PATCH] fix ODR violation: many files had the wrong definition of
+ Enum
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+This enum has a different number of values, depending on whether
+gwenview is configured with the semanticinfo backend "none" or
+fake/baloo.
+
+In order to avoid Undefined Behavior, every file that includes sorting.h
+also has to include config-gwenview.h *before* sorting.h, which was not
+true. Solve this by including the config header inside the sorting.h
+header.
+
+Fixes link failures when LTO is enabled, since LTO allows the compiler
+to do whole-program optimization and type-check across the entire
+program:
+
+```
+/var/tmp/portage/kde-apps/gwenview-24.08.0/work/gwenview-24.08.0/app/../lib/sorting.h:37:6:
 error: type ‘Gwenview::Sorting::Enum’ violates the C++ One Definition Rule 
[-Werror=odr]
+   37 | enum Enum {
+      |      ^
+/var/tmp/portage/kde-apps/gwenview-24.08.0/work/gwenview-24.08.0/app/../lib/sorting.h:37:6:
 note: an enum with different number of values is defined in another 
translation unit
+   37 | enum Enum {
+      |      ^
+lto1: some warnings being treated as errors
+lto-wrapper: fatal error: /usr/bin/x86_64-pc-linux-gnu-g++ returned 1 exit 
status
+compilation terminated.
+/usr/libexec/gcc/x86_64-pc-linux-gnu/ld: error: lto-wrapper failed
+collect2: error: ld returned 1 exit status
+```
+
+Fixes: https://bugs.gentoo.org/921649
+---
+ lib/sorting.h | 3 +++
+ 1 file changed, 3 insertions(+)
+
+diff --git a/lib/sorting.h b/lib/sorting.h
+index 529ea6fc9..c008865cf 100644
+--- a/lib/sorting.h
++++ b/lib/sorting.h
+@@ -21,6 +21,9 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, 
Cambridge, MA 02110-1301, USA
+ #ifndef SORTING_H
+ #define SORTING_H
+ 
++// Do not assume every file that includes this one, includes the config.h
++#include <config-gwenview.h>
++
+ // Qt
+ 
+ // KF
+-- 
+GitLab
+

diff --git a/kde-apps/gwenview/gwenview-24.08.0.ebuild 
b/kde-apps/gwenview/gwenview-24.05.2-r2.ebuild
similarity index 96%
copy from kde-apps/gwenview/gwenview-24.08.0.ebuild
copy to kde-apps/gwenview/gwenview-24.05.2-r2.ebuild
index d209a9e40aee..622f9c53904b 100644
--- a/kde-apps/gwenview/gwenview-24.08.0.ebuild
+++ b/kde-apps/gwenview/gwenview-24.05.2-r2.ebuild
@@ -6,8 +6,8 @@ EAPI=8
 ECM_HANDBOOK="optional"
 ECM_TEST="true"
 PVCUT=$(ver_cut 1-3)
-KFMIN=6.5.0
-QTMIN=6.7.2
+KFMIN=6.3.0
+QTMIN=6.6.2
 inherit ecm gear.kde.org optfeature
 
 DESCRIPTION="Image viewer by KDE"
@@ -15,7 +15,7 @@ HOMEPAGE="https://apps.kde.org/gwenview/ 
https://userbase.kde.org/Gwenview";
 
 LICENSE="GPL-2+ handbook? ( FDL-1.2 )"
 SLOT="6"
-KEYWORDS="~amd64 ~arm64 ~riscv ~x86"
+KEYWORDS="~amd64 ~arm64 ~ppc64 ~riscv ~x86"
 IUSE="activities fits +mpris raw semantic-desktop share X"
 
 # requires running environment
@@ -81,6 +81,10 @@ BDEPEND="
        dev-util/wayland-scanner
 "
 
+PATCHES=(
+       "${FILESDIR}"/${PN}-24.08.0-odr.patch
+)
+
 src_prepare() {
        ecm_src_prepare
        if ! use mpris; then

diff --git a/kde-apps/gwenview/gwenview-24.08.0.ebuild 
b/kde-apps/gwenview/gwenview-24.08.0-r1.ebuild
similarity index 98%
rename from kde-apps/gwenview/gwenview-24.08.0.ebuild
rename to kde-apps/gwenview/gwenview-24.08.0-r1.ebuild
index d209a9e40aee..d720385f4680 100644
--- a/kde-apps/gwenview/gwenview-24.08.0.ebuild
+++ b/kde-apps/gwenview/gwenview-24.08.0-r1.ebuild
@@ -81,6 +81,10 @@ BDEPEND="
        dev-util/wayland-scanner
 "
 
+PATCHES=(
+       "${FILESDIR}"/${P}-odr.patch
+)
+
 src_prepare() {
        ecm_src_prepare
        if ! use mpris; then

Reply via email to