From 1515d90f83ad7b00602dc0f5eb227da595c9f415 Mon Sep 17 00:00:00 2001 From: Orion Poplawski Date: Mon, 14 Oct 2019 15:57:43 -0600 Subject: [PATCH] Build ILP64 version (bugz#1294200) --- suitesparse.spec | 448 +++++++++++++++++++++++++++++++++-------------- 1 file changed, 314 insertions(+), 134 deletions(-) diff --git a/suitesparse.spec b/suitesparse.spec index 8123f57..967c989 100644 --- a/suitesparse.spec +++ b/suitesparse.spec @@ -19,9 +19,14 @@ ### enable_csparse as 1 below. %global enable_csparse 0 +# Whether to build a separate version of libraries linked against an ILP64 BLAS +%if 0%{?__isa_bits} == 64 +%global build64 1 +%endif + Name: suitesparse Version: 5.4.0 -Release: 1%{?dist} +Release: 2%{?dist} Summary: A collection of sparse matrix libraries License: (LGPLv2+ or BSD) and LGPLv2+ and GPLv2+ @@ -81,10 +86,67 @@ Provides: ufsparse-static = %{version}-%{release} The suitesparse-static package contains the statically linkable version of the suitesparse libraries. + +%if 0%{?build64} +%package -n %{name}64 +Summary: A collection of sparse matrix libraries (ILP64 version) + +%description -n %{name}64 +The suitesparse collection compiled against an ILP64 BLAS library. + + +%package -n %{name}64-devel +Summary: Development headers for SuiteSparse (ILP64 version) +Requires: %{name}-devel = %{version}-%{release} +Requires: %{name}64 = %{version}-%{release} + +%description -n %{name}64-devel +The suitesparse64-devel package contains files needed for developing +applications which use the suitesparse libraries (ILP64 version). + + +%package -n %{name}64-static +Summary: Static version of SuiteSparse libraries (ILP64 version) +Requires: %{name}-devel = %{version}-%{release} + +%description -n %{name}64-static +The suitesparse64-static package contains the statically linkable +version of the suitesparse libraries (ILP64 version). + + +%package -n %{name}64_ +Summary: A collection of sparse matrix libraries (ILP64 version) + +%description -n %{name}64_ +The suitesparse collection compiled against an ILP64 BLAS library. + + +%package -n %{name}64_-devel +Summary: Development headers for SuiteSparse (ILP64 version) +Requires: %{name}-devel = %{version}-%{release} +Requires: %{name}64_ = %{version}-%{release} + +%description -n %{name}64_-devel +The suitesparse64_-devel package contains files needed for developing +applications which use the suitesparse libraries (ILP64 version) compiled +against a BLAS library with the "64_" symbol name suffix (see openblas-*64_ +packages). + + +%package -n %{name}64_-static +Summary: Static version of SuiteSparse libraries (ILP64 version) +Requires: %{name}-devel = %{version}-%{release} + +%description -n %{name}64_-static +The suitesparse64_-static package contains the statically linkable +version of the suitesparse libraries (ILP64 version) compiled against a +BLAS library with the "64_" symbol name suffix (see openblas-*64_ packages). +%endif + + %package doc Summary: Documentation files for SuiteSparse BuildArch: noarch - Requires: %{name} = %{version}-%{release} %description doc @@ -92,173 +154,212 @@ This package contains documentation files for %{name}. %prep -%setup -q -n SuiteSparse -rm -r metis* +%setup -c -q +pushd SuiteSparse + # Remove bundled metis + rm -r metis* + # Makefiles look for metis.h specifically + ln -s %{_includedir}/metis/*.h include/ -# Fix pragma ivdep so gcc understands it. -for fil in $(grep -Frl 'pragma ivdep' .); do - sed -i.orig 's/pragma ivdep/pragma GCC ivdep/' $fil - touch -r ${fil}.orig $fil - rm -f ${fil}.orig -done + # Fix pragma ivdep so gcc understands it. + for fil in $(grep -Frl 'pragma ivdep' .); do + sed -i.orig 's/pragma ivdep/pragma GCC ivdep/' $fil + touch -r ${fil}.orig $fil + rm -f ${fil}.orig + done -# drop non-standard -O3 and duplicate -fexceptions from default CFLAGS -sed -i -e '/^ CF =/ s/ -O3 -fexceptions//' SuiteSparse_config/SuiteSparse_config.mk + # drop non-standard -O3 and duplicate -fexceptions from default CFLAGS + sed -i -e '/^ CF =/ s/ -O3 -fexceptions//' SuiteSparse_config/SuiteSparse_config.mk + + # Allow adding a suffix to the library name + sed -i -e '/SO.*=/s/$(LIBRARY).so/$(LIBRARY)$(LIBRARY_SUFFIX).so/' \ + -e '/AR_TARGET *=/s/$(LIBRARY).a/$(LIBRARY)$(LIBRARY_SUFFIX).a/' SuiteSparse_config/SuiteSparse_config.mk + sed -i -e 's/-l\(amd\|btf\|camd\|ccolamd\|cholmod\|colamd\|csparse\|cxsparse\|klu\|ldl\|rbio\|spqr\|suitesparseconfig\|umfpack\)/-l\1$(LIBRARY_SUFFIX)/g' \ + $(find -name Makefile\* -o -name \*.mk) +popd +%if 0%{?build64} +cp -a SuiteSparse SuiteSparse64 +cp -a SuiteSparse SuiteSparse64_ +%endif %build export AUTOCC=no export CC=gcc -# Makefiles look for metis.h specifically -ln -s %{_includedir}/metis/*.h include/ -# TODO - Try to use upstream makefile - will build more components -mkdir -p Doc/{AMD,BTF,CAMD,CCOLAMD,CHOLMOD,COLAMD,KLU,LDL,UMFPACK,SPQR,RBio} Include -# SuiteSparse_config needs to come first -pushd SuiteSparse_config - %make_build CFLAGS="$RPM_OPT_FLAGS" LAPACK=-lopenblas - cp -p *.h ../Include -popd +for build in SuiteSparse %{?build64:SuiteSparse64 SuiteSparse64_} +do + pushd $build -pushd AMD - pushd Lib - %make_build CFLAGS="$RPM_OPT_FLAGS" LAPACK=-lopenblas + # TODO - Try to use upstream makefile - will build more components + mkdir -p Doc/{AMD,BTF,CAMD,CCOLAMD,CHOLMOD,COLAMD,KLU,LDL,UMFPACK,SPQR,RBio} Include + + export CFLAGS="$RPM_OPT_FLAGS -I%{_includedir}/metis" + export LAPACK="" + # Set flags for ILP64 build + if [ $build = SuiteSparse64 ] + then + export CFLAGS="$CFLAGS -DBLAS64" + export BLAS=-lopenblas64 + export LIBRARY_SUFFIX=64 + elif [ $build = SuiteSparse64_ ] + then + export CFLAGS="$CFLAGS -DBLAS64 -DSUN64" + export BLAS=-lopenblas64_ + export LIBRARY_SUFFIX=64_ + else + export BLAS=-lopenblas + fi + + # SuiteSparse_config needs to come first + pushd SuiteSparse_config + %make_build CFLAGS="$CFLAGS" BLAS="$BLAS" LIBRARY_SUFFIX="$LIBRARY_SUFFIX" + cp -p *.h ../Include popd - cp -p Include/*.h ../Include - cp -p README.txt Doc/License.txt Doc/lesser.txt Doc/ChangeLog Doc/*.pdf ../Doc/AMD -popd -pushd BTF - pushd Lib - %make_build CFLAGS="$RPM_OPT_FLAGS" LAPACK=-lopenblas + pushd AMD + pushd Lib + %make_build CFLAGS="$CFLAGS" BLAS="$BLAS" LIBRARY_SUFFIX="$LIBRARY_SUFFIX" + popd + cp -p Include/*.h ../Include + cp -p README.txt Doc/License.txt Doc/lesser.txt Doc/ChangeLog Doc/*.pdf ../Doc/AMD popd - cp -p Include/*.h ../Include - cp -p README.txt Doc/* ../Doc/BTF -popd -pushd CAMD - pushd Lib - %make_build CFLAGS="$RPM_OPT_FLAGS" LAPACK=-lopenblas + pushd BTF + pushd Lib + %make_build CFLAGS="$CFLAGS" BLAS="$BLAS" LIBRARY_SUFFIX="$LIBRARY_SUFFIX" + popd + cp -p Include/*.h ../Include + cp -p README.txt Doc/* ../Doc/BTF popd - cp -p Include/*.h ../Include - cp -p README.txt Doc/ChangeLog Doc/License.txt Doc/*.pdf ../Doc/CAMD -popd -pushd CCOLAMD - pushd Lib - %make_build CFLAGS="$RPM_OPT_FLAGS" LAPACK=-lopenblas + pushd CAMD + pushd Lib + %make_build CFLAGS="$CFLAGS" BLAS="$BLAS" LIBRARY_SUFFIX="$LIBRARY_SUFFIX" + popd + cp -p Include/*.h ../Include + cp -p README.txt Doc/ChangeLog Doc/License.txt Doc/*.pdf ../Doc/CAMD popd - cp -p Include/*.h ../Include - cp -p README.txt Doc/* ../Doc/CCOLAMD -popd -pushd COLAMD - pushd Lib - %make_build CFLAGS="$RPM_OPT_FLAGS" LAPACK=-lopenblas + pushd CCOLAMD + pushd Lib + %make_build CFLAGS="$CFLAGS" BLAS="$BLAS" LIBRARY_SUFFIX="$LIBRARY_SUFFIX" + popd + cp -p Include/*.h ../Include + cp -p README.txt Doc/* ../Doc/CCOLAMD popd - cp -p Include/*.h ../Include - cp -p README.txt Doc/* ../Doc/COLAMD -popd -CHOLMOD_FLAGS="$RPM_OPT_FLAGS -I%{_includedir}/metis" -pushd CHOLMOD - pushd Lib - %make_build CFLAGS="$CHOLMOD_FLAGS" LAPACK=-lopenblas + pushd COLAMD + pushd Lib + %make_build CFLAGS="$CFLAGS" BLAS="$BLAS" LIBRARY_SUFFIX="$LIBRARY_SUFFIX" + popd + cp -p Include/*.h ../Include + cp -p README.txt Doc/* ../Doc/COLAMD popd - cp -p Include/*.h ../Include - cp -p README.txt Doc/*.pdf ../Doc/CHOLMOD - cp -p Cholesky/lesser.txt ../Doc/CHOLMOD/Cholesky_License.txt - cp -p Core/lesser.txt ../Doc/CHOLMOD/Core_License.txt - cp -p MatrixOps/gpl.txt ../Doc/CHOLMOD/MatrixOps_License.txt - cp -p Partition/lesser.txt ../Doc/CHOLMOD/Partition_License.txt - cp -p Supernodal/gpl.txt ../Doc/CHOLMOD/Supernodal_License.txt -popd -%if "%{?enable_csparse}" == "1" -pushd CSparse - pushd Source - %make_build CFLAGS="$RPM_OPT_FLAGS" LAPACK=-lopenblas - cp -p cs.h ../../Include + pushd CHOLMOD + pushd Lib + %make_build CFLAGS="$CFLAGS" BLAS="$BLAS" LIBRARY_SUFFIX="$LIBRARY_SUFFIX" + popd + cp -p Include/*.h ../Include + cp -p README.txt Doc/*.pdf ../Doc/CHOLMOD + cp -p Cholesky/lesser.txt ../Doc/CHOLMOD/Cholesky_License.txt + cp -p Core/lesser.txt ../Doc/CHOLMOD/Core_License.txt + cp -p MatrixOps/gpl.txt ../Doc/CHOLMOD/MatrixOps_License.txt + cp -p Partition/lesser.txt ../Doc/CHOLMOD/Partition_License.txt + cp -p Supernodal/gpl.txt ../Doc/CHOLMOD/Supernodal_License.txt popd - mkdir ../Doc/CSparse/ - cp -p Doc/* ../Doc/CSparse -popd -%else -pushd CXSparse - pushd Lib - %make_build CFLAGS="$RPM_OPT_FLAGS" LAPACK=-lopenblas + %if "%{?enable_csparse}" == "1" + pushd CSparse + pushd Source + %make_build CFLAGS="$CFLAGS" BLAS="$BLAS" LIBRARY_SUFFIX="$LIBRARY_SUFFIX" + cp -p cs.h ../../Include + popd + mkdir ../Doc/CSparse/ + cp -p Doc/* ../Doc/CSparse popd - cp -p Include/cs.h ../Include - mkdir ../Doc/CXSparse/ - cp -p Doc/* ../Doc/CXSparse -popd -%endif -pushd KLU - pushd Lib - %make_build CFLAGS="$RPM_OPT_FLAGS" LAPACK=-lopenblas + %else + pushd CXSparse + pushd Lib + %make_build CFLAGS="$CFLAGS" BLAS="$BLAS" LIBRARY_SUFFIX="$LIBRARY_SUFFIX" + popd + cp -p Include/cs.h ../Include + mkdir ../Doc/CXSparse/ + cp -p Doc/* ../Doc/CXSparse popd - cp -p Include/*.h ../Include - cp -p README.txt Doc/lesser.txt ../Doc/KLU -popd + %endif -pushd LDL - pushd Lib - %make_build CFLAGS="$RPM_OPT_FLAGS" LAPACK=-lopenblas + pushd KLU + pushd Lib + %make_build CFLAGS="$CFLAGS" BLAS="$BLAS" LIBRARY_SUFFIX="$LIBRARY_SUFFIX" + popd + cp -p Include/*.h ../Include + cp -p README.txt Doc/lesser.txt ../Doc/KLU popd - cp -p Include/*.h ../Include - cp -p README.txt Doc/ChangeLog Doc/lesser.txt Doc/*.pdf ../Doc/LDL -popd -pushd UMFPACK - pushd Lib - %make_build CFLAGS="$RPM_OPT_FLAGS" LAPACK=-lopenblas + pushd LDL + pushd Lib + %make_build CFLAGS="$CFLAGS" BLAS="$BLAS" LIBRARY_SUFFIX="$LIBRARY_SUFFIX" + popd + cp -p Include/*.h ../Include + cp -p README.txt Doc/ChangeLog Doc/lesser.txt Doc/*.pdf ../Doc/LDL popd - cp -p Include/*.h ../Include - cp -p README.txt Doc/License.txt Doc/ChangeLog Doc/gpl.txt Doc/*.pdf ../Doc/UMFPACK -popd -pushd SPQR - pushd Lib - %make_build CFLAGS="$RPM_OPT_FLAGS -DHAVE_TBB -DNPARTITION" LAPACK=-lopenblas TBB=-ltbb + pushd UMFPACK + pushd Lib + %make_build CFLAGS="$CFLAGS" BLAS="$BLAS" LIBRARY_SUFFIX="$LIBRARY_SUFFIX" + popd + cp -p Include/*.h ../Include + cp -p README.txt Doc/License.txt Doc/ChangeLog Doc/gpl.txt Doc/*.pdf ../Doc/UMFPACK popd - cp -p Include/*.h* ../Include - cp -p README{,_SPQR}.txt - cp -p README_SPQR.txt Doc/* ../Doc/SPQR -popd -pushd RBio - pushd Lib - %make_build CFLAGS="$RPM_OPT_FLAGS" LAPACK=-lopenblas + pushd SPQR + pushd Lib + %make_build CFLAGS="$CFLAGS -DHAVE_TBB -DNPARTITION" TBB=-ltbb BLAS="$BLAS" LIBRARY_SUFFIX="$LIBRARY_SUFFIX" + popd + cp -p Include/*.h* ../Include + cp -p README{,_SPQR}.txt + cp -p README_SPQR.txt Doc/* ../Doc/SPQR popd - cp -p Include/*.h ../Include - cp -p README.txt Doc/ChangeLog Doc/License.txt ../Doc/RBio -popd + + pushd RBio + pushd Lib + %make_build CFLAGS="$CFLAGS" BLAS="$BLAS" LIBRARY_SUFFIX="$LIBRARY_SUFFIX" + popd + cp -p Include/*.h ../Include + cp -p README.txt Doc/ChangeLog Doc/License.txt ../Doc/RBio + popd + + popd +done %install mkdir -p ${RPM_BUILD_ROOT}%{_libdir} mkdir -p ${RPM_BUILD_ROOT}%{_includedir}/%{name} -cp -a */Lib/*.a lib/*.so* ${RPM_BUILD_ROOT}%{_libdir}/ -chmod 755 ${RPM_BUILD_ROOT}%{_libdir}/*.so.* -pushd Include - for f in *.h *.hpp; do - cp -a $f ${RPM_BUILD_ROOT}%{_includedir}/%{name}/$f - done -popd +cp -a SuiteSparse/Include/*.{h,hpp} ${RPM_BUILD_ROOT}%{_includedir}/%{name}/ +for build in SuiteSparse %{?build64:SuiteSparse64 SuiteSparse64_} +do + pushd $build + cp -a */Lib/*.a lib/*.so* ${RPM_BUILD_ROOT}%{_libdir}/ + chmod 755 ${RPM_BUILD_ROOT}%{_libdir}/*.so.* -# collect licenses in one place to ship as base package documentation -rm -rf Licenses -mkdir Licenses -find */ -iname lesser.txt -o -iname license.txt -o -iname gpl.txt -o \ - -iname license | while read f; do - b="${f%%/*}" - r="${f#$b}" - x="$(echo "$r" | sed 's|/doc/|/|gi')" - install -m0644 -D "$f" "./Licenses/$b/$x" - done + # collect licenses in one place to ship as base package documentation + rm -rf Licenses + mkdir Licenses + find */ -iname lesser.txt -o -iname license.txt -o -iname gpl.txt -o \ + -iname license | while read f; do + b="${f%%/*}" + r="${f#$b}" + x="$(echo "$r" | sed 's|/doc/|/|gi')" + install -m0644 -D "$f" "./Licenses/$b/$x" + done + + # hardlink duplicate documentation files + hardlink -cv Docs/ Licenses/ + popd +done -# hardlink duplicate documentation files -hardlink -cv Docs/ Licenses/ %check export AUTOCC=no @@ -269,12 +370,34 @@ TESTDIRS="$TESTDIRS CSparse" %else TESTDIRS="$TESTDIRS CXSparse" %endif -for d in $TESTDIRS ; do - %make_build -C $d/Demo CFLAGS="$RPM_OPT_FLAGS" LIB="%{?__global_ldflags} -lm -lrt" LAPACK="" SPQR_CONFIG=-DHAVE_TBB TBB=-ltbb +for build in SuiteSparse %{?build64:SuiteSparse64 SuiteSparse64_} +do + pushd $build + export CFLAGS="$RPM_OPT_FLAGS -I%{_includedir}/metis" + export LAPACK="" + # Set flags for ILP64 build + if [ $build = SuiteSparse64 ] + then + export CFLAGS="$CFLAGS -DBLAS64" + export BLAS=-lopenblas64 + export LIBRARY_SUFFIX=64 + elif [ $build = SuiteSparse64_ ] + then + export CFLAGS="$CFLAGS -DBLAS64 -DSUN64" + export BLAS=-lopenblas64_ + export LIBRARY_SUFFIX=64_ + else + export BLAS=-lopenblas + fi + + for d in $TESTDIRS ; do + %make_build -C $d/Demo CFLAGS="$CFLAGS" LIB="%{?__global_ldflags} -lm -lrt" BLAS="$BLAS" LIBRARY_SUFFIX="$LIBRARY_SUFFIX" SPQR_CONFIG=-DHAVE_TBB TBB=-ltbb + done + popd done %files -%license Licenses +%license SuiteSparse/Licenses %{_libdir}/libamd.so.%{amd_version_major}* %{_libdir}/libbtf.so.%{btf_version_major}* %{_libdir}/libcamd.so.%{camd_version_major}* @@ -295,14 +418,71 @@ done %files devel %{_includedir}/%{name} %{_libdir}/lib*.so +%exclude %{_libdir}/lib*64*.so %files static %{_libdir}/lib*.a +%exclude %{_libdir}/lib*64*.a + +%if 0%{?build64} +%files -n %{name}64 +%license SuiteSparse64/Licenses +%{_libdir}/libamd64.so.%{amd_version_major}* +%{_libdir}/libbtf64.so.%{btf_version_major}* +%{_libdir}/libcamd64.so.%{camd_version_major}* +%{_libdir}/libccolamd64.so.%{ccolamd_version_major}* +%{_libdir}/libcholmod64.so.%{cholmod_version_major}* +%{_libdir}/libcolamd64.so.%{colamd_version_major}* +%if "%{?enable_csparse}" == "1" +%{_libdir}/libcsparse64.so.%{csparse_version_major}* +%endif +%{_libdir}/libcxsparse64.so.%{cxsparse_version_major}* +%{_libdir}/libklu64.so.%{klu_version_major}* +%{_libdir}/libldl64.so.%{ldl_version_major}* +%{_libdir}/librbio64.so.%{rbio_version_major}* +%{_libdir}/libspqr64.so.%{spqr_version_major}* +%{_libdir}/libsuitesparseconfig64.so.%{SuiteSparse_config_major}* +%{_libdir}/libumfpack64.so.%{umfpack_version_major}* + +%files -n %{name}64-devel +%{_libdir}/lib*64.so + +%files -n %{name}64-static +%{_libdir}/lib*64.a + +%files -n %{name}64_ +%license SuiteSparse64_/Licenses +%{_libdir}/libamd64_.so.%{amd_version_major}* +%{_libdir}/libbtf64_.so.%{btf_version_major}* +%{_libdir}/libcamd64_.so.%{camd_version_major}* +%{_libdir}/libccolamd64_.so.%{ccolamd_version_major}* +%{_libdir}/libcholmod64_.so.%{cholmod_version_major}* +%{_libdir}/libcolamd64_.so.%{colamd_version_major}* +%if "%{?enable_csparse}" == "1" +%{_libdir}/libcsparse64_.so.%{csparse_version_major}* +%endif +%{_libdir}/libcxsparse64_.so.%{cxsparse_version_major}* +%{_libdir}/libklu64_.so.%{klu_version_major}* +%{_libdir}/libldl64_.so.%{ldl_version_major}* +%{_libdir}/librbio64_.so.%{rbio_version_major}* +%{_libdir}/libspqr64_.so.%{spqr_version_major}* +%{_libdir}/libsuitesparseconfig64_.so.%{SuiteSparse_config_major}* +%{_libdir}/libumfpack64_.so.%{umfpack_version_major}* + +%files -n %{name}64_-devel +%{_libdir}/lib*64_.so + +%files -n %{name}64_-static +%{_libdir}/lib*64_.a +%endif %files doc -%doc Doc/* +%doc SuiteSparse/Doc/* %changelog +* Mon Oct 14 2019 Orion Poplawski - 5.4.0-2 +- Build ILP64 version (bugz#1294200) + * Sun Sep 29 2019 Orion Poplawski - 5.4.0-1 - Update to 5.4.0 - Use upstream shared library builds