Subject: RPMs for ppc64/ppc64le

From: Bernd Helmle <[email-masked]>
Date: Mon, 04 Sep 2017 18:00:08 +0200

Folks

POWER support is finally there, that's great and thanks for all the
guys involved to make that happen!

However, i found the way how the SPEC file define the build parameters
for POWER not very usable at the moment. Currently, we build per
default with the IBM Advanced Toolchain (AT) if ppc64 and ppc64le
architecture is defined and use those definitions in all SPEC files.
I've got complaints from some people building from upstream source
packages on their ppc64/ppc64le infrastructure, that the current
behavior is suboptimal if you don't want to rely on IBM AT (not
everyone is convinced that it is better to build with higher
optimization levels) or even power8 CPU instructions. E.g. there are
still users out there running PostgreSQL on dozens of POWER7 machines
and the current behavior of the SPEC files breaks their build
environments. The latter makes it currently hard on those older POWER
CPUs to build packages based on current upstream source rpms, cause
they install but can't be executed without patching all the SPEC files.

There are several solutions to this situation which come to my mind
which i want to discuss. Maybe there are some others, better ones, but
let's start with this:

The current behavior forces you to use the IBM Advanced Toolchain, so
what i would like to see is to turn that feature easily off. We could
make the procedure to choose the IBM AT conditional with the default to
on , like i've done in the attached patch. Though this requires to
specialize all SPEC files currently supported on ppc64/ppc64le. It
basically moves all tests for ppc64/ppc64le into a single conditional
and summarizes them with a new macro %ibmpower. That's used afterwards
for checking if IBM AT or special flags are required. This allows
rpmbuild to deselect the default IBM AT based build with --define
"ibmpower 0", enabling the default compiler to be used.

Another solution that come to my mind: use a single centralized rpmrc
passed to rpmbuild (via --rcfile) during the build process. This file
defines all necessary macros to build the packages like now, but in a
single place. This would make it better maintainable in the future,
say, when POWER9 comes along and would allow to easily override default
settings with custom ones. We could make that a special setting to make
(e.g RPMRC=<yourfile> make rpm96), but i haven't dug too deep into that
approach yet.

I'm willing to work on that, if we agree that we want to improve in
that area.

Opinions?

Thanks,
	Bernd
diff --git a/rpm/redhat/9.6/postgresql/master/postgresql-9.6.spec b/rpm/redhat/9.6/postgresql/master/postgresql-9.6.spec
index e4dd607..2260c27 100644
--- a/rpm/redhat/9.6/postgresql/master/postgresql-9.6.spec
+++ b/rpm/redhat/9.6/postgresql/master/postgresql-9.6.spec
@@ -5,6 +5,10 @@
 %global pgpackageversion 9.6
 %global pginstdir /usr/pgsql-%{pgpackageversion}
 
+# use IBM Advanced Toolchain per default
+%ifarch ppc64 ppc64le
+%{!?ibmpower:%global ibmpower 1}
+%endif
 
 %global beta 0
 %{?beta:%global __os_install_post /usr/lib/rpm/brp-compress}
@@ -54,7 +58,7 @@
 %{!?selinux:%global selinux 0}
 %else
 %{!?systemd_enabled:%global systemd_enabled 1}
-%ifarch ppc64 ppc64le
+%if %ibmpower
 %{!?sdt:%global sdt 0}
 %else
 %{!?sdt:%global sdt 1}
@@ -65,7 +69,7 @@
 %global _hardened_build 1
 %endif
 
-%ifarch ppc64 ppc64le
+%if %ibmpower
 # Define the AT version and path.
 %global atstring	at10.0
 %global atpath		/opt/%{atstring}
@@ -109,7 +113,7 @@ Patch6:		%{sname}-%{pgmajorversion}-perl-rpath.patch
 BuildRequires:	perl glibc-devel bison flex >= 2.5.31
 BuildRequires:	perl(ExtUtils::MakeMaker)
 
-%ifarch ppc64 ppc64le
+%if %ibmpower
 BuildRequires:	advance-toolchain-%{atstring}-devel
 %endif
 
@@ -142,7 +146,7 @@ BuildRequires:	zlib-devel >= 1.0.4
 %if %ssl
 # We depend un the SSL libraries provided by Advance Toolchain on PPC,
 # so use openssl-devel only on other platforms:
-%ifnarch ppc64 ppc64le
+%if 0%{?ibmpower}
 BuildRequires:	openssl-devel
 %endif
 %endif
@@ -229,7 +233,7 @@ Requires(postun):	%{_sbindir}/update-alternatives
 BuildRoot:	%{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
 Provides:	postgresql
 
-%ifarch ppc64 ppc64le
+%if %ibmpower
 AutoReq:	0
 Requires:	advance-toolchain-%{atstring}-runtime
 %endif
@@ -252,7 +256,7 @@ Summary:	The shared libraries required for any PostgreSQL clients
 Group:		Applications/Databases
 Provides:	postgresql-libs = %{pgpackageversion}
 
-%ifarch ppc64 ppc64le
+%if %ibmpower
 AutoReq:	0
 Requires:	advance-toolchain-%{atstring}-runtime
 %endif
@@ -289,7 +293,7 @@ Requires:	/usr/sbin/useradd, /sbin/chkconfig
 %endif
 Provides:	postgresql-server
 
-%ifarch ppc64 ppc64le
+%if %ibmpower
 AutoReq:	0
 Requires:	advance-toolchain-%{atstring}-runtime
 %endif
@@ -319,7 +323,7 @@ Requires:	%{name}%{?_isa} = %{version}-%{release}
 Requires:	%{name}-libs%{?_isa} = %{version}-%{release}
 Provides:	postgresql-contrib
 
-%ifarch ppc64 ppc64le
+%if %ibmpower
 AutoReq:	0
 Requires:	advance-toolchain-%{atstring}-runtime
 %endif
@@ -358,13 +362,13 @@ Summary:	The Perl procedural language for PostgreSQL
 Group:		Applications/Databases
 Requires:	%{name}-server%{?_isa} = %{version}-%{release}
 Requires:	perl(:MODULE_COMPAT_%(eval "`%{__perl} -V:version`"; echo $version))
-%ifarch ppc ppc64
+%if %ibmpower
 BuildRequires:	perl-devel
 %endif
 Obsoletes:	postgresql%{pgmajorversion}-pl
 Provides:	postgresql-plperl
 
-%ifarch ppc64 ppc64le
+%if %ibmpower
 AutoReq:	0
 Requires:	advance-toolchain-%{atstring}-runtime
 %endif
@@ -385,7 +389,7 @@ Requires:	%{name}-server%{?_isa} = %{version}-%{release}
 Obsoletes:	%{name}-pl
 Provides:	postgresql-plpython
 
-%ifarch ppc64 ppc64le
+%if %ibmpower
 AutoReq:	0
 Requires:	advance-toolchain-%{atstring}-runtime
 %endif
@@ -406,7 +410,7 @@ Requires:	%{name}-server%{?_isa} = %{version}-%{release}
 Obsoletes:	%{name}-pl
 Provides:	postgresql-plpython3
 
-%ifarch ppc64 ppc64le
+%if %ibmpower
 AutoReq:	0
 Requires:	advance-toolchain-%{atstring}-runtime
 %endif
@@ -428,7 +432,7 @@ Requires:	tcl
 Obsoletes:	%{name}-pl
 Provides:	postgresql-pltcl
 
-%ifarch ppc64 ppc64le
+%if %ibmpower
 AutoReq:	0
 Requires:	advance-toolchain-%{atstring}-runtime
 %endif
@@ -447,7 +451,7 @@ Requires:	%{name}-server%{?_isa} = %{version}-%{release}
 Requires:	%{name}-devel%{?_isa} = %{version}-%{release}
 Provides:	postgresql-test
 
-%ifarch ppc64 ppc64le
+%if %ibmpower
 AutoReq:	0
 Requires:	advance-toolchain-%{atstring}-runtime
 %endif
@@ -482,7 +486,7 @@ benchmarks.
 %endif
 
 CFLAGS="${CFLAGS:-%optflags}"
-%ifarch ppc64 ppc64le
+%if %ibmpower
 	CFLAGS="${CFLAGS} $(echo %{__global_cflags} | sed 's/-O2/-O3/g') -m64 -mcpu=power8 -mtune=power8 -I%{atpath}/include"
 	CXXFLAGS="${CXXFLAGS} $(echo %{__global_cflags} | sed 's/-O2/-O3/g') -m64 -mcpu=power8 -mtune=power8 -I%{atpath}/include"
 	LDFLAGS="-L%{atpath}/%{_lib}"
@@ -571,7 +575,7 @@ export PYTHON=/usr/bin/python3
 %if %{systemd_enabled}
 	--with-systemd \
 %endif
-%ifarch ppc64 ppc64le
+%if %ibmpower
 	--with-includes=%{atpath}/include \
 	--with-libraries=%{atpath}/lib64 \
 %endif
@@ -662,7 +666,7 @@ unset PYTHON
 %if %{systemd_enabled}
 	--with-systemd \
 %endif
-%ifarch ppc64 ppc64le
+%if %ibmpower
 	--with-includes=%{atpath}/include \
 	--with-libraries=%{atpath}/lib64 \
 %endif

-- 
Sent via pgsql-pkg-yum mailing list ([email-masked])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-pkg-yum

---

From: Devrim Gündüz <[email-masked]>
Date: Thu, 05 Oct 2017 02:00:50 +0100

Hi Bernd,

Apologies for the *very* late response.

I am really interested in this, but we need to find a solution which we can
apply to all of the packages that include Power support.

Are you coming to PGConf.EU? If so, we can discuss this there.

Regards, Devrim

-- 
Devrim Gündüz
EnterpriseDB: https://www.enterprisedb.com
PostgreSQL Consultant, Red Hat Certified Engineer
Twitter: @DevrimGunduz , @DevrimGunduzTR

---

From: Bernd Helmle <[email-masked]>
Date: Fri, 06 Oct 2017 14:18:16 +0200

> Are you coming to PGConf.EU? If so, we can discuss this there.

Great, see you there then!

	Bernd