From e67dfd718c13e2007e513652a13ebf352dfcffa9 Mon Sep 17 00:00:00 2001 From: Paul McCarthy <pauldmccarthy@gmail.com> Date: Thu, 18 Nov 2021 19:00:55 +0000 Subject: [PATCH] RF: Set -std=c++14 for nvcc-compiled code - CUDA 11.0 is the earliest to support c++17 --- config/buildSettings.mk | 2 +- config/vars.mk | 15 ++++++++++----- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/config/buildSettings.mk b/config/buildSettings.mk index 7492b5f..a958de2 100644 --- a/config/buildSettings.mk +++ b/config/buildSettings.mk @@ -65,7 +65,7 @@ ARCHLIBS = # armadillo structures may have different byte-alignment # to equivalent g++-compiled structures (see # include/armadillo_bits/compiler_setup.hpp) -ARCHNVCCFLAGS = -DARMA_ALLOW_FAKE_GCC +ARCHNVCCFLAGS = -DARMA_ALLOW_FAKE_GCC -std=c++14 # Linker flags for CUDA projects. ARCHNVCCLDFLAGS = diff --git a/config/vars.mk b/config/vars.mk index 7b75794..dd43589 100644 --- a/config/vars.mk +++ b/config/vars.mk @@ -119,11 +119,16 @@ CXXFLAGS += ${CPPFLAGS} ${ARCHCXXFLAGS} ${USRCXXFLAGS} ${INCFLAGS} LDFLAGS += ${ARCHLDFLAGS} ${USRLDFLAGS} \ -L. -L${DEVLIBDIR} -L${LIBDIR} \ ${LIBS} ${ARCHLIBS} -NVCCFLAGS += --compiler-options "${CPPFLAGS}" \ - ${ARCHNVCCFLAGS} \ - --compiler-options "${ARCHCXXFLAGS}" \ - ${USRNVCCFLAGS} \ - --compiler-options "${USRCXXFLAGS}" \ +# 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 +# nvcc. We assume that project Makefile has not added +# -std to USRCXXFLAGGS/USRCPPFLAGS. +NVCCFLAGS += --compiler-options "${CPPFLAGS}" \ + ${ARCHNVCCFLAGS} \ + --compiler-options "$(patsubst -std=c++%,,${ARCHCXXFLAGS})" \ + ${USRNVCCFLAGS} \ + --compiler-options "${USRCXXFLAGS}" \ ${INCFLAGS} NVCCLDFLAGS += ${ARCHNVCCLDFLAGS} \ --compiler-options "${ARCHLDFLAGS}" \ -- GitLab