libtool-patches
[Top][All Lists]
Advanced

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

Re: [PATCH] [cygwin|mingw] Fix compile warnings when -std=c89.


From: Ralf Wildenhues
Subject: Re: [PATCH] [cygwin|mingw] Fix compile warnings when -std=c89.
Date: Thu, 22 Jan 2009 22:08:41 +0100
User-agent: Mutt/1.5.18 (2008-05-17)

* Charles Wilson wrote on Thu, Jan 22, 2009 at 04:14:51AM CET:
> Ralf Wildenhues wrote:
> 
> > I don't see a need to skip the test elsewhere.  Here's what I'd do:
> > transform $LIBTOOL to have CFLAGS and LTCFLAGS also contain -std=c89
> > -Werror.  (The test would be even cleaner with a re-configured libtool,
> > but let's not go overboard here.)
> 
> Being a total novice with autotest, I couldn't figure out how to do the
> former, so I did the latter. Attached is my first attempt.  It probably
> should be named something other than 'c89 test' because that name
> implies building all of libtool (including libltdl) with -std=c89. But I
> couldn't think of anything else to call it.

Let's let it test both c89 and c99 (and maybe other restrictive options
later, as users report them).  So how about we call it cwrapper test,
because that's what it's supposed to test, and put it in a file named
cwrapper.at?

> --- a/Makefile.am
> +++ b/Makefile.am
> @@ -467,6 +467,7 @@ TESTSUITE_AT      = tests/testsuite.at \
>                 tests/indirect_deps.at \
>                 tests/archive-in-archive.at \
>                 tests/execute-mode.at \
> +               tests/c89.at \
>                 tests/infer-tag.at \
>                 tests/localization.at \
>                 tests/install.at \

Order here is good.

> --- a/tests/c89.at    2006-11-30 19:00:00.000000000 -0500
> +++ b/tests/c89.at    2009-01-21 21:32:01.792100000 -0500

> +AT_SETUP([c89 test])
> +AT_KEYWORDS([libtool])

> +# make sure existing libtool is configured for shared libraries
> +AT_CHECK([$LIBTOOL --features | grep 'disable shared libraries' && (exit 
> 77)],
> +      [1], [ignore])

No need for the subshell for exit, BTW.  This test isn't strictly
needed, but of course helps avoid the test on some systems where we
shouldn't use a cwrapper.  BTW2, in your version of the patch you could
even let your sub configure script have --enable-shared although the
user --disable'd it for the Libtool tree.  But anyway.

The following could be wrapped in

orig_CFLAGS=$CFLAGS
orig_LIBTOOL=$LIBTOOL
for restrictive_flags in '-std=c89 -Werror' '-std=c99 -Werror'; do
  CFLAGS="$orig_CFLAGS $restrictive_flags"

  sed "s/LTCFLAGS=.*/&' $restrictive_flags'/" < $orig_LIBTOOL > ./libtool
  LIBTOOL=./libtool

...
done

> +# make sure CFLAGS -std=c89 -Werror do not cause a failure 
> +# themselves (e.g. because a non-gcc compiler doesn't support
> +# those flags).
> +AT_DATA([trivial.c],
> +[[
> +int main (void)
> +{
> +  return 0;
> +}
> +]])
> +AT_CHECK([$LIBTOOL --mode=compile $CC $CPPFLAGS $CFLAGS -std=c89 -Werror -c 
> trivial.c || exit 77],[0],[ignore],[ignore])

I'd just make this
  $LIBTOOL --mode=compile $CC $CPPFLAGS $CFLAGS -c trivial.c || continue

then.

Then, let's drop configure.ac, Makefile.am, and just

> +AT_DATA([liba.c],
> +[[int liba_func1 (int arg)
> +{
> +  return arg + 1;
> +}
> +]])
> +AT_DATA([usea.c],
> +[[extern int liba_func1(int arg);
> +int main (void)
> +{
> +  int a = 2;
> +  int b = liba_func1 (a);
> +  if (b == 3) return 0;
> +  return 1;
> +}
> +]])

AT_CHECK([$LIBTOOL --mode=compile $CC $CPPFLAGS $CFLAGS -c liba.c],
         [], [ignore], [ignore])
AT_CHECK([$LIBTOOL --mode=link $CC $CFLAGS $LDFLAGS -o liba.la -rpath /foo 
liba.lo],
         [], [ignore], [ignore])
AT_CHECK([$CC $CPPFLAGS $CFLAGS -c usea.c],
         [], [ignore], [ignore])
AT_CHECK([$LIBTOOL --mode=link $CC $CFLAGS $LDFLAGS -o usea$EXEEXT usea.$OBJEXT 
liba.la],
         [], [ignore], [ignore])

> +AT_CHECK([test -f liba.la])
> +LT_AT_EXEC_CHECK([./usea], [0], [ignore], [ignore], [])
> +
> +AT_CLEANUP

Can you test those changes for me, please (TESTSUITEFLAGS='-v -d -x -k 
cwrapper')
and ensure that test passes, but only with your ltmain patch applied?

Thanks,
Ralf




reply via email to

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