public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Sam James" <sam@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] repo/gentoo:master commit in: kde-apps/konsole/, kde-apps/konsole/files/
Date: Sun, 26 Jun 2022 20:18:55 +0000 (UTC)	[thread overview]
Message-ID: <1656274658.4497060a03e90facbcf724ed7fb36db040ca1f39.sam@gentoo> (raw)

commit:     4497060a03e90facbcf724ed7fb36db040ca1f39
Author:     Alfred Persson Forsberg <cat <AT> catcream <DOT> org>
AuthorDate: Sun Jun 26 19:42:45 2022 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Sun Jun 26 20:17:38 2022 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=4497060a

kde-apps/konsole: fix build for musl

This patch fixes building Konsole with musl. Konsole uses the GNU
extension malloc_trim and this patch makes Konsole use it conditionally
depending on if it's present on the target system.

This is upstreamed for release 22.04.3 (mid July).

See-also: https://invent.kde.org/utilities/konsole/-/merge_requests/621
Signed-off-by: Alfred Persson Forsberg <cat <AT> catcream.org>
Closes: https://github.com/gentoo/gentoo/pull/26084
Signed-off-by: Sam James <sam <AT> gentoo.org>

 .../files/konsole-22.04.2-musl_malloc_trim.patch   | 92 ++++++++++++++++++++++
 kde-apps/konsole/konsole-22.04.2.ebuild            |  2 +
 2 files changed, 94 insertions(+)

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
new file mode 100644
index 000000000000..455dbc55821f
--- /dev/null
+++ b/kde-apps/konsole/files/konsole-22.04.2-musl_malloc_trim.patch
@@ -0,0 +1,92 @@
+https://invent.kde.org/utilities/konsole/-/merge_requests/621
+https://invent.kde.org/utilities/konsole/-/commit/b8c90a830ceaf293e61f6cd5217bb3e584f997b8 (backport)
+
+
+From b8c90a830ceaf293e61f6cd5217bb3e584f997b8 Mon Sep 17 00:00:00 2001
+From: Heiko Becker <heiko.becker@kde.org>
+Date: Tue, 22 Mar 2022 22:08:10 +0100
+Subject: [PATCH] Detect the presence of malloc_trim to fix the build with musl
+
+malloc_trim is indeed a GNU extension, but an extension of glibc.
+Relying on __GNUC__ unfortunately doesn't help with that. Check for
+the actual presence of malloc_trim with cmake's check_function_exists
+instead.
+This fixes the build with musl libc, which doesn't come with
+malloc_trim.
+
+Co-authored-by: Ahmad Samir <a.samirh78@gmail.com>
+(cherry picked from commit f6310c2b791275f3727f2240ca7fab9f58db943d)
+---
+ CMakeLists.txt             |  2 +-
+ src/Screen.cpp             | 17 +++++++----------
+ src/config-konsole.h.cmake |  4 ++--
+ 3 files changed, 10 insertions(+), 13 deletions(-)
+
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index f2c9d43ac..b306597ba 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -94,7 +94,7 @@ set(HAVE_X11 ${X11_FOUND})
+ # Check for function GETPWUID
+ check_symbol_exists(getpwuid "pwd.h" HAVE_GETPWUID)
+ 
+-check_include_files(malloc.h      HAVE_MALLOC_H)
++check_function_exists(malloc_trim HAVE_MALLOC_TRIM)
+ 
+ # See above includes for defaults
+ add_definitions(
+diff --git a/src/Screen.cpp b/src/Screen.cpp
+index e57314cd5..dff9b54a4 100644
+--- a/src/Screen.cpp
++++ b/src/Screen.cpp
+@@ -28,13 +28,11 @@
+ #include "history/HistoryType.h"
+ #include "profile/Profile.h"
+ 
+-#ifdef HAVE_MALLOC_H
+-    // For malloc_trim, which is a GNU extension
+-    #ifdef __GNUC__
+-    extern "C" {
+-            #include <malloc.h>
+-    }
+-    #endif
++#ifdef HAVE_MALLOC_TRIM
++// For malloc_trim, which is a GNU extension
++extern "C" {
++#include <malloc.h>
++}
+ #endif
+ 
+ using namespace Konsole;
+@@ -1799,14 +1797,13 @@ void Screen::setScroll(const HistoryType &t, bool copyPreviousScroll)
+         t.scroll(_history);
+     }
+ 
+-#ifdef HAVE_MALLOC_H
++#ifdef HAVE_MALLOC_TRIM
++
+ #ifdef Q_OS_LINUX
+-#ifdef __GNUC__
+     // We might have been using gigabytes of memory, so make sure it is actually released
+     malloc_trim(0);
+ #endif
+ #endif
+-#endif
+ }
+ 
+ bool Screen::hasScroll() const
+diff --git a/src/config-konsole.h.cmake b/src/config-konsole.h.cmake
+index b74992b0a..4b1d9b515 100644
+--- a/src/config-konsole.h.cmake
++++ b/src/config-konsole.h.cmake
+@@ -15,5 +15,5 @@
+ 
+ #cmakedefine HAVE_GETPWUID ${HAVE_GETPWUID}
+ 
+-/* Define to 1 if you have the <malloc.h> header file. */
+-#cmakedefine HAVE_MALLOC_H 1
++/* Defined if system has the malloc_trim function, which is a GNU extension */
++#cmakedefine HAVE_MALLOC_TRIM
+-- 
+GitLab
+

diff --git a/kde-apps/konsole/konsole-22.04.2.ebuild b/kde-apps/konsole/konsole-22.04.2.ebuild
index cd237a5abc51..76ba1af7bc7f 100644
--- a/kde-apps/konsole/konsole-22.04.2.ebuild
+++ b/kde-apps/konsole/konsole-22.04.2.ebuild
@@ -18,6 +18,8 @@ SLOT="5"
 KEYWORDS="~amd64 ~arm64 ~ppc64 ~riscv ~x86"
 IUSE="X"
 
+PATCHES=( "${FILESDIR}"/${PN}-22.04.2-musl_malloc_trim.patch )
+
 DEPEND="
 	>=dev-qt/qtdbus-${QTMIN}:5
 	>=dev-qt/qtgui-${QTMIN}:5


             reply	other threads:[~2022-06-26 20:19 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-26 20:18 Sam James [this message]
  -- strict thread matches above, loose matches on Subject: below --
2021-09-22 21:59 [gentoo-commits] repo/gentoo:master commit in: kde-apps/konsole/, kde-apps/konsole/files/ Andreas Sturmlechner
2021-08-24 13:39 Andreas Sturmlechner
2021-08-15 19:11 Andreas Sturmlechner
2021-08-13 20:14 Andreas Sturmlechner
2021-05-01 21:24 Andreas Sturmlechner
2020-05-28 20:20 Andreas Sturmlechner
2020-03-23 23:57 Andreas Sturmlechner
2018-12-23  1:25 Andreas Sturmlechner
2018-02-08  0:10 Andreas Sturmlechner
2017-04-25 12:47 Michael Palimaka

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1656274658.4497060a03e90facbcf724ed7fb36db040ca1f39.sam@gentoo \
    --to=sam@gentoo.org \
    --cc=gentoo-commits@lists.gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox