[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Wrong order of preprocessor and compiler flags

From: Evgeny Grin
Subject: Wrong order of preprocessor and compiler flags
Date: Thu, 24 Mar 2022 10:47:26 +0300
User-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.7.0


I've found that everywhere in autoconf scripts flags are used like:
$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&AS_MESSAGE_LOG_FD
while automake and libtool use flags in the other order:

Autoconf uses CFLAGS before CPPFLAGS during configure, but during compile-time flags are used in another order: CPPFLAGS are followed by CFLAGS. This can easily create hard-to-find problems, for example:
During configure, the macro ENABLE_HEADERS_FEATURE will be defined in tests so some features can be detected by configure, but during the compile time the macro ENABLE_HEADERS_FEATURE will be undefined.

It's not uncommon to use CFLAGS for macros or for '-I' flags.
I think it's easy to imagine other conflicting situation where the order of used flags is significant.

Usage of CPPFLAGS before CFLAGS looks logical for me, I think autoconf should be fixed.

The list of lines to be fixed in autoconf for (Obj)C/C++:;a=blob;f=lib/autoconf/c.m4;hb=00358457d09c19ff6b5ec7ed98708540d1994a5f#l64;a=blob;f=lib/autoconf/c.m4;hb=00358457d09c19ff6b5ec7ed98708540d1994a5f#l65;a=blob;f=lib/autoconf/c.m4;hb=00358457d09c19ff6b5ec7ed98708540d1994a5f#l240;a=blob;f=lib/autoconf/c.m4;hb=00358457d09c19ff6b5ec7ed98708540d1994a5f#l241;a=blob;f=lib/autoconf/c.m4;hb=00358457d09c19ff6b5ec7ed98708540d1994a5f#l282;a=blob;f=lib/autoconf/c.m4;hb=00358457d09c19ff6b5ec7ed98708540d1994a5f#l283;a=blob;f=lib/autoconf/c.m4;hb=00358457d09c19ff6b5ec7ed98708540d1994a5f#l304;a=blob;f=lib/autoconf/c.m4;hb=00358457d09c19ff6b5ec7ed98708540d1994a5f#l305;a=blob;f=lib/autoconf/c.m4;hb=00358457d09c19ff6b5ec7ed98708540d1994a5f#l1757

Example of how flags are used by automake:

If you agree, I will send the patch for autoconf.


PS I have tried to post it to bugs-autoconf, but failed for some reason.

Attachment: OpenPGP_0x460A317C3326D2AE.asc
Description: OpenPGP public key

Attachment: OpenPGP_signature
Description: OpenPGP digital signature

reply via email to

[Prev in Thread] Current Thread [Next in Thread]