mainAutoconf - Support: sr #110369, AC_PROG_CC_C99 is not recognized...

 
 

sr #110369: AC_PROG_CC_C99 is not recognized as empty macro

Submitter:  Sergei Trofimovich <slyfox>
Submitted:  Wed 11 Nov 2020 08:22:41 AM UTC
   
 
Priority:  * 5 - Unprioritized Severity:  3 - Normal
Status:  Done Privacy:  Public
Assigned to:  None Open/Closed:  Closed
Operating System:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Sun 15 Nov 2020 08:24:20 PM UTC, comment #3: 

Fixed in fd633e92cb63f7bb592dcffd2f2871fa28ab189d.

Zack Weinberg <zackw>
Group administrator
Wed 11 Nov 2020 02:21:12 PM UTC, comment #2: 

I can't reproduce the bad error message, I get


configure.ac:31: warning: The macro `AC_PROG_CC_C99' is obsolete.
configure.ac:31: You should run autoupdate.
../lib/autoconf/c.m4:1493: AC_PROG_CC_C99 is expanded from...
../lib/m4sugar/m4sh.m4:673: AS_IF is expanded from...
configure.ac:11: AX_CHECK_COMPILE_FLAG is expanded from...
configure.ac:31: the top level


with both 2.69d and git trunk.  However, I do get a broken configure script:


$ ./configure
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether the compiler supports GNU C... yes
checking whether gcc accepts -g... yes
checking for gcc option to enable C11 features... none needed
checking whether C compiler accepts -std=gnu11... yes
./configure: line 3176: syntax error near unexpected token `fi'
./configure: line 3176: `fi'


What appears to be going on is, in the betas, AC_PROG_CC_C99 is a stub that does all its work at m4 expansion time (calling m4_warn and AC_REQUIRE) and emits no shell code.  AS_VAR_IF does not recognize that its third argument is going to expand to no shell code, so it emits an if-then-else-fi with an empty else clause, which is a syntax error.  I'll make AS_VAR_IF more defensive.

The reason AC_PROG_CC_C99 is now a stub, is that in the betas, AC_PROG_CC will automatically detect and enable C2011 mode if available, falling back to C99 and then to C89 for older compilers.  So, with 2.70, what zeromq is doing here becomes unnecessary.  Once 2.70-final is released, zeromq could either bump their AC_PREREQ to [2.70] and remove the AX_CHECK_COMPILE_FLAG line altogether, or, if they don't want to raise the minimum autoconf requirement, they could change the AX_CHECK_COMPILE_FLAG line to


m4_version_prereq([2.70], [], [
  AX_CHECK_COMPILE_FLAG([-std=gnu11], [CFLAGS+=" -std=gnu11"], [AC_PROG_CC_C99])
])


which omits the line only when it's unnecessary.

Zack Weinberg <zackw>
Group administrator
Wed 11 Nov 2020 08:24:12 AM UTC, comment #1: 

Forgot the detail:

- autoconf-2.69 generates working shell
- autoconf-2.69d generates the shell with failure

Sergei Trofimovich <slyfox>
Wed 11 Nov 2020 08:22:41 AM UTC, original submission:  

The configure error originally observed on libzmq project https://github.com/zeromq/libzmq/blob/master/configure.ac#L67

Here is the minimal single file example:

$ cat configure.ac
AC_PREREQ(2.61)

AC_INIT([zeromq],[4.3.3])

  # ===========================================================================
  #  https://www.gnu.org/software/autoconf-archive/ax_check_compile_flag.html
  # ===========================================================================
  # ...
  #serial 6

  AC_DEFUN([AX_CHECK_COMPILE_FLAG],
  [AC_PREREQ(2.64)dnl for _AC_LANG_PREFIX and AS_VAR_IF
  AS_VAR_PUSHDEF([CACHEVAR],[ax_cv_check_[]_AC_LANG_ABBREV[]flags_$4_$1])dnl
  AC_CACHE_CHECK([whether _AC_LANG compiler accepts $1], CACHEVAR, [
    ax_check_save_flags=$[]_AC_LANG_PREFIX[]FLAGS
    _AC_LANG_PREFIX[]FLAGS="$[]_AC_LANG_PREFIX[]FLAGS $4 $1"
    AC_COMPILE_IFELSE([m4_default([$5],[AC_LANG_PROGRAM()])],
      [AS_VAR_SET(CACHEVAR,[yes])],
      [AS_VAR_SET(CACHEVAR,[no])])
    _AC_LANG_PREFIX[]FLAGS=$ax_check_save_flags])
  AS_VAR_IF(CACHEVAR,yes,
    [m4_default([$2], :)],
    [m4_default([$3], :)])
  AS_VAR_POPDEF([CACHEVAR])dnl
  ])dnl AX_CHECK_COMPILE_FLAGS

  # End of https://www.gnu.org/software/autoconf-archive/ax_check_compile_flag.html

# Checks for programs.
AC_PROG_CC
AX_CHECK_COMPILE_FLAG([-std=gnu11], [CFLAGS+=" -std=gnu11"], [AC_PROG_CC_C99])

AC_OUTPUT


Trying to use it fails as:

$ autoconf
configure.ac:31: warning: The macro `' is obsolete.
configure.ac:31: You should run autoupdate.
./lib/autoconf/c.m4:1493: AC_PROG_CC_C99 is expanded from...
lib/m4sugar/m4sh.m4:673: AS_IF is expanded from...
configure.ac:11: AX_CHECK_COMPILE_FLAG is expanded from...
configure.ac:31: the top level

$ ./configure --host=x86_64-pc-linux-gnu
...
checking whether C compiler accepts -std=gnu11... yes
./configure: line 3145: syntax error near unexpected token `fi'
./configure: line 3145: `fi'

There `[AC_PROG_CC_C99]` gets expanded to empty shell text instead of `:`.

Looks like `AC_PROG_CC_C99` definition is not considered to be empty by `AX_CHECK_COMPILE_FLAG`. I'm not sure if it's a `AX_CHECK_COMPILE_FLAG` macro bug or deficiency in `AC_PROG_CC_C99` definition.

Sergei Trofimovich <slyfox>

 

(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 (Posted a comment)
  • -email is unavailable- added by slyfox (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
    2020-11-15 zackw StatusConfirmed Done
        Open/ClosedOpen Closed
    2020-11-11 zackw StatusNone Confirmed

    Back to the top

    Powered by Savane 3.13-758e.
    Corresponding source code