configure: Set language to C++ globally

As of commit dd941df19d, we no longer
build any plain C, except within AM_PROG_AR.

Signed-off-by: Anders Kaseorg <andersk@mit.edu>
This commit is contained in:
Anders Kaseorg
2019-06-12 17:25:45 -07:00
parent b1da700535
commit e009ba4e76
2 changed files with 10 additions and 32 deletions
+9 -31
View File
@@ -8,6 +8,7 @@ m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
AC_CONFIG_SRCDIR([src/frontend/mosh-client.cc]) AC_CONFIG_SRCDIR([src/frontend/mosh-client.cc])
AC_CONFIG_MACRO_DIR([m4]) AC_CONFIG_MACRO_DIR([m4])
AC_CONFIG_HEADERS([config.h]) AC_CONFIG_HEADERS([config.h])
AC_LANG([C++])
# Checks for programs. # Checks for programs.
AC_PROG_CC([cc gcc clang]) AC_PROG_CC([cc gcc clang])
@@ -47,7 +48,6 @@ AC_ARG_ENABLE([compile-warnings],
distcheck) distcheck)
WARNING_CXXFLAGS="-Wall -Werror" WARNING_CXXFLAGS="-Wall -Werror"
PICKY_CXXFLAGS="-Wextra -pedantic -Wno-long-long -Weffc++ -Wmissing-declarations" PICKY_CXXFLAGS="-Wextra -pedantic -Wno-long-long -Weffc++ -Wmissing-declarations"
AC_LANG_PUSH(C++)
AX_CHECK_COMPILE_FLAG([-Wno-error=unused-parameter], AX_CHECK_COMPILE_FLAG([-Wno-error=unused-parameter],
[PICKY_CXXFLAGS="$PICKY_CXXFLAGS -Wno-error=unused-parameter"], [], [-Werror]) [PICKY_CXXFLAGS="$PICKY_CXXFLAGS -Wno-error=unused-parameter"], [], [-Werror])
AX_CHECK_COMPILE_FLAG([-Wno-error=c++11-extensions], AX_CHECK_COMPILE_FLAG([-Wno-error=c++11-extensions],
@@ -56,7 +56,6 @@ AC_ARG_ENABLE([compile-warnings],
[PICKY_CXXFLAGS="$PICKY_CXXFLAGS -Wno-error=deprecated-declarations"], [], [-Werror]) [PICKY_CXXFLAGS="$PICKY_CXXFLAGS -Wno-error=deprecated-declarations"], [], [-Werror])
AX_CHECK_COMPILE_FLAG([-Wno-error=nested-anon-types], AX_CHECK_COMPILE_FLAG([-Wno-error=nested-anon-types],
[PICKY_CXXFLAGS="$PICKY_CXXFLAGS -Wno-error=nested-anon-types"], [], [-Werror]) [PICKY_CXXFLAGS="$PICKY_CXXFLAGS -Wno-error=nested-anon-types"], [], [-Werror])
AC_LANG_POP(C++)
;; ;;
*) *)
AC_MSG_ERROR([Unknown argument '$enableval' to --enable-compile-warnings]) AC_MSG_ERROR([Unknown argument '$enableval' to --enable-compile-warnings])
@@ -70,26 +69,16 @@ AC_SUBST([PICKY_CXXFLAGS])
# clang's "argument unused" warning fatal. So we invoke the compiler through a # clang's "argument unused" warning fatal. So we invoke the compiler through a
# wrapper script that greps for this message. # wrapper script that greps for this message.
saved_CC="$CC"
saved_CXX="$CXX" saved_CXX="$CXX"
saved_LD="$LD" saved_LD="$LD"
flag_wrap="$srcdir/scripts/wrap-compiler-for-flag-check" flag_wrap="$srcdir/scripts/wrap-compiler-for-flag-check"
CC="$flag_wrap $CC"
CXX="$flag_wrap $CXX" CXX="$flag_wrap $CXX"
LD="$flag_wrap $LD" LD="$flag_wrap $LD"
# We use the same hardening flags for C and C++. We must check that each flag AC_DEFUN([check_cxx_flag],
# is supported by both compilers. [AX_CHECK_COMPILE_FLAG([$1], [$2], [$3], [-Werror $4])])
AC_DEFUN([check_cc_cxx_flag],
[AC_LANG_PUSH(C)
AX_CHECK_COMPILE_FLAG([$1],
[AC_LANG_PUSH(C++)
AX_CHECK_COMPILE_FLAG([$1], [$2], [$3], [-Werror $4])
AC_LANG_POP(C++)],
[$3], [-Werror $4])
AC_LANG_POP(C)])
AC_DEFUN([check_link_flag], AC_DEFUN([check_link_flag],
[AX_CHECK_LINK_FLAG([$1], [$2], [$3], [-Werror $4])]) [AX_CHECK_LINK_FLAG([$1], [$2], [$3], [-Werror $4])])
AC_ARG_ENABLE([hardening], AC_ARG_ENABLE([hardening],
[AS_HELP_STRING([--enable-hardening], [AS_HELP_STRING([--enable-hardening],
@@ -100,19 +89,19 @@ AC_ARG_ENABLE([hardening],
HARDEN_CFLAGS="" HARDEN_CFLAGS=""
HARDEN_LDFLAGS="" HARDEN_LDFLAGS=""
AS_IF([test x"$hardening" != x"no"], [ AS_IF([test x"$hardening" != x"no"], [
check_cc_cxx_flag([-fno-strict-overflow], [HARDEN_CFLAGS="$HARDEN_CFLAGS -fno-strict-overflow"]) check_cxx_flag([-fno-strict-overflow], [HARDEN_CFLAGS="$HARDEN_CFLAGS -fno-strict-overflow"])
# This one will likely succeed, even on platforms where it does nothing. # This one will likely succeed, even on platforms where it does nothing.
check_cc_cxx_flag([-D_FORTIFY_SOURCE=2], [HARDEN_CFLAGS="$HARDEN_CFLAGS -D_FORTIFY_SOURCE=2"]) check_cxx_flag([-D_FORTIFY_SOURCE=2], [HARDEN_CFLAGS="$HARDEN_CFLAGS -D_FORTIFY_SOURCE=2"])
check_link_flag([-fstack-protector-all], check_link_flag([-fstack-protector-all],
[HARDEN_CFLAGS="$HARDEN_CFLAGS -fstack-protector-all" [HARDEN_CFLAGS="$HARDEN_CFLAGS -fstack-protector-all"
check_cc_cxx_flag([-Wstack-protector], [HARDEN_CFLAGS="$HARDEN_CFLAGS -Wstack-protector"], check_cxx_flag([-Wstack-protector], [HARDEN_CFLAGS="$HARDEN_CFLAGS -Wstack-protector"],
[], [-fstack-protector-all]) [], [-fstack-protector-all])
check_cc_cxx_flag([--param ssp-buffer-size=1], [HARDEN_CFLAGS="$HARDEN_CFLAGS --param ssp-buffer-size=1"], check_cxx_flag([--param ssp-buffer-size=1], [HARDEN_CFLAGS="$HARDEN_CFLAGS --param ssp-buffer-size=1"],
[], [-fstack-protector-all])]) [], [-fstack-protector-all])])
check_cc_cxx_flag([-fPIE], check_cxx_flag([-fPIE],
[check_link_flag([-fPIE -pie], [check_link_flag([-fPIE -pie],
[HARDEN_CFLAGS="$HARDEN_CFLAGS -fPIE" [HARDEN_CFLAGS="$HARDEN_CFLAGS -fPIE"
HARDEN_LDFLAGS="$HARDEN_LDFLAGS -pie"], HARDEN_LDFLAGS="$HARDEN_LDFLAGS -pie"],
@@ -128,16 +117,13 @@ AC_SUBST([HARDEN_LDFLAGS])
# Also check for a few non-hardening-related flags. # Also check for a few non-hardening-related flags.
MISC_CXXFLAGS="" MISC_CXXFLAGS=""
AC_LANG_PUSH(C++)
AX_CHECK_COMPILE_FLAG([-fno-default-inline], AX_CHECK_COMPILE_FLAG([-fno-default-inline],
[MISC_CXXFLAGS="$MISC_CXXFLAGS -fno-default-inline"], [], [-Werror]) [MISC_CXXFLAGS="$MISC_CXXFLAGS -fno-default-inline"], [], [-Werror])
AX_CHECK_COMPILE_FLAG([-pipe], AX_CHECK_COMPILE_FLAG([-pipe],
[MISC_CXXFLAGS="$MISC_CXXFLAGS -pipe"], [], [-Werror]) [MISC_CXXFLAGS="$MISC_CXXFLAGS -pipe"], [], [-Werror])
AC_LANG_POP(C++)
AC_SUBST([MISC_CXXFLAGS]) AC_SUBST([MISC_CXXFLAGS])
# End of flag tests. # End of flag tests.
CC="$saved_CC"
CXX="$saved_CXX" CXX="$saved_CXX"
LD="$saved_LD" LD="$saved_LD"
@@ -260,9 +246,7 @@ AC_CHECK_HEADERS([endian.h sys/endian.h])
AC_CHECK_HEADERS([utmpx.h]) AC_CHECK_HEADERS([utmpx.h])
AC_CHECK_HEADERS([termio.h]) AC_CHECK_HEADERS([termio.h])
AC_CHECK_HEADERS([sys/uio.h]) AC_CHECK_HEADERS([sys/uio.h])
AC_LANG_PUSH(C++)
AC_CHECK_HEADERS([memory tr1/memory]) AC_CHECK_HEADERS([memory tr1/memory])
AC_LANG_POP(C++)
# Checks for typedefs, structures, and compiler characteristics. # Checks for typedefs, structures, and compiler characteristics.
AC_HEADER_STDBOOL AC_HEADER_STDBOOL
@@ -427,7 +411,6 @@ int pipefd[2];
[AC_MSG_RESULT([no])]) [AC_MSG_RESULT([no])])
AC_MSG_CHECKING([whether FD_ISSET() argument is const]) AC_MSG_CHECKING([whether FD_ISSET() argument is const])
AC_LANG_PUSH(C++)
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/select.h> AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/select.h>
class T { class T {
public: public:
@@ -438,10 +421,8 @@ public:
[Define if FD_ISSET() fd_set argument is const.]) [Define if FD_ISSET() fd_set argument is const.])
AC_MSG_RESULT([yes])], AC_MSG_RESULT([yes])],
[AC_MSG_RESULT([no])]) [AC_MSG_RESULT([no])])
AC_LANG_POP(C++)
AC_MSG_CHECKING([whether std::shared_ptr is available]) AC_MSG_CHECKING([whether std::shared_ptr is available])
AC_LANG_PUSH(C++)
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <memory> AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <memory>
class T { class T {
public: public:
@@ -451,10 +432,8 @@ public:
[Define if std::shared_ptr is available.]) [Define if std::shared_ptr is available.])
AC_MSG_RESULT([yes])], AC_MSG_RESULT([yes])],
[AC_MSG_RESULT([no])]) [AC_MSG_RESULT([no])])
AC_LANG_POP(C++)
AC_MSG_CHECKING([whether std::tr1::shared_ptr is available]) AC_MSG_CHECKING([whether std::tr1::shared_ptr is available])
AC_LANG_PUSH(C++)
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <tr1/memory> AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <tr1/memory>
class T { class T {
public: public:
@@ -464,7 +443,6 @@ public:
[Define if std::tr1::shared_ptr is available.]) [Define if std::tr1::shared_ptr is available.])
AC_MSG_RESULT([yes])], AC_MSG_RESULT([yes])],
[AC_MSG_RESULT([no])]) [AC_MSG_RESULT([no])])
AC_LANG_POP(C++)
AC_MSG_CHECKING([whether clock_gettime() is supported]) AC_MSG_CHECKING([whether clock_gettime() is supported])
AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <time.h> AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <time.h>
+1 -1
View File
@@ -1,7 +1,7 @@
#!/bin/sh #!/bin/sh
# There is no way to make clang's "argument unused" warning fatal. So when # There is no way to make clang's "argument unused" warning fatal. So when
# configure checks for supported flags, it runs $CC, $CXX, $LD via this # configure checks for supported flags, it runs $CXX and $LD via this
# wrapper. # wrapper.
# #
# Ideally the search string would also include 'clang: ' but this output might # Ideally the search string would also include 'clang: ' but this output might