Skip to content

Commit 38e53f3

Browse files
committed
No longer require a C++ compiler to build Open MPI
Fix several places where old code assumptions effectively required a C++ compiler to build Open MPI. Most of these were a holdover from early days when we (deliberately) assumed that there was always a C++ compiler available. In most cases this is true, but at least in some CI cases that have come up recently, some Linux distros do not install a C++ compiler by default. The list of changes in this commit include the following: - AC_PROG_CXX will set $CXX to "g++" even if no C++ compiler was found (!!). Change that to set $CXX to "no" if no C++ compiler was found. - Change the C++ configury to only test for C/C++ linker compatibility when there's actually a C++ compiler. - Remove duplicate C++ configury checks (in OPAL and OMPI) - Remove C++ "bool" alignment and sizeof checks in configury; the results of these tests aren't used in the code anywhere. - Remove assumptions in opal/mca/threads/pthreads/configure.m4 that we always have a C++ compiler (and stop using the undocumented AC_PROVIDE_IFELSE macro; this Autoconf list post sums it up well: https://lists.gnu.org/archive/html/autoconf/2012-11/msg00038.html). - Do not install any C++ wrapper sym links or data files if there is no C++ compiler Signed-off-by: Jeff Squyres <jsquyres@cisco.com>
1 parent 435a8c8 commit 38e53f3

File tree

6 files changed

+97
-280
lines changed

6 files changed

+97
-280
lines changed

config/ompi_setup_cxx.m4

Lines changed: 30 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,33 @@ AC_DEFUN([OMPI_SETUP_CXX_BANNER],[
2929
])
3030

3131
AC_DEFUN([OMPI_PROG_CXX],[
32-
OPAL_VAR_SCOPE_PUSH([ompi_cxxflags_save])
32+
OPAL_VAR_SCOPE_PUSH([ompi_cxxflags_save ompi_cxx_argv0])
33+
3334
ompi_cxxflags_save="$CXXFLAGS"
3435
AC_PROG_CXX
3536
AC_PROG_CXXCPP
3637
CXXFLAGS="$ompi_cxxflags_save"
38+
39+
# Note: according to the Autoconf docs, if no C++ compiler is
40+
# found, $CXX is still set to "g++" (!!). So make sure that we
41+
# actually found a C++ compiler; if not, set CXX to "no", per
42+
# thread at
43+
# https://www.open-mpi.org/community/lists/users/2013/02/21356.php,
44+
# which advises us to set Libtool precious variables to "no" if we
45+
# don't want Libtool to setup that language at all.
46+
AS_IF([test "x$CXX" = "x"], [CXX=no])
47+
set dummy $CXX
48+
ompi_cxx_argv0=[$]2
49+
OPAL_WHICH([$ompi_cxx_argv0], [OMPI_CXX_ABSOLUTE])
50+
AS_IF([test "x$OMPI_CXX_ABSOLUTE" = "x"],
51+
[CXX=no
52+
OMPI_CXX_ABSOLUTE=no])
53+
54+
AC_DEFINE_UNQUOTED(OMPI_CXX, "$CXX", [OMPI underlying C++ compiler])
55+
AC_SUBST(OMPI_CXX_ABSOLUTE)
56+
57+
AM_CONDITIONAL([OMPI_HAVE_CXX_COMPILER], [test "$CXX" != "no"])
58+
3759
OPAL_VAR_SCOPE_POP
3860
])
3961

@@ -44,8 +66,6 @@ dnl wrapper compiler (there is no C++ code in Open MPI, so we do not
4466
dnl need to setup for internal C++ compilations). Safe to AC_REQUIRE
4567
dnl this macro.
4668
AC_DEFUN([OMPI_SETUP_CXX],[
47-
OPAL_VAR_SCOPE_PUSH([ompi_cxx_argv0])
48-
4969
# Do a little tomfoolery to get the subsection title printed first
5070
AC_REQUIRE([OMPI_SETUP_CXX_BANNER])
5171

@@ -54,20 +74,11 @@ AC_DEFUN([OMPI_SETUP_CXX],[
5474
# see the docs for AC PROG_CC for details.
5575
AC_REQUIRE([OMPI_PROG_CXX])
5676

57-
BASECXX="`basename $CXX`"
58-
59-
AS_IF([test "x$CXX" = "x"], [CXX=none])
60-
set dummy $CXX
61-
ompi_cxx_argv0=[$]2
62-
OPAL_WHICH([$ompi_cxx_argv0], [OMPI_CXX_ABSOLUTE])
63-
AS_IF([test "x$OMPI_CXX_ABSOLUTE" = "x"], [OMPI_CXX_ABSOLUTE=none])
64-
65-
AC_DEFINE_UNQUOTED(OMPI_CXX, "$CXX", [OMPI underlying C++ compiler])
66-
AC_SUBST(OMPI_CXX_ABSOLUTE)
67-
68-
# Make sure we can link with the C compiler
69-
OPAL_LANG_LINK_WITH_C([C++], [],
70-
[cat <<EOF >&2
77+
# If we have a C++ compiler, do some additional tests
78+
AS_IF([test "$CXX" != "no"],
79+
[ # Make sure we can link with the C compiler
80+
OPAL_LANG_LINK_WITH_C([C++], [],
81+
[cat <<EOF >&2
7182
**********************************************************************
7283
* It appears that your C++ compiler is unable to link against object
7384
* files created by your C compiler. This generally indicates either
@@ -78,13 +89,6 @@ AC_DEFUN([OMPI_SETUP_CXX],[
7889
* available in the config.log file in this directory.
7990
**********************************************************************
8091
EOF
81-
AC_MSG_ERROR([C and C++ compilers are not link compatible. Can not continue.])])
82-
83-
# bool type size and alignment
84-
AC_LANG_PUSH(C++)
85-
AC_CHECK_SIZEOF(bool)
86-
OPAL_C_GET_ALIGNMENT(bool, OPAL_ALIGNMENT_CXX_BOOL)
87-
AC_LANG_POP(C++)
88-
89-
OPAL_VAR_SCOPE_POP
92+
AC_MSG_ERROR([C and C++ compilers are not link compatible. Can not continue.])])
93+
])
9094
])

config/opal_case_sensitive_fs_setup.m4

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ AC_ARG_WITH([cs_fs],
6363
[AS_HELP_STRING([--with-cs-fs],
6464
[Destination FS is case sensitive (default: set to value of the build FS's case sensitivity)])])
6565
66+
dnl Stupid emacs syntax hilighting: '
67+
6668
if test "$with_cs_fs" = "yes"; then
6769
OPAL_WANT_CS_FS=1
6870
elif test -z "$with_cs_fs"; then
@@ -78,6 +80,12 @@ else
7880
fi
7981

8082
AM_CONDITIONAL(CASE_SENSITIVE_FS, test "$OPAL_WANT_CS_FS" = "1")
83+
# There is a case in the ompi/tools/wrappers/Makefile.am where we need
84+
# to know if there is a case sensitive filesystem *and* if we have a
85+
# C++ compiler. Since we can't use operators like "&&" or "and" to
86+
# join together AM CONDITIONALs in a Makefile.am, effectively make a
87+
# combo CONDITIONAL here.
88+
AM_CONDITIONAL([CASE_SENSITIVE_FS_AND_HAVE_CXX_COMPILER], [test "$OPAL_WANT_CS_FS" = "1" && test "$CXX" != "no"])
8189

8290
if test "$OPAL_WANT_CS_FS" = "0"; then
8391
cat <<EOF

config/opal_config_asm.m4

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1087,7 +1087,6 @@ dnl
10871087
dnl #################################################################
10881088
AC_DEFUN([OPAL_CONFIG_ASM],[
10891089
AC_REQUIRE([OPAL_SETUP_CC])
1090-
AC_REQUIRE([OPAL_SETUP_CXX])
10911090
AC_REQUIRE([AM_PROG_AS])
10921091
10931092
AC_ARG_ENABLE([c11-atomics],[AS_HELP_STRING([--enable-c11-atomics],

config/opal_setup_cxx.m4

Lines changed: 0 additions & 218 deletions
This file was deleted.

0 commit comments

Comments
 (0)