Skip to content

Commit

Permalink
Update SuiteSparse build recipe for when `USE_BINARYBUILDER_LIBSUITES…
Browse files Browse the repository at this point in the history
…PARSE=0`
  • Loading branch information
giordano committed Jan 6, 2024
1 parent 40096dc commit 2b9634a
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 22 deletions.
50 changes: 28 additions & 22 deletions deps/libsuitesparse.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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)
Expand All @@ -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 > $@
Expand Down
40 changes: 40 additions & 0 deletions deps/patches/suitesparse-blas-suffix.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
From b936940aab08dc4bc60ccf2b9daec2105a960ad4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Markus=20M=C3=BCtzel?= <[email protected]>
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 )

0 comments on commit 2b9634a

Please sign in to comment.