]> git.ipfire.org Git - thirdparty/autoconf.git/commitdiff
Save/restore AC_LANG setting in AC_PROG_CC_C_O.
authorZack Weinberg <zack@owlfolio.org>
Fri, 22 Dec 2023 16:22:36 +0000 (11:22 -0500)
committerZack Weinberg <zack@owlfolio.org>
Fri, 22 Dec 2023 16:22:36 +0000 (11:22 -0500)
All of the AC_PROG_{compiler}_C_O macros, *except* AC_PROG_CC_C_O,
wrap their test in an AC_LANG_PUSH/POP pair for the appropriate
language.  https://savannah.gnu.org/support/index.php?110987 reports
that AC_PROG_CC_C_O’s not doing this can cause a configure script to
malfunction.  Specifically, if a script invokes AC_PROG_CC_C_O with
AC_LANG([C++]) in effect, AC_PROG_CC_C_O still runs $CC but it passes
a .cpp source file, possibly along with C-specific options.  Either
of those can cause the test to mis-detect support for -c -o.

Add an AC_LANG_PUSH/POP pair to AC_PROG_CC_C_O, ensuring we are
testing the right compiler and giving it appropriate input.

* lib/autoconf/c.m4 (AC_PROG_CC_C_O): Wrap body of test in
  AC_LANG_PUSH/POP to C.

lib/autoconf/c.m4

index 6cdef6fae098b96c807312c4c585db716e730681..d4f7fbe6350f71e296e8d73e8318031344973522 100644 (file)
@@ -557,6 +557,7 @@ fi[]dnl
 # --------------
 AC_DEFUN([AC_PROG_CC_C_O],
 [AC_REQUIRE([AC_PROG_CC])dnl
+AC_LANG_PUSH([C])
 if test "x$CC" != xcc; then
   AC_MSG_CHECKING([whether $CC and cc understand -c and -o together])
 else
@@ -603,6 +604,7 @@ else
   AC_DEFINE(NO_MINUS_C_MINUS_O, 1,
           [Define to 1 if your C compiler doesn't accept -c and -o together.])
 fi
+AC_LANG_POP([C])
 ])# AC_PROG_CC_C_O