Drop link and optimization flags from pkgconf file

Patches are rearranged a bit for clarity.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek 2022-02-08 10:27:19 +01:00
parent f29c84ef27
commit 760052bc68
3 changed files with 86 additions and 13 deletions

View File

@ -0,0 +1,43 @@
From 395fecb92fb362b3cd1a91cb278d14160c5ded29 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
Date: Tue, 8 Feb 2022 10:19:12 +0100
Subject: [PATCH] pkgconf: remove optimization and link flags from pkgconf file
Those flags are generally something "private" to a particular build. If we build
mpich with -O2, it does not mean that some other program using the library should
be built with -O2.
In package builds in Fedora we ended up with:
WRAPPER_LDFLAGS = -Wl,-z,relro -Wl,--as-needed -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -Wl,--build-id=sha1 -Wl,-dT,/builddir/build/BUILD/mpich-3.4.1/.package_note-mpich-3.4.1-11.fc36.x86_64.ld -Lsystem/lib
WRAPPER_CFLAGS = -O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection
None of those are appropriate to be exported to dependent projects.
For https://fedoraproject.org/wiki/Changes/Package_information_on_ELF_objects.
---
src/packaging/pkgconfig/mpich.pc.in | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/src/packaging/pkgconfig/mpich.pc.in b/src/packaging/pkgconfig/mpich.pc.in
index e905ff2e20..ff6dc35807 100644
--- a/src/packaging/pkgconfig/mpich.pc.in
+++ b/src/packaging/pkgconfig/mpich.pc.in
@@ -9,12 +9,12 @@ Description: High Performance and portable MPI
Version: @MPICH_VERSION@
URL: http://www.mcs.anl.gov/research/projects/mpich
Requires:
-Libs: @WRAPPER_C_DYNAMIC_LOADING_FLAGS@ @WRAPPER_LDFLAGS@ -L${libdir} -l@MPILIBNAME@ @LPMPILIBNAME@ @WRAPPER_LIBS@
-Cflags: @WRAPPER_CPPFLAGS@ @WRAPPER_CFLAGS@ -I${includedir}
+Libs: @WRAPPER_C_DYNAMIC_LOADING_FLAGS@ -L${libdir} -l@MPILIBNAME@ @LPMPILIBNAME@ @WRAPPER_LIBS@
+Cflags: @WRAPPER_CPPFLAGS@ -I${includedir}
# pkg-config does not understand Cxxflags, etc. So we allow users to
# query them using the --variable option
-cxxflags=@WRAPPER_CPPFLAGS@ @WRAPPER_CXXFLAGS@ -I${includedir}
-fflags=@WRAPPER_FFLAGS@ -I${includedir}
-fcflags=@WRAPPER_FCFLAGS@ -I${includedir}
+cxxflags=@WRAPPER_CPPFLAGS@ -I${includedir}
+fflags=-I${includedir}
+fcflags=-I${includedir}

View File

@ -0,0 +1,25 @@
From 3af7825496ad12951d941ddba28361686028534b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
Date: Tue, 8 Feb 2022 10:45:41 +0100
Subject: [PATCH] pkgconf: also drop rpath flags from pkgconf file
When environment modules are used, libraries are resolved using normal
linker search options. The rpath argument here is actually completely
wrong in that case.
---
src/packaging/pkgconfig/mpich.pc.in | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/packaging/pkgconfig/mpich.pc.in b/src/packaging/pkgconfig/mpich.pc.in
index ff6dc35807..5ad7e8bcbc 100644
--- a/src/packaging/pkgconfig/mpich.pc.in
+++ b/src/packaging/pkgconfig/mpich.pc.in
@@ -9,7 +9,7 @@ Description: High Performance and portable MPI
Version: @MPICH_VERSION@
URL: http://www.mcs.anl.gov/research/projects/mpich
Requires:
-Libs: @WRAPPER_C_DYNAMIC_LOADING_FLAGS@ -L${libdir} -l@MPILIBNAME@ @LPMPILIBNAME@ @WRAPPER_LIBS@
+Libs: -L${libdir} -l@MPILIBNAME@ @LPMPILIBNAME@ @WRAPPER_LIBS@
Cflags: @WRAPPER_CPPFLAGS@ -I${includedir}
# pkg-config does not understand Cxxflags, etc. So we allow users to

View File

@ -9,15 +9,24 @@ Source0: https://www.mpich.org/static/downloads/%{version}/%{name}-%{vers
Source1: mpich.macros
Source2: mpich.pth.py2
Source3: mpich.pth.py3
Patch0: mpich-modules.patch
Patch1: 0001-Drop-real128.patch
Patch0: 0001-Drop-real128.patch
Patch1: mpich-modules.patch
# Drop build flags, e.g. -specs... and -lto from mpi wrappers (mpicc and mpicxx)
# for discussion see:
# https://lists.fedoraproject.org/archives/list/devel@lists.fedoraproject.org/message/7TFWEKTDWBYBHEGMIWBVI3AVGORZGNBS/
Patch3: fix_wrapper_flags.patch
Patch2: fix_wrapper_flags.patch
Patch3: 0001-pkgconf-remove-optimization-and-link-flags-from-pkgc.patch
Patch4: 0002-pkgconf-also-drop-rpath-flags-from-pkgconf-file.patch
# TODO: submit ^ upstream
# https://github.com/pmodels/mpich/issues/4534
Patch4: 0001-Revert-Remove-use-of-vasprintf.patch
Patch5: esac-syntax-fix.diff
Patch5: 0001-Revert-Remove-use-of-vasprintf.patch
# There seems to be some syntax error, but I cannot figure out what it
# is (";;" is missing, but adding it doesn't fix things). Since we use
# clock_gettime anyway, just rip out the whole block.
Patch6: esac-syntax-fix.diff
BuildRequires: make
BuildRequires: gcc
@ -110,20 +119,16 @@ mpich support for Python 3.
%prep
%setup
%patch0 -p1
%ifarch %{arm}
%patch1 -p1
%patch0 -p1
%endif
%patch1 -p1
%patch2 -p1
%patch3 -p1
%patch4 -p1
# There seems to be some syntax error, but I cannot figure out what it
# is (";;" is missing, but adding it doesn't fix things). Since we use
# clock_gettime anyway, just rip out the whole block.
%patch5 -p1
%patch6 -p1
%build
./autogen.sh