helpAutoconf - Support: sr #110660, AC_LANG_INT_SAVE (used by...

 
 

sr #110660: AC_LANG_INT_SAVE (used by AC_CHECK_SIZEOF) includes stdlib.h without checking whether it actually exists

Submitter:  Alain Knaff <alainknaff>
Submitted:  Tue 17 May 2022 06:15:00 PM UTC
 
Category:  None Priority:  3 - Low
Severity:  1 - Wish Status:  None
Privacy:  Public Assigned to:  None
Open/Closed:  Open Operating System:  None
* Mandatory Fields

Add a New Comment (Rich Markup)
   

Comment Type & Canned Response:
       

 

Tue 17 May 2022 09:28:38 PM UTC, comment #3: 

> This fails if stdlib.h doesn't actually exist.

Yes, and that's documented behavior. The Autoconf manual says:

> If your program needs to be portable to a freestanding
> environment, such as an embedded OS that doesn't provide all of the
> facilities of the C90 standard library, you may need to test for some of
> the above headers as well.  Note that many Autoconf macros internally
> assume that the complete set of C90 headers are available.

It'd be nice if Autoconf also worked for freestanding programs too. That'd require a bit of work though. In the meantime I'll mark this as a wishlist item.

Paul Eggert <eggert>
Project Administrator
Tue 17 May 2022 08:19:11 PM UTC, comment #2: 

comment #1:

> You've been filing all of these bugs -- exactly which version of Autoconf are you using to generate the configure scripts that show these bugs?


I'm using 2.69-14, currently included with Debian 11.

>  Some of the things you have said (e.g. talking about configure.in instead of configure.ac) suggest that you are using a very old version of Autoconf.


Indeed, I just noticed that this is 10 years old, and that there have been 2 new releases last year.

Sorry for not having noticed that earlier.

I'll continue my tests with the new version... Don't expect fast updates to my other bugs though, as a full run of configure takes between 2 and 3 hours...

>
> The code generated for AC_CHECK_SIZEOF, in current versions of autoconf, is completely different from the code you quoted, and does not make any use of either stdio.h or stdlib.h, so the bug seems moot to me.
>
> (N.B. Current versions of autoconf do not support pre-C89 compilers.  However, the bug report is abstractly valid anyway, because a "freestanding" C89 compiler doesn't have to provide stdio.h and stdlib.h.)


The compiler included with the UnixPC image I'm using is gcc 2.5.8 if that helps.
UnixPC also has a "native" cc compiler, but that one is unusable for the purpose as it is Kernighan&Ritchie syntax (no types in prototype)

Alain Knaff <alainknaff>
Tue 17 May 2022 07:44:38 PM UTC, comment #1: 

You've been filing all of these bugs -- exactly which version of Autoconf are you using to generate the configure scripts that show these bugs?  Some of the things you have said (e.g. talking about configure.in instead of configure.ac) suggest that you are using a very old version of Autoconf.

The code generated for AC_CHECK_SIZEOF, in current versions of autoconf, is completely different from the code you quoted, and does not make any use of either stdio.h or stdlib.h, so the bug seems moot to me.

(N.B. Current versions of autoconf do not support pre-C89 compilers.  However, the bug report is abstractly valid anyway, because a "freestanding" C89 compiler doesn't have to provide stdio.h and stdlib.h.)

Zack Weinberg <zackw>
Project Administrator
Tue 17 May 2022 06:15:00 PM UTC, original submission:  

if stdlib.h doesn't exist, AC_CHECK_SIZEOF(size_t) fails with

conftest.c:80: stdlib.h: No such file or directory
configure:5433: error: cannot compute sizeof (size_t)

Code quoted in config.log includes the following:

...
| #ifdef HAVE_UNISTD_H
| # include <unistd.h>
| #endif
| static long int longval () { return (long int) (sizeof (size_t)); }
| static unsigned long int ulongval () { return (long int) (sizeof (size_t)); }
| #include <stdio.h>
| #include <stdlib.h>
| int
| main ()
| {
|
|   FILE *f = fopen ("conftest.val", "w");
|   if (! f)
|     return 1;
|   if (((long int) (sizeof (size_t))) < 0)
|     {
|       long int i = longval ();
|       if (i != ((long int) (sizeof (size_t))))
| return 1;
|       fprintf (f, "%ld", i);
|     }
|   else
|     {
|       unsigned long int i = ulongval ();
|       if (i != ((long int) (sizeof (size_t))))
| return 1;
|       fprintf (f, "%lu", i);
|     }
|   /* Do not output a trailing newline, as this causes \r\n confusion
|      on some platforms.  */
|   return ferror (f) || fclose (f) != 0;
...

As you see, most includes are correctly protected by #ifdef HAVE_*, except stdio.h and stdlib.h

This fails if stdlib.h doesn't actually exist. Most other tests until then run fine (AC_CHECK_LIB, AC_CHECK_HEADERS, AC_CHECK_TYPES).

N.B. I do have AC_CHECK_HEADERS(stdlib.h) early in my configure.in, it correctly determines that stdlib.h doesn't exist, but that result is not used by AC_LANG_INT_SAVE

Alain Knaff <alainknaff>

 

(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 eggert (Posted a comment)
  • -email is unavailable- added by zackw (Posted a comment)
  • -email is unavailable- added by alainknaff (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 2 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2022-05-17 eggert Priority5 - Normal 3 - Low
        Severity3 - Normal 1 - Wish

    Back to the top


    Powered by Savane 3.9