[sr #110987] AC_PROG_CC_C_O + AC_LANG([C++]) combines C-specific compiler options with C++ source

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

                 Summary: AC_PROG_CC_C_O + AC_LANG([C++]) combines C-specific
compiler options with C++ source
                   Group: Autoconf
               Submitter: zackw
               Submitted: Thu 21 Dec 2023 07:14:49 PM UTC
                Priority: 5 - Unprioritized
                Severity: 2 - Minor
                  Status: Confirmed
                 Privacy: Public
             Assigned to: None
        Originator Email: 
             Open/Closed: Open
         Discussion Lock: Any
        Operating System: None


    _______________________________________________________

Follow-up Comments:


-------------------------------------------------------
Date: Thu 21 Dec 2023 07:14:49 PM UTC By: Zack Weinberg <zackw>
A configure.ac like this


AC_INIT
AC_LANG([C++])
AC_PROG_CC_C_O
...


may (depending on exactly which compiler you have) run a compilation command
that combines C-specific options with a C++ source file.  Some compilers
object to this:


configure:2575: checking for C compiler version
configure:2584: gcc --version >&5
Apple LLVM version 6.0 (clang-600.0.57) (based on LLVM 3.5svn)
Target: x86_64-apple-darwin13.4.0
...
configure:3008: gcc -std=gnu11 -c -g -O2  conftest.c >&5
configure:3008: $? = 0
configure:3030: result: -std=gnu11
configure:3146: checking whether gcc -std=gnu11 and cc understand -c and -o
together
configure:3178: gcc -std=gnu11 -c conftest.cpp -o conftest2.o >&5
error: invalid argument '-std=gnu11' not allowed with 'C++/ObjC++'


and that in turn causes the test to get the wrong answer, thinking the C++
compiler does *not* support -c and -o together, when it does.

AC_PROG_CC_C_O is specifically a test of the C compiler. There's another macro
AC_PROG_CXX_C_O that does the same test on the C++ compiler (and two more for
Fortran compilers).  They should all be
either refusing to execute under the wrong AC_LANG setting, or ignoring the
AC_LANG setting; not invoking the C compiler, using C-specific options, on a
C++ source file.

Originally reported by Sevan Janiyan.







    _______________________________________________________

Reply to this item at:

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

_______________________________________________
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.