mainAutoconf - Support: sr #110987, AC_PROG_CC_C_O + AC_LANG([C++])...

 
 

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

Submitter:  Zack Weinberg <zackw>
Submitted:  Thu 21 Dec 2023 07:14:49 PM UTC
   
 
Priority:  * 2 - Eventually Severity:  2 - Minor
Status:  Done Privacy:  Public
Assigned to:  None Open/Closed:  Closed
Operating System:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Fri 22 Dec 2023 04:33:04 PM UTC, comment #2: 

Turns out there is an obvious correct patch for this bug: all the other AC_PROG_compiler_C_O macros do an AC_LANG_PUSH/POP to the appropriate language, so AC_PROG_CC_C_O should too.  Committed as e544a323845c1bcc33729927137b09c681073ebd.

Zack Weinberg <zackw>
Group administrator
Thu 21 Dec 2023 07:15:17 PM UTC, comment #1: 

Low priority as this affects only unusual configure.ac layout, and as all of the AC_PROG_*_C_O macros are testing for a problem that exists only in very old compilers.

Zack Weinberg <zackw>
Group administrator
Thu 21 Dec 2023 07:14:49 PM UTC, original submission:  

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.

Zack Weinberg <zackw>
Group administrator

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by zackw (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

    Follow 3 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2023-12-22 zackw StatusConfirmed Done
        Open/ClosedOpen Closed
    2023-12-21 zackw Priority5 - Unprioritized 2 - Eventually

    Back to the top

    Powered by Savane 3.13-04b1.
    Corresponding source code