1 |
commit: 4497060a03e90facbcf724ed7fb36db040ca1f39 |
2 |
Author: Alfred Persson Forsberg <cat <AT> catcream <DOT> org> |
3 |
AuthorDate: Sun Jun 26 19:42:45 2022 +0000 |
4 |
Commit: Sam James <sam <AT> gentoo <DOT> org> |
5 |
CommitDate: Sun Jun 26 20:17:38 2022 +0000 |
6 |
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=4497060a |
7 |
|
8 |
kde-apps/konsole: fix build for musl |
9 |
|
10 |
This patch fixes building Konsole with musl. Konsole uses the GNU |
11 |
extension malloc_trim and this patch makes Konsole use it conditionally |
12 |
depending on if it's present on the target system. |
13 |
|
14 |
This is upstreamed for release 22.04.3 (mid July). |
15 |
|
16 |
See-also: https://invent.kde.org/utilities/konsole/-/merge_requests/621 |
17 |
Signed-off-by: Alfred Persson Forsberg <cat <AT> catcream.org> |
18 |
Closes: https://github.com/gentoo/gentoo/pull/26084 |
19 |
Signed-off-by: Sam James <sam <AT> gentoo.org> |
20 |
|
21 |
.../files/konsole-22.04.2-musl_malloc_trim.patch | 92 ++++++++++++++++++++++ |
22 |
kde-apps/konsole/konsole-22.04.2.ebuild | 2 + |
23 |
2 files changed, 94 insertions(+) |
24 |
|
25 |
diff --git a/kde-apps/konsole/files/konsole-22.04.2-musl_malloc_trim.patch b/kde-apps/konsole/files/konsole-22.04.2-musl_malloc_trim.patch |
26 |
new file mode 100644 |
27 |
index 000000000000..455dbc55821f |
28 |
--- /dev/null |
29 |
+++ b/kde-apps/konsole/files/konsole-22.04.2-musl_malloc_trim.patch |
30 |
@@ -0,0 +1,92 @@ |
31 |
+https://invent.kde.org/utilities/konsole/-/merge_requests/621 |
32 |
+https://invent.kde.org/utilities/konsole/-/commit/b8c90a830ceaf293e61f6cd5217bb3e584f997b8 (backport) |
33 |
+ |
34 |
+ |
35 |
+From b8c90a830ceaf293e61f6cd5217bb3e584f997b8 Mon Sep 17 00:00:00 2001 |
36 |
+From: Heiko Becker <heiko.becker@×××.org> |
37 |
+Date: Tue, 22 Mar 2022 22:08:10 +0100 |
38 |
+Subject: [PATCH] Detect the presence of malloc_trim to fix the build with musl |
39 |
+ |
40 |
+malloc_trim is indeed a GNU extension, but an extension of glibc. |
41 |
+Relying on __GNUC__ unfortunately doesn't help with that. Check for |
42 |
+the actual presence of malloc_trim with cmake's check_function_exists |
43 |
+instead. |
44 |
+This fixes the build with musl libc, which doesn't come with |
45 |
+malloc_trim. |
46 |
+ |
47 |
+Co-authored-by: Ahmad Samir <a.samirh78@×××××.com> |
48 |
+(cherry picked from commit f6310c2b791275f3727f2240ca7fab9f58db943d) |
49 |
+--- |
50 |
+ CMakeLists.txt | 2 +- |
51 |
+ src/Screen.cpp | 17 +++++++---------- |
52 |
+ src/config-konsole.h.cmake | 4 ++-- |
53 |
+ 3 files changed, 10 insertions(+), 13 deletions(-) |
54 |
+ |
55 |
+diff --git a/CMakeLists.txt b/CMakeLists.txt |
56 |
+index f2c9d43ac..b306597ba 100644 |
57 |
+--- a/CMakeLists.txt |
58 |
++++ b/CMakeLists.txt |
59 |
+@@ -94,7 +94,7 @@ set(HAVE_X11 ${X11_FOUND}) |
60 |
+ # Check for function GETPWUID |
61 |
+ check_symbol_exists(getpwuid "pwd.h" HAVE_GETPWUID) |
62 |
+ |
63 |
+-check_include_files(malloc.h HAVE_MALLOC_H) |
64 |
++check_function_exists(malloc_trim HAVE_MALLOC_TRIM) |
65 |
+ |
66 |
+ # See above includes for defaults |
67 |
+ add_definitions( |
68 |
+diff --git a/src/Screen.cpp b/src/Screen.cpp |
69 |
+index e57314cd5..dff9b54a4 100644 |
70 |
+--- a/src/Screen.cpp |
71 |
++++ b/src/Screen.cpp |
72 |
+@@ -28,13 +28,11 @@ |
73 |
+ #include "history/HistoryType.h" |
74 |
+ #include "profile/Profile.h" |
75 |
+ |
76 |
+-#ifdef HAVE_MALLOC_H |
77 |
+- // For malloc_trim, which is a GNU extension |
78 |
+- #ifdef __GNUC__ |
79 |
+- extern "C" { |
80 |
+- #include <malloc.h> |
81 |
+- } |
82 |
+- #endif |
83 |
++#ifdef HAVE_MALLOC_TRIM |
84 |
++// For malloc_trim, which is a GNU extension |
85 |
++extern "C" { |
86 |
++#include <malloc.h> |
87 |
++} |
88 |
+ #endif |
89 |
+ |
90 |
+ using namespace Konsole; |
91 |
+@@ -1799,14 +1797,13 @@ void Screen::setScroll(const HistoryType &t, bool copyPreviousScroll) |
92 |
+ t.scroll(_history); |
93 |
+ } |
94 |
+ |
95 |
+-#ifdef HAVE_MALLOC_H |
96 |
++#ifdef HAVE_MALLOC_TRIM |
97 |
++ |
98 |
+ #ifdef Q_OS_LINUX |
99 |
+-#ifdef __GNUC__ |
100 |
+ // We might have been using gigabytes of memory, so make sure it is actually released |
101 |
+ malloc_trim(0); |
102 |
+ #endif |
103 |
+ #endif |
104 |
+-#endif |
105 |
+ } |
106 |
+ |
107 |
+ bool Screen::hasScroll() const |
108 |
+diff --git a/src/config-konsole.h.cmake b/src/config-konsole.h.cmake |
109 |
+index b74992b0a..4b1d9b515 100644 |
110 |
+--- a/src/config-konsole.h.cmake |
111 |
++++ b/src/config-konsole.h.cmake |
112 |
+@@ -15,5 +15,5 @@ |
113 |
+ |
114 |
+ #cmakedefine HAVE_GETPWUID ${HAVE_GETPWUID} |
115 |
+ |
116 |
+-/* Define to 1 if you have the <malloc.h> header file. */ |
117 |
+-#cmakedefine HAVE_MALLOC_H 1 |
118 |
++/* Defined if system has the malloc_trim function, which is a GNU extension */ |
119 |
++#cmakedefine HAVE_MALLOC_TRIM |
120 |
+-- |
121 |
+GitLab |
122 |
+ |
123 |
|
124 |
diff --git a/kde-apps/konsole/konsole-22.04.2.ebuild b/kde-apps/konsole/konsole-22.04.2.ebuild |
125 |
index cd237a5abc51..76ba1af7bc7f 100644 |
126 |
--- a/kde-apps/konsole/konsole-22.04.2.ebuild |
127 |
+++ b/kde-apps/konsole/konsole-22.04.2.ebuild |
128 |
@@ -18,6 +18,8 @@ SLOT="5" |
129 |
KEYWORDS="~amd64 ~arm64 ~ppc64 ~riscv ~x86" |
130 |
IUSE="X" |
131 |
|
132 |
+PATCHES=( "${FILESDIR}"/${PN}-22.04.2-musl_malloc_trim.patch ) |
133 |
+ |
134 |
DEPEND=" |
135 |
>=dev-qt/qtdbus-${QTMIN}:5 |
136 |
>=dev-qt/qtgui-${QTMIN}:5 |