I will be pushing these later today as prerequisites to fixing fchdir and splitting fdopendir into its own module. This series avoids some compilation warnings due to missing chmod on mingw, and allows me to run gnulib testsuites under cygwin while cross-compiling to mingw:
$ cross_compiling=yes gl_cv_func_open_slash=no CC='gcc -mno-cygwin' \ CFLAGS='-Wall -gdwarf-2' ./gnulib-tool --with-tests --test canonicalize without failing the canonicalize tests (running mingw tests under cygwin is an unusual case - most cross-compilation environments cannot run cross-compiled executables in the build environment). The problem was that cygwin host tools support symlinks, but the cross-compiled mingw executables do not, so test- canonicalize.c was failing to resolve the symlink created in test- canonicalize.sh. I suspect (but don't know for sure) that this second patch will also help the case of using wine/qemu as a setup where the build environment can run cross-hosted binaries. Someday, when cygwin 1.7 starts shipping a real mingw cross-compiler (gcc-i686- pc-mingw) rather than a weird one (gcc -mno-cygwin), I hope that the gl_cv_func_open_slash hack can go away. Or maybe there is a missing piece of support in './gnulib-tool --with-tests' to make it easy to specify cross- compilation mode. I guess we could also change m4/open.m4 to add: #if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ choke me #endif for the situation where AC_CANONICAL_HOST is mis-detected as cygwin rather than mingw (as in my above gnulib-tool command line), but I didn't want to do that without some feedback. From: Eric Blake <e...@byu.net> Date: Mon, 31 Aug 2009 09:00:45 -0600 Subject: [PATCH 1/2] chown: avoid compilation warning on mingw * m4/chown.m4 (gl_FUNC_CHOWN): Recognize missing chown. * lib/chown.c (rpl_chown) [!HAVE_CHOWN]: Always return failure on mingw. * lib/lchown.c (lchown) [!HAVE_CHOWN]: Likewise. * modules/chown (Depends-on): Add errno. Signed-off-by: Eric Blake <e...@byu.net> --- ChangeLog | 9 +++++++++ lib/chown.c | 16 +++++++++++----- lib/lchown.c | 14 ++++++++++---- m4/chown.m4 | 3 ++- modules/chown | 1 + 5 files changed, 33 insertions(+), 10 deletions(-) diff --git a/ChangeLog b/ChangeLog index 4883188..3b76ac5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2009-08-31 Eric Blake <e...@byu.net> + + chown: avoid compilation warning on mingw + * m4/chown.m4 (gl_FUNC_CHOWN): Recognize missing chown. + * lib/chown.c (rpl_chown) [!HAVE_CHOWN]: Always return failure on + mingw. + * lib/lchown.c (lchown) [!HAVE_CHOWN]: Likewise. + * modules/chown (Depends-on): Add errno. + 2009-08-31 Jim Meyering <meyer...@redhat.com> canonicalize: remove useless initialization diff --git a/lib/chown.c b/lib/chown.c index 3582b04..cca1d7f 100644 --- a/lib/chown.c +++ b/lib/chown.c @@ -1,7 +1,7 @@ /* provide consistent interface to chown for systems that don't interpret an ID of -1 as meaning `don't change the corresponding ID'. - Copyright (C) 1997, 2004, 2005, 2006, 2007 Free Software Foundation, Inc. + Copyright (C) 1997, 2004-2007, 2009 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -46,7 +46,8 @@ int rpl_chown (const char *file, uid_t uid, gid_t gid) { -#if CHOWN_FAILS_TO_HONOR_ID_OF_NEGATIVE_ONE +#if HAVE_CHOWN +# if CHOWN_FAILS_TO_HONOR_ID_OF_NEGATIVE_ONE if (gid == (gid_t) -1 || uid == (uid_t) -1) { struct stat file_stats; @@ -61,9 +62,9 @@ rpl_chown (const char *file, uid_t uid, gid_t gid) if (uid == (uid_t) -1) uid = file_stats.st_uid; } -#endif +# endif -#if CHOWN_MODIFIES_SYMLINK +# if CHOWN_MODIFIES_SYMLINK { /* Handle the case in which the system-supplied chown function does *not* follow symlinks. Instead, it changes permissions @@ -97,7 +98,12 @@ rpl_chown (const char *file, uid_t uid, gid_t gid) else if (errno != EACCES) return -1; } -#endif +# endif return chown (file, uid, gid); + +#else /* !HAVE_CHOWN */ + errno = EOPNOTSUPP; + return -1; +#endif } diff --git a/lib/lchown.c b/lib/lchown.c index 07aef87..5bc7074 100644 --- a/lib/lchown.c +++ b/lib/lchown.c @@ -1,7 +1,7 @@ /* Provide a stub lchown function for systems that lack it. - Copyright (C) 1998, 1999, 2002, 2004, 2006, 2007 Free Software - Foundation, Inc. + Copyright (C) 1998, 1999, 2002, 2004, 2006, 2007, 2009 Free + Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -48,7 +48,8 @@ int lchown (const char *file, uid_t uid, gid_t gid) { -#if ! CHOWN_MODIFIES_SYMLINK +#if HAVE_CHOWN +# if ! CHOWN_MODIFIES_SYMLINK struct stat stats; if (lstat (file, &stats) == 0 && S_ISLNK (stats.st_mode)) @@ -56,7 +57,12 @@ lchown (const char *file, uid_t uid, gid_t gid) errno = EOPNOTSUPP; return -1; } -#endif +# endif return chown (file, uid, gid); + +#else /* !HAVE_CHOWN */ + errno = EOPNOTSUPP; + return -1; +#endif } diff --git a/m4/chown.m4 b/m4/chown.m4 index 5d30ae3..ac76d3f 100644 --- a/m4/chown.m4 +++ b/m4/chown.m4 @@ -1,4 +1,4 @@ -# serial 18 +# serial 19 # Determine whether we need the chown wrapper. dnl Copyright (C) 1997-2001, 2003-2005, 2007, 2009 @@ -20,6 +20,7 @@ AC_DEFUN([gl_FUNC_CHOWN], AC_REQUIRE([AC_TYPE_UID_T]) AC_REQUIRE([AC_FUNC_CHOWN]) AC_REQUIRE([gl_FUNC_CHOWN_FOLLOWS_SYMLINK]) + AC_CHECK_FUNCS_ONCE([chown]) if test $ac_cv_func_chown_works = no; then AC_DEFINE([CHOWN_FAILS_TO_HONOR_ID_OF_NEGATIVE_ONE], [1], diff --git a/modules/chown b/modules/chown index cf99210..7cd07f5 100644 --- a/modules/chown +++ b/modules/chown @@ -7,6 +7,7 @@ lib/fchown-stub.c m4/chown.m4 Depends-on: +errno open unistd sys_stat -- 1.6.3.2 >From b5303b066289f6d618c349def738f4b688dc1349 Mon Sep 17 00:00:00 2001 From: Eric Blake <e...@byu.net> Date: Mon, 31 Aug 2009 09:12:30 -0600 Subject: [PATCH 2/2] canonicalize: allow cross-testing from cygwin to mingw * modules/canonicalize-tests (configure.ac): Define HAVE_SYMLINK. (Makefile.am): Pass it through TESTS_ENVIRONMENT. * modules/canonicalize-lgpl-tests (configure.ac, Makefile.am): Likewise. * tests/test-canonicalize.sh: Also skip test if 'ln -s' works, but target does not support symlinks. * tests/test-canonicalize-lgpl.sh: Likewise. Signed-off-by: Eric Blake <e...@byu.net> --- ChangeLog | 9 +++++++++ modules/canonicalize-lgpl-tests | 5 ++++- modules/canonicalize-tests | 5 ++++- tests/test-canonicalize-lgpl.sh | 3 ++- tests/test-canonicalize.sh | 3 ++- 5 files changed, 21 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 3b76ac5..6e39cef 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,14 @@ 2009-08-31 Eric Blake <e...@byu.net> + canonicalize: allow cross-testing from cygwin to mingw + * modules/canonicalize-tests (configure.ac): Define HAVE_SYMLINK. + (Makefile.am): Pass it through TESTS_ENVIRONMENT. + * modules/canonicalize-lgpl-tests (configure.ac, Makefile.am): + Likewise. + * tests/test-canonicalize.sh: Also skip test if 'ln -s' works, but + target does not support symlinks. + * tests/test-canonicalize-lgpl.sh: Likewise. + chown: avoid compilation warning on mingw * m4/chown.m4 (gl_FUNC_CHOWN): Recognize missing chown. * lib/chown.c (rpl_chown) [!HAVE_CHOWN]: Always return failure on diff --git a/modules/canonicalize-lgpl-tests b/modules/canonicalize-lgpl-tests index 5028ee7..9d86078 100644 --- a/modules/canonicalize-lgpl-tests +++ b/modules/canonicalize-lgpl-tests @@ -5,9 +5,12 @@ tests/test-canonicalize-lgpl.c Depends-on: configure.ac: +AC_CHECK_FUNCS_ONCE([symlink]) +HAVE_SYMLINK=ac_cv_func_symlink +AC_SUBST([HAVE_SYMLINK]) Makefile.am: TESTS += test-canonicalize-lgpl.sh -TESTS_ENVIRONMENT += EXEEXT='@EXEEXT@' +TESTS_ENVIRONMENT += EXEEXT='@EXEEXT@' HAVE_SYMLINK='$(HAVE_SYMLINK)' check_PROGRAMS += test-canonicalize-lgpl test_canonicalize_lgpl_LDADD = $(LDADD) diff --git a/modules/canonicalize-tests b/modules/canonicalize-tests index 875984e..092b9ef 100644 --- a/modules/canonicalize-tests +++ b/modules/canonicalize-tests @@ -5,9 +5,12 @@ tests/test-canonicalize.c Depends-on: configure.ac: +AC_CHECK_FUNCS_ONCE([symlink]) +HAVE_SYMLINK=ac_cv_func_symlink +AC_SUBST([HAVE_SYMLINK]) Makefile.am: TESTS += test-canonicalize.sh -TESTS_ENVIRONMENT += EXEEXT='@EXEEXT@' +TESTS_ENVIRONMENT += EXEEXT='@EXEEXT@' HAVE_SYMLINK='$(HAVE_SYMLINK)' check_PROGRAMS += test-canonicalize test_canonicalize_LDADD = $(LDADD) @LIBINTL@ diff --git a/tests/test-canonicalize-lgpl.sh b/tests/test-canonicalize-lgpl.sh index 54d30b7..e439b7a 100755 --- a/tests/test-canonicalize-lgpl.sh +++ b/tests/test-canonicalize-lgpl.sh @@ -5,7 +5,8 @@ trap 'rm -fr $tmpfiles' 1 2 3 15 tmpfiles="$tmpfiles t-can-lgpl.tmp ise" mkdir t-can-lgpl.tmp -ln -s t-can-lgpl.tmp/ket ise \ +test "x$HAVE_SYMLINK" = xyes \ + && ln -s t-can-lgpl.tmp/ket ise \ || { echo "Skipping test: symbolic links not supported on this filesystem" rm -fr $tmpfiles exit 77 diff --git a/tests/test-canonicalize.sh b/tests/test-canonicalize.sh index 0ef91f3..a4ab962 100755 --- a/tests/test-canonicalize.sh +++ b/tests/test-canonicalize.sh @@ -5,7 +5,8 @@ trap 'rm -fr $tmpfiles' 1 2 3 15 tmpfiles="$tmpfiles t-can.tmp ise" mkdir t-can.tmp -ln -s t-can.tmp/ket ise \ +test "x$HAVE_SYMLINK" = xyes \ + && ln -s t-can.tmp/ket ise \ || { echo "Skipping test: symbolic links not supported on this filesystem" rm -fr $tmpfiles exit 77 -- 1.6.3.2