Search code examples
gccmakefilemingwconfigureautoconf

What is `ac_cv_func_malloc_0_nonnull` as provided to ./configure?


I'm cross-compling with mingw and got this error:

undefined reference to `rpl_realloc'

After some searching I found this can be resolved as follows in configure.ac or as environment variables set prior to calling ./mingw64-configure:

ac_cv_func_malloc_0_nonnull=yes
ac_cv_func_realloc_0_nonnull=yes

What defines these macros, and as there any documentation on the subject? I couldn't find any...


Solution

  • What defines these macros, and as there any documentation on the subject?

    Autoconf uses the ac_cv_ prefix for its "cache variables", in which it records the results of configuration tests it has performed. In the event that the same check is requested multiple times, these allow it to use the previously-determined result instead of performing the check again.

    The general naming convention for these is documented in the Autoconf manual. The particular cache variable names you ask about are documented to cache the results of the Autoconf's AC_FUNC_MALLOC and AC_FUNC_REALLOC macros, respectively. That documentation also speaks to the rpl_realloc name.

    It is allowed to use these variables in configure.ac to programmatically determine the results of those checks, but it is a relatively nasty hack to assign values to those variables directly. In this particular case, however, the error suggests that whoever prepared the autotooling for the project you're trying to build did a sloppy job of it. If fudging the cache variables gets you a successful build and a working program then that's a tempting and much easier alternative to actually fixing the project.