Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing linking Sundials as an external library #2861

Merged
merged 4 commits into from
Feb 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions make/compiler_flags
Original file line number Diff line number Diff line change
Expand Up @@ -314,8 +314,8 @@ endif

CXXFLAGS += $(CXXFLAGS_LANG) $(CXXFLAGS_OS) $(CXXFLAGS_WARNINGS) $(CXXFLAGS_BOOST) $(CXXFLAGS_EIGEN) $(CXXFLAGS_OPENCL) $(CXXFLAGS_MPI) $(CXXFLAGS_THREADS) $(CXXFLAGS_TBB) $(CXXFLAGS_FLTO) $(CXXFLAGS_OPTIM) $(CXXFLAGS_NO_RANGE_CHECKS) -O$(O) $(INC)
CPPFLAGS += $(CPPFLAGS_LANG) $(CPPFLAGS_OS) $(CPPFLAGS_WARNINGS) $(CPPFLAGS_BOOST) $(CPPFLAGS_EIGEN) $(CPPFLAGS_OPENCL) $(CPPFLAGS_TBB) $(CPPFLAGS_MPI) $(CPPFLAGS_TBB) $(CPPFLAGS_FLTO) $(CPPFLAGS_OPTIM) $(CXXFLAGS_NO_RANGE_CHECKS)
LDFLAGS += $(LDFLAGS_LANG) $(LDFLAGS_OS) $(LDFLAGS_WARNINGS) $(LDFLAGS_BOOST) $(LDFLAGS_EIGEN) $(LDFLAGS_OPENCL) $(LDFLAGS_MPI) $(LDFLAGS_TBB) $(LDFLAGS_FLTO) $(LDFLAGS_OPTIM)
LDLIBS += $(LDLIBS_LANG) $(LDLIBS_OS) $(LDLIBS_WARNINGS) $(LDLIBS_BOOST) $(LDLIBS_EIGEN) $(LDLIBS_OPENCL) $(LDLIBS_MPI) $(LDLIBS_TBB)
LDFLAGS += $(LDFLAGS_LANG) $(LDFLAGS_OS) $(LDFLAGS_WARNINGS) $(LDFLAGS_EIGEN) $(LDFLAGS_BOOST) $(LDFLAGS_SUNDIALS) $(LDFLAGS_TBB) $(LDFLAGS_OPENCL) $(LDFLAGS_MPI) $(LDFLAGS_FLTO) $(LDFLAGS_OPTIM)
LDLIBS += $(LDLIBS_LANG) $(LDLIBS_OS) $(LDLIBS_WARNINGS) $(LDLIBS_EIGEN) $(LDLIBS_BOOST) $(LDLIBS_SUNDIALS) $(LDLIBS_TBB) $(LDLIBS_OPENCL) $(LDLIBS_MPI)

.PHONY: print-compiler-flags
print-compiler-flags:
Expand Down Expand Up @@ -354,8 +354,9 @@ print-compiler-flags:
@echo ' LDLIBS:'
@echo ' - LDLIBS_LANG ' $(LDLIBS_LANG)
@echo ' - LDLIBS_WARNINGS ' $(LDLIBS_WARNINGS)
@echo ' - LDLIBS_BOOST ' $(LDLIBS_BOOST)
@echo ' - LDLIBS_EIGEN ' $(LDLIBS_EIGEN)
@echo ' - LDLIBS_BOOST ' $(LDLIBS_BOOST)
@echo ' - LDLIBS_SUNDIALS ' $(LDLIBS_SUNDIALS)
@echo ' - LDLIBS_OS ' $(LDLIBS_OS)
@echo ' - LDLIBS_GTEST ' $(LDLIBS_GTEST)
@echo ' - LDLIBS_OPENCL ' $(LDLIBS_OPENCL)
Expand All @@ -364,8 +365,9 @@ print-compiler-flags:
@echo ' LDFLAGS:'
@echo ' - LDFLAGS_LANG ' $(LDFLAGS_LANG)
@echo ' - LDFLAGS_WARNINGS ' $(LDFLAGS_WARNINGS)
@echo ' - LDFLAGS_BOOST ' $(LDFLAGS_BOOST)
@echo ' - LDFLAGS_EIGEN ' $(LDFLAGS_EIGEN)
@echo ' - LDFLAGS_BOOST ' $(LDFLAGS_BOOST)
@echo ' - LDFLAGS_SUNDIALS ' $(LDFLAGS_SUNDIALS)
@echo ' - LDFLAGS_OS ' $(LDFLAGS_OS)
@echo ' - LDFLAGS_GTEST ' $(LDFLAGS_GTEST)
@echo ' - LDFLAGS_OPENCL ' $(LDFLAGS_OPENCL)
Expand Down
9 changes: 6 additions & 3 deletions make/libraries
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,17 @@ $(SUNDIALS)/lib/libsundials_nvecserial.a: $(SUNDIALS_NVECSERIAL)
@mkdir -p $(dir $@)
$(AR) -rs $@ $^

