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

RF: New CUDACXXFLAGS, used for compiling c++ files which are to be linked

into a CUDA lib / exe - so that USRNVCCFLAGS, and CUDA include paths are added
to compiler flags for these targets.
parent e35bb505
No related branches found
No related tags found
1 merge request!34RF: New CUDACXXFLAGS
...@@ -174,13 +174,14 @@ ifneq (${NVCC}, ) ...@@ -174,13 +174,14 @@ ifneq (${NVCC}, )
# "-ccbin" rather than "--compiler-bindir" here, # "-ccbin" rather than "--compiler-bindir" here,
# because the conda-forge nvcc wrapper checks for # because the conda-forge nvcc wrapper checks for
# -ccbin, and adds its own if not present. # -ccbin, and adds its own if not present.
NVCCFLAGS ?= -I${CUDA_HOME}/include \ CUDACXXFLAGS ?= -I${CUDA_HOME}/include
${GENCODEFLAGS} \ NVCCFLAGS ?= ${GENCODEFLAGS} \
-ccbin $(CXX) -ccbin $(CXX) \
NVCCLDFLAGS ?= -L${CUDA_HOME}/lib \ ${CUDACXXFLAGS}
-L${CUDA_HOME}/lib64 \ NVCCLDFLAGS ?= -L${CUDA_HOME}/lib \
-L${CUDA_HOME}/lib/stubs \ -L${CUDA_HOME}/lib64 \
-L${CUDA_HOME}/lib64/stubs -L${CUDA_HOME}/lib/stubs \
-L${CUDA_HOME}/lib64/stubs
# Link CUDA libraries statically, if compilation # Link CUDA libraries statically, if compilation
# was invoked with "make CUDA_STATIC=1". # was invoked with "make CUDA_STATIC=1".
......
...@@ -22,13 +22,13 @@ PROJNAME = ...@@ -22,13 +22,13 @@ PROJNAME =
USRLDFLAGS = # Linker flags USRLDFLAGS = # Linker flags
USRINCFLAGS = # Include directories USRINCFLAGS = # Include directories
USRCFLAGS = # Compiler flags for C projects USRCFLAGS = # Compiler flags for C files
USRCXXFLAGS = # Compiler flags for C++ projects USRCXXFLAGS = # Compiler flags for C++ files
USRCPPFLAGS = # Preprocessor flags USRCPPFLAGS = # Preprocessor flags
LIBS = # Libraries to link against for C and C++ projects - LIBS = # Libraries to link against for C and C++ projects -
# these are incorporated into the final LDFLAGS, below. # these are incorporated into the final LDFLAGS, below.
USRNVCCFLAGS = # Compiler flags for CUDA projects USRNVCCFLAGS = # Compiler flags for CUDA files
USRNVCCLDFLAGS = # Linker flags for CUDA projects USRNVCCLDFLAGS = # Linker flags for CUDA libraries/executables
CUDALIBS = # CUDA libraries to link against (e.g. curand, cublas, etc) - CUDALIBS = # CUDA libraries to link against (e.g. curand, cublas, etc) -
# these are incorporated into the final NVCCLDFLAGS, below. # these are incorporated into the final NVCCLDFLAGS, below.
# -lcuda and -lcudart are automatically added, so do not # -lcuda and -lcudart are automatically added, so do not
...@@ -84,20 +84,25 @@ INCFLAGS = ${USRINCFLAGS} -I. -I${DEVINCDIR} -I${INCDIR} ...@@ -84,20 +84,25 @@ INCFLAGS = ${USRINCFLAGS} -I. -I${DEVINCDIR} -I${INCDIR}
# All projects must use these flags for compilation/linking. # All projects must use these flags for compilation/linking.
# Commands for compilation of intermediate object files # Commands for compilation of intermediate object files
# should have the form: # should have the form:
#
# $(CC) $(CFLAGS) <input/output files> # $(CC) $(CFLAGS) <input/output files> # for .c files
# $(CXX) $(CXXFLAGS) <input/output files> # $(CXX) $(CXXFLAGS) <input/output files> # for .cc files
# $(NVCC) $(NVCCFLAGS) <input/output files> # $(CXX) $(CUDACXXFLAGS) <input/output files> # for .cc files which are to
# # be linked into CUDA
# # libraries/executables
# $(NVCC) $(NVCCFLAGS) <input/output files> # for .cu files
# #
# And commands for compilation and linking of executables # And commands for compilation and linking of executables
# and libraries should have the form: # and libraries should have the form:
# #
# $(CC) $(CFLAGS) <input/output files> ${LDFLAGS} # $(CC) $(CFLAGS) <input/output files> ${LDFLAGS} # for c libs/exes
# $(CXX) $(CXXFLAGS) <input/output files> ${LDFLAGS} # $(CXX) $(CXXFLAGS) <input/output files> ${LDFLAGS} # for c++ exes
# $(NVCC) $(NVCCFLAGS) <input/output files> ${NVCCLDFLAGS} # $(CXX) $(CXXFLAGS) -shared <input/output files> ${LDFLAGS} # for c++ libs
# $(NVCC) $(NVCCFLAGS) -shared <input/output files> ${NVCCLDFLAGS} # for CUDA libs
# $(NVCC) $(NVCCFLAGS) <input/output files> ${NVCCLDFLAGS} # for CUDA exes
#
# `LDFLAGS` *must* come at the end, to ensure proper linking.
# #
# LDFLAGS *must* come at the end, to ensure proper linking.
# The order in which the final FLAGS variables are # The order in which the final FLAGS variables are
# constructed here is important: # constructed here is important:
# #
...@@ -113,12 +118,13 @@ INCFLAGS = ${USRINCFLAGS} -I. -I${DEVINCDIR} -I${INCDIR} ...@@ -113,12 +118,13 @@ INCFLAGS = ${USRINCFLAGS} -I. -I${DEVINCDIR} -I${INCDIR}
# the default options specified in buildSettings.mk, # the default options specified in buildSettings.mk,
# which in turn can override options provided by the # which in turn can override options provided by the
# environment. # environment.
CPPFLAGS += ${ARCHCPPFLAGS} ${USRCPPFLAGS} CPPFLAGS += ${ARCHCPPFLAGS} ${USRCPPFLAGS}
CFLAGS += ${CPPFLAGS} ${ARCHCFLAGS} ${USRCFLAGS} ${INCFLAGS} CFLAGS += ${CPPFLAGS} ${ARCHCFLAGS} ${USRCFLAGS} ${INCFLAGS}
CXXFLAGS += ${CPPFLAGS} ${ARCHCXXFLAGS} ${USRCXXFLAGS} ${INCFLAGS} CXXFLAGS += ${CPPFLAGS} ${ARCHCXXFLAGS} ${USRCXXFLAGS} ${INCFLAGS}
LDFLAGS += ${ARCHLDFLAGS} ${USRLDFLAGS} \ CUDACXXFLAGS += ${CXXFLAGS} ${USRNVCCFLAGS}
-L. -L${DEVLIBDIR} -L${LIBDIR} \ LDFLAGS += ${ARCHLDFLAGS} ${USRLDFLAGS} \
${LIBS} ${ARCHLIBS} -L. -L${DEVLIBDIR} -L${LIBDIR} \
${LIBS} ${ARCHLIBS}
# Remove any -std=c++ options, as we are already setting # Remove any -std=c++ options, as we are already setting
# -std in ARCHNVCCFLAGS (seee buildSettings.mk), and # -std in ARCHNVCCFLAGS (seee buildSettings.mk), and
# passing another one via --compiler-options will confuse # passing another one via --compiler-options will confuse
......
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