[sr #109676] only one "checking whether the AC_LANG compiler works"

anonymous <[email protected]>
Newsgroups gmane.comp.sysutils.autoconf.bugs
Message-ID <[email protected]>
URL:
  <https://savannah.gnu.org/support/?109676>

                 Summary: only one "checking whether the AC_LANG compiler
works"
                 Project: Autoconf
            Submitted by: None
            Submitted on: Sat 04 May 2019 07:44:13 PM UTC
                Category: None
                Priority: 5 - Normal
                Severity: 3 - Normal
                  Status: None
                 Privacy: Public
             Assigned to: None
        Originator Email: [email protected]
             Open/Closed: Open
         Discussion Lock: Any
        Operating System: GNU/Linux

    _______________________________________________________

Details:

Consider this simple configure.ac file.
AC_INIT
AC_PROG_CC
AC_PROG_CXX

AC_LANG(C)
AC_COMPILE_IFELSE([AC_LANG_SOURCE([
int i = 0;
])],
    [AC_MSG_RESULT([yes])],
    [AC_MSG_ERROR([int not supported])])
AC_LANG(C++)
AC_COMPILE_IFELSE([AC_LANG_SOURCE([
int i = 0;
])],
    [AC_MSG_RESULT([yes])],
    [AC_MSG_ERROR([int not supported])])

If I run autoconf 2.69 to create a configure script, and then run it with a
broken C compiler, I get a useful error.
rohan:2097$ CC=/bin/broken ./configure
checking for gcc... /bin/broken
checking whether the C compiler works... no
configure: error: in `/home/jimw/tmp':
configure: error: C compiler cannot create executables
See `config.log' for more details
rohan:2098$ 

If I run it with a broken C++ compiler, I get a confusing error.
rohan:2098$ CXX=/bin/broken ./configure
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking whether we are using the GNU C++ compiler... no
checking whether /bin/broken accepts -g... no
yes
configure: error: int not supported
rohan:2099$ 

The problem here is that the check to verity whether a compiler works is
buried in _AC_COMPILER_EXEEXT_DEFAULT in lang.m4 which is used in c.m4 via
m4_expand_once([_AC_COMPILER_EXEEXT])[]dnl
so only the very first AC_PROG_C* call gets checked.  Most linux distros will
let you install a C compiler without installing a C++ compiler.  This has
resulted in some user confusion with the GCC configure script.  See for
instance
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63509
and
https://github.com/riscv/riscv-gnu-toolchain/issues/431

We could work around the problem in GCC by calling AC_PROG_CXX before
AC_PROG_CC, but it would be nice if autoconf created a configure script that
verified that both compilers work instead of just the first one.





    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/support/?109676>

_______________________________________________
  Message sent via Savannah
  https://savannah.gnu.org/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.