mainAutoconf - Support: sr #110484, CFLAGS/CXXFLAGS and CPPFLAGS order...

 
 

sr #110484: CFLAGS/CXXFLAGS and CPPFLAGS order in c.m4 ac_compile is nonstandard

Submitter:  None
Submitted:  Wed 05 May 2021 03:10:42 PM UTC
   
 
Priority:  * 5 - Unprioritized Severity:  3 - Normal
Status:  Invalid Privacy:  Public
Assigned to:  None Originator Email:  -email is unavailable-
Open/Closed:  Closed Operating System:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Fri 08 Dec 2023 05:46:53 PM UTC, comment #1: 

Autoconf is consistent with GNU make's implicit rules:


make: *** No targets.  Stop.
COMPILE.c = $(CC) $(CFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c
COMPILE.cc = $(CXX) $(CXXFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c


Therefore I think it is actually Automake, and the expectations of AX_CHECK_COMPILE_FLAG, that are incorrect here.

Please take this up with both the maintainers of Automake (see https://www.gnu.org/software/automake/manual/html_node/Reporting-Bugs.html) and the maintainers of GNU make (write to bug-make@gnu.org).  If they both agree that the order ought to be CPPFLAGS first, and GNU make's implicit rules are changed, then I will change Autoconf to match.

Zack Weinberg <zackw>
Group administrator
Wed 05 May 2021 03:10:42 PM UTC, original submission:  

The definition of ac_compile in lib/autoconf/c.m4 contains $CFLAGS/$CXXFLAGS/$OBJCFLAGS before $CPPFLAGS, whereas the usual expected order (for example in the implicit rules of GNU automake) is the other way around. This prevents other macros from working as expected when flag shadowing is involved.

One such case is AX_CHECK_COMPILE_FLAG of autoconf-archive being unable to properly detect accepted compiler flags: it appends the tested flag to C/CXXFLAGS and tries to compile with AC_COMPILE_IFELSE, but a flag set in CPPFLAGS is able to take precedence, falsifying the result.

A minimal working example is attached, using the latest AX_CHECK_COMPILE_FLAG, where running

autoconf
./configure CPPFLAGS=-march=native

gives

checking whether C compiler accepts "-march=pentiumpro"... yes

whereas running without CPPFLAGS gives

checking whether C compiler accepts "-march=pentiumpro"... no


This leads to projects which use AX_CC_MAXOPT being unable to compile when CPPFLAG=-march=native is set.

Anonymous

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #51384:  configure.ac added by None (2KiB - application/vnd.nokia.n-gage.ac+xml)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by zackw (Posted a comment)
  • -email is unavailable- added by None (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 4 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2023-12-08 zackw Open/ClosedOpen Closed
    2023-12-08 zackw Severity4 - Important 3 - Normal
        StatusNone Invalid
    2021-05-05 None Attached File- Added configure.ac, #51384

    Back to the top

    Powered by Savane 3.13-d3ae.
    Corresponding source code