diff --git a/.github/workflows/distcheck.yaml b/.github/workflows/distcheck.yaml index ce5d91b74..59ab9ea2c 100644 --- a/.github/workflows/distcheck.yaml +++ b/.github/workflows/distcheck.yaml @@ -85,7 +85,7 @@ jobs: - name: Install hwloc, utilities. run: | - yum -y install hwloc-devel autoconf automake libtool gcc g++ git make + yum -y install hwloc-devel autoconf automake libtool gcc gcc-c++ git make - name: Install CUDA if: matrix.sdk == 'cuda' diff --git a/configure.ac b/configure.ac index a29074660..c0617e521 100644 --- a/configure.ac +++ b/configure.ac @@ -46,6 +46,7 @@ NCCL_NET_OFI_DISTCHCK_CONFIGURE_FLAGS= # Checks for programs AC_PROG_CC AM_PROG_CC_C_O +AC_PROG_CXX m4_version_prereq([2.70], [], [AC_PROG_CC_STDC]) AC_C_INLINE @@ -55,12 +56,18 @@ dnl between this and AC_PROG_CC. AS_IF([test "${ax_enable_debug}" = "no"], [ dnl Enable O3 optimization CFLAGS="${CFLAGS} -O3" + CXXFLAGS="${CXXFLAGS} -O3" + + dnl use C++17, disable exceptions, and disable runtime type information + CXXFLAGS="-std=c++17 -fno-rtti -fno-exceptions" dnl dead code elim CFLAGS="${CFLAGS} -ffunction-sections -fdata-sections" + CXXFLAGS="${CXXFLAGS} -ffunction-sections -fdata-sections" dnl https://maskray.me/blog/2021-05-09-fno-semantic-interposition CFLAGS="${CFLAGS} -fno-semantic-interposition -fvisibility=hidden" + CXXFLAGS="${CXXFLAGS} -fno-semantic-interposition -fvisibility=hidden " LDFLAGS="${LDFLAGS} -Bsymbolic" ]) CHECK_ENABLE_SANITIZER() @@ -175,10 +182,15 @@ AS_IF([test "${enable_trace}" = "yes" ], AC_DEFINE_UNQUOTED([OFI_NCCL_TRACE], [${trace}], [Defined to 1 unit test output should include TRACE level]) picky_cflags="" +picky_cxxflags="" AC_DEFUN([ADD_PICKY_FLAGS],[ AC_LANG_PUSH([C]) AX_CHECK_COMPILE_FLAG([$1], [picky_cflags="${picky_cflags} $1"], [], [-Werror]) AC_LANG_POP() + + AC_LANG_PUSH([C++]) + AX_CHECK_COMPILE_FLAG([$1], [picky_cxxflags="${picky_cxxflags} $1"], [], [-Werror -x c++]) + AC_LANG_POP() ]) dnl standard and normal @@ -220,6 +232,8 @@ AC_ARG_ENABLE([picky-compiler], AS_IF([test "${enable_picky_compiler}" != "no"], [AC_MSG_NOTICE([Adding ${picky_cflags} to CFLAGS.]) CFLAGS="${CFLAGS} ${picky_cflags}" + CXXFLAGS="${CXXFLAGS} ${picky_cxxflags}" + AS_UNSET([picky_cxxflags]) AS_UNSET([picky_cflags])]) werror_flags="-Werror" @@ -227,10 +241,12 @@ AC_ARG_ENABLE([werror], [AS_HELP_STRING([--enable-werror], [(Developer) Enable setting -Werror. Off by default, unless building from Git tree.])]) AS_IF([test -d "${srcdir}/.git" -a -z "${enable_werror}"], [AC_MSG_NOTICE([Found .git directory. Adding ${werror_flags} to CFLAGS.]) - CFLAGS="${werror_flags} ${CFLAGS}"], + CXXFLAGS="${werror_flags} ${CXXFLAGS} " + CFLAGS="${werror_flags} ${CFLAGS} "], [test "${enable_werror}" = "yes"], [AC_MSG_NOTICE([Adding ${werror_flags} to CFLAGS.]) - CFLAGS="${werror_flags} ${CFLAGS}"]) + CXXFLAGS="${werror_flags} ${CXXFLAGS} " + CFLAGS="${werror_flags} ${CFLAGS} "]) AC_SUBST([NCCL_NET_OFI_DISTCHCK_CONFIGURE_FLAGS]) diff --git a/m4/check_pkg_mpi.m4 b/m4/check_pkg_mpi.m4 index a89333ad9..1b57b552d 100644 --- a/m4/check_pkg_mpi.m4 +++ b/m4/check_pkg_mpi.m4 @@ -31,6 +31,7 @@ AC_DEFUN([CHECK_PKG_MPI], [ LDFLAGS="${MPI_LDFLAGS} ${LDFLAGS}"]) MPICC=${mpi_bindir}mpicc + MPICXX=${mpi_bindir}mpicxx AC_MSG_CHECKING([for working mpicc]) ${MPICC} --help >& AS_MESSAGE_LOG_FD @@ -38,6 +39,7 @@ AC_DEFUN([CHECK_PKG_MPI], [ [AC_MSG_RESULT([yes])], [AC_MSG_RESULT([no]) MPICC="${CC}" + MPICXX="${CXX}" AS_IF([test "${check_pkg_found}" = "yes"], [AC_CHECK_HEADERS([mpi.h], [], [check_pkg_found=no])]) @@ -49,6 +51,7 @@ AC_DEFUN([CHECK_PKG_MPI], [ [$2]) AC_SUBST([MPICC]) + AC_SUBST([MPICXX]) AC_SUBST([MPI_CPPFLAGS]) AC_SUBST([MPI_LDFLAGS]) AC_SUBST([MPI_LIBS]) diff --git a/tests/functional/Makefile.am b/tests/functional/Makefile.am index 7238e6c35..53ace71c9 100644 --- a/tests/functional/Makefile.am +++ b/tests/functional/Makefile.am @@ -12,6 +12,7 @@ AM_CPPFLAGS += $(MPI_CPPFLAGS) $(CUDA_CPPFLAGS) AM_LDFLAGS = $(MPI_LDFLAGS) $(CUDA_LDFLAGS) LDADD = $(top_builddir)/src/libinternal_net_plugin.la $(MPI_LIBS) $(CUDA_LIBS) CC = $(MPICC) +CXX = $(MPICXX) if ENABLE_FUNC_TESTS noinst_HEADERS = test-common.h