diff mbox series

shared-mime-info-native: handle old GCC for AlmaLinux8

Message ID 20231201181515.3346703-1-patrick@stwcx.xyz
State Accepted, archived
Commit 664c7f09ddc15ec9bcb7d8a5bac453922be86a37
Headers show
Series shared-mime-info-native: handle old GCC for AlmaLinux8 | expand

Commit Message

Patrick Williams Dec. 1, 2023, 6:15 p.m. UTC
shared-mime-info-native fails to build on AlmaLinux 8 due to its use of
GCC-8 and the upstream package missing a required `-lstdc++fs` on that
compiler.  Submitted a patch upstream which fixes this and am porting.

Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
---
 ...dle-build-with-older-versions-of-GCC.patch | 60 +++++++++++++++++++
 .../shared-mime-info/shared-mime-info_2.4.bb  |  3 +-
 2 files changed, 62 insertions(+), 1 deletion(-)
 create mode 100644 meta/recipes-support/shared-mime-info/shared-mime-info/0002-Handle-build-with-older-versions-of-GCC.patch
diff mbox series

Patch

diff --git a/meta/recipes-support/shared-mime-info/shared-mime-info/0002-Handle-build-with-older-versions-of-GCC.patch b/meta/recipes-support/shared-mime-info/shared-mime-info/0002-Handle-build-with-older-versions-of-GCC.patch
new file mode 100644
index 0000000000..037431ad40
--- /dev/null
+++ b/meta/recipes-support/shared-mime-info/shared-mime-info/0002-Handle-build-with-older-versions-of-GCC.patch
@@ -0,0 +1,60 @@ 
+From ee15d73fe2790bbe9d4077757523aba276419fbf Mon Sep 17 00:00:00 2001
+From: Patrick Williams <patrick@stwcx.xyz>
+Date: Fri, 1 Dec 2023 11:19:02 -0600
+Subject: [PATCH] Handle build with older versions of GCC
+
+Older versions of GCC (prior to 9.1) did not put the `std::filesystem`
+support directly into libstdcpp, but in a separate `libstdc++fs`.  Add
+meson logic to detect if an extra linker flag is necessary.
+
+Fixes #223.
+
+Tested on AlmaLinux 8 which uses GCC-8.
+
+Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
+Upstream-Status: Submitted [https://gitlab.freedesktop.org/xdg/shared-mime-info/-/merge_requests/278]
+---
+ meson.build | 15 ++++++++++++++-
+ 1 file changed, 14 insertions(+), 1 deletion(-)
+
+diff --git a/meson.build b/meson.build
+index ecc012f..3a6dbbc 100644
+--- a/meson.build
++++ b/meson.build
+@@ -11,6 +11,7 @@ config = configuration_data()
+ i18n = import('i18n')
+ 
+ cc = meson.get_compiler('c')
++cxx = meson.get_compiler('cpp')
+ 
+ ###############################################################################
+ # Project configuration
+@@ -46,12 +47,24 @@ if not xdgmime_found
+     ''')
+ endif
+ 
++###############################################################################
++# Check if GCC needs -lstdc++fs (before 9.1)
++
++if not cxx.links('''
++        #include <filesystem>
++        int main() {
++            return std::filesystem::is_directory(
++                std::filesystem::status("/tmp")) ? 0 : 1;
++        }
++        ''', name: 'std++fs-check')
++    add_project_link_arguments('-lstdc++fs', language : 'cpp')
++endif
++
+ ###############################################################################
+ # Dependencies
+ 
+ config.set('HAVE_FDATASYNC', cc.has_function('fdatasync', prefix: '#include <unistd.h>'))
+ 
+-
+ if get_option('build-translations')
+     subdir('po')
+ endif
+-- 
+2.41.0
+
diff --git a/meta/recipes-support/shared-mime-info/shared-mime-info_2.4.bb b/meta/recipes-support/shared-mime-info/shared-mime-info_2.4.bb
index c7da0ca2d2..ef5df44ad6 100644
--- a/meta/recipes-support/shared-mime-info/shared-mime-info_2.4.bb
+++ b/meta/recipes-support/shared-mime-info/shared-mime-info_2.4.bb
@@ -9,7 +9,8 @@  LIC_FILES_CHKSUM = "file://COPYING;md5=b234ee4d69f5fce4486a80fdaf4a4263"
 DEPENDS = "libxml2 itstool-native glib-2.0 shared-mime-info-native xmlto-native"
 
 SRC_URI = "git://gitlab.freedesktop.org/xdg/shared-mime-info.git;protocol=https;branch=master \
-           file://0001-Fix-build-with-libxml2-2.12.0-and-clang-17.patch"
+           file://0001-Fix-build-with-libxml2-2.12.0-and-clang-17.patch \
+           file://0002-Handle-build-with-older-versions-of-GCC.patch"
 SRCREV = "9a6d6b8e963935f145f3a1ef446552de6996dada"
 
 S = "${WORKDIR}/git"