Skip to content
Snippets Groups Projects
Commit cee18efa authored by Paul McCarthy's avatar Paul McCarthy :mountain_bicyclist:
Browse files

ENH: New CUDA_STATIC option, which allows static linking to the CUDA

runtime/toolkit
parent cca81aee
No related branches found
No related tags found
1 merge request!13ENH: New CUDA_STATIC option, which allows static linking to the CUDA runtime/toolkit
......@@ -121,8 +121,9 @@ endif
ifneq ($(shell which nvcc), )
# NVCC, CUDA_HOME, CUDA_VER, GENCODEFLAGS,
# NVCCFLAGS, and NVCCLDFLAGS may be
# overridden by the environment.
# NVCCFLAGS, NVCCLDFLAGS, and CUDA_STATIC
# may be specified/overridden by the
# environment.
# We specifically use variable names "CUDA_VER"
# and "CUDA_HOME" because they will be set in
......@@ -147,4 +148,22 @@ ifneq ($(shell which nvcc), )
-L${CUDA_HOME}/lib64 \
-L${CUDA_HOME}/lib/stubs \
-L${CUDA_HOME}/lib64/stubs
# Link CUDA libraries statically, if compilation
# was invoked with "make CUDA_STATIC=1".
ifdef CUDA_STATIC
# The cuda/cudart libs are handled by nvcc. Other
# components of the CUDA toolkit are provided as
# both dynamic and static libraries. "_CUDALIBS"
# is what is used to construct the final NVCCLDFLAGS
# (see vars.mk)
# Other CUDA toolkit components will be added here
# on an as-needed basis.
NVCCFLAGS += --cudart=static
_CUDALIBS = $(subst -lcublas,-lcublas_static -lcublasLt_static -lculibos, \
$(subst -lcurand,-lcurand_static,${CUDALIBS}))
else
NVCCFLAGS += --cudart=shared
_CUDALIBS = ${CUDALIBS}
endif
endif
......@@ -13,19 +13,21 @@ PROJNAME =
# Project-specific compiler/linker flags - these
# can be overridden in the project Makefile.
USRLDFLAGS = # Project-specific linker flags
USRINCFLAGS = # Project-specific include directories
USRCFLAGS = # Project-specific compiler flags for C projects
USRCXXFLAGS = # Project-specific compiler flags for C++ projects
USRCPPFLAGS = # Project-specific preprocessor flags
LIBS = # Project-specific libraries to link against for C
# and C++ projects - these are incorporated into the
# final LDFLAGS, below.
USRNVCCFLAGS = # Project-specific compiler flags for CUDA projects
USRNVCCLDFLAGS = # Project-specific linker flags for CUDA projects
CUDALIBS = # Project-specific libraries to link against for CUDA
# projects - these are incorporated into the final
# NVCCLDFLAGS, below.
USRLDFLAGS = # Linker flags
USRINCFLAGS = # Include directories
USRCFLAGS = # Compiler flags for C projects
USRCXXFLAGS = # Compiler flags for C++ projects
USRCPPFLAGS = # Preprocessor flags
LIBS = # Libraries to link against for C and C++ projects -
# these are incorporated into the final LDFLAGS, below.
USRNVCCFLAGS = # Compiler flags for CUDA projects
USRNVCCLDFLAGS = # Linker flags for CUDA projects
CUDALIBS = # CUDA libraries to link against (e.g. curand, cublas, etc) -
# these are incorporated into the final NVCCLDFLAGS, below.
# -lcuda and -lcudart are automatically added, so do not
# need to be explicitly listed. Dynamic library names should
# be used here - they will be transformed to their static
# versions if CUDA_STATIC is set (see buildSettings.mk).
# Project outputs - these variables control
# what gets installed from a project. They
......@@ -121,4 +123,4 @@ NVCCLDFLAGS += ${ARCHNVCCLDFLAGS} \
${USRNVCCLDFLAGS} \
--compiler-options "${USRLDFLAGS}" \
-L. -L${DEVLIBDIR} -L${LIBDIR} \
${LIBS} ${CUDALIBS} ${ARCHLIBS}
${LIBS} ${_CUDALIBS} ${ARCHLIBS}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment