From aeba6d19d4a4cead825f5fa28677e56788aba8e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mos=C3=A8=20Giordano?= Date: Fri, 5 Jan 2024 19:14:53 +0100 Subject: [PATCH] Update SuiteSparse build recipe for when `USE_BINARYBUILDER_LIBSUITESPARSE=0` --- deps/libsuitesparse.mk | 50 ++++++++++++---------- deps/patches/suitesparse-blas-suffix.patch | 40 +++++++++++++++++ 2 files changed, 68 insertions(+), 22 deletions(-) create mode 100644 deps/patches/suitesparse-blas-suffix.patch diff --git a/deps/libsuitesparse.mk b/deps/libsuitesparse.mk index fa1eda94b5c4f4..386194221b43c2 100644 --- a/deps/libsuitesparse.mk +++ b/deps/libsuitesparse.mk @@ -3,26 +3,28 @@ include $(SRCDIR)/libsuitesparse.version ifneq ($(USE_BINARYBUILDER_LIBSUITESPARSE), 1) -LIBSUITESPARSE_PROJECTS := AMD BTF CAMD CCOLAMD COLAMD CHOLMOD LDL KLU UMFPACK RBio SPQR -LIBSUITESPARSE_LIBS := $(addsuffix .*$(SHLIB_EXT)*,suitesparseconfig amd btf camd ccolamd colamd cholmod klu ldl umfpack rbio spqr) +LIBSUITESPARSE_PROJECTS := "amd;btf;camd;ccolamd;colamd;cholmod;klu;ldl;umfpack;rbio;spqr" +LIBSUITESPARSE_LIBS := $(addsuffix .*$(SHLIB_EXT)*,suitesparseconfig $(subst ;, ,$(LIBSUITESPARSE_PROJECTS))) LIBSUITESPARSE_CMAKE_FLAGS := $(CMAKE_COMMON) \ -DCMAKE_BUILD_TYPE=Release \ - -DENABLE_CUDA=0 \ - -DNFORTRAN=1 \ - -DNOPENMP=1 \ - -DNPARTITION=0 \ - -DNSTATIC=1 \ + -DBUILD_STATIC_LIBS=OFF \ + -DBUILD_TESTING=OFF \ + -DSUITESPARSE_ENABLE_PROJECTS="suitesparse_config;$(LIBSUITESPARSE_PROJECTS)" \ + -DSUITESPARSE_DEMOS=OFF \ + -DSUITESPARSE_USE_STRICT=ON \ + -DSUITESPARSE_USE_CUDA=OFF \ + -DSUITESPARSE_USE_FORTRAN=OFF \ + -DSUITESPARSE_USE_OPENMP=OFF \ + -DCHOLMOD_PARTITION=ON \ -DBLAS_FOUND=1 \ -DBLAS_LIBRARIES="$(build_shlibdir)/libblastrampoline.$(SHLIB_EXT)" \ -DBLAS_LINKER_FLAGS="blastrampoline" \ - -DBLAS_UNDERSCORE=ON \ -DBLA_VENDOR="blastrampoline" \ - -DBLAS64_SUFFIX="_64" \ - -DALLOW_64BIT_BLAS=ON \ - -DLAPACK_FOUND=1 \ -DLAPACK_LIBRARIES="$(build_shlibdir)/libblastrampoline.$(SHLIB_EXT)" \ - -DLAPACK_LINKER_FLAGS="blastrampoline" + -DLAPACK_LINKER_FLAGS="blastrampoline" \ + -DBLAS64_SUFFIX="_64" \ + -DSUITESPARSE_USE_64BIT_BLAS=YES ifneq (,$(findstring $(OS),Linux FreeBSD)) LIBSUITESPARSE_CMAKE_FLAGS += -DCMAKE_INSTALL_RPATH="\$$ORIGIN" @@ -40,17 +42,21 @@ $(BUILDDIR)/SuiteSparse-$(LIBSUITESPARSE_VER)/source-extracted: $(SRCCACHE)/Suit checksum-libsuitesparse: $(SRCCACHE)/SuiteSparse-$(LIBSUITESPARSE_VER).tar.gz $(JLCHECKSUM) $< +# https://github.com/DrTimothyAldenDavis/SuiteSparse/pull/671 +$(SRCCACHE)/SuiteSparse-$(LIBSUITESPARSE_VER)/suitesparse-blas-suffix.patch-applied: $(SRCCACHE)/SuiteSparse-$(LIBSUITESPARSE_VER)/source-extracted + cd $(dir $@) && \ + patch -p1 -f < $(SRCDIR)/patches/suitesparse-blas-suffix.patch + echo 1 > $@ + +$(SRCCACHE)/SuiteSparse-$(LIBSUITESPARSE_VER)/source-patched: $(SRCCACHE)/SuiteSparse-$(LIBSUITESPARSE_VER)/suitesparse-blas-suffix.patch-applied + echo 1 > $@ + $(BUILDDIR)/SuiteSparse-$(LIBSUITESPARSE_VER)/build-compiled: | $(build_prefix)/manifest/blastrampoline -$(BUILDDIR)/SuiteSparse-$(LIBSUITESPARSE_VER)/build-compiled: $(BUILDDIR)/SuiteSparse-$(LIBSUITESPARSE_VER)/source-extracted - cd $(dir $<); \ - for PROJ in SuiteSparse_config $(LIBSUITESPARSE_PROJECTS); do \ - cd $${PROJ}/build || exit 1; \ - $(CMAKE) .. $(LIBSUITESPARSE_CMAKE_FLAGS) || exit 1; \ - make || exit 1; \ - make install || exit 1; \ - cd ../..; \ - done +$(BUILDDIR)/SuiteSparse-$(LIBSUITESPARSE_VER)/build-compiled: $(SRCCACHE)/SuiteSparse-$(LIBSUITESPARSE_VER)/source-patched + cd $(dir $<) && $(CMAKE) .. $(LIBSUITESPARSE_CMAKE_FLAGS) + make + make install echo 1 > $@ ifeq ($(OS),WINNT) @@ -59,7 +65,7 @@ else LIBSUITESPARSE_SHLIB_ENV:=LD_LIBRARY_PATH="$(build_shlibdir)" endif $(BUILDDIR)/SuiteSparse-$(LIBSUITESPARSE_VER)/build-checked: $(BUILDDIR)/SuiteSparse-$(LIBSUITESPARSE_VER)/build-compiled - for PROJ in $(LIBSUITESPARSE_PROJECTS); do \ + for PROJ in $(shell echo $(subst ;, ,$(LIBSUITESPARSE_PROJECTS))); do \ $(LIBSUITESPARSE_SHLIB_ENV) $(MAKE) -C $(dir $<)$${PROJ} default $(LIBSUITESPARSE_MFLAGS) || exit 1; \ done echo 1 > $@ diff --git a/deps/patches/suitesparse-blas-suffix.patch b/deps/patches/suitesparse-blas-suffix.patch new file mode 100644 index 00000000000000..c6a04ddee618db --- /dev/null +++ b/deps/patches/suitesparse-blas-suffix.patch @@ -0,0 +1,40 @@ +From b936940aab08dc4bc60ccf2b9daec2105a960ad4 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Markus=20M=C3=BCtzel?= +Date: Mon, 1 Jan 2024 13:00:17 +0100 +Subject: [PATCH] Add preprocessor definitions also with user-supplied + BLAS_LIBRARIES + +--- + SuiteSparse_config/cmake_modules/SuiteSparseBLAS.cmake | 4 ++-- + SuiteSparse_config/cmake_modules/SuiteSparseBLAS64.cmake | 2 +- + 2 files changed, 3 insertions(+), 3 deletions(-) + +diff --git a/SuiteSparse_config/cmake_modules/SuiteSparseBLAS.cmake b/SuiteSparse_config/cmake_modules/SuiteSparseBLAS.cmake +index ca241472d..be7cd2e73 100644 +--- a/SuiteSparse_config/cmake_modules/SuiteSparseBLAS.cmake ++++ b/SuiteSparse_config/cmake_modules/SuiteSparseBLAS.cmake +@@ -36,9 +36,9 @@ if ( DEFINED BLAS_LIBRARIES OR DEFINED BLAS_INCLUDE_DIRS ) + # User supplied variables for libraries and/or include directories. + # Use them as-is. + if ( SUITESPARSE_USE_64BIT_BLAS ) +- set ( SuiteSparse_BLAS_integer "int64_t" ) ++ include ( SuiteSparseBLAS64 ) + else ( ) +- set ( SuiteSparse_BLAS_integer "int32_t" ) ++ include ( SuiteSparseBLAS32 ) + endif ( ) + return ( ) + endif ( ) +diff --git a/SuiteSparse_config/cmake_modules/SuiteSparseBLAS64.cmake b/SuiteSparse_config/cmake_modules/SuiteSparseBLAS64.cmake +index 744aaef91..1a5c63690 100644 +--- a/SuiteSparse_config/cmake_modules/SuiteSparseBLAS64.cmake ++++ b/SuiteSparse_config/cmake_modules/SuiteSparseBLAS64.cmake +@@ -37,7 +37,7 @@ set ( SuiteSparse_BLAS_integer "int64_t" ) + # https://github.com/spack/spack/blob/develop/var/spack/repos/builtin/packages/suite-sparse/package.py + + if ( DEFINED BLAS64_SUFFIX ) +- # append BLAS64_SUFFIX to each BLAS and LAPACK name ++ # append BLAS64_SUFFIX to each BLAS and LAPACK function name + string ( FIND ${BLAS64_SUFFIX} "_" HAS_UNDERSCORE ) + message ( STATUS "BLAS64_suffix: ${BLAS64_SUFFIX}" ) + if ( HAS_UNDERSCORE EQUAL -1 )