From 7a510bbf4b6b21342611d8934a3f29ab67c991b8 Mon Sep 17 00:00:00 2001 From: Orion Poplawski Date: Mon, 11 Jan 2016 13:41:57 -0700 Subject: [PATCH 1/3] Allow conditional build with or without system lapack, default to without --- openblas.spec | 34 +++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/openblas.spec b/openblas.spec index 26e2f95..8949b65 100644 --- a/openblas.spec +++ b/openblas.spec @@ -1,6 +1,8 @@ +%bcond_with system_lapack + Name: openblas Version: 0.2.15 -Release: 2%{?dist} +Release: 3%{?dist} Summary: An optimized BLAS library based on GotoBLAS2 Group: Development/Libraries License: BSD @@ -10,14 +12,13 @@ Source0: https://github.com/xianyi/OpenBLAS/archive/v%{version}.tar.gz Patch0: openblas-0.2.15-system_lapack.patch # Drop extra p from threaded library name Patch1: openblas-0.2.5-libname.patch -# Don't test link against functions in lapacke 3.5.0 if only 3.4.0 is available -Patch2: openblas-0.2.10-lapacke.patch BuildRoot: %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX) BuildRequires: gcc-gfortran # For execstack BuildRequires: /usr/bin/execstack # LAPACK +%if %{with system_lapack} %if 0%{?rhel} == 5 || 0%{?rhel} == 6 BuildRequires: lapack-devel%{?_isa} %else @@ -25,11 +26,16 @@ BuildRequires: lapack-static%{?_isa} %endif # Do we have LAPACKE? (Needs at least lapack 3.4.0) -%if 0%{?fedora} > 16 +%if 0%{?fedora} %global lapacke 1 %else %global lapacke 0 %endif +%else +%global lapacke 1 + +Provides: bundled(lapack) +%endif # Build 64-bit interface binaries? %if 0%{?rhel} == 5 || 0%{?rhel} == 6 @@ -43,9 +49,11 @@ BuildRequires: lapack-static%{?_isa} %endif %endif +%if %{with system_lapack} %if %build64 BuildRequires: lapack64-static %endif +%endif # Upstream supports the package only on these architectures. # Runtime processor detection is not available on other archs. @@ -177,17 +185,18 @@ This package contains the static libraries. # Untar source tar zxf %{SOURCE0} cd OpenBLAS-%{version} +%if %{with system_lapack} %patch0 -p1 -b .system_lapack -%patch1 -p1 -b .libname -%if 0%{?fedora} > 0 && 0%{?fedora} < 21 -%patch2 -p1 -b .lapacke %endif +%patch1 -p1 -b .libname # Fix source permissions find -name \*.f -exec chmod 644 {} \; +%if %{with system_lapack} # Get rid of bundled LAPACK sources rm -rf lapack-netlib +%endif # Make serial, threaded and OpenMP versions; as well as 64-bit versions cd .. @@ -200,6 +209,7 @@ done %endif mv OpenBLAS-%{version} serial +%if %{with system_lapack} # Setup 32-bit interface LAPACK mkdir netliblapack cd netliblapack @@ -272,11 +282,10 @@ for d in {serial,threaded,openmp}64{,_}; do done rm -rf netliblapack64 %endif +%endif %build -%if %{lapacke} -LAPACKE="NO_LAPACKE=0" -%else +%if !%{lapacke} LAPACKE="NO_LAPACKE=1" %endif @@ -323,7 +332,7 @@ rm -rf %{buildroot} make -C serial USE_THREAD=0 PREFIX=%{buildroot} OPENBLAS_LIBRARY_DIR=%{buildroot}%{_libdir} OPENBLAS_INCLUDE_DIR=%{buildroot}%{_includedir}/%name OPENBLAS_BINARY_DIR=%{buildroot}%{_bindir} OPENBLAS_CMAKE_DIR=%{buildroot}%{_libdir}/cmake install # Copy lapacke include files -%if %{lapacke} +%if %{with system_lapack} && %{lapacke} cp -a %{_includedir}/lapacke %{buildroot}%{_includedir}/%{name} %endif @@ -556,6 +565,9 @@ rm -rf %{buildroot} %endif %changelog +* Mon Jan 11 2016 Orion Poplawski - 0.2.15-3 +- Allow conditional build with or without system lapack, default to without + * Tue Dec 01 2015 Susi Lehtola - 0.2.15-2 - Enable armv7hl and ppc64le architectures. - Build versions of the 64-bit libraries with an additional suffix From 0d5c1dbfb37cf2929bbb51131696699bb2fd49d8 Mon Sep 17 00:00:00 2001 From: Orion Poplawski Date: Mon, 11 Jan 2016 13:42:32 -0700 Subject: [PATCH 2/3] Drop %defattr() --- openblas.spec | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/openblas.spec b/openblas.spec index 8949b65..d7994f1 100644 --- a/openblas.spec +++ b/openblas.spec @@ -488,55 +488,45 @@ rm -rf %{buildroot}%{_libdir}/cmake rm -rf %{buildroot} %files -%defattr(-,root,root,-) %doc serial/Changelog.txt serial/GotoBLAS* serial/LICENSE %{_libdir}/lib%{name}-*.so %{_libdir}/lib%{name}.so.* %files openmp -%defattr(-,root,root,-) %{_libdir}/lib%{name}o-*.so %{_libdir}/lib%{name}o.so.* %files threads -%defattr(-,root,root,-) %{_libdir}/lib%{name}p-*.so %{_libdir}/lib%{name}p.so.* %if %build64 %files serial64 -%defattr(-,root,root,-) %{_libdir}/lib%{name}64-*.so %{_libdir}/lib%{name}64.so.* %files openmp64 -%defattr(-,root,root,-) %{_libdir}/lib%{name}o64-*.so %{_libdir}/lib%{name}o64.so.* %files threads64 -%defattr(-,root,root,-) %{_libdir}/lib%{name}p64-*.so %{_libdir}/lib%{name}p64.so.* %files serial64_ -%defattr(-,root,root,-) %{_libdir}/lib%{name}64_-*.so %{_libdir}/lib%{name}64_.so.* %files openmp64_ -%defattr(-,root,root,-) %{_libdir}/lib%{name}o64_-*.so %{_libdir}/lib%{name}o64_.so.* %files threads64_ -%defattr(-,root,root,-) %{_libdir}/lib%{name}p64_-*.so %{_libdir}/lib%{name}p64_.so.* %endif %files devel -%defattr(-,root,root,-) %{_includedir}/%{name}/ %{_libdir}/lib%{name}.so %{_libdir}/lib%{name}o.so @@ -551,7 +541,6 @@ rm -rf %{buildroot} %endif %files static -%defattr(-,root,root,-) %{_libdir}/lib%{name}.a %{_libdir}/lib%{name}o.a %{_libdir}/lib%{name}p.a From f2466da44399f25d5f9852acc44875c2d374e8ce Mon Sep 17 00:00:00 2001 From: Susi Lehtola Date: Tue, 12 Jan 2016 20:30:18 +0100 Subject: [PATCH 3/3] Versionize lapack provide. Pull in patches to build in EPEL5 and EPEL7. --- openblas-0.2.15-constructor.patch | 22 ++++++++++++++ openblas.spec | 50 ++++++++++++++++++++++++++----- 2 files changed, 65 insertions(+), 7 deletions(-) create mode 100644 openblas-0.2.15-constructor.patch diff --git a/openblas-0.2.15-constructor.patch b/openblas-0.2.15-constructor.patch new file mode 100644 index 0000000..19ad242 --- /dev/null +++ b/openblas-0.2.15-constructor.patch @@ -0,0 +1,22 @@ +diff -up OpenBLAS-0.2.15/driver/others/memory.c.orig OpenBLAS-0.2.15/driver/others/memory.c +--- OpenBLAS-0.2.15/driver/others/memory.c.orig 2015-10-27 21:44:50.000000000 +0100 ++++ OpenBLAS-0.2.15/driver/others/memory.c 2016-01-12 20:22:14.935338309 +0100 +@@ -1338,7 +1338,7 @@ static void gotoblas_memory_init(void) { + + static int gotoblas_initialized = 0; + +-void CONSTRUCTOR gotoblas_init(void) { ++void gotoblas_init(void) { + + if (gotoblas_initialized) return; + +@@ -1381,7 +1381,7 @@ void CONSTRUCTOR gotoblas_init(void) { + + } + +-void DESTRUCTOR gotoblas_quit(void) { ++void gotoblas_quit(void) { + + if (gotoblas_initialized == 0) return; + +diff -up OpenBLAS-0.2.15/getarch.c.orig OpenBLAS-0.2.15/getarch.c diff --git a/openblas.spec b/openblas.spec index d7994f1..ad43275 100644 --- a/openblas.spec +++ b/openblas.spec @@ -1,8 +1,10 @@ %bcond_with system_lapack +# Version of bundled lapack +%global lapackver 3.5.0 Name: openblas Version: 0.2.15 -Release: 3%{?dist} +Release: 4%{?dist} Summary: An optimized BLAS library based on GotoBLAS2 Group: Development/Libraries License: BSD @@ -12,11 +14,26 @@ Source0: https://github.com/xianyi/OpenBLAS/archive/v%{version}.tar.gz Patch0: openblas-0.2.15-system_lapack.patch # Drop extra p from threaded library name Patch1: openblas-0.2.5-libname.patch +# Don't use constructor priorities +Patch2: openblas-0.2.15-constructor.patch BuildRoot: %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX) BuildRequires: gcc-gfortran -# For execstack + +# Do we have execstack? +%if 0%{?rhel} == 7 +%ifarch ppc64le +%global execstack 0 +%else +%global execstack 1 +%endif +%else +%global execstack 1 +%endif +%if %{execstack} BuildRequires: /usr/bin/execstack +%endif + # LAPACK %if %{with system_lapack} %if 0%{?rhel} == 5 || 0%{?rhel} == 6 @@ -24,17 +41,17 @@ BuildRequires: lapack-devel%{?_isa} %else BuildRequires: lapack-static%{?_isa} %endif - # Do we have LAPACKE? (Needs at least lapack 3.4.0) %if 0%{?fedora} %global lapacke 1 %else %global lapacke 0 %endif -%else -%global lapacke 1 -Provides: bundled(lapack) +%else +# Use bundled LAPACK +%global lapacke 1 +Provides: bundled(lapack) = %{lapackver} %endif # Build 64-bit interface binaries? @@ -189,6 +206,9 @@ cd OpenBLAS-%{version} %patch0 -p1 -b .system_lapack %endif %patch1 -p1 -b .libname +%if 0%{?rhel} == 5 +%patch2 -p1 -b .constructor +%endif # Fix source permissions find -name \*.f -exec chmod 644 {} \; @@ -357,7 +377,7 @@ olibname=`echo ${slibname} | sed "s|lib%{name}|lib%{name}o|g"` install -D -p -m 644 openmp/${olibname}.a %{buildroot}%{_libdir}/lib%{name}o.a if [[ "$suffix" != "" ]]; then oname=$(echo $olibname | sed "s|$suffix||g") -else +else oname=${olibname} fi install -D -p -m 755 openmp/${olibname}.so %{buildroot}%{_libdir}/${oname}.so @@ -450,10 +470,12 @@ ln -sf ${pname64_}.so lib%{name}p64_.so ln -sf ${pname64_}.so lib%{name}p64_.so.0 %endif +%if %{execstack} # Get rid of executable stacks for lib in %{buildroot}%{_libdir}/libopenblas*.so; do execstack -c $lib done +%endif # Get rid of generated CMake config rm -rf %{buildroot}%{_libdir}/cmake @@ -488,45 +510,55 @@ rm -rf %{buildroot}%{_libdir}/cmake rm -rf %{buildroot} %files +%defattr(-,root,root,-) %doc serial/Changelog.txt serial/GotoBLAS* serial/LICENSE %{_libdir}/lib%{name}-*.so %{_libdir}/lib%{name}.so.* %files openmp +%defattr(-,root,root,-) %{_libdir}/lib%{name}o-*.so %{_libdir}/lib%{name}o.so.* %files threads +%defattr(-,root,root,-) %{_libdir}/lib%{name}p-*.so %{_libdir}/lib%{name}p.so.* %if %build64 %files serial64 +%defattr(-,root,root,-) %{_libdir}/lib%{name}64-*.so %{_libdir}/lib%{name}64.so.* %files openmp64 +%defattr(-,root,root,-) %{_libdir}/lib%{name}o64-*.so %{_libdir}/lib%{name}o64.so.* %files threads64 +%defattr(-,root,root,-) %{_libdir}/lib%{name}p64-*.so %{_libdir}/lib%{name}p64.so.* %files serial64_ +%defattr(-,root,root,-) %{_libdir}/lib%{name}64_-*.so %{_libdir}/lib%{name}64_.so.* %files openmp64_ +%defattr(-,root,root,-) %{_libdir}/lib%{name}o64_-*.so %{_libdir}/lib%{name}o64_.so.* %files threads64_ +%defattr(-,root,root,-) %{_libdir}/lib%{name}p64_-*.so %{_libdir}/lib%{name}p64_.so.* %endif %files devel +%defattr(-,root,root,-) %{_includedir}/%{name}/ %{_libdir}/lib%{name}.so %{_libdir}/lib%{name}o.so @@ -541,6 +573,7 @@ rm -rf %{buildroot} %endif %files static +%defattr(-,root,root,-) %{_libdir}/lib%{name}.a %{_libdir}/lib%{name}o.a %{_libdir}/lib%{name}p.a @@ -554,6 +587,9 @@ rm -rf %{buildroot} %endif %changelog +* Tue Jan 12 2016 Susi Lehtola - 0.2.15-4 +- Add version to bundled lapack provide. + * Mon Jan 11 2016 Orion Poplawski - 0.2.15-3 - Allow conditional build with or without system lapack, default to without