AM_PROG_CC_C_O: don't rely on AC_PROG_CC_C_O, re-implement similar logic
authorStefano Lattarini <stefano.lattarini@gmail.com>
Wed, 15 May 2013 08:14:46 +0000 (10:14 +0200)
committerStefano Lattarini <stefano.lattarini@gmail.com>
Fri, 24 May 2013 15:35:30 +0000 (17:35 +0200)
commite90126cf20ab1bd848631fca5d4bc32433ca52e4
tree7b3085164affd19344266f90bdc7f6e8154cdacb
parent9877109c1f00e20f76a69ac656fc02a439ae318a
AM_PROG_CC_C_O: don't rely on AC_PROG_CC_C_O, re-implement similar logic

** Theoretical problems of AC_PROG_CC_C_O:

  Both cc and $CC are checked to see if they support the '-c' and '-o'
  options together.
  This behaviour is highly inconsistent with that of the other macros
  related to C compiler checks -- which test only $CC.
  It can also cause unwarranted uses of the 'compile' script on systems
  where the default 'cc' is inferior, but the user is compiling with a
  proper, different compiler (e.g., gcc).

** Practical problems with our previous implementation of C support m4
   macros in Automake:

  - AM_PROG_AR must now be called *before* AC_PROG_CC; this wasn't the
    case before, and it turns out there are packages in the wild that
    relied on the old behaviour.

  - The cross-referenced requirements and macro rewrites juggled among
    AC_PROG_CC, AC_PROG_CC_C_O and AM_PROG_CC_C_O caused warnings in
    autoconf; for example, in our test 't/libobj3.sh', we could see
    warnings like these (here slightly tweaked for legibility):

        configure.ac:5: AC_REQUIRE: `AC_PROG_CC' expanded before required
        autoconf/c.m4:567: AC_PROG_CC_C_O is expanded from...
        autoconf/c.m4:429: AC_LANG_COMPILER(C) is expanded from...
        autoconf/lang.m4:329: AC_LANG_COMPILER_REQUIRE is expanded from...
        autoconf/general.m4:2606: AC_COMPILE_IFELSE is expanded from...
        m4sugar/m4sh.m4:639: AS_IF is expanded from...
        autoconf/general.m4:2031: AC_CACHE_VAL is expanded from...
        autoconf/general.m4:2052: AC_CACHE_CHECK is expanded from...
        aclocal.m4:70: AM_PROG_AR is expanded from...
        configure.ac:5: the top level

** Fix all of that:

We fix all of the described issues with a new internal m4 macro
_AM_PROG_CC_C_O (inspired to, but not based on, AC_PROG_CC_C_O) that
gets tacked on to AC_PROG_CC automatically (this is done in the
Automake-generated aclocal.m4) and that takes care of checking and
adjusting '$CC' for "-c -o" support.

The macro AM_PROG_CC_C_O is still present, but is now just a thin
wrapper around such Automake-enhanced AC_PROG_CC.

It is worth noting that the present patch causes three slight
*backward-incompatibilities*:

  1. The name cache variable used by AM_PROG_CC_C_O is no longer
     computed (at configure runtime!) from the content of '$CC',
     but is statically defined as 'am_cv_prog_cc_c_o'.

  2. 'cc' is no longer checked by AM_PROG_CC_C_O, only '$CC' is.

  3. AM_PROG_CC_C_O no longer AC_DEFINE the C preprocessor symbol
     'NO_MINUS_C_MINUS_O'.

Given however that the third change can easily be worked around, that
the first two changes can be legitimately seen as bug fixes, and that
the new semantics introduced by such changes will simplify the transition
to Automake 2.0 (when the 'subdir-objects' will always be enabled
unconditionally), we believe they are acceptable to be shipped with
Automake 1.14.

With this patch, we also revert some of the testsuite adjustments done
in previous commit v1.13.2-178-g9877109 of 2013-05-24 (compile: rewrite
AC_PROG_CC with AM_PROG_CC_C_O contents).  Such adjustments are no longer
needed.

* m4/minuso.m4 (_AM_PROG_CC_C_O): New internal macro, basically and
adjusted version of a merge between Autoconf-provided AC_PROG_CC_C_O
and our old implementation of AM_PROG_CC_C_O.
(AM_PROG_CC_C_O): Redefine as a simple wrapper around AC_PROG_CC.
* m4/init.m4 (AC_PROG_CC): Append _AM_PROG_CC_C_O, not AM_PROG_CC_C_O,
to the pre-existing expansion of this macro.
* m4/ar-lib.m4 (AM_PROG_AR): No longer require it to be expanded after
AC_PROG_CC.
* t/aclocal-deps.sh: Move AC_PROG_CC invocation after AC_PROG_RANLIB
and AM_PROG_AR invocations.  Things should work this way too (as they
used to).
* t/subobj-clean-lt-pr10697.sh: Likewise.
* t/alloca.sh: Move AC_PROG_CC invocation after AM_PROG_AR invocation.
* t/condlib.sh: Likewise.
* t/aclocal-deps.sh: Move AC_PROG_CC invocation after LT_INIT and
AM_PROG_AR invocations.  Make autoconf and autoheader warnings fatal.
* t/am-prog-cc-c-o.sh: Adjust to the new semantics, enhance a  little,
and reduce code duplication.
* t/ccnoco.sh: Make autoconf warnings fatal.
* t/subpkg.sh: Likewise.
* t/ccnoco-lib.sh: Likewise, and fix a comment.
* t/link_cond.sh: Enhance a couple of error messages.
* configure.ac: Drop "nullification" of AM_PROG_CC_C_O.
* NEWS: Adjust.

Signed-off-by: Stefano Lattarini <stefano.lattarini@gmail.com>
15 files changed:
NEWS
configure.ac
m4/ar-lib.m4
m4/init.m4
m4/minuso.m4
t/aclocal-deps.sh
t/alloca.sh
t/am-prog-cc-c-o.sh
t/ccnoco-lib.sh
t/ccnoco.sh
t/condlib.sh
t/link_cond.sh
t/objc-megademo.sh
t/subobj-clean-lt-pr10697.sh
t/subpkg.sh