[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: memcmp and cross-compilation
From: |
Jim Meyering |
Subject: |
Re: memcmp and cross-compilation |
Date: |
Wed, 21 May 2008 09:04:21 +0200 |
Simon Josefsson <address@hidden> wrote:
>>>> MinGW apparently needs gnulib's memcmp module
>>>
>>> That was rather surprising to me, so I started investigating why that is
>>> the case.
>>
>> The reason was that Autoconf's AC_FUNC_MEMCMP uses AC_RUN_IFELSE with a
>> cross-compile default of no. I prefer to assume memcmp exists on
>> cross-compile targets since I assume C89 or later in my projects. That
>> is probably not the right choice for autoconf, but I think it is for
Hi Simon,
These days, I'd guess that the least common denominator cross-compiling
target environment is C89 -- and consistently more modern than the minimal
native environment, so Autoconf might need to review assumptions like that.
The trouble is that the penalty for making a mistake is incorrect operation,
while maintaining the status quo is merely degraded performance.
>> gnulib. Thus it seems gnulib needs to extend autoconf's test somewhat?
>> I'll suggest something for review.
>
> The patch below works in the sense that, for cross-compilations only, it
> will assume that memcmp works when it is declared. This works better
> for MinGW.
...
> Jim, what do you think?
...
> AC_DEFUN([gl_FUNC_MEMCMP],
> [
> + if test $cross_compiling != no; then
> + # AC_FUNC_MEMCMP as of 2.62 defaults to 'no' when cross compiling.
> + # We default to yes if memcmp appears to exist, which works
> + # better for MinGW.
> + AC_CACHE_CHECK([whether cross-compiling target has memcmp],
> + [ac_cv_func_memcmp_working],
> + [AC_LINK_IFELSE([
> + AC_LANG_PROGRAM([[#include <string.h>
> + ]], [[int ret = memcmp ("foo", "bar", 0)]])],
That looks fine.
However, please add the conventional semicolon:
]], [[int ret = memcmp ("foo", "bar", 0);]])],
I know it's not officially needed, since AC_LANG_PROGRAM
provides one, but I had to look to confirm that.
You're welcome to commit the result.
Thanks!
Re: rpl_memcmp on mingw with g++?, Bruno Haible, 2008/05/20