bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

gl_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK is wrong in some cases


From: Pavel Fedin
Subject: gl_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK is wrong in some cases
Date: Mon, 20 Apr 2015 16:27:54 +0300

 Hello!

 gnulib is used by libvirt project (http://libvirt.org), and during
cross-compiling libvirt i stumbled upon a problem in gnulib's autoconf
module.
 The problem happens under the following conditions:
--build=i686-mingw32 --host=arm-linux-gnueabihf
 Yes, i am cross-compiling Linux version of libvirt under Windows. It works
fine except this small test. The problem is in the first line:
--- cut ---
     if test "$as_ln_s" = "ln -s" && ln -s conftest.file conftest.sym; then
       AC_RUN_IFELSE(
         [AC_LANG_PROGRAM(
            [AC_INCLUDES_DEFAULT],
            [[struct stat sbuf;
              /* Linux will dereference the symlink and fail, as required by
                 POSIX.  That is better in the sense that it means we will
not
                 have to compile and use the lstat wrapper.  */
              return lstat ("conftest.sym/", &sbuf) == 0;
            ]])],
         [gl_cv_func_lstat_dereferences_slashed_symlink=yes],
         [gl_cv_func_lstat_dereferences_slashed_symlink=no],
         [case "$host_os" in
                    # Guess yes on glibc systems.
            *-gnu*) gl_cv_func_lstat_dereferences_slashed_symlink="guessing
yes" ;;
                    # If we don't know, assume the worst.
            *)      gl_cv_func_lstat_dereferences_slashed_symlink="guessing
no" ;;
          esac
         ])
     else
       # If the 'ln -s' command failed, then we probably don't even
       # have an lstat function.
       gl_cv_func_lstat_dereferences_slashed_symlink="guessing no"
     fi
--- cut ---
 AC_RUN_IFELSE() is supposed to perfectly handle cross-compilation case and
it knows that *-gnu* systems normally answer "yes" to this test. However,
"$as_ln_s" = "ln -s" test spoils everything on MinGW because 'ln' is
substituted by 'cp' there (because there is no support for symlinks in MinGW
for historical reasons).
 I would suggest to fix this by explicit check for "cross-compiling" = "no"
before attempting the whole thing:
--- cut ---
     if test "$cross_compiling" = no; then
       --- the whole original AC_RUN_IFELSE() thing goes here, except
cross-compile fragment ---
     else
       # cross-compiling
       case "$host_os" in
                 # Guess yes on glibc systems.
         *-gnu*) gl_cv_func_lstat_dereferences_slashed_symlink="guessing
yes" ;;
                 # If we don't know, assume the worst.
         *)      gl_cv_func_lstat_dereferences_slashed_symlink="guessing no"
;;
       esac
     fi
--- cut ---
 Anyway, this test makes no sense when build != host.

Kind regards,
Pavel Fedin
Expert Engineer
Samsung Electronics Research center Russia






reply via email to

[Prev in Thread] Current Thread [Next in Thread]