Two AX_PROG_CC_FOR_BUILD issues

Harald van Dijk <[email protected]> Sat, 13 Jul 2019 18:48:05 +0100
Newsgroups gmane.comp.sysutils.autoconf.archive-maintainers
Message-ID <[email protected]>
Hi,

I am using AX_PROG_CC_FOR_BUILD to support cross-compilation. Some 
utilities are needed to generate files at build time, so these must not 
be built with a cross-compiler. This mostly works, except for two things.

1:

When doing a native build, if CC is set and CC_FOR_BUILD is unset, I 
expect CC to be used for build-time jobs too. Instead, the default 
compiler is used. Would it be acceptable to change it to check whether a 
cross-compile is performed, and if not, if CC_FOR_BUILD is not set, just 
copy all the host compilation variables without doing any extra checks?

2:

When CC and CC_FOR_BUILD are different, a few checks are done both for 
CC and for CC_FOR_BUILD, but they use the same cache variables. As a 
result, the CC results are also re-used for CC_FOR_BUILD. On an AIX 
system, configuring with ./configure CC=cc detected that the 
-qlanglvl=extc89 option was needed for C90 conformance, but it picked 
CC_FOR_BUILD=gcc and still used that same -qlanglvl=extc89 option. 
Needless to say, the build broke.

For 1, I have not yet looked at what would be needed to change this, 
since I do not know whether the current behaviour is by design.

For 2, I have looked a bit at what would be needed to change this, but 
it is problematic. For the flags, it is easy: just add a pushdef() and 
popdef() for ac_cv_prog_cc_c89, same as all the other variables. 
However, this is not the only check that is performed, and other checks 
are more difficult. There is AC_PROG_CC_C_O, but it is defined one way 
in Autoconf, and is redefined another way in Automake, using different 
cache variables. There is also _AC_LANG_COMPILER_GNU, where pushdef() 
and popdef() for the cache variable does not work, for reasons I have 
not yet figured out. Would it be okay to submit a patch just for the C90 
conformance flag issue and to ignore the other problems?

Cheers,
Harald van Dijk