[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] tweak lstat.c to avoid mingw link failure
From: |
Bruno Haible |
Subject: |
Re: [PATCH] tweak lstat.c to avoid mingw link failure |
Date: |
Thu, 13 Nov 2008 04:03:57 +0100 |
User-agent: |
KMail/1.5.4 |
Jim Meyering wrote:
> I needed this patch in libvirt to avoid a link error.
> * lib/lstat.c: Include <sys/stat.h> *before* the use of stat in
> orig_stat.
This is not right: On Unix systems on which lstat is not POSIX compliant,
it will lead to an endless recursion
rpl_lstat -> orig_lstat -> rpl_lstat -> ...
In a compilation on mingw, test-lstat.exe linked fine for me. The only
anomaly that I can see is that lstat.c is compiled, indeed with an undefined
reference to 'lstat'. It will lead to a link error when creating a shared
library. I would propose this fix instead:
2008-11-12 Bruno Haible <address@hidden>
* m4/lstat.m4 (gl_FUNC_LSTAT): Don't compile lstat.c on systems
which don't have lstat; this is handled by lib/sys_stat.in.h already.
Reported by Daniel P. Berrange via Jim Meyering.
*** m4/lstat.m4.orig 2008-11-13 03:56:56.000000000 +0100
--- m4/lstat.m4 2008-11-13 03:56:35.000000000 +0100
***************
*** 12,23 ****
AC_DEFUN([gl_FUNC_LSTAT],
[
AC_REQUIRE([gl_SYS_STAT_H_DEFAULTS])
! AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK
! dnl Note: AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK does AC_LIBOBJ(lstat).
! if test $ac_cv_func_lstat_dereferences_slashed_symlink = no; then
! REPLACE_LSTAT=1
fi
- # Prerequisites of lib/lstat.c.
- AC_REQUIRE([AC_C_INLINE])
- :
])
--- 12,27 ----
AC_DEFUN([gl_FUNC_LSTAT],
[
AC_REQUIRE([gl_SYS_STAT_H_DEFAULTS])
! dnl If lstat does not exist, the replacement <sys/stat.h> does
! dnl "#define lstat stat", and lstat.c does not need to be compiled.
! AC_CHECK_FUNCS_ONCE([lstat])
! if test $ac_cv_func_lstat = yes; then
! AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK
! dnl Note: AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK does AC_LIBOBJ(lstat).
! if test $ac_cv_func_lstat_dereferences_slashed_symlink = no; then
! REPLACE_LSTAT=1
! fi
! # Prerequisites of lib/lstat.c.
! AC_REQUIRE([AC_C_INLINE])
fi
])