LIBSUNDIALS := $(SUNDIALS)/lib/libsundials_nvecserial.a $(SUNDIALS)/lib/libsundials_cvodes.a $(SUNDIALS)/lib/libsundials_idas.a $(SUNDIALS)/lib/libsundials_kinsol.a
SUNDIALS_TARGETS ?= $(SUNDIALS)/lib/libsundials_nvecserial.a $(SUNDIALS)/lib/libsundials_cvodes.a $(SUNDIALS)/lib/libsundials_idas.a $(SUNDIALS)/lib/libsundials_kinsol.a

# FIXME(dl, 02/2023): remove LIBSUNDIALS variable after replacing use in Stan and CmdStan with SUNDIALS_TARGETS
LIBSUNDIALS = $(SUNDIALS_TARGETS)

STAN_SUNDIALS_HEADERS := $(call findfiles,$(MATH)stan,*cvodes*.hpp) $(call findfiles,$(MATH)stan,*idas*.hpp) $(call findfiles,$(MATH)stan,*kinsol*.hpp)
$(STAN_SUNDIALS_HEADERS) : $(LIBSUNDIALS)
$(STAN_SUNDIALS_HEADERS) : $(SUNDIALS_TARGETS)

clean-sundials:
@echo ' cleaning sundials targets'
$(RM) $(wildcard $(sort $(SUNDIALS_CVODES) $(SUNDIALS_IDAS) $(SUNDIALS_KINSOL) $(SUNDIALS_NVECSERIAL) $(LIBSUNDIALS)))
$(RM) $(wildcard $(sort $(SUNDIALS_CVODES) $(SUNDIALS_IDAS) $(SUNDIALS_KINSOL) $(SUNDIALS_NVECSERIAL) $(SUNDIALS_TARGETS)))


############################################################
Expand Down
2 changes: 1 addition & 1 deletion make/standalone
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ MATH ?= $(realpath $(MATH_MAKE)..)/
# The sundials libraries are only needed for
# programs using the stiff ode solver or the
# algebra solver
MATH_LIBS ?= $(LIBSUNDIALS) $(MPI_TARGETS) $(TBB_TARGETS)
MATH_LIBS ?= $(SUNDIALS_TARGETS) $(MPI_TARGETS) $(TBB_TARGETS)

LDLIBS += $(MATH_LIBS)

Expand Down
10 changes: 5 additions & 5 deletions make/tests
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ test/unit/multiple_translation_units_test$(EXE): test/unit/libmultiple.so
##

EXPRESSION_TESTS := $(subst .cpp,$(EXE),$(call findfiles,test/expressions,*_test.cpp))
$(EXPRESSION_TESTS) : $(LIBSUNDIALS)
$(EXPRESSION_TESTS) : $(SUNDIALS_TARGETS)


############################################################
Expand All @@ -65,7 +65,7 @@ $(EXPRESSION_TESTS) : $(LIBSUNDIALS)
##

CVODES_TESTS := $(subst .cpp,$(EXE),$(call findfiles,test,*cvodes*_test.cpp) $(call findfiles,test,*_bdf_*_test.cpp) $(call findfiles,test,*_adams_*_test.cpp) $(call findfiles,test,*_ode_typed_*test.cpp) $(call findfiles,test,*_ode_adjoint_typed_*test.cpp))
$(CVODES_TESTS) : $(LIBSUNDIALS)
$(CVODES_TESTS) : $(SUNDIALS_TARGETS)


############################################################
Expand All @@ -74,7 +74,7 @@ $(CVODES_TESTS) : $(LIBSUNDIALS)
##

IDAS_TESTS := $(subst .cpp,$(EXE),$(call findfiles,test,*idas*_test.cpp) $(call findfiles,test,*_dae*_test.cpp))
$(IDAS_TESTS) : $(LIBSUNDIALS)
$(IDAS_TESTS) : $(SUNDIALS_TARGETS)


############################################################
Expand All @@ -83,11 +83,11 @@ $(IDAS_TESTS) : $(LIBSUNDIALS)
##

ALGEBRA_SOLVER_TESTS := $(subst .cpp,$(EXE),$(call findfiles,test,*solve*_test.cpp))
$(ALGEBRA_SOLVER_TESTS) : $(LIBSUNDIALS)
$(ALGEBRA_SOLVER_TESTS) : $(SUNDIALS_TARGETS)

### These can be generated by the jumbo tests and include the above kinds
FUNCTOR_TESTS := $(subst .cpp,$(EXE),$(call findfiles,test,functor_*_test.cpp))
$(FUNCTOR_TESTS) : $(LIBSUNDIALS)
$(FUNCTOR_TESTS) : $(SUNDIALS_TARGETS)

############################################################
#
Expand Down