Skip to content

Commit

Permalink
build: make automake accept c++ source files
Browse files Browse the repository at this point in the history
Signed-off-by: Nicholas Sielicki <nslick@amazon.com>
  • Loading branch information
Nicholas Sielicki committed Dec 3, 2024
1 parent 5455f73 commit 162b8a6
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/distcheck.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
20 changes: 18 additions & 2 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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()
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -220,17 +232,21 @@ 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"
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])

Expand Down
3 changes: 3 additions & 0 deletions m4/check_pkg_mpi.m4
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,15 @@ 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
AS_IF([test $? -eq 0],
[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])])
Expand All @@ -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])
Expand Down
1 change: 1 addition & 0 deletions tests/functional/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 162b8a6

Please sign in to comment.