diff --git a/config/buildSettings.mk b/config/buildSettings.mk index 46c3cceed5a119d7464a04439ada0fe553cf6dd9..7ac95feb11d83fa79f6c877f7558f5bb77a5c55b 100644 --- a/config/buildSettings.mk +++ b/config/buildSettings.mk @@ -174,13 +174,14 @@ ifneq (${NVCC}, ) # "-ccbin" rather than "--compiler-bindir" here, # because the conda-forge nvcc wrapper checks for # -ccbin, and adds its own if not present. - NVCCFLAGS ?= -I${CUDA_HOME}/include \ - ${GENCODEFLAGS} \ - -ccbin $(CXX) - NVCCLDFLAGS ?= -L${CUDA_HOME}/lib \ - -L${CUDA_HOME}/lib64 \ - -L${CUDA_HOME}/lib/stubs \ - -L${CUDA_HOME}/lib64/stubs + CUDACXXFLAGS ?= -I${CUDA_HOME}/include + NVCCFLAGS ?= ${GENCODEFLAGS} \ + -ccbin $(CXX) \ + ${CUDACXXFLAGS} + NVCCLDFLAGS ?= -L${CUDA_HOME}/lib \ + -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". diff --git a/config/vars.mk b/config/vars.mk index dd4358974a964c3ad267dcc4f4ead73acc7dc532..fe402f5c776903a567e364ab629338beac4b9d3c 100644 --- a/config/vars.mk +++ b/config/vars.mk @@ -22,13 +22,13 @@ PROJNAME = USRLDFLAGS = # Linker flags USRINCFLAGS = # Include directories -USRCFLAGS = # Compiler flags for C projects -USRCXXFLAGS = # Compiler flags for C++ projects +USRCFLAGS = # Compiler flags for C files +USRCXXFLAGS = # Compiler flags for C++ files 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 +USRNVCCFLAGS = # Compiler flags for CUDA files +USRNVCCLDFLAGS = # Linker flags for CUDA libraries/executables 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 @@ -84,20 +84,25 @@ INCFLAGS = ${USRINCFLAGS} -I. -I${DEVINCDIR} -I${INCDIR} # All projects must use these flags for compilation/linking. # Commands for compilation of intermediate object files # should have the form: -# -# $(CC) $(CFLAGS) <input/output files> -# $(CXX) $(CXXFLAGS) <input/output files> -# $(NVCC) $(NVCCFLAGS) <input/output files> + +# $(CC) $(CFLAGS) <input/output files> # for .c files +# $(CXX) $(CXXFLAGS) <input/output files> # for .cc 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 libraries should have the form: # -# $(CC) $(CFLAGS) <input/output files> ${LDFLAGS} -# $(CXX) $(CXXFLAGS) <input/output files> ${LDFLAGS} -# $(NVCC) $(NVCCFLAGS) <input/output files> ${NVCCLDFLAGS} +# $(CC) $(CFLAGS) <input/output files> ${LDFLAGS} # for c libs/exes +# $(CXX) $(CXXFLAGS) <input/output files> ${LDFLAGS} # for c++ exes +# $(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 # constructed here is important: # @@ -113,12 +118,13 @@ INCFLAGS = ${USRINCFLAGS} -I. -I${DEVINCDIR} -I${INCDIR} # the default options specified in buildSettings.mk, # which in turn can override options provided by the # environment. -CPPFLAGS += ${ARCHCPPFLAGS} ${USRCPPFLAGS} -CFLAGS += ${CPPFLAGS} ${ARCHCFLAGS} ${USRCFLAGS} ${INCFLAGS} -CXXFLAGS += ${CPPFLAGS} ${ARCHCXXFLAGS} ${USRCXXFLAGS} ${INCFLAGS} -LDFLAGS += ${ARCHLDFLAGS} ${USRLDFLAGS} \ - -L. -L${DEVLIBDIR} -L${LIBDIR} \ - ${LIBS} ${ARCHLIBS} +CPPFLAGS += ${ARCHCPPFLAGS} ${USRCPPFLAGS} +CFLAGS += ${CPPFLAGS} ${ARCHCFLAGS} ${USRCFLAGS} ${INCFLAGS} +CXXFLAGS += ${CPPFLAGS} ${ARCHCXXFLAGS} ${USRCXXFLAGS} ${INCFLAGS} +CUDACXXFLAGS += ${CXXFLAGS} ${USRNVCCFLAGS} +LDFLAGS += ${ARCHLDFLAGS} ${USRLDFLAGS} \ + -L. -L${DEVLIBDIR} -L${LIBDIR} \ + ${LIBS} ${ARCHLIBS} # Remove any -std=c++ options, as we are already setting # -std in ARCHNVCCFLAGS (seee buildSettings.mk), and # passing another one via --compiler-options will confuse