#2 Add patch for building on rhel8
Merged 2 years ago by ngompa. Opened 2 years ago by tdawson.
rpms/ tdawson/libksysguard patch-for-gcc8  into  rawhide

@@ -0,0 +1,24 @@ 

+ From 47a9b6c58db012941a1c0e171c6abfdaef31acd1 Mon Sep 17 00:00:00 2001

+ From: Troy Dawson <tdawson@redhat.com>

+ Date: Fri, 25 Jun 2021 06:43:04 -0700

+ Subject: [PATCH] fix processcore on gcc8

+ 

+ ---

+  processcore/CMakeLists.txt | 1 +

+  1 file changed, 1 insertion(+)

+ 

+ diff --git a/processcore/CMakeLists.txt b/processcore/CMakeLists.txt

+ index c28d364..d3da632 100644

+ --- a/processcore/CMakeLists.txt

+ +++ b/processcore/CMakeLists.txt

+ @@ -36,6 +36,7 @@ target_link_libraries(processcore

+      KF5::CoreAddons

+      KF5::Service

+      ZLIB::ZLIB

+ +    stdc++fs

+  )

+  

+  if( ${CMAKE_SYSTEM_NAME} MATCHES "NetBSD" )

+ -- 

+ 2.27.0

+ 

file modified
+4
@@ -15,6 +15,10 @@ 

  %endif

  Source0: http://download.kde.org/%{stable}/plasma/%{version}/%{name}-%{version}.tar.xz

  

+ # GCC 8 and older need stdc++fs link library set

+ # GCC 9+ have it set by default.  It does not harm to set it again.

+ Patch1:            libksysguard-5.22.2.1_fix-processcore-on-gcc8.patch

+ 

  BuildRequires:  extra-cmake-modules

  BuildRequires:  kf5-rpm-macros

  # kf5 required

RHEL8 still has gcc8.
gcc8 requires stdc++fs to be set. This patch sets it for RHEL8 and older.

Signed-off-by: Troy Dawson tdawson@redhat.com

Wouldn't another way to do this be to do something like this in %build?

%build
%if 0%{?rhel} && %{?rhel} < 8
export LDFLAGS="%{__global_ldflags} -lstdc++fs"
%endif
%cmake_kf5 \
  -DKDE_INSTALL_INCLUDEDIR:PATH=%{_kf5_includedir}

%cmake_build

Or alternatively, maybe we want to use a newer GCC for EPEL8 and older?

Wouldn't another way to do this be to do something like this in %build?

```
%build
%if 0%{?rhel} && %{?rhel} < 8
export LDFLAGS="%{__global_ldflags} -lstdc++fs"
%endif
%cmake_kf5 \
-DKDE_INSTALL_INCLUDEDIR:PATH=%{_kf5_includedir}

%cmake_build

```

Nope (just tried it)
I tried all the variations I could think of, and more. The only way I could get it to work was patch the cmakelist.txt file.

Or alternatively, maybe we want to use a newer GCC for EPEL8 and older?

That sounds scary. I'd prefer all my kde builds to use the same gcc, and I don't want to change all the other packages.

What's wrong with this patch that only happens on RHEL8 builds?

Here is a successful build
https://koji.fedoraproject.org/koji/taskinfo?taskID=70796970

The only thing wrong with it is the conditional Patch entry. We're not supposed to do that, since that leads to SRPMs with missing content.

Actually, is it harmful to apply the patch, even on Fedora?

The only thing wrong with it is the conditional Patch entry. We're not supposed to do that, since that leads to SRPMs with missing content.

That's right. I hate it when that happens, but it does happen.

Actually, is it harmful to apply the patch, even on Fedora?

No, it should not be harmful.
stdc++fs was set to default in gcc9+. Thus adding this option for newer versions of gcc doesn't change anything.
I have done test builds with the patch on both rawhide and f34, and both build just fine.
https://koji.fedoraproject.org/koji/taskinfo?taskID=70818390
https://koji.fedoraproject.org/koji/taskinfo?taskID=70818410

I will update my pull request with the %if taken off.

1 new commit added

  • remove %if around patch
2 years ago

Pull-Request has been merged by ngompa

2 years ago

For posterity, looks like an open problem for cmake upstream as well,
https://gitlab.kitware.com/cmake/cmake/-/issues/17834

They provided a funky conditional we could consider too (which may be upstreamable):

target_link_libraries(mylibrary PRIVATE $<$<AND:$<CXX_COMPILER_ID:GNU>,$<VERSION_LESS:$<CXX_COMPILER_VERSION>,9.0>>:stdc++fs>)

If it works, we can certainly try to upstream it.

I have tested it on both epel8-next and rawhide. success on all arches for both.
So LGTM.

I have tested it on both epel8-next and rawhide. success on all arches for both.
So LGTM.

Meaning I have tested rdieter's updated patch. Just to be clear